diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-08-16 12:19:38 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-08-16 12:19:38 +0800 |
commit | fd3514c75ff7f2aeb2d904015b984796205a05fe (patch) | |
tree | 118346e4b0f143b27faa40354c0d66d390d31638 /shell/e-sidebar.c | |
parent | 7ade227e6409c98a4010992450e111cf7bb10520 (diff) | |
download | gsoc2013-evolution-fd3514c75ff7f2aeb2d904015b984796205a05fe.tar gsoc2013-evolution-fd3514c75ff7f2aeb2d904015b984796205a05fe.tar.gz gsoc2013-evolution-fd3514c75ff7f2aeb2d904015b984796205a05fe.tar.bz2 gsoc2013-evolution-fd3514c75ff7f2aeb2d904015b984796205a05fe.tar.lz gsoc2013-evolution-fd3514c75ff7f2aeb2d904015b984796205a05fe.tar.xz gsoc2013-evolution-fd3514c75ff7f2aeb2d904015b984796205a05fe.tar.zst gsoc2013-evolution-fd3514c75ff7f2aeb2d904015b984796205a05fe.zip |
Have the sidebar update itself when the "gtk-toolbar-style" global GtkSetting
changes, without using GConf.
svn path=/branches/kill-bonobo/; revision=36001
Diffstat (limited to 'shell/e-sidebar.c')
-rw-r--r-- | shell/e-sidebar.c | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/shell/e-sidebar.c b/shell/e-sidebar.c index ea479918bc..db5134fb79 100644 --- a/shell/e-sidebar.c +++ b/shell/e-sidebar.c @@ -34,6 +34,8 @@ struct _ESidebarPrivate { gboolean actions_visible; gboolean style_set; GtkToolbarStyle style; + GtkSettings *settings; + gulong settings_handler_id; }; enum { @@ -151,6 +153,15 @@ sidebar_layout_actions (ESidebar *sidebar) } static void +sidebar_toolbar_style_changed_cb (ESidebar *sidebar) +{ + if (!sidebar->priv->style_set) { + sidebar->priv->style_set = TRUE; + e_sidebar_unset_style (sidebar); + } +} + +static void sidebar_set_property (GObject *object, guint property_id, const GValue *value, @@ -278,6 +289,40 @@ sidebar_size_allocate (GtkWidget *widget, } static void +sidebar_screen_changed (GtkWidget *widget, + GdkScreen *previous_screen) +{ + ESidebarPrivate *priv; + GtkSettings *settings; + + priv = E_SIDEBAR_GET_PRIVATE (widget); + + if (gtk_widget_has_screen (widget)) + settings = gtk_widget_get_settings (widget); + else + settings = NULL; + + if (settings == priv->settings) + return; + + if (priv->settings != NULL) { + g_signal_handler_disconnect ( + priv->settings, priv->settings_handler_id); + g_object_unref (priv->settings); + } + + if (settings != NULL) { + priv->settings = g_object_ref (settings); + priv->settings_handler_id = g_signal_connect_swapped ( + settings, "notify::gtk-toolbar-style", + G_CALLBACK (sidebar_toolbar_style_changed_cb), widget); + } else + priv->settings = NULL; + + sidebar_toolbar_style_changed_cb (E_SIDEBAR (widget)); +} + +static void sidebar_remove (GtkContainer *container, GtkWidget *widget) { @@ -379,6 +424,7 @@ sidebar_class_init (ESidebarClass *class) widget_class = GTK_WIDGET_CLASS (class); widget_class->size_request = sidebar_size_request; widget_class->size_allocate = sidebar_size_allocate; + widget_class->screen_changed = sidebar_screen_changed; container_class = GTK_CONTAINER_CLASS (class); container_class->remove = sidebar_remove; @@ -555,8 +601,11 @@ e_sidebar_unset_style (ESidebar *sidebar) if (!sidebar->priv->style_set) return; - settings = gtk_widget_get_settings (GTK_WIDGET (sidebar)); - g_object_get (settings, "gtk-toolbar-style", &style, NULL); + settings = sidebar->priv->settings; + if (settings != NULL) + g_object_get (settings, "gtk-toolbar-style", &style, NULL); + else + style = DEFAULT_TOOLBAR_STYLE; if (style == GTK_TOOLBAR_BOTH) style = GTK_TOOLBAR_BOTH_HORIZ; |