summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@dhcp-100-2-40.bos.redhat.com>2009-04-14 12:44:15 -0400
committerSøren Sandmann Pedersen <ssp@dhcp-100-2-40.bos.redhat.com>2009-04-14 12:44:15 -0400
commit0d3ed0c9f3bac72b5072997c93ff349dcb0b151d (patch)
tree4fea1d22434aba2dfc10fb942508c67a81446841
parent97c68da0c64c0c97fa5dfe99c57ece9a31231c5a (diff)
Pass startup id across dbus
-rw-r--r--siv.c32
-rw-r--r--siv.h4
-rw-r--r--window.c15
3 files changed, 32 insertions, 19 deletions
diff --git a/siv.c b/siv.c
index 3bd7000..529fb8e 100644
--- a/siv.c
+++ b/siv.c
@@ -368,7 +368,10 @@ process_options (int argc, char **argv)
}
static gboolean
-open_file (App *app, const char *filename, GPtrArray *err_files)
+open_file (App *app,
+ const char *startup_id,
+ const char *filename,
+ GPtrArray *err_files)
{
SivWindow *window = NULL;
GError *err = NULL;
@@ -380,13 +383,13 @@ open_file (App *app, const char *filename, GPtrArray *err_files)
if (window_matches_file (w, filename))
{
- window_present (w, GDK_CURRENT_TIME);
+ window_present (w, startup_id);
return TRUE;
}
}
window = window_new (app);
-
+
if (!window_load_file (window, filename, &err))
{
if (err_files)
@@ -396,7 +399,7 @@ open_file (App *app, const char *filename, GPtrArray *err_files)
return FALSE;
}
- window_show (window, GDK_CURRENT_TIME);
+ window_show (window, startup_id);
return TRUE;
}
@@ -422,11 +425,14 @@ app_end_load (App *app)
}
static void
-on_open (App *app, const char *filename)
+on_open (App *app, const char *startup_id, const char *filename)
{
+ if (startup_id && *startup_id == 0)
+ startup_id = NULL;
+
app_begin_load (app);
- if (!open_file (app, filename, NULL))
+ if (!open_file (app, startup_id, filename, NULL))
{
/* FIXME: show error
*
@@ -462,11 +468,11 @@ app_new (int argc, char **argv)
if (filenames[0])
{
for (i = 0; filenames[i] != NULL; ++i)
- open_file (app, filenames[i], err_files);
+ open_file (app, NULL, filenames[i], err_files);
}
else
{
- window_show (window_new (app), GDK_CURRENT_TIME);
+ window_show (window_new (app), NULL);
}
g_strfreev (filenames);
@@ -497,6 +503,7 @@ make_object (gpointer data)
nul_dbus_method (
"open",
(nul_dbus_function_t)on_open, /* on_open,*/
+ nul_dbus_parameter_in ("startup_id", nul_dbus_type_string()),
nul_dbus_parameter_in ("filename", nul_dbus_type_string()),
nul_dbus_parameter_out ("result", nul_dbus_type_int32()),
NULL),
@@ -569,11 +576,11 @@ main (int argc,
}
else
{
+ const char *startup_id = g_getenv ("DESKTOP_STARTUP_ID");
char **files;
int i;
- gboolean sn = g_getenv ("DESKTOP_STARTUP_ID");
-
- if (sn)
+
+ if (startup_id)
gtk_init (&argc, &argv);
files = process_options (argc, argv);
@@ -584,10 +591,11 @@ main (int argc,
{
nul_dbus_invoke (service, "/app/dk.au.daimi.sandmann.siv.open",
NULL/* callback */, NULL/* data */,
+ startup_id? startup_id : "",
files[i]);
}
- if (sn)
+ if (startup_id)
{
/* FIXME: send the startup ID across the wire instead */
gdk_notify_startup_complete ();
diff --git a/siv.h b/siv.h
index be40cd3..c3d9d5a 100644
--- a/siv.h
+++ b/siv.h
@@ -70,9 +70,9 @@ gboolean window_load_file (SivWindow *window,
const char *file,
GError **err);
void window_present (SivWindow *window,
- guint32 time);
+ const char *startup_id);
void window_show (SivWindow *window,
- guint32 time);
+ const char *startup_id);
gboolean window_matches_file (SivWindow *window,
const char *filename);
gboolean window_is_blank (SivWindow *window);
diff --git a/window.c b/window.c
index 56176ca..790c058 100644
--- a/window.c
+++ b/window.c
@@ -853,7 +853,7 @@ retry:
if (success)
{
if (target != window)
- window_show (target, gtk_get_current_event_time());
+ window_show (target, NULL);
}
else
{
@@ -1118,13 +1118,18 @@ window_free (SivWindow *window)
}
void
-window_present (SivWindow *window, guint32 time)
+window_present (SivWindow *window, const char *startup_id)
{
- gtk_window_present_with_time (get_widget (window, "main_window"), time);
+ GtkWindow *w = get_widget (window, "main_window");
+
+ if (startup_id)
+ gtk_window_set_startup_id (w, startup_id);
+ else
+ gtk_window_present_with_time (w, gtk_get_current_event_time());
}
void
-window_show (SivWindow *window, guint32 time)
+window_show (SivWindow *window, const char *startup_id)
{
GtkAdjustment *vadj, *hadj;
@@ -1142,7 +1147,7 @@ window_show (SivWindow *window, guint32 time)
gtk_adjustment_set_value (vadj, window->vadj);
gtk_adjustment_set_value (hadj, window->hadj);
- window_present (window, time);
+ window_present (window, startup_id);
}
gboolean