summaryrefslogtreecommitdiff
path: root/libmate-panel-applet
diff options
context:
space:
mode:
authorlukefromdc <[email protected]>2016-03-10 17:33:07 -0500
committerraveit65 <[email protected]>2016-03-13 20:05:32 +0100
commita4d5480a2f4f7524fe2b5599dd99842465d4eeb3 (patch)
treec6397f4fa520dc8e41a6df16476fa0d0b696e34e /libmate-panel-applet
parentdb46e948f57ad16170afeaf72d418c508ef63d1e (diff)
downloadmate-panel-a4d5480a2f4f7524fe2b5599dd99842465d4eeb3.tar.bz2
mate-panel-a4d5480a2f4f7524fe2b5599dd99842465d4eeb3.tar.xz
gtk3.20-fix custom BG change on applets
mate-panel-applet.c based on github.com/GNOME/gnome-panel/commit/3115f77b536a7c79c7d43ded0591e2b8f45219c4 "restore custom background on applets) Reverts and replaces use of gtk_window_ensure_native on applets, uses the panel-plug-private files from gnome panel intact. This way the system theme returns when custom background is deselected w/o having to restart the panel. These changes kept behind gtk3.20 only build time conditionals. requires if-elif-endif three-way conditionals due to the extent to GTK differences. Doing it this way keeps panel applets from being twice as dark as the panel when an alpha color background is selected
Diffstat (limited to 'libmate-panel-applet')
-rw-r--r--libmate-panel-applet/mate-panel-applet.c137
1 files changed, 113 insertions, 24 deletions
diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c
index 17de8e13..a1e504ba 100644
--- a/libmate-panel-applet/mate-panel-applet.c
+++ b/libmate-panel-applet/mate-panel-applet.c
@@ -47,7 +47,9 @@
#include "mate-panel-applet-factory.h"
#include "mate-panel-applet-marshal.h"
#include "mate-panel-applet-enums.h"
-
+#if GTK_CHECK_VERSION (3, 19, 0)
+#include "panel-plug-private.h"
+#endif
#define MATE_PANEL_APPLET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET, MatePanelAppletPrivate))
struct _MatePanelAppletPrivate {
@@ -69,7 +71,9 @@ struct _MatePanelAppletPrivate {
MatePanelAppletOrient orient;
guint size;
char *background;
+#if !GTK_CHECK_VERSION (3, 19, 0)
GtkWidget *background_widget;
+#endif
int previous_width;
int previous_height;
@@ -1710,16 +1714,49 @@ mate_panel_applet_update_background_for_widget (GtkWidget *widge
}
#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
static void
mate_panel_applet_handle_background (MatePanelApplet *applet)
{
MatePanelAppletBackgroundType type;
-#if GTK_CHECK_VERSION (3, 0, 0)
+
GdkRGBA color;
cairo_pattern_t *pattern;
type = mate_panel_applet_get_background (applet, &color, &pattern);
+
+ switch (type) {
+ case PANEL_NO_BACKGROUND:
+ g_signal_emit (G_OBJECT (applet),
+ mate_panel_applet_signals [CHANGE_BACKGROUND],
+ 0, PANEL_NO_BACKGROUND, NULL, NULL);
+ break;
+ case PANEL_COLOR_BACKGROUND:
+ g_signal_emit (G_OBJECT (applet),
+ mate_panel_applet_signals [CHANGE_BACKGROUND],
+ 0, PANEL_COLOR_BACKGROUND, &color, NULL);
+ break;
+ case PANEL_PIXMAP_BACKGROUND:
+ g_signal_emit (G_OBJECT (applet),
+ mate_panel_applet_signals [CHANGE_BACKGROUND],
+
+ 0, PANEL_PIXMAP_BACKGROUND, NULL, pattern);
+
+
+ cairo_pattern_destroy (pattern);
+
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
#else
+static void
+mate_panel_applet_handle_background (MatePanelApplet *applet)
+{
+ MatePanelAppletBackgroundType type;
+
GdkColor color;
GdkPixmap *pixmap;
@@ -1728,7 +1765,6 @@ mate_panel_applet_handle_background (MatePanelApplet *applet)
if (applet->priv->background_widget)
mate_panel_applet_update_background_for_widget (applet->priv->background_widget,
type, &color, pixmap);
-#endif
switch (type) {
case PANEL_NO_BACKGROUND:
@@ -1744,17 +1780,11 @@ mate_panel_applet_handle_background (MatePanelApplet *applet)
case PANEL_PIXMAP_BACKGROUND:
g_signal_emit (G_OBJECT (applet),
mate_panel_applet_signals [CHANGE_BACKGROUND],
-#if GTK_CHECK_VERSION (3, 0, 0)
- 0, PANEL_PIXMAP_BACKGROUND, NULL, pattern);
-#else
+
0, PANEL_PIXMAP_BACKGROUND, NULL, pixmap);
-#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
- cairo_pattern_destroy (pattern);
-#else
g_object_unref (pixmap);
-#endif
+
break;
default:
g_assert_not_reached ();
@@ -1762,6 +1792,8 @@ mate_panel_applet_handle_background (MatePanelApplet *applet)
}
}
+#endif
+
static void
mate_panel_applet_realize (GtkWidget *widget)
{
@@ -1785,7 +1817,36 @@ mate_panel_applet_move_focus_out_of_applet (MatePanelApplet *applet,
applet->priv->moving_focus_out = FALSE;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
+#if GTK_CHECK_VERSION (3, 19, 0)
+static void
+mate_panel_applet_change_background(MatePanelApplet *applet,
+ MatePanelAppletBackgroundType type,
+ GdkRGBA* color,
+ cairo_pattern_t *pattern)
+{
+ GdkWindow* window = gtk_widget_get_window (applet->priv->plug);
+ 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);
+ gtk_widget_queue_draw (applet->priv->plug); /*change the bg right away always */
+ break;
+ case PANEL_PIXMAP_BACKGROUND:
+ gdk_window_set_background_pattern(window,pattern);
+ gtk_widget_queue_draw (applet->priv->plug); /*change the bg right away always */
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+#elif GTK_CHECK_VERSION (3, 0, 0)
+
static void
mate_panel_applet_change_background(MatePanelApplet *applet,
MatePanelAppletBackgroundType type,
@@ -1801,21 +1862,16 @@ mate_panel_applet_change_background(MatePanelApplet *applet,
break;
case PANEL_COLOR_BACKGROUND:
gdk_window_set_background_rgba(window,color);
-#if GTK_CHECK_VERSION (3, 19, 0)
- gdk_window_ensure_native (window);
-#endif
break;
case PANEL_PIXMAP_BACKGROUND:
gdk_window_set_background_pattern(window,pattern);
-#if GTK_CHECK_VERSION (3, 19, 0)
- gdk_window_ensure_native (window);
-#endif
break;
default:
g_assert_not_reached ();
break;
}
}
+
#endif
static void
@@ -2545,19 +2601,36 @@ int mate_panel_applet_factory_main(const gchar* factory_id, gboolean out_process
return 1;
}
+/**
+ * mate_panel_applet_set_background_widget:
+ * @applet: a #PanelApplet.
+ * @widget: a #GtkWidget.
+ *
+ * Configure #PanelApplet to automatically draw the background of the applet on
+ * @widget. It is generally enough to call this function with @applet as
+ * @widget.
+ *
+ * Deprecated: 3.20: Do not use this API. Since 3.20 this function does nothing.
+ **/
+
+
+#if GTK_CHECK_VERSION (3, 19, 0)
+
+void
+mate_panel_applet_set_background_widget (MatePanelApplet *applet,
+ GtkWidget *widget)
+{
+}
+
+#elif GTK_CHECK_VERSION (3, 0, 0)
void
mate_panel_applet_set_background_widget (MatePanelApplet *applet,
GtkWidget *widget)
{
applet->priv->background_widget = widget;
-#if GTK_CHECK_VERSION (3, 0, 0)
if (widget && gtk_widget_get_realized (widget)) {
-#else
- if (widget) {
-#endif
MatePanelAppletBackgroundType type;
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkRGBA color;
cairo_pattern_t *pattern;
type = mate_panel_applet_get_background (applet, &color, &pattern);
@@ -2565,7 +2638,21 @@ mate_panel_applet_set_background_widget (MatePanelApplet *applet,
if (type == PANEL_PIXMAP_BACKGROUND)
cairo_pattern_destroy (pattern);
+ }
+}
+
#else
+void
+mate_panel_applet_set_background_widget (MatePanelApplet *applet,
+ GtkWidget *widget)
+{
+ applet->priv->background_widget = widget;
+
+
+ if (widget) {
+
+ MatePanelAppletBackgroundType type;
+
GdkColor color;
GdkPixmap *pixmap;
type = mate_panel_applet_get_background (applet, &color, &pixmap);
@@ -2573,10 +2660,12 @@ mate_panel_applet_set_background_widget (MatePanelApplet *applet,
&color, pixmap);
if (type == PANEL_PIXMAP_BACKGROUND)
g_object_unref (pixmap);
-#endif
+
}
}
+#endif
+
guint32
mate_panel_applet_get_xid (MatePanelApplet *applet,
GdkScreen *screen)