aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-05-24 20:20:36 +0200
committerJavier <dev.git@javispedro.com>2014-05-24 20:20:36 +0200
commit9bfa7f4a218c8458f411ad50561ac86485d89383 (patch)
treeab8c37f08330a56cf6e1547bca92bc67f9432d2e
parent9e6a4592f2674b9b6e4722e3212dd2584201a19a (diff)
downloadtopmenu-gtk-9bfa7f4a218c8458f411ad50561ac86485d89383.tar.gz
topmenu-gtk-9bfa7f4a218c8458f411ad50561ac86485d89383.zip
implement gtk3's preferred_width/height functions
-rw-r--r--libtopmenu-server/topmenu-widget.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/libtopmenu-server/topmenu-widget.c b/libtopmenu-server/topmenu-widget.c
index 4dd1ed8..69ae3a0 100644
--- a/libtopmenu-server/topmenu-widget.c
+++ b/libtopmenu-server/topmenu-widget.c
@@ -328,7 +328,23 @@ static void topmenu_widget_size_allocate(GtkWidget *widget, GtkAllocation *alloc
GTK_WIDGET_CLASS(topmenu_widget_parent_class)->size_allocate(widget, allocation);
}
-#if GTK_MAJOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 3
+static void topmenu_widget_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width)
+{
+ TopMenuWidget *self = TOPMENU_WIDGET(widget);
+ if (self->socket) {
+ gtk_widget_get_preferred_width(GTK_WIDGET(self->socket), minimal_width, natural_width);
+ }
+}
+
+static void topmenu_widget_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height)
+{
+ TopMenuWidget *self = TOPMENU_WIDGET(widget);
+ if (self->socket) {
+ gtk_widget_get_preferred_height(GTK_WIDGET(self->socket), minimal_height, natural_height);
+ }
+}
+#elif GTK_MAJOR_VERSION == 2
static void topmenu_widget_size_request(GtkWidget *widget, GtkRequisition *requisition)
{
TopMenuWidget *self = TOPMENU_WIDGET(widget);
@@ -362,7 +378,10 @@ static void topmenu_widget_class_init(TopMenuWidgetClass *klass)
widget_class->map = topmenu_widget_map;
widget_class->unmap = topmenu_widget_unmap;
widget_class->size_allocate = topmenu_widget_size_allocate;
-#if GTK_MAJOR_VERSION == 2
+#if GTK_MAJOR_VERSION == 3
+ widget_class->get_preferred_width = topmenu_widget_get_preferred_width;
+ widget_class->get_preferred_height = topmenu_widget_get_preferred_height;
+#elif GTK_MAJOR_VERSION == 2
widget_class->size_request = topmenu_widget_size_request;
#endif