diff options
author | Balló György <[email protected]> | 2015-11-20 01:14:25 +0100 |
---|---|---|
committer | Wolfgang Ulbrich <[email protected]> | 2015-11-28 21:03:29 +0100 |
commit | 0e477da32b80e6c8f071d0d5380efbd7e9ae2e35 (patch) | |
tree | 39e608c46aacfd05dbd7a1a4a7ce7a32eac8681d | |
parent | 22f1787182a46bc7583be4bb07eb7e0f91c60b65 (diff) | |
download | mate-panel-0e477da32b80e6c8f071d0d5380efbd7e9ae2e35.tar.bz2 mate-panel-0e477da32b80e6c8f071d0d5380efbd7e9ae2e35.tar.xz |
Don't set the panel transparent by default
This fixes the background for GTK+ 3 themes which don't support mate-panel explicitly. Themes could still overwrite the background if they want in the usual way.
-rw-r--r-- | libmate-panel-applet/mate-panel-applet.c | 34 | ||||
-rw-r--r-- | mate-panel/mate-panel-applet-frame.c | 6 | ||||
-rw-r--r-- | mate-panel/panel-background.c | 45 | ||||
-rw-r--r-- | mate-panel/panel-background.h | 2 | ||||
-rw-r--r-- | mate-panel/panel-menu-bar.c | 2 | ||||
-rw-r--r-- | mate-panel/panel-separator.c | 2 | ||||
-rw-r--r-- | mate-panel/panel-widget.c | 1 |
7 files changed, 61 insertions, 31 deletions
diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index 260ef2bb..57520218 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -1979,34 +1979,40 @@ mate_panel_applet_setup (MatePanelApplet *applet) void _mate_panel_applet_apply_css(GtkWidget* widget, MatePanelAppletBackgroundType type) { GtkStyleContext* context; - GtkCssProvider *provider; context = gtk_widget_get_style_context (widget); - gtk_widget_reset_style(widget); + gtk_widget_reset_style (widget); switch (type) { case PANEL_NO_BACKGROUND: - gtk_style_context_remove_class(context,"mate-custom-panel-background"); + gtk_style_context_remove_class (context, "mate-custom-panel-background"); break; case PANEL_COLOR_BACKGROUND: case PANEL_PIXMAP_BACKGROUND: - provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, - ".mate-custom-panel-background{\n" - " background-color: rgba (0, 0, 0, 0);\n" - " background-image: none;\n" - "}", - -1, NULL); gtk_style_context_add_class (context, "mate-custom-panel-background"); - gtk_style_context_add_provider (context, - GTK_STYLE_PROVIDER (provider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); break; default: g_assert_not_reached (); break; } } + +void _mate_panel_applet_prepare_css (GtkStyleContext *context) +{ + GtkCssProvider *provider; + + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_data (provider, + ".mate-custom-panel-background{\n" + " background-color: rgba (0, 0, 0, 0);\n" + " background-image: none;\n" + "}", + -1, NULL); + gtk_style_context_add_provider (context, + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (provider); +} #endif static void @@ -2045,10 +2051,10 @@ mate_panel_applet_init (MatePanelApplet *applet) gtk_widget_set_visual(GTK_WIDGET(applet->priv->plug), visual); GtkStyleContext *context; context = gtk_widget_get_style_context (GTK_WIDGET(applet->priv->plug)); - gtk_style_context_remove_class (context,GTK_STYLE_CLASS_BACKGROUND); gtk_style_context_add_class(context,"gnome-panel-menu-bar"); gtk_style_context_add_class(context,"mate-panel-menu-bar"); gtk_widget_set_name(GTK_WIDGET(applet->priv->plug), "PanelPlug"); + _mate_panel_applet_prepare_css(context); #endif g_signal_connect_swapped (G_OBJECT (applet->priv->plug), "embedded", G_CALLBACK (mate_panel_applet_setup), diff --git a/mate-panel/mate-panel-applet-frame.c b/mate-panel/mate-panel-applet-frame.c index ac4205f5..dda1290e 100644 --- a/mate-panel/mate-panel-applet-frame.c +++ b/mate-panel/mate-panel-applet-frame.c @@ -640,15 +640,17 @@ mate_panel_applet_frame_change_background (MatePanelAppletFrame *frame, g_return_if_fail (PANEL_IS_WIDGET (parent)); -#if !GTK_CHECK_VERSION (3, 0, 0) if (frame->priv->has_handle) { PanelBackground *background; background = &PANEL_WIDGET (parent)->background; +#if GTK_CHECK_VERSION (3, 0, 0) + panel_background_apply_css (GTK_WIDGET (frame), background); +#else panel_background_change_background_on_widget (background, GTK_WIDGET (frame)); - } #endif + } MATE_PANEL_APPLET_FRAME_GET_CLASS (frame)->change_background (frame, type); } diff --git a/mate-panel/panel-background.c b/mate-panel/panel-background.c index 35018409..ecfc7c1e 100644 --- a/mate-panel/panel-background.c +++ b/mate-panel/panel-background.c @@ -97,13 +97,34 @@ set_pixbuf_background (PanelBackground *background) } #if GTK_CHECK_VERSION (3, 0, 0) -void panel_background_apply_css (GtkWidget* widget) +void panel_background_apply_css (GtkWidget* widget, PanelBackground *background) { - GtkStyleContext* context; - GtkCssProvider *provider; + GtkStyleContext *context; + PanelBackgroundType effective_type; context = gtk_widget_get_style_context (widget); - gtk_widget_reset_style(widget); + effective_type = panel_background_effective_type (background); + gtk_widget_reset_style (widget); + + switch (effective_type) { + case PANEL_BACK_NONE: + gtk_style_context_remove_class (context, "mate-custom-panel-background"); + break; + case PANEL_BACK_COLOR: + case PANEL_BACK_IMAGE: + gtk_style_context_add_class (context, "mate-custom-panel-background"); + break; + default: + g_assert_not_reached (); + break; + } +} + +static void +panel_background_prepare_css () +{ + GtkCssProvider *provider; + provider = gtk_css_provider_new (); gtk_css_provider_load_from_data (provider, ".mate-custom-panel-background{\n" @@ -111,10 +132,10 @@ void panel_background_apply_css (GtkWidget* widget) " background-image: none;\n" "}", -1, NULL); - gtk_style_context_add_class (context, "mate-custom-panel-background"); - gtk_style_context_add_provider (context, - GTK_STYLE_PROVIDER (provider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_object_unref (provider); } #endif @@ -221,6 +242,9 @@ panel_background_prepare (PanelBackground *background) (gpointer) &widget); if (GTK_IS_WIDGET (widget)) { +#if GTK_CHECK_VERSION (3, 0, 0) + panel_background_apply_css (gtk_widget_get_toplevel(widget), background); +#endif gtk_widget_set_app_paintable(widget,TRUE); gtk_widget_queue_draw (widget); } @@ -1057,10 +1081,7 @@ panel_background_realized (PanelBackground *background, background->gc = gdk_gc_new (window); #endif #if GTK_CHECK_VERSION(3, 0, 0) - GtkWidget* widget; - gdk_window_get_user_data (GDK_WINDOW (background->window), - (gpointer) &widget); - panel_background_apply_css(gtk_widget_get_toplevel(widget)); + panel_background_prepare_css (); #endif panel_background_prepare (background); } diff --git a/mate-panel/panel-background.h b/mate-panel/panel-background.h index d69f529c..1d984073 100644 --- a/mate-panel/panel-background.h +++ b/mate-panel/panel-background.h @@ -163,7 +163,7 @@ void panel_background_change_background_on_widget (PanelBackground *background, GtkWidget *widget); #else -void panel_background_apply_css(GtkWidget* widget); +void panel_background_apply_css(GtkWidget* widget, PanelBackground *background); #endif #endif /* __PANEL_BACKGROUND_H__ */ diff --git a/mate-panel/panel-menu-bar.c b/mate-panel/panel-menu-bar.c index f6ae7682..99381bf2 100644 --- a/mate-panel/panel-menu-bar.c +++ b/mate-panel/panel-menu-bar.c @@ -479,7 +479,7 @@ void panel_menu_bar_popup_menu(PanelMenuBar* menubar, guint32 activate_time) void panel_menu_bar_change_background(PanelMenuBar* menubar) { #if GTK_CHECK_VERSION (3, 0, 0) - panel_background_apply_css(GTK_WIDGET(menubar)); + panel_background_apply_css(GTK_WIDGET(menubar), &menubar->priv->panel->background); #else panel_background_change_background_on_widget(&menubar->priv->panel->background, GTK_WIDGET(menubar)); #endif diff --git a/mate-panel/panel-separator.c b/mate-panel/panel-separator.c index 7f9c53fe..b5a41487 100644 --- a/mate-panel/panel-separator.c +++ b/mate-panel/panel-separator.c @@ -350,7 +350,7 @@ void panel_separator_change_background (PanelSeparator *separator) { #if GTK_CHECK_VERSION (3, 0, 0) - panel_background_apply_css(GTK_WIDGET(separator)); + panel_background_apply_css(GTK_WIDGET(separator), &separator->priv->panel->background); #else panel_background_change_background_on_widget(&separator->priv->panel->background, GTK_WIDGET(separator)); #endif diff --git a/mate-panel/panel-widget.c b/mate-panel/panel-widget.c index 30e55f9c..e3752d61 100644 --- a/mate-panel/panel-widget.c +++ b/mate-panel/panel-widget.c @@ -1657,6 +1657,7 @@ panel_widget_style_set (GtkWidget *widget, GtkStyle *previous_style) state = gtk_widget_get_state_flags (widget); gtk_style_context_add_class(context,"gnome-panel-menu-bar"); gtk_style_context_add_class(context,"mate-panel-menu-bar"); + panel_background_apply_css (widget, &PANEL_WIDGET (widget)->background); gtk_style_context_get_background_color (context, state, &bg_color); gtk_style_context_get (context, state, "background-image", &bg_image, NULL); |