From 232713d42e79c519cfb060bb286e4cd600678559 Mon Sep 17 00:00:00 2001 From: infirit Date: Sat, 22 Nov 2014 18:30:38 +0100 Subject: Gtk3: Sync get_preferred_width/height() usage with gnome-panel Even tough it works it makes taking code (eg StyleContext) from gnome-panel much easier. Also fixes a bug where applets are not drawn when moved/added. --- mate-panel/panel-separator.c | 58 ++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'mate-panel/panel-separator.c') diff --git a/mate-panel/panel-separator.c b/mate-panel/panel-separator.c index 022797c6..7233d59a 100644 --- a/mate-panel/panel-separator.c +++ b/mate-panel/panel-separator.c @@ -133,6 +133,43 @@ static gboolean panel_separator_expose_event(GtkWidget* widget, GdkEventExpose* return FALSE; } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +panel_separator_get_preferred_width (GtkWidget *widget, + gint *minimal_width, + gint *natural_width) +{ + PanelSeparator *separator; + int size; + + separator = PANEL_SEPARATOR (widget); + + size = panel_toplevel_get_size (separator->priv->panel->toplevel); + + if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL) + *minimal_width = *natural_width = size; + else + *minimal_width = *natural_width = SEPARATOR_SIZE; +} + +static void +panel_separator_get_preferred_height (GtkWidget *widget, + gint *minimal_height, + gint *natural_height) +{ + PanelSeparator *separator; + int size; + + separator = PANEL_SEPARATOR (widget); + + size = panel_toplevel_get_size (separator->priv->panel->toplevel); + + if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL) + *minimal_height = *natural_height = SEPARATOR_SIZE; + else + *minimal_height = *natural_height = size; +} +#else static void panel_separator_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -152,27 +189,6 @@ panel_separator_size_request (GtkWidget *widget, requisition->height = size; } } - -#if GTK_CHECK_VERSION (3, 0, 0) -static void -panel_separator_get_preferred_width (GtkWidget *widget, - gint *minimum_width, - gint *natural_width) -{ - GtkRequisition req; - panel_separator_size_request (widget, &req); - *minimum_width = *natural_width = req.width; -} - -static void -panel_separator_get_preferred_height (GtkWidget *widget, - gint *minimum_height, - gint *natural_height) -{ - GtkRequisition req; - panel_separator_size_request (widget, &req); - *minimum_height = *natural_height = req.height; -} #endif static void -- cgit v1.2.1