summaryrefslogtreecommitdiff
path: root/mate-panel
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-11-29 14:36:23 +0100
committerStefano Karapetsas <[email protected]>2013-11-29 14:36:23 +0100
commit17fc492a17e8f5317d7438c771ac9c95ce1e0a04 (patch)
treee40ede01db66cccda81ecf1a2c49ad76037ac26c /mate-panel
parent3f71479324ce6896c3cd8a480aacaf588ab159a9 (diff)
downloadmate-panel-17fc492a17e8f5317d7438c771ac9c95ce1e0a04.tar.bz2
mate-panel-17fc492a17e8f5317d7438c771ac9c95ce1e0a04.tar.xz
Panel background improvements for GTK3
Diffstat (limited to 'mate-panel')
-rw-r--r--mate-panel/panel-background.c105
-rw-r--r--mate-panel/panel-background.h8
-rw-r--r--mate-panel/panel-profile.c54
-rw-r--r--mate-panel/panel-profile.h17
-rw-r--r--mate-panel/panel-properties-dialog.c35
-rw-r--r--mate-panel/panel-types.h2
-rw-r--r--mate-panel/panel-widget.c104
-rw-r--r--mate-panel/panel.c11
8 files changed, 272 insertions, 64 deletions
diff --git a/mate-panel/panel-background.c b/mate-panel/panel-background.c
index eb2308e5..f85fb939 100644
--- a/mate-panel/panel-background.c
+++ b/mate-panel/panel-background.c
@@ -29,7 +29,11 @@
#include <string.h>
#include <gdk/gdkx.h>
#include <gdk/gdk.h>
+#include <gtk/gtk.h>
#include <cairo.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <cairo-xlib.h>
+#endif
#include "panel-background-monitor.h"
#include "panel-util.h"
@@ -43,15 +47,11 @@ static void
free_prepared_resources (PanelBackground *background)
{
background->prepared = FALSE;
-
+#if !GTK_CHECK_VERSION (3, 0, 0)
switch (background->type) {
case PANEL_BACK_NONE:
break;
case PANEL_BACK_COLOR:
-#if GTK_CHECK_VERSION (3, 0, 0)
- if (!background->has_alpha)
- background->color.red = background->color.green = background->color.blue = 0.;
-#else
if (background->has_alpha) {
if (background->pixmap)
g_object_unref (background->pixmap);
@@ -63,19 +63,17 @@ free_prepared_resources (PanelBackground *background)
&background->color.gdk, 1);
background->color.gdk.pixel = 0;
}
-#endif
break;
case PANEL_BACK_IMAGE:
-#if !GTK_CHECK_VERSION (3, 0, 0)
if (background->pixmap)
g_object_unref (background->pixmap);
background->pixmap = NULL;
-#endif
break;
default:
g_assert_not_reached ();
break;
}
+#endif
}
static void
@@ -146,8 +144,13 @@ panel_background_prepare (PanelBackground *background)
TRUE);
#endif
} else
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window_set_background_rgba (
+ background->window, &background->default_color);
+#else
gdk_window_set_background (
background->window, &background->default_color);
+#endif
break;
case PANEL_BACK_COLOR:
if (background->has_alpha &&
@@ -278,9 +281,7 @@ static GdkPixbuf *
#endif
composite_image_onto_desktop (PanelBackground *background)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
- static const cairo_user_data_key_t key;
-#else
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf *retval;
unsigned char *data;
#endif
@@ -708,7 +709,11 @@ panel_background_update_has_alpha (PanelBackground *background)
gboolean has_alpha = FALSE;
if (background->type == PANEL_BACK_COLOR)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ has_alpha = (background->color.alpha < 1.);
+#else
has_alpha = (background->color.alpha != 0xffff);
+#endif
else if (background->type == PANEL_BACK_IMAGE &&
background->loaded_image)
@@ -786,12 +791,17 @@ panel_background_set_gdk_color (PanelBackground *background,
panel_background_set_gdk_color_no_update (background, gdk_color);
panel_background_transform (background);
}
+#endif
static void
panel_background_set_opacity_no_update (PanelBackground *background,
guint16 opacity)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ background->color.alpha = opacity / 65535.0;
+#else
background->color.alpha = opacity;
+#endif
panel_background_update_has_alpha (background);
}
@@ -799,14 +809,17 @@ void
panel_background_set_opacity (PanelBackground *background,
guint16 opacity)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (background->color.alpha == (opacity / 65535.0))
+#else
if (background->color.alpha == opacity)
+#endif
return;
free_transformed_resources (background);
panel_background_set_opacity_no_update (background, opacity);
panel_background_transform (background);
}
-#endif
static void
panel_background_set_color_no_update (PanelBackground *background,
@@ -974,10 +987,11 @@ panel_background_set (PanelBackground *background,
void
panel_background_set_default_style (PanelBackground *background,
- GdkColor *color,
#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA *color,
cairo_pattern_t *pattern)
#else
+ GdkColor *color,
GdkPixmap *pixmap)
#endif
{
@@ -1180,10 +1194,18 @@ panel_background_init (PanelBackground *background,
#else
background->default_pixmap = NULL;
#endif
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ background->default_color.red = 0.;
+ background->default_color.green = 0.;
+ background->default_color.blue = 0.;
+ background->default_color.alpha = 1.;
+#else
background->default_color.red = 0;
background->default_color.green = 0;
background->default_color.blue = 0;
background->default_color.pixel = 0;
+#endif
background->fit_image = FALSE;
background->stretch_image = FALSE;
@@ -1246,7 +1268,7 @@ panel_background_make_string (PanelBackground *background,
{
PanelBackgroundType effective_type;
char *retval;
-
+
retval = NULL;
effective_type = panel_background_effective_type (background);
@@ -1254,7 +1276,10 @@ panel_background_make_string (PanelBackground *background,
if (effective_type == PANEL_BACK_IMAGE ||
(effective_type == PANEL_BACK_COLOR && background->has_alpha)) {
#if GTK_CHECK_VERSION (3, 0, 0)
- Window pixmap_xid;
+ cairo_surface_t *surface;
+
+ if (!background->composited_pattern)
+ return NULL;
#else
GdkNativeWindow pixmap_xid;
@@ -1263,31 +1288,37 @@ panel_background_make_string (PanelBackground *background,
#endif
#if GTK_CHECK_VERSION (3, 0, 0)
- pixmap_xid = gdk_x11_window_get_xid (background->window);
+ if (cairo_pattern_get_surface (background->composited_pattern, &surface))
+ return NULL;
+
+ if (cairo_surface_get_type (surface) != CAIRO_SURFACE_TYPE_XLIB)
+ return NULL;
+
+ retval = g_strdup_printf ("pixmap:%d,%d,%d", (guint32)cairo_xlib_surface_get_drawable (surface), x, y);
#else
pixmap_xid = gdk_x11_drawable_get_xid (
GDK_DRAWABLE (background->pixmap));
-#endif
retval = g_strdup_printf ("pixmap:%d,%d,%d", pixmap_xid, x, y);
-
- } else if (effective_type == PANEL_BACK_COLOR)
- retval = g_strdup_printf (
- "color:%.4x%.4x%.4x",
+#endif
+ } else if (effective_type == PANEL_BACK_COLOR) {
#if GTK_CHECK_VERSION (3, 0, 0)
- background->color.red,
- background->color.green,
- background->color.blue);
+ gchar *rgba = gdk_rgba_to_string (&background->color);
+ retval = g_strdup_printf (
+ "color:%s",
+ rgba);
+ g_free (rgba);
#else
+ retval = g_strdup_printf (
+ "color:%.4x%.4x%.4x",
background->color.gdk.red,
background->color.gdk.green,
background->color.gdk.blue);
#endif
- else
+ } else
retval = g_strdup ("none:");
- return retval;
-
+ return retval;
}
PanelBackgroundType
@@ -1335,6 +1366,7 @@ panel_background_effective_type (PanelBackground *background)
return retval;
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
static void
panel_background_set_no_background_on_widget (PanelBackground *background,
GtkWidget *widget)
@@ -1346,6 +1378,7 @@ panel_background_set_no_background_on_widget (PanelBackground *background,
gtk_widget_modify_style (widget, rc_style);
g_object_unref (rc_style);
}
+#endif
#if GTK_CHECK_VERSION (3, 0, 0)
static cairo_pattern_t *
@@ -1432,37 +1465,23 @@ panel_background_set_image_background_on_widget (PanelBackground *background,
#endif
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
static void
panel_background_set_color_background_on_widget (PanelBackground *background,
GtkWidget *widget)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
- const GdkRGBA *color;
- GdkColor gdkcolor;
-#else
const PanelColor *color;
-#endif
color = panel_background_get_color (background);
-#if GTK_CHECK_VERSION (3, 0, 0)
- if (color->alpha < 1.) {
-#else
if (color->alpha != 0xffff) {
-#endif
panel_background_set_image_background_on_widget (background,
widget);
return;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
- gdkcolor.red = color->red * 65535.;
- gdkcolor.green = color->green * 65535.;
- gdkcolor.blue = color->blue * 65535.;
- gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &gdkcolor);
-#else
gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &color->gdk);
-#endif
}
+#endif
#if GTK_CHECK_VERSION (3, 0, 0)
static GtkStyleProperties *
diff --git a/mate-panel/panel-background.h b/mate-panel/panel-background.h
index b5aeb6eb..fead8648 100644
--- a/mate-panel/panel-background.h
+++ b/mate-panel/panel-background.h
@@ -69,13 +69,14 @@ struct _PanelBackground {
GdkWindow *window;
#if GTK_CHECK_VERSION (3, 0, 0)
cairo_pattern_t *default_pattern;
+ GdkRGBA default_color;
#else
GdkPixmap *pixmap;
GdkColormap *colormap;
GdkGC *gc;
GdkPixmap *default_pixmap;
-#endif
GdkColor default_color;
+#endif
guint fit_image : 1;
guint stretch_image : 1;
@@ -109,9 +110,9 @@ void panel_background_set_type (PanelBackground *background,
#if !GTK_CHECK_VERSION (3, 0, 0)
void panel_background_set_gdk_color (PanelBackground *background,
GdkColor *gdk_color);
+#endif
void panel_background_set_opacity (PanelBackground *background,
guint16 opacity);
-#endif
void panel_background_set_color (PanelBackground *background,
#if GTK_CHECK_VERSION (3, 0, 0)
const GdkRGBA *color);
@@ -127,10 +128,11 @@ void panel_background_set_stretch (PanelBackground *background,
void panel_background_set_rotate (PanelBackground *background,
gboolean rotate_image);
void panel_background_set_default_style (PanelBackground *background,
- GdkColor *color,
#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA *color,
cairo_pattern_t *pattern);
#else
+ GdkColor *color,
GdkPixmap *pixmap);
#endif
void panel_background_realized (PanelBackground *background,
diff --git a/mate-panel/panel-profile.c b/mate-panel/panel-profile.c
index 2c5b328c..3dad813b 100644
--- a/mate-panel/panel-profile.c
+++ b/mate-panel/panel-profile.c
@@ -232,20 +232,67 @@ panel_profile_get_background_type (PanelToplevel *toplevel)
void
panel_profile_set_background_color (PanelToplevel *toplevel,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA *color)
+#else
PanelColor *color)
+#endif
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ panel_profile_set_background_gdk_rgba_color (toplevel, color);
+#else
panel_profile_set_background_gdk_color (toplevel, &color->gdk);
+#endif
panel_profile_set_background_opacity (toplevel, color->alpha);
}
void
panel_profile_get_background_color (PanelToplevel *toplevel,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA *color)
+#else
PanelColor *color)
+#endif
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ panel_profile_get_background_gdk_rgba_color (toplevel, color);
+ color->alpha = panel_profile_get_background_opacity (toplevel) / 65535.0;
+#else
panel_profile_get_background_gdk_color (toplevel, &(color->gdk));
color->alpha = panel_profile_get_background_opacity (toplevel);
+#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+void
+panel_profile_set_background_gdk_rgba_color (PanelToplevel *toplevel,
+ GdkRGBA *color)
+{
+ char *color_str;
+
+ color_str = gdk_rgba_to_string (color);
+
+ g_settings_set_string(toplevel->background_settings, "color", color_str);
+
+ g_free (color_str);
+}
+
+void
+panel_profile_get_background_gdk_rgba_color (PanelToplevel *toplevel,
+ GdkRGBA *color)
+{
+ char *color_str;
+
+ color_str = g_settings_get_string (toplevel->background_settings, "color");
+ if (!color_str || !gdk_rgba_parse (color, color_str)) {
+ color->red = 0.;
+ color->green = 0.;
+ color->blue = 0.;
+ }
+
+ g_free (color_str);
+}
+#else
void
panel_profile_set_background_gdk_color (PanelToplevel *toplevel,
GdkColor *gdk_color)
@@ -277,6 +324,7 @@ panel_profile_get_background_gdk_color (PanelToplevel *toplevel,
g_free (color_str);
}
+#endif
void
panel_profile_set_background_opacity (PanelToplevel *toplevel,
@@ -518,7 +566,11 @@ get_background_color (PanelToplevel *toplevel,
#endif
g_free (color_str);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ color->alpha = g_settings_get_int (toplevel->background_settings, "opacity") / 65535.0;
+#else
color->alpha = g_settings_get_int (toplevel->background_settings, "opacity");
+#endif
}
static char *
@@ -855,10 +907,8 @@ panel_profile_background_change_notify (GSettings *settings,
g_free (str);
#endif
} else if (!strcmp (key, "opacity")) {
-#if !GTK_CHECK_VERSION (3, 0, 0)
panel_background_set_opacity (background,
g_settings_get_int (settings, key));
-#endif
} else if (!strcmp (key, "image")) {
panel_background_set_image (background,
g_settings_get_string (settings, key));
diff --git a/mate-panel/panel-profile.h b/mate-panel/panel-profile.h
index 665e237b..ffa43af3 100644
--- a/mate-panel/panel-profile.h
+++ b/mate-panel/panel-profile.h
@@ -110,14 +110,29 @@ PanelBackgroundType
panel_profile_get_background_type (PanelToplevel *toplevel);
void panel_profile_set_background_color (PanelToplevel *toplevel,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA *color);
+#else
PanelColor *color);
+#endif
void panel_profile_get_background_color (PanelToplevel *toplevel,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA *color);
+#else
PanelColor *color);
-
+#endif
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+void panel_profile_set_background_gdk_rgba_color (PanelToplevel *toplevel,
+ GdkRGBA *color);
+void panel_profile_get_background_gdk_rgba_color (PanelToplevel *toplevel,
+ GdkRGBA *color);
+#else
void panel_profile_set_background_gdk_color (PanelToplevel *toplevel,
GdkColor *gdk_color);
void panel_profile_get_background_gdk_color (PanelToplevel *toplevel,
GdkColor *gdk_color);
+#endif
void panel_profile_set_background_opacity (PanelToplevel *toplevel,
guint16 opacity);
diff --git a/mate-panel/panel-properties-dialog.c b/mate-panel/panel-properties-dialog.c
index 5818522f..c14dae99 100644
--- a/mate-panel/panel-properties-dialog.c
+++ b/mate-panel/panel-properties-dialog.c
@@ -327,19 +327,32 @@ static void
panel_properties_dialog_color_changed (PanelPropertiesDialog *dialog,
GtkColorButton *color_button)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
GdkColor color;
+#endif
g_assert (dialog->color_button == GTK_WIDGET (color_button));
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_color_button_get_rgba (color_button, &color);
+ panel_profile_set_background_gdk_rgba_color (dialog->toplevel, &color);
+#else
gtk_color_button_get_color (color_button, &color);
panel_profile_set_background_gdk_color (dialog->toplevel, &color);
+#endif
}
static void
panel_properties_dialog_setup_color_button (PanelPropertiesDialog *dialog,
GtkBuilder *gui)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
PanelColor color;
+#endif
dialog->color_button = PANEL_GTK_BUILDER_GET (gui, "color_button");
g_return_if_fail (dialog->color_button != NULL);
@@ -348,8 +361,13 @@ panel_properties_dialog_setup_color_button (PanelPropertiesDialog *dialog,
panel_profile_get_background_color (dialog->toplevel, &color);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (dialog->color_button),
+ &color);
+#else
gtk_color_button_set_color (GTK_COLOR_BUTTON (dialog->color_button),
&(color.gdk));
+#endif
g_signal_connect_swapped (dialog->color_button, "color_set",
G_CALLBACK (panel_properties_dialog_color_changed),
@@ -693,19 +711,36 @@ static void
panel_properties_dialog_update_background_color (PanelPropertiesDialog *dialog,
gchar *str_color)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA new_color;
+ GdkRGBA old_color;
+#else
GdkColor new_color = { 0, };
GdkColor old_color;
+#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (!gdk_rgba_parse (&new_color, str_color))
+#else
if (!gdk_color_parse (str_color, &new_color))
+#endif
return;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_color_button_get_rgba (GTK_COLOR_BUTTON (dialog->color_button),
+#else
gtk_color_button_get_color (GTK_COLOR_BUTTON (dialog->color_button),
+#endif
&old_color);
if (old_color.red != new_color.red ||
old_color.green != new_color.green ||
old_color.blue != new_color.blue)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_color_button_set_rgba (GTK_COLOR_BUTTON (dialog->color_button),
+#else
gtk_color_button_set_color (GTK_COLOR_BUTTON (dialog->color_button),
+#endif
&new_color);
}
diff --git a/mate-panel/panel-types.h b/mate-panel/panel-types.h
index e71549ae..2d16942f 100644
--- a/mate-panel/panel-types.h
+++ b/mate-panel/panel-types.h
@@ -11,9 +11,11 @@ typedef enum {
PANEL_SPEED_FAST
} PanelSpeed;
+#if !GTK_CHECK_VERSION (3, 0, 0)
typedef struct {
GdkColor gdk;
guint16 alpha;
} PanelColor;
+#endif
#endif
diff --git a/mate-panel/panel-widget.c b/mate-panel/panel-widget.c
index 969096b2..734eb459 100644
--- a/mate-panel/panel-widget.c
+++ b/mate-panel/panel-widget.c
@@ -87,10 +87,16 @@ static void panel_widget_destroy (GtkObject *obj);
static void panel_widget_finalize (GObject *obj);
static void panel_widget_realize (GtkWidget *widget);
static void panel_widget_unrealize (GtkWidget *panel);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void panel_widget_state_flags_changed (GtkWidget *widget,
+ GtkStateFlags previous_state);
+static void panel_widget_style_updated (GtkWidget *widget);
+#else
static void panel_widget_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void panel_widget_style_set (GtkWidget *widget,
GtkStyle *previous_style);
+#endif
static void panel_widget_background_changed (PanelBackground *background,
PanelWidget *panel);
@@ -127,6 +133,11 @@ static void
emit_applet_moved (PanelWidget *panel_widget,
AppletData *applet)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ /* we always want to queue a draw after moving, so do it here instead
+ * of after the signal emission in all callers */
+ gtk_widget_queue_draw (applet->applet);
+#endif
g_signal_emit (panel_widget,
panel_widget_signals [APPLET_MOVE_SIGNAL], 0,
applet->applet);
@@ -445,8 +456,13 @@ panel_widget_class_init (PanelWidgetClass *class)
widget_class->realize = panel_widget_realize;
widget_class->unrealize = panel_widget_unrealize;
widget_class->focus = panel_widget_real_focus;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->state_flags_changed = panel_widget_state_flags_changed;
+ widget_class->style_updated = panel_widget_style_updated;
+#else
widget_class->state_changed = panel_widget_state_changed;
widget_class->style_set = panel_widget_style_set;
+#endif
container_class->add = panel_widget_cadd;
container_class->remove = panel_widget_cremove;
@@ -1244,7 +1260,11 @@ panel_widget_size_request(GtkWidget *widget, GtkRequisition *requisition)
for(list = panel->applet_list; list!=NULL; list = g_list_next(list)) {
AppletData *ad = list->data;
GtkRequisition chreq;
- gtk_widget_size_request(ad->applet,&chreq);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);
+#else
+ gtk_widget_size_request(ad->applet, &chreq);
+#endif
if (panel->orient == GTK_ORIENTATION_HORIZONTAL) {
if (requisition->height < chreq.height && !ad->size_constrained)
@@ -1424,7 +1444,11 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
AppletData *ad = list->data;
GtkAllocation challoc;
GtkRequisition chreq;
- gtk_widget_get_child_requisition(ad->applet,&chreq);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);
+#else
+ gtk_widget_get_child_requisition(ad->applet, &chreq);
+#endif
ad->constrained = i;
@@ -1475,7 +1499,11 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
AppletData *ad = list->data;
GtkRequisition chreq;
- gtk_widget_get_child_requisition(ad->applet,&chreq);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);
+#else
+ gtk_widget_get_child_requisition(ad->applet, &chreq);
+#endif
if (!ad->expand_major || !ad->size_hints) {
if(panel->orient == GTK_ORIENTATION_HORIZONTAL)
@@ -1545,7 +1573,11 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
AppletData *ad = list->data;
GtkAllocation challoc;
GtkRequisition chreq;
- gtk_widget_get_child_requisition(ad->applet,&chreq);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (ad->applet, &chreq, NULL);
+#else
+ gtk_widget_get_child_requisition (ad->applet, &chreq);
+#endif
challoc.width = chreq.width;
challoc.height = chreq.height;
if(panel->orient == GTK_ORIENTATION_HORIZONTAL) {
@@ -1564,6 +1596,9 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
challoc.y = ad->constrained;
}
+ challoc.width = MAX(challoc.width, 1);
+ challoc.height = MAX(challoc.height, 1);
+
gtk_widget_size_allocate(ad->applet,&challoc);
}
}
@@ -1607,31 +1642,61 @@ panel_widget_is_cursor(PanelWidget *panel, int overlap)
}
static void
-panel_widget_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+#if GTK_CHECK_VERSION (3, 0, 0)
+panel_widget_set_background_default_style (GtkWidget *widget)
+#else
+panel_widget_style_set (GtkWidget *widget, GtkStyle *previous_style)
+#endif
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ GdkRGBA bg_color;
+ cairo_pattern_t *bg_image;
+#else
GtkStyle *style;
GtkStateType state;
+#endif
if (gtk_widget_get_realized (widget)) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_widget_get_state_flags (widget);
+
+ gtk_style_context_get_background_color (context, state, &bg_color);
+ gtk_style_context_get (context, state, "background-image", &bg_image, NULL);
+#else
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
+#endif
panel_background_set_default_style (
&PANEL_WIDGET (widget)->background,
- &style->bg [state],
#if GTK_CHECK_VERSION (3, 0, 0)
- style->background [state]);
+ &bg_color,
+ bg_image);
+
+ if (bg_image)
+ cairo_pattern_destroy (bg_image);
#else
+ &style->bg [state],
style->bg_pixmap [state]);
#endif
}
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+panel_widget_style_updated (GtkWidget *widget)
+#else
panel_widget_state_changed (GtkWidget *widget,
GtkStateType previous_state)
+#endif
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ panel_widget_set_background_default_style (widget);
+ GTK_WIDGET_CLASS (panel_widget_parent_class)->style_updated (widget);
+#else
GtkStyle *style;
GtkStateType state;
@@ -1642,14 +1707,19 @@ panel_widget_state_changed (GtkWidget *widget,
panel_background_set_default_style (
&PANEL_WIDGET (widget)->background,
&style->bg [state],
-#if GTK_CHECK_VERSION (3, 0, 0)
- style->background [state]);
-#else
style->bg_pixmap [state]);
-#endif
}
+#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+panel_widget_state_flags_changed (GtkWidget *widget, GtkStateFlags previous_state)
+{
+ panel_widget_set_background_default_style (widget);
+}
+#endif
+
static gboolean
toplevel_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
@@ -1665,8 +1735,10 @@ panel_widget_realize (GtkWidget *widget)
{
PanelWidget *panel = (PanelWidget *) widget;
GdkWindow *window;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GtkStyle *style;
GtkStateType state;
+#endif
g_signal_connect (panel->toplevel, "configure-event",
G_CALLBACK (toplevel_configure_event), panel);
@@ -1674,19 +1746,21 @@ panel_widget_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (panel_widget_parent_class)->realize (widget);
window = gtk_widget_get_window (widget);
+#if !GTK_CHECK_VERSION (3, 0, 0)
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
+#endif
/* For auto-hidden panels with a colored background, we need native
* windows to avoid some uglyness on unhide */
gdk_window_ensure_native (window);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ panel_widget_set_background_default_style (widget);
+#else
panel_background_set_default_style (
&panel->background,
&style->bg [state],
-#if GTK_CHECK_VERSION (3, 0, 0)
- style->background [state]);
-#else
style->bg_pixmap [state]);
#endif
diff --git a/mate-panel/panel.c b/mate-panel/panel.c
index 8ac44a88..666a62b7 100644
--- a/mate-panel/panel.c
+++ b/mate-panel/panel.c
@@ -433,7 +433,11 @@ static gboolean
set_background_color (PanelToplevel *toplevel,
guint16 *dropped)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA color;
+#else
PanelColor color;
+#endif
if (!dropped)
return FALSE;
@@ -442,10 +446,17 @@ set_background_color (PanelToplevel *toplevel,
! panel_profile_background_key_is_writable (toplevel, "type"))
return FALSE;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ color.red = dropped [0];
+ color.green = dropped [1];
+ color.blue = dropped [2];
+ color.alpha = 1.;
+#else
color.gdk.red = dropped [0];
color.gdk.green = dropped [1];
color.gdk.blue = dropped [2];
color.alpha = 65535;
+#endif
panel_profile_set_background_color (toplevel, &color);
panel_profile_set_background_type (toplevel, PANEL_BACK_COLOR);