summaryrefslogtreecommitdiff
path: root/libmate-panel-applet
diff options
context:
space:
mode:
authorKonstantin Pugin <[email protected]>2014-06-20 00:04:13 +0700
committerKonstantin Pugin <[email protected]>2014-06-20 01:26:52 +0700
commita9d01e5afb6fd97d96f1b298e6e34d2dfa02f25c (patch)
tree4634f12585ec2259fb63b2743d16928c8b4dda86 /libmate-panel-applet
parentf327306271032e7b8ef716655f91c58513792cde (diff)
downloadmate-panel-a9d01e5afb6fd97d96f1b298e6e34d2dfa02f25c.tar.bz2
mate-panel-a9d01e5afb6fd97d96f1b298e6e34d2dfa02f25c.tar.xz
Fix RGBA issues for GTK3
Diffstat (limited to 'libmate-panel-applet')
-rw-r--r--libmate-panel-applet/mate-panel-applet.c90
-rw-r--r--libmate-panel-applet/mate-panel-applet.h2
2 files changed, 84 insertions, 8 deletions
diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c
index ef61f846..ac00bafa 100644
--- a/libmate-panel-applet/mate-panel-applet.c
+++ b/libmate-panel-applet/mate-panel-applet.c
@@ -120,6 +120,9 @@ static void mate_panel_applet_menu_cmd_move (GtkAction *acti
static void mate_panel_applet_menu_cmd_lock (GtkAction *action,
MatePanelApplet *applet);
static void mate_panel_applet_register_object (MatePanelApplet *applet);
+#if GTK_CHECK_VERSION (3, 0, 0)
+void _mate_panel_applet_apply_css (GtkWidget* widget, MatePanelAppletBackgroundType type);
+#endif
static const gchar panel_menu_ui[] =
"<ui>\n"
@@ -1464,7 +1467,7 @@ mate_panel_applet_get_pixmap (MatePanelApplet *applet,
width = gdk_window_get_width(window);
height = gdk_window_get_height(window);
#if GTK_CHECK_VERSION(3, 0, 0)
- surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
#endif
#if GTK_CHECK_VERSION (3, 0, 0)
@@ -1490,10 +1493,6 @@ mate_panel_applet_get_pixmap (MatePanelApplet *applet,
#if GTK_CHECK_VERSION (3, 0, 0)
if (cairo_status (cr) == CAIRO_STATUS_SUCCESS) {
pattern = cairo_pattern_create_for_surface (surface);
- cairo_matrix_init_translate (&matrix, 0, 0);
- cairo_matrix_scale (&matrix, width, height);
- cairo_pattern_set_matrix (pattern, &matrix);
- cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
}
cairo_destroy (cr);
@@ -1770,9 +1769,14 @@ mate_panel_applet_handle_background (MatePanelApplet *applet)
type = mate_panel_applet_get_background (applet, &color, &pattern);
+
if (applet->priv->background_widget)
+ {
mate_panel_applet_update_background_for_widget (applet->priv->background_widget,
type, &color, pattern);
+ _mate_panel_applet_apply_css(applet->priv->background_widget,type);
+ }
+
#else
GdkColor color;
GdkPixmap *pixmap;
@@ -1839,6 +1843,33 @@ mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet,
applet->priv->moving_focus_out = FALSE;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+mate_panel_applet_change_background(MatePanelApplet *applet,
+ MatePanelAppletBackgroundType type,
+ GdkRGBA* color,
+ cairo_pattern_t *pattern)
+{
+ GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(applet));
+ gtk_widget_set_app_paintable(GTK_WIDGET(applet),TRUE);
+ _mate_panel_applet_apply_css(GTK_WIDGET(applet->priv->plug),type);
+ switch (type) {
+ case PANEL_NO_BACKGROUND:
+ gdk_window_set_background_pattern(window,NULL);
+ break;
+ case PANEL_COLOR_BACKGROUND:
+ gdk_window_set_background_rgba(window,color);
+ break;
+ case PANEL_PIXMAP_BACKGROUND:
+ gdk_window_set_background_pattern(window,pattern);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+#endif
+
static void
mate_panel_applet_get_property (GObject *object,
guint prop_id,
@@ -2009,6 +2040,40 @@ mate_panel_applet_setup (MatePanelApplet *applet)
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+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);
+
+ switch (type) {
+ case PANEL_NO_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;
+ }
+}
+#endif
+
static void
mate_panel_applet_init (MatePanelApplet *applet)
{
@@ -2043,6 +2108,12 @@ mate_panel_applet_init (MatePanelApplet *applet)
GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(applet->priv->plug));
GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
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");
#endif
g_signal_connect_swapped (G_OBJECT (applet->priv->plug), "embedded",
G_CALLBACK (mate_panel_applet_setup),
@@ -2082,7 +2153,9 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass)
gobject_class->set_property = mate_panel_applet_set_property;
gobject_class->constructed = mate_panel_applet_constructed;
klass->move_focus_out_of_applet = mate_panel_applet_move_focus_out_of_applet;
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+ klass->change_background = mate_panel_applet_change_background;
+#endif
widget_class->button_press_event = mate_panel_applet_button_press;
widget_class->button_release_event = mate_panel_applet_button_release;
#if GTK_CHECK_VERSION (3, 0, 0)
@@ -2218,10 +2291,11 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass)
G_TYPE_NONE,
3,
PANEL_TYPE_MATE_PANEL_APPLET_BACKGROUND_TYPE,
- GDK_TYPE_COLOR,
#if GTK_CHECK_VERSION (3, 0, 0)
+ GDK_TYPE_RGBA,
CAIRO_GOBJECT_TYPE_PATTERN);
#else
+ GDK_TYPE_COLOR,
GDK_TYPE_PIXMAP);
#endif
@@ -2533,6 +2607,8 @@ mate_panel_applet_set_background_widget (MatePanelApplet *applet,
type = mate_panel_applet_get_background (applet, &color, &pattern);
mate_panel_applet_update_background_for_widget (widget, type,
&color, pattern);
+ _mate_panel_applet_apply_css(widget,type);
+
if (type == PANEL_PIXMAP_BACKGROUND)
cairo_pattern_destroy (pattern);
#else
diff --git a/libmate-panel-applet/mate-panel-applet.h b/libmate-panel-applet/mate-panel-applet.h
index a5f91be2..1190b4bb 100644
--- a/libmate-panel-applet/mate-panel-applet.h
+++ b/libmate-panel-applet/mate-panel-applet.h
@@ -84,7 +84,7 @@ struct _MatePanelAppletClass {
void (*change_size) (MatePanelApplet* applet, guint size);
#if GTK_CHECK_VERSION (3, 0, 0)
- void (*change_background) (MatePanelApplet *applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t *pattern);
+ void (*change_background) (MatePanelApplet *applet, MatePanelAppletBackgroundType type, GdkRGBA* color, cairo_pattern_t *pattern);
#else
void (*change_background) (MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap);
#endif