summaryrefslogtreecommitdiff
path: root/mate-panel
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-11-22 18:30:38 +0100
committerinfirit <[email protected]>2014-11-22 18:43:04 +0100
commit232713d42e79c519cfb060bb286e4cd600678559 (patch)
tree10f856f9c23aef8c83a107f457f6864b548f5e2c /mate-panel
parent1b0b03e09e3910280c1734475f0b0ac4122fcfca (diff)
downloadmate-panel-232713d42e79c519cfb060bb286e4cd600678559.tar.bz2
mate-panel-232713d42e79c519cfb060bb286e4cd600678559.tar.xz
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.
Diffstat (limited to 'mate-panel')
-rw-r--r--mate-panel/button-widget.c47
-rw-r--r--mate-panel/panel-frame.c96
-rw-r--r--mate-panel/panel-separator.c58
3 files changed, 130 insertions, 71 deletions
diff --git a/mate-panel/button-widget.c b/mate-panel/button-widget.c
index 8f2d4483..faea383f 100644
--- a/mate-panel/button-widget.c
+++ b/mate-panel/button-widget.c
@@ -645,37 +645,37 @@ button_widget_expose (GtkWidget *widget,
}
#endif
-static void
-button_widget_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- ButtonWidget *button_widget = BUTTON_WIDGET (widget);
-
- if (button_widget->priv->pixbuf) {
- requisition->width = gdk_pixbuf_get_width (button_widget->priv->pixbuf);
- requisition->height = gdk_pixbuf_get_height (button_widget->priv->pixbuf);
- }
-}
-
#if GTK_CHECK_VERSION (3, 0, 0)
static void
button_widget_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
+ gint *minimal_width,
gint *natural_width)
{
- GtkRequisition req;
- button_widget_size_request (widget, &req);
- *minimum_width = *natural_width = req.width;
+ ButtonWidget *button_widget = BUTTON_WIDGET (widget);
+
+ *minimal_width = *natural_width = gdk_pixbuf_get_width (button_widget->priv->pixbuf);
}
static void
button_widget_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
+ gint *minimal_height,
gint *natural_height)
{
- GtkRequisition req;
- button_widget_size_request (widget, &req);
- *minimum_height = *natural_height = req.height;
+ ButtonWidget *button_widget = BUTTON_WIDGET (widget);
+
+ *minimal_height = *natural_height = gdk_pixbuf_get_height (button_widget->priv->pixbuf);
+}
+#else
+static void
+button_widget_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ ButtonWidget *button_widget = BUTTON_WIDGET (widget);
+
+ if (button_widget->priv->pixbuf) {
+ requisition->width = gdk_pixbuf_get_width (button_widget->priv->pixbuf);
+ requisition->height = gdk_pixbuf_get_height (button_widget->priv->pixbuf);
+ }
}
#endif
@@ -845,17 +845,14 @@ button_widget_class_init (ButtonWidgetClass *klass)
#if GTK_CHECK_VERSION (3, 0, 0)
widget_class->get_preferred_width = button_widget_get_preferred_width;
widget_class->get_preferred_height = button_widget_get_preferred_height;
+ widget_class->draw = button_widget_draw;
#else
widget_class->size_request = button_widget_size_request;
+ widget_class->expose_event = button_widget_expose;
#endif
widget_class->button_press_event = button_widget_button_press;
widget_class->enter_notify_event = button_widget_enter_notify;
widget_class->leave_notify_event = button_widget_leave_notify;
-#if GTK_CHECK_VERSION (3, 0, 0)
- widget_class->draw = button_widget_draw;
-#else
- widget_class->expose_event = button_widget_expose;
-#endif
button_class->activate = button_widget_activate;
diff --git a/mate-panel/panel-frame.c b/mate-panel/panel-frame.c
index 7602a724..224a00b8 100644
--- a/mate-panel/panel-frame.c
+++ b/mate-panel/panel-frame.c
@@ -35,6 +35,77 @@ enum {
PROP_EDGES
};
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+panel_frame_get_preferred_width (GtkWidget *widget,
+ gint *minimal_width,
+ gint *natural_width)
+{
+ PanelFrame *frame = (PanelFrame *) widget;
+ GtkBin *bin = (GtkBin *) widget;
+ GtkStyle *style;
+ GtkWidget *child;
+ int border_width;
+
+ style = gtk_widget_get_style (widget);
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ *minimal_width = 1;
+ *natural_width = 1;
+
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
+ gtk_widget_get_preferred_width (child, minimal_width, natural_width);
+
+ *minimal_width += border_width;
+ *natural_width += border_width;
+
+ if (frame->edges & PANEL_EDGE_LEFT) {
+ *minimal_width += style->ythickness;
+ *natural_width += style->ythickness;
+ }
+ if (frame->edges & PANEL_EDGE_RIGHT) {
+ *minimal_width += style->ythickness;
+ *natural_width += style->ythickness;
+ }
+}
+
+static void
+panel_frame_get_preferred_height (GtkWidget *widget,
+ gint *minimal_height,
+ gint *natural_height)
+{
+ PanelFrame *frame = (PanelFrame *) widget;
+ GtkBin *bin = (GtkBin *) widget;
+ GtkStyle *style;
+ GtkWidget *child;
+ int border_width;
+
+ style = gtk_widget_get_style (widget);
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ *minimal_height = 1;
+ *natural_height = 1;
+
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
+ gtk_widget_get_preferred_height (child, minimal_height, natural_height);
+
+ *minimal_height += border_width;
+ *natural_height += border_width;
+
+
+ if (frame->edges & PANEL_EDGE_TOP) {
+ *minimal_height += style->xthickness;
+ *natural_height += style->xthickness;
+ }
+ if (frame->edges & PANEL_EDGE_BOTTOM) {
+ *minimal_height += style->xthickness;
+ *natural_height += style->xthickness;
+ }
+}
+
+#else
static void
panel_frame_size_request (GtkWidget *widget,
GtkRequisition *requisition)
@@ -53,11 +124,7 @@ panel_frame_size_request (GtkWidget *widget,
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
-#if GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_get_preferred_size (child, requisition, NULL);
-#else
gtk_widget_size_request (child, requisition);
-#endif
requisition->width += border_width;
requisition->height += border_width;
@@ -71,27 +138,6 @@ panel_frame_size_request (GtkWidget *widget,
if (frame->edges & PANEL_EDGE_RIGHT)
requisition->width += style->ythickness;
}
-
-#if GTK_CHECK_VERSION (3, 0, 0)
-static void
-panel_frame_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
-{
- GtkRequisition req;
- panel_frame_size_request (widget, &req);
- *minimum_width = *natural_width = req.width;
-}
-
-static void
-panel_frame_get_preferred_height (GtkWidget *widget,
- gint *minimum_height,
- gint *natural_height)
-{
- GtkRequisition req;
- panel_frame_size_request (widget, &req);
- *minimum_height = *natural_height = req.height;
-}
#endif
static void
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