diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-08-18 19:33:53 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-08-18 20:01:27 -0400 |
commit | fa565f3a3e1d459591dd9068e80767420c58fd8b (patch) | |
tree | 8838252c8d4f782151810f2832db7d755c821ed4 /gtk | |
parent | 0cb7aa9c7bf9c2ae051ee49e8ad7c0d79f4befe5 (diff) | |
download | gtk+-fa565f3a3e1d459591dd9068e80767420c58fd8b.tar.gz |
Fixed accel label to do its derived work in ->get_width() instead of the old ->size_request()
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkaccellabel.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index 716e8d7cd0..564213c9a0 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -33,6 +33,7 @@ #include "gtkaccellabel.h" #include "gtkaccelmap.h" #include "gtkmain.h" +#include "gtksizerequest.h" #include "gtkprivate.h" #include "gtkintl.h" @@ -119,15 +120,24 @@ static void gtk_accel_label_get_property (GObject *object, GParamSpec *pspec); static void gtk_accel_label_destroy (GtkObject *object); static void gtk_accel_label_finalize (GObject *object); -static void gtk_accel_label_size_request (GtkWidget *widget, - GtkRequisition *requisition); static gboolean gtk_accel_label_expose_event (GtkWidget *widget, GdkEventExpose *event); 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); + #define GTK_ACCEL_LABEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_ACCEL_LABEL, GtkAccelLabelPrivate)) -G_DEFINE_TYPE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_LABEL) + +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)) static void gtk_accel_label_class_init (GtkAccelLabelClass *class) @@ -142,7 +152,6 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class) object_class->destroy = gtk_accel_label_destroy; - widget_class->size_request = gtk_accel_label_size_request; widget_class->expose_event = gtk_accel_label_expose_event; class->signal_quote1 = g_strdup ("<:"); @@ -340,16 +349,25 @@ gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label) } static void -gtk_accel_label_size_request (GtkWidget *widget, - GtkRequisition *requisition) +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) { GtkAccelLabel *accel_label = GTK_ACCEL_LABEL (widget); - PangoLayout *layout; - gint width; + PangoLayout *layout; + gint width; - GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->size_request (widget, requisition); + parent_size_request_iface->get_width (widget, min_width, nat_width); - layout = gtk_widget_create_pango_layout (widget, gtk_accel_label_get_string (accel_label)); + layout = gtk_widget_create_pango_layout (GTK_WIDGET (widget), + gtk_accel_label_get_string (accel_label)); pango_layout_get_pixel_size (layout, &width, NULL); accel_label->priv->accel_string_width = width; |