[gtk+/wip/gmenu] Listen for settings changes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/gmenu] Listen for settings changes
- Date: Sat, 3 Dec 2011 21:43:55 +0000 (UTC)
commit c67ed28c7feee5bdee759c1bdfb5dd200144dc0a
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 3 16:43:29 2011 -0500
Listen for settings changes
gtk/gtkapplicationwindow.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c
index f68a0a2..c4a4d01 100644
--- a/gtk/gtkapplicationwindow.c
+++ b/gtk/gtkapplicationwindow.c
@@ -63,6 +63,9 @@ struct _GtkApplicationWindowPrivate
GMenu *app_menu_section;
GMenu *menubar_section;
gboolean show_menubar;
+
+ gulong menubar_handler;
+ gulong menu_handler;
};
static GtkWidget *
@@ -511,6 +514,32 @@ gtk_application_window_dispose (GObject *object)
}
static void
+gtk_application_window_screen_changed (GtkWidget *widget,
+ GdkScreen *previous_screen)
+{
+ GtkApplicationWindow *win = GTK_APPLICATION_WINDOW (widget);
+ GtkSettings *settings;
+
+ if (previous_screen)
+ {
+ settings = gtk_settings_get_for_screen (previous_screen);
+ if (win->priv->menubar_handler)
+ g_signal_handler_disconnect (settings, win->priv->menubar_handler);
+ if (win->priv->menu_handler)
+ g_signal_handler_disconnect (settings, win->priv->menu_handler);
+ }
+
+g_print ("screen changed\n");
+ settings = gtk_widget_get_settings (widget);
+ win->priv->menu_handler =
+ g_signal_connect_object (settings, "notify::gtk-shell-shows-app-menu",
+ G_CALLBACK (gtk_application_window_shell_shows_app_menu_changed), win, 0);
+ win->priv->menubar_handler =
+ g_signal_connect_object (settings, "notify::gtk-shell-shows-menubar",
+ G_CALLBACK (gtk_application_window_shell_shows_menubar_changed), win, 0);
+}
+
+static void
gtk_application_window_init (GtkApplicationWindow *window)
{
window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, GTK_TYPE_APPLICATION_WINDOW, GtkApplicationWindowPrivate);
@@ -530,6 +559,8 @@ gtk_application_window_init (GtkApplicationWindow *window)
G_CALLBACK (g_action_group_action_state_changed), window);
g_signal_connect_swapped (window->priv->actions, "action-removed",
G_CALLBACK (g_action_group_action_removed), window);
+
+ gtk_application_window_screen_changed (GTK_WIDGET (window), NULL);
}
static void
@@ -547,6 +578,7 @@ gtk_application_window_class_init (GtkApplicationWindowClass *class)
widget_class->size_allocate = gtk_application_window_real_size_allocate;
widget_class->realize = gtk_application_window_real_realize;
widget_class->map = gtk_application_window_real_map;
+ widget_class->screen_changed = gtk_application_window_screen_changed;
object_class->get_property = gtk_application_window_get_property;
object_class->set_property = gtk_application_window_set_property;
object_class->dispose = gtk_application_window_dispose;
@@ -559,6 +591,7 @@ gtk_application_window_class_init (GtkApplicationWindowClass *class)
TRUE, G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
g_object_class_install_properties (object_class, N_PROPS, gtk_application_window_properties);
g_type_class_add_private (class, sizeof (GtkApplicationWindowPrivate));
+
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]