From 5a5854f6f64231be8df028dbcb87f75a8025609e Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Fri, 28 Jan 2011 15:54:50 +0900 Subject: [PATCH] Add default class implementation of gtk_widget_get_request_mode(). Instead of checking if klass->get_request_mode is != NULL from the gtk_widget_get_request_mode() api, this allows classes to trust that there is a default implementation and chain up (specifically added this for gtkmm wrapper objects). --- gtk/gtksizerequest.c | 9 +-------- gtk/gtkwidget.c | 9 +++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c index 272f2ebfbe..ef96ed0402 100644 --- a/gtk/gtksizerequest.c +++ b/gtk/gtksizerequest.c @@ -370,16 +370,9 @@ compute_size_for_orientation (GtkWidget *widget, GtkSizeRequestMode gtk_widget_get_request_mode (GtkWidget *widget) { - GtkWidgetClass *klass; - g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH); - klass = GTK_WIDGET_GET_CLASS (widget); - if (klass->get_request_mode) - return klass->get_request_mode (widget); - - /* By default widgets are height-for-width. */ - return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; + return GTK_WIDGET_GET_CLASS (widget)->get_request_mode (widget); } /** diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 00343bfb5f..281e539232 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -634,6 +634,7 @@ static void gtk_widget_buildable_custom_finished (GtkBuildable static void gtk_widget_buildable_parser_finished (GtkBuildable *buildable, GtkBuilder *builder); +static GtkSizeRequestMode gtk_widget_real_get_request_mode (GtkWidget *widget); static void gtk_widget_real_get_width (GtkWidget *widget, gint *minimum_size, gint *natural_size); @@ -834,6 +835,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) klass->realize = gtk_widget_real_realize; klass->unrealize = gtk_widget_real_unrealize; klass->size_allocate = gtk_widget_real_size_allocate; + klass->get_request_mode = gtk_widget_real_get_request_mode; klass->get_preferred_width = gtk_widget_real_get_width; klass->get_preferred_height = gtk_widget_real_get_height; klass->get_preferred_width_for_height = gtk_widget_real_get_width_for_height; @@ -12940,6 +12942,13 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable, } } +static GtkSizeRequestMode +gtk_widget_real_get_request_mode (GtkWidget *widget) +{ + /* By default widgets are height-for-width. */ + return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; +} + static void gtk_widget_real_get_width (GtkWidget *widget, gint *minimum_size,