summaryrefslogtreecommitdiff
path: root/mate-panel/panel-toplevel.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-06-25 11:26:17 +0200
committerStefano Karapetsas <[email protected]>2014-06-25 11:26:17 +0200
commit67c9f12a0d4188b546284efec2d0cd1b90f9052d (patch)
treed91e012aa6489f8e227bbc0d769c8130923dc2f6 /mate-panel/panel-toplevel.c
parent4a769cc810d949623d9f489f244092407c924882 (diff)
parent5185103c7acac7f6f291bbd5f7c969c8809237e7 (diff)
downloadmate-panel-67c9f12a0d4188b546284efec2d0cd1b90f9052d.tar.bz2
mate-panel-67c9f12a0d4188b546284efec2d0cd1b90f9052d.tar.xz
Merge pull request #212 from rilian-la-te/fix_expand
Fix expand
Diffstat (limited to 'mate-panel/panel-toplevel.c')
-rw-r--r--mate-panel/panel-toplevel.c124
1 files changed, 90 insertions, 34 deletions
diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c
index 9f23d1e9..00659e5d 100644
--- a/mate-panel/panel-toplevel.c
+++ b/mate-panel/panel-toplevel.c
@@ -1475,8 +1475,11 @@ void panel_toplevel_update_edges(PanelToplevel* toplevel)
background = &toplevel->priv->panel_widget->background;
+
/* We don't want any bevels with a color/image background */
+#if !GTK_CHECK_VERSION(3, 0, 0)
if (panel_background_effective_type (background) == PANEL_BACK_NONE) {
+#endif
if (toplevel->priv->geometry.y > 0)
edges |= PANEL_EDGE_TOP;
@@ -1515,7 +1518,9 @@ void panel_toplevel_update_edges(PanelToplevel* toplevel)
inner_frame = TRUE;
edges |= PANEL_EDGE_TOP | PANEL_EDGE_BOTTOM;
}
+#if !GTK_CHECK_VERSION(3, 0, 0)
}
+#endif
if (!inner_frame) {
inner_edges = PANEL_EDGE_NONE;
@@ -2973,7 +2978,9 @@ static void
panel_toplevel_check_resize (GtkContainer *container)
{
GtkAllocation allocation;
+#if !GTK_CHECK_VERSION(3, 0, 0)
GtkAllocation widget_allocation;
+#endif
GtkRequisition requisition;
GtkWidget *widget;
@@ -2990,13 +2997,11 @@ panel_toplevel_check_resize (GtkContainer *container)
#else
gtk_widget_size_request (widget, &requisition);
#endif
- gtk_widget_get_allocation (widget, &widget_allocation);
+ gtk_widget_get_allocation (widget, &allocation);
- if (widget_allocation.width != requisition.width ||
- widget_allocation.height != requisition.height)
- return;
+ allocation.width = requisition.width;
+ allocation.height = requisition.height;
- allocation = widget_allocation;
gtk_widget_size_allocate (widget, &allocation);
}
@@ -3148,13 +3153,16 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event)
PanelToplevel* toplevel = (PanelToplevel*) widget;
PanelFrameEdge edges;
gboolean retval = FALSE;
- GdkWindow *window;
- GtkStyle *style;
- GtkStateType state;
#if GTK_CHECK_VERSION (3, 0, 0)
int awidth;
int aheight;
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ GtkBorder padding;
#else
+ GdkWindow *window;
+ GtkStyle *style;
+ GtkStateType state;
GtkAllocation allocation;
#endif
@@ -3181,57 +3189,77 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event)
toplevel->priv->attached)
return retval;
- window = gtk_widget_get_window (widget);
- style = gtk_widget_get_style (widget);
- state = gtk_widget_get_state (widget);
#if GTK_CHECK_VERSION (3, 0, 0)
+ state = gtk_widget_get_state_flags (widget);
awidth = gtk_widget_get_allocated_width (widget);
aheight = gtk_widget_get_allocated_height (widget);
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (context, state, &padding);
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
#else
+ window = gtk_widget_get_window (widget);
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
gtk_widget_get_allocation (widget, &allocation);
#endif
if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK) {
int x, y, width, height;
- int xthickness, ythickness;
#if GTK_CHECK_VERSION (3, 0, 0)
x = 0;
y = 0;
height = height;
#else
+ int xthickness, ythickness;
x = allocation.x;
y = allocation.y;
height = allocation.height;
#endif
width = HANDLE_SIZE;
+#if !GTK_CHECK_VERSION(3, 0, 0)
xthickness = style->xthickness;
ythickness = style->ythickness;
+#endif
if (edges & PANEL_EDGE_TOP) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ y += padding.top;
+ height -= padding.top;
+#else
y += ythickness;
height -= ythickness;
+#endif
}
if (edges & PANEL_EDGE_BOTTOM)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ height -= padding.bottom;
+#else
height -= ythickness;
+#endif
if (edges & PANEL_EDGE_LEFT)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ x += padding.left;
+#else
x += xthickness;
+#endif
- gtk_paint_handle (style,
#if GTK_CHECK_VERSION (3, 0, 0)
- cr,
+ cairo_save (cr);
+ gtk_render_handle (context, cr, x, y, width, height);
+ cairo_restore (cr);
#else
+ gtk_paint_handle (style,
window,
-#endif
state,
GTK_SHADOW_OUT,
-#if !GTK_CHECK_VERSION (3, 0, 0)
&event->area,
-#endif
widget, "handlebox",
x, y, width, height,
GTK_ORIENTATION_VERTICAL);
+#endif
#if GTK_CHECK_VERSION (3, 0, 0)
x = awidth - HANDLE_SIZE;
@@ -3239,63 +3267,83 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event)
x = allocation.width - HANDLE_SIZE;
#endif
if (edges & PANEL_EDGE_RIGHT)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ x -= padding.right;
+#else
x -= xthickness;
+#endif
- gtk_paint_handle (style,
-#if GTK_CHECK_VERSION (3, 0, 0)
- cr,
+#if GTK_CHECK_VERSION(3, 0, 0)
+ cairo_save (cr);
+ gtk_render_handle (context, cr, x, y, width, height);
+ cairo_restore (cr);
#else
+ gtk_paint_handle (style,
window,
-#endif
state,
GTK_SHADOW_OUT,
-#if !GTK_CHECK_VERSION (3, 0, 0)
&event->area,
-#endif
widget, "handlebox",
x, y, width, height,
GTK_ORIENTATION_VERTICAL);
+#endif
} else {
int x, y, width, height;
- int xthickness, ythickness;
#if GTK_CHECK_VERSION (3, 0, 0)
x = 0;
y = 0;
width = awidth;
#else
+ int xthickness, ythickness;
+
x = allocation.x;
y = allocation.y;
width = allocation.width;
#endif
height = HANDLE_SIZE;
+#if !GTK_CHECK_VERSION (3, 0, 0)
xthickness = style->xthickness;
ythickness = style->ythickness;
+#endif
if (edges & PANEL_EDGE_LEFT) {
+#if GTK_CHECK_VERSION (3, 0, 0)
+ x += padding.left;
+ width -= padding.left;
+#else
x += xthickness;
width -= xthickness;
+#endif
}
if (edges & PANEL_EDGE_RIGHT)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ width -= padding.right;
+#else
width -= xthickness;
+#endif
if (edges & PANEL_EDGE_TOP)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ y += padding.top;
+#else
y += ythickness;
+#endif
- gtk_paint_handle (style,
#if GTK_CHECK_VERSION (3, 0, 0)
- cr,
+ cairo_save (cr);
+ gtk_render_handle (context, cr, x, y, width, height);
+ cairo_restore (cr);
#else
+ gtk_paint_handle (style,
window,
-#endif
state,
GTK_SHADOW_OUT,
-#if !GTK_CHECK_VERSION (3, 0, 0)
&event->area,
-#endif
widget, "handlebox",
x, y, width, height,
GTK_ORIENTATION_HORIZONTAL);
+#endif
#if GTK_CHECK_VERSION (3, 0, 0)
y = aheight - HANDLE_SIZE;
@@ -3303,24 +3351,32 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event)
y = allocation.height - HANDLE_SIZE;
#endif
if (edges & PANEL_EDGE_BOTTOM)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ y -= padding.bottom;
+#else
y -= ythickness;
+#endif
- gtk_paint_handle (style,
#if GTK_CHECK_VERSION (3, 0, 0)
- cr,
+ cairo_save (cr);
+ gtk_render_handle (context, cr, x, y, width, height);
+ cairo_restore (cr);
#else
+ gtk_paint_handle (style,
window,
-#endif
state,
GTK_SHADOW_OUT,
-#if !GTK_CHECK_VERSION (3, 0, 0)
&event->area,
-#endif
widget, "handlebox",
x, y, width, height,
GTK_ORIENTATION_HORIZONTAL);
+#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_style_context_restore (context);
+#endif
+
return retval;
}