[gtk+] GtkWindow: change muxer setup with application
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkWindow: change muxer setup with application
- Date: Tue, 15 Oct 2013 13:24:26 +0000 (UTC)
commit abcddd3ae08a6bfefec0d4298288adc8f672c924
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Jul 9 22:33:22 2013 -0400
GtkWindow: change muxer setup with application
Previously, GtkWindow would add the "app" action group to its own
toplevel muxer.
Change the setup so that GtkApplication creates the toplevel muxer and
adds itself to it as "app". Use this muxer as the parent muxer of any
GtkWindow associated with the application.
This saves a small amount of memory and will allow for accels to be
propagated from the application through to all of the windows.
gtk/gtkapplication.c | 27 +++++++++++++++++++++++----
gtk/gtkapplicationprivate.h | 5 +++++
gtk/gtkwidget.c | 19 ++++++++++++++-----
gtk/gtkwindow.c | 3 +--
4 files changed, 43 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index dfd6924..b4c9b51 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -143,6 +143,7 @@ struct _GtkApplicationPrivate
GMenuModel *menubar;
gboolean register_session;
+ GtkActionMuxer *muxer;
#ifdef GDK_WINDOWING_X11
guint next_id;
@@ -396,19 +397,24 @@ gtk_application_focus_in_event_cb (GtkWindow *window,
}
static void
-gtk_application_startup (GApplication *application)
+gtk_application_startup (GApplication *g_application)
{
+ GtkApplication *application = GTK_APPLICATION (g_application);
+
G_APPLICATION_CLASS (gtk_application_parent_class)
- ->startup (application);
+ ->startup (g_application);
+
+ application->priv->muxer = gtk_action_muxer_new ();
+ gtk_action_muxer_insert (application->priv->muxer, "app", G_ACTION_GROUP (application));
gtk_init (0, 0);
#ifdef GDK_WINDOWING_X11
- gtk_application_startup_x11 (GTK_APPLICATION (application));
+ gtk_application_startup_x11 (application);
#endif
#ifdef GDK_WINDOWING_QUARTZ
- gtk_application_startup_quartz (GTK_APPLICATION (application));
+ gtk_application_startup_quartz (application);
#endif
}
@@ -1688,3 +1694,16 @@ gtk_application_is_inhibited (GtkApplication *application,
}
#endif
+
+GtkActionMuxer *
+gtk_application_get_parent_muxer_for_window (GtkWindow *window)
+{
+ GtkApplication *application;
+
+ application = gtk_window_get_application (window);
+
+ if (!application)
+ return NULL;
+
+ return application->priv->muxer;
+}
diff --git a/gtk/gtkapplicationprivate.h b/gtk/gtkapplicationprivate.h
index bd84b1a..e0c278a 100644
--- a/gtk/gtkapplicationprivate.h
+++ b/gtk/gtkapplicationprivate.h
@@ -23,6 +23,8 @@
#include "gtkapplicationwindow.h"
+#include "gtkactionmuxer.h"
+
G_GNUC_INTERNAL
gboolean gtk_application_window_publish (GtkApplicationWindow *window,
GDBusConnection *session,
@@ -40,4 +42,7 @@ const gchar * gtk_application_get_app_menu_object_path (GtkAppl
G_GNUC_INTERNAL
const gchar * gtk_application_get_menubar_object_path (GtkApplication *application);
+G_GNUC_INTERNAL
+GtkActionMuxer * gtk_application_get_parent_muxer_for_window (GtkWindow *window);
+
#endif /* __GTK_APPLICATION_PRIVATE_H__ */
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 1f05c8b..c4068d1 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -64,6 +64,7 @@
#include "gtkplug.h"
#include "gtktypebuiltins.h"
#include "a11y/gtkwidgetaccessible.h"
+#include "gtkapplicationprivate.h"
/* for the use of round() */
#include "fallback-c89.c"
@@ -15457,18 +15458,26 @@ _gtk_widget_set_style (GtkWidget *widget,
void
_gtk_widget_update_parent_muxer (GtkWidget *widget)
{
- GtkWidget *parent;
GtkActionMuxer *parent_muxer;
if (widget->priv->muxer == NULL)
return;
- if (GTK_IS_MENU (widget))
- parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
+ if (GTK_IS_WINDOW (widget))
+ {
+ parent_muxer = gtk_application_get_parent_muxer_for_window (GTK_WINDOW (widget));
+ }
else
- parent = gtk_widget_get_parent (widget);
+ {
+ GtkWidget *parent;
+
+ if (GTK_IS_MENU (widget))
+ parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
+ else
+ parent = gtk_widget_get_parent (widget);
- parent_muxer = parent ? _gtk_widget_get_action_muxer (parent) : NULL;
+ parent_muxer = parent ? _gtk_widget_get_action_muxer (parent) : NULL;
+ }
gtk_action_muxer_set_parent (widget->priv->muxer, parent_muxer);
}
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index a433721..dfe34f1 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -2958,8 +2958,7 @@ gtk_window_set_application (GtkWindow *window,
gtk_application_add_window (priv->application, window);
}
- /* don't use a normal cast: application may be NULL */
- gtk_widget_insert_action_group (GTK_WIDGET (window), "app", (GActionGroup *) application);
+ _gtk_widget_update_parent_muxer (GTK_WIDGET (window));
g_object_notify (G_OBJECT (window), "application");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]