diff options
author | Christian Persch <chpe@gnome.org> | 2012-04-20 19:29:11 +0200 |
---|---|---|
committer | Christian Persch <chpe@gnome.org> | 2012-05-03 17:45:46 +0200 |
commit | ff66d0d8e5817596cc7fd736abfebbf3dfd94fc5 (patch) | |
tree | 3f456995c21de297a3a8473d36f07affa3177ad1 /gtk/gtkapplication.c | |
parent | 824776cb02af011424ad6bdaa15238a1eafcb700 (diff) | |
download | gtk+-ff66d0d8e5817596cc7fd736abfebbf3dfd94fc5.tar.gz |
application: Add unique IDs for GtkApplicationWindow
This will allow to refer to specific GtkApplicationWindows remotely by ID.
https://bugzilla.gnome.org/show_bug.cgi?id=674409
Diffstat (limited to 'gtk/gtkapplication.c')
-rw-r--r-- | gtk/gtkapplication.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c index 06403d39ed..8758fc3b85 100644 --- a/gtk/gtkapplication.c +++ b/gtk/gtkapplication.c @@ -255,8 +255,8 @@ gtk_application_window_added_x11 (GtkApplication *application, guint window_id; window_id = application->priv->next_id++; - window_path = g_strdup_printf ("%s/window/%d", application->priv->object_path, window_id); - success = gtk_application_window_publish (app_window, application->priv->session_bus, window_path); + window_path = g_strdup_printf ("%s/window/%u", application->priv->object_path, window_id); + success = gtk_application_window_publish (app_window, application->priv->session_bus, window_path, window_id); g_free (window_path); } while (!success); @@ -501,6 +501,8 @@ gtk_application_init (GtkApplication *application) application->priv = G_TYPE_INSTANCE_GET_PRIVATE (application, GTK_TYPE_APPLICATION, GtkApplicationPrivate); + + application->priv->next_id = 1; } static void @@ -874,6 +876,34 @@ gtk_application_get_windows (GtkApplication *application) } /** + * gtk_application_get_window_by_id: + * @application: a #GtkApplication + * @id: an identifier number + * + * Returns: (transfer none): the #GtkApplicationWindow with ID @id, or + * %NULL if there is no window with this ID + * + * Since: 3.6 + */ +GtkWindow * +gtk_application_get_window_by_id (GtkApplication *application, + guint id) +{ + GList *l; + + g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL); + + for (l = application->priv->windows; l != NULL; l = l->next) + { + if (GTK_IS_APPLICATION_WINDOW (l->data) && + gtk_application_window_get_id (GTK_APPLICATION_WINDOW (l->data)) == id) + return l->data; + } + + return NULL; +} + +/** * gtk_application_add_accelerator: * @application: a #GtkApplication * @accelerator: accelerator string |