diff options
author | Benjamin Otte <otte@redhat.com> | 2010-09-21 16:35:17 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-09-26 15:11:45 +0200 |
commit | d9c92598612714683eab96fecf6e90a9531607e5 (patch) | |
tree | 4091fc22f94eeed203385670e1eb05d43b6f264c /gtk/gtkaccellabel.c | |
parent | f52a1fcfbde5c1b1108d4a03a9bf5c409b59a73e (diff) | |
download | gtk+-d9c92598612714683eab96fecf6e90a9531607e5.tar.gz |
Move GtkSizeRequest into GtkWidget
It doesn't make sense to keep them separate as GtkSizeRequest requires a
GtkWidget and GtkWidget implements GtkSizeRequest, so you can never have
one without the other.
It also makes the code a lot easier because no casts are required when
calling functions.
Also, the names would translate to gtk_widget_get_width() and people
agreed that this would be a too generic name, so a "preferred" was added
to the names.
So this patch moves the functions:
gtk_size_request_get_request_mode() => gtk_widget_get_request_mode()
gtk_size_request_get_width() => gtk_widget_get_preferred_width()
gtk_size_request_get_height() => gtk_widget_get_preferred_height()
gtk_size_request_get_size() => gtk_widget_get_preferred_size()
gtk_size_request_get_width_for_height() =>
gtk_widget_get_preferred_width_for_height()
gtk_size_request_get_height_for_width() =>
gtk_widget_get_preferred_height_for_width()
... and moves the corresponding vfuncs to the GtkWidgetClass.
The patch also renames the implementations of the vfuncs in widgets to
include the word "preferrred".
Diffstat (limited to 'gtk/gtkaccellabel.c')
-rw-r--r-- | gtk/gtkaccellabel.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index ffaeed834b..41a28b5d74 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -125,19 +125,14 @@ static gboolean gtk_accel_label_draw (GtkWidget *widget, static const gchar *gtk_accel_label_get_string (GtkAccelLabel *accel_label); -static void gtk_accel_label_size_request_init (GtkSizeRequestIface *iface); -static void gtk_accel_label_get_width (GtkSizeRequest *widget, - gint *min_width, - gint *nat_width); +static void gtk_accel_label_get_preferred_width (GtkWidget *widget, + gint *min_width, + gint *nat_width); #define GTK_ACCEL_LABEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_ACCEL_LABEL, GtkAccelLabelPrivate)) -static GtkSizeRequestIface *parent_size_request_iface; - -G_DEFINE_TYPE_WITH_CODE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_LABEL, - G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST, - gtk_accel_label_size_request_init)) +G_DEFINE_TYPE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_LABEL) static void gtk_accel_label_class_init (GtkAccelLabelClass *class) @@ -153,6 +148,7 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class) object_class->destroy = gtk_accel_label_destroy; widget_class->draw = gtk_accel_label_draw; + widget_class->get_preferred_width = gtk_accel_label_get_preferred_width; class->signal_quote1 = g_strdup ("<:"); class->signal_quote2 = g_strdup (":>"); @@ -349,22 +345,15 @@ gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label) } static void -gtk_accel_label_size_request_init (GtkSizeRequestIface *iface) -{ - parent_size_request_iface = g_type_interface_peek_parent (iface); - iface->get_width = gtk_accel_label_get_width; -} - -static void -gtk_accel_label_get_width (GtkSizeRequest *widget, - gint *min_width, - gint *nat_width) +gtk_accel_label_get_preferred_width (GtkWidget *widget, + gint *min_width, + gint *nat_width) { GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (widget); PangoLayout *layout; gint width; - parent_size_request_iface->get_width (widget, min_width, nat_width); + GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->get_preferred_width (widget, min_width, nat_width); layout = gtk_widget_create_pango_layout (GTK_WIDGET (widget), gtk_accel_label_get_string (accel_label)); @@ -405,8 +394,7 @@ gtk_accel_label_draw (GtkWidget *widget, ac_width = gtk_accel_label_get_accel_width (accel_label); gtk_widget_get_allocation (widget, &allocation); - gtk_size_request_get_size (GTK_SIZE_REQUEST (widget), - &requisition, NULL); + gtk_widget_get_preferred_size (widget, &requisition, NULL); if (allocation.width >= requisition.width + ac_width) { |