diff options
author | Benjamin Otte <otte@redhat.com> | 2010-09-14 01:25:07 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-09-14 01:25:07 +0200 |
commit | 032d3f0ada5057fcfe1a767e4ccb750e4c6de81d (patch) | |
tree | 8b76e163cdc96d2c3e49f4d73592f6b7930671ab /gtk/gtkspinner.c | |
parent | c22b80949dd58474b508fbce399852909edd15ea (diff) | |
download | gtk+-032d3f0ada5057fcfe1a767e4ccb750e4c6de81d.tar.gz |
spinner: Implement the size request interface
Doing size requests in expose is broken.
Diffstat (limited to 'gtk/gtkspinner.c')
-rw-r--r-- | gtk/gtkspinner.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c index be85995d81..a8bd56b6c2 100644 --- a/gtk/gtkspinner.c +++ b/gtk/gtkspinner.c @@ -34,6 +34,7 @@ #include "gtkintl.h" #include "gtkaccessible.h" #include "gtkimage.h" +#include "gtksizerequest.h" #include "gtkspinner.h" #include "gtkstyle.h" @@ -90,8 +91,11 @@ static void gtk_spinner_set_active (GtkSpinner *spinner, gboolean active); static AtkObject *gtk_spinner_get_accessible (GtkWidget *widget); static GType gtk_spinner_accessible_get_type (void); +static void gtk_spinner_size_request_init (GtkSizeRequestIface *iface); -G_DEFINE_TYPE (GtkSpinner, gtk_spinner, GTK_TYPE_DRAWING_AREA); +G_DEFINE_TYPE_WITH_CODE (GtkSpinner, gtk_spinner, GTK_TYPE_DRAWING_AREA, + G_IMPLEMENT_INTERFACE (GTK_TYPE_SIZE_REQUEST, + gtk_spinner_size_request_init)) static void gtk_spinner_class_init (GtkSpinnerClass *klass) @@ -213,6 +217,38 @@ gtk_spinner_init (GtkSpinner *spinner) gtk_widget_set_has_window (GTK_WIDGET (spinner), FALSE); } +static void +gtk_spinner_get_width (GtkSizeRequest *widget, + gint *minimum_size, + gint *natural_size) +{ + if (minimum_size) + *minimum_size = SPINNER_SIZE; + + if (natural_size) + *natural_size = SPINNER_SIZE; +} + +static void +gtk_spinner_get_height (GtkSizeRequest *widget, + gint *minimum_size, + gint *natural_size) +{ + if (minimum_size) + *minimum_size = SPINNER_SIZE; + + if (natural_size) + *natural_size = SPINNER_SIZE; +} + +static void +gtk_spinner_size_request_init (GtkSizeRequestIface *iface) +{ + iface->get_width = gtk_spinner_get_width; + iface->get_height = gtk_spinner_get_height; +} + + static gboolean gtk_spinner_expose (GtkWidget *widget, GdkEventExpose *event) @@ -228,9 +264,6 @@ gtk_spinner_expose (GtkWidget *widget, width = allocation.width; height = allocation.height; - if ((width < SPINNER_SIZE) || (height < SPINNER_SIZE)) - gtk_widget_set_size_request (widget, SPINNER_SIZE, SPINNER_SIZE); - state_type = GTK_STATE_NORMAL; if (!gtk_widget_is_sensitive (widget)) state_type = GTK_STATE_INSENSITIVE; |