This will allow to refer to specific GtkApplicationWindows remotely by ID.
https://bugzilla.gnome.org/show_bug.cgi?id=674409
gtk_application_add_window
gtk_application_remove_window
gtk_application_get_windows
+gtk_application_get_window_by_id
<SUBSECTION>
GtkApplicationInhibitFlags
gtk_application_window_new
gtk_application_window_set_show_menubar
gtk_application_window_get_show_menubar
+gtk_application_window_get_id
<SUBSECTION Standard>
GtkApplicationWindowClass
gtk_application_get_menubar
gtk_application_get_type
gtk_application_get_windows
+gtk_application_get_window_by_id
gtk_application_inhibit
gtk_application_inhibit_flags_get_type
gtk_application_is_inhibited
gtk_application_uninhibit
gtk_application_window_get_show_menubar
gtk_application_window_get_type
+gtk_application_window_get_id
gtk_application_window_new
gtk_application_window_set_show_menubar
gtk_arrow_get_type
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);
application->priv = G_TYPE_INSTANCE_GET_PRIVATE (application,
GTK_TYPE_APPLICATION,
GtkApplicationPrivate);
+
+ application->priv->next_id = 1;
}
static void
return application->priv->windows;
}
+/**
+ * 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
gboolean gtk_application_is_inhibited (GtkApplication *application,
GtkApplicationInhibitFlags flags);
+GDK_AVAILABLE_IN_3_6
+GtkWindow * gtk_application_get_window_by_id (GtkApplication *application,
+ guint id);
+
G_END_DECLS
#endif /* __GTK_APPLICATION_H__ */
G_GNUC_INTERNAL
gboolean gtk_application_window_publish (GtkApplicationWindow *window,
GDBusConnection *session,
- const gchar *object_path);
+ const gchar *object_path,
+ guint object_id);
G_GNUC_INTERNAL
void gtk_application_window_unpublish (GtkApplicationWindow *window);
GDBusConnection *session;
gchar *object_path;
guint export_id;
+
+ guint id;
};
static void
gboolean
gtk_application_window_publish (GtkApplicationWindow *window,
GDBusConnection *session,
- const gchar *object_path)
+ const gchar *object_path,
+ guint object_id)
{
g_assert (window->priv->session == NULL);
g_assert (window->priv->export_id == 0);
g_assert (window->priv->object_path == NULL);
+ g_assert (window->priv->id == 0);
window->priv->export_id = g_dbus_connection_export_action_group (session, object_path,
G_ACTION_GROUP (window->priv->actions),
window->priv->session = session;
window->priv->object_path = g_strdup (object_path);
+ window->priv->id = object_id;
return TRUE;
}
g_assert (window->priv->session != NULL);
g_assert (window->priv->export_id != 0);
g_assert (window->priv->object_path != NULL);
+ g_assert (window->priv->id != 0);
g_dbus_connection_unexport_action_group (window->priv->session, window->priv->export_id);
window->priv->session = NULL;
window->priv->export_id = 0;
+ window->priv->id = 0;
g_free (window->priv->object_path);
window->priv->object_path = NULL;
{
return window->priv->accels;
}
+
+/**
+ * gtk_application_window_get_id:
+ * @window: a #GtkApplicationWindow
+ *
+ * Returns the unique ID of the window. If the window has not yet been added to
+ * a #GtkApplication, returns <literal>0</literal>.
+ *
+ * Returns: the unique ID for @window, or <literal>0</literal> if the window
+ * has not yet been added to a #GtkApplication
+ *
+ * Since: 3.6
+ */
+guint
+gtk_application_window_get_id (GtkApplicationWindow *window)
+{
+ g_return_val_if_fail (GTK_IS_APPLICATION_WINDOW (window), 0);
+
+ return window->priv->id;
+}
GDK_AVAILABLE_IN_3_4
gboolean gtk_application_window_get_show_menubar (GtkApplicationWindow *window);
+GDK_AVAILABLE_IN_3_6
+guint gtk_application_window_get_id (GtkApplicationWindow *window);
+
G_END_DECLS
#endif /* __GTK_APPLICATION_WINDOW_H__ */