diff options
author | Havoc Pennington <hp@redhat.com> | 2001-02-21 00:29:03 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-02-21 00:29:03 +0000 |
commit | 7884954089bfdf0f4c06df4bd7868962792cd2d5 (patch) | |
tree | f476a3679b1cadb70b3a98c516587a4da9743f68 | |
parent | 8832f1d3adfbbc02bc249b6cbe5a604a2e0406c2 (diff) | |
download | gdk-pixbuf-7884954089bfdf0f4c06df4bd7868962792cd2d5.tar.gz |
Convert to new property API, patch from Lee Mallabone
2001-02-20 Havoc Pennington <hp@redhat.com>
* gtk/gtkaspectframe.c: Convert to new property API, patch from
Lee Mallabone
* gtk/gtkarrow.c: Convert to new property API, patch from
Lee Mallabone
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 8 | ||||
-rw-r--r-- | gtk/gtkarrow.c | 116 | ||||
-rw-r--r-- | gtk/gtkarrow.h | 2 | ||||
-rw-r--r-- | gtk/gtkaspectframe.c | 166 | ||||
-rw-r--r-- | gtk/gtkaspectframe.h | 2 |
11 files changed, 242 insertions, 100 deletions
@@ -1,3 +1,11 @@ +2001-02-20 Havoc Pennington <hp@redhat.com> + + * gtk/gtkaspectframe.c: Convert to new property API, patch from + Lee Mallabone + + * gtk/gtkarrow.c: Convert to new property API, patch from + Lee Mallabone + Tue Feb 20 12:16:12 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtkiconfactory.c (gtk_icon_set_new_from_pixbuf): New diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 435ace142..63b783dd1 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,11 @@ +2001-02-20 Havoc Pennington <hp@redhat.com> + + * gtk/gtkaspectframe.c: Convert to new property API, patch from + Lee Mallabone + + * gtk/gtkarrow.c: Convert to new property API, patch from + Lee Mallabone + Tue Feb 20 12:16:12 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtkiconfactory.c (gtk_icon_set_new_from_pixbuf): New diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 435ace142..63b783dd1 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2001-02-20 Havoc Pennington <hp@redhat.com> + + * gtk/gtkaspectframe.c: Convert to new property API, patch from + Lee Mallabone + + * gtk/gtkarrow.c: Convert to new property API, patch from + Lee Mallabone + Tue Feb 20 12:16:12 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtkiconfactory.c (gtk_icon_set_new_from_pixbuf): New diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 435ace142..63b783dd1 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,11 @@ +2001-02-20 Havoc Pennington <hp@redhat.com> + + * gtk/gtkaspectframe.c: Convert to new property API, patch from + Lee Mallabone + + * gtk/gtkarrow.c: Convert to new property API, patch from + Lee Mallabone + Tue Feb 20 12:16:12 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtkiconfactory.c (gtk_icon_set_new_from_pixbuf): New diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 435ace142..63b783dd1 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +2001-02-20 Havoc Pennington <hp@redhat.com> + + * gtk/gtkaspectframe.c: Convert to new property API, patch from + Lee Mallabone + + * gtk/gtkarrow.c: Convert to new property API, patch from + Lee Mallabone + Tue Feb 20 12:16:12 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtkiconfactory.c (gtk_icon_set_new_from_pixbuf): New diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 435ace142..63b783dd1 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +2001-02-20 Havoc Pennington <hp@redhat.com> + + * gtk/gtkaspectframe.c: Convert to new property API, patch from + Lee Mallabone + + * gtk/gtkarrow.c: Convert to new property API, patch from + Lee Mallabone + Tue Feb 20 12:16:12 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtkiconfactory.c (gtk_icon_set_new_from_pixbuf): New diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 435ace142..63b783dd1 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2001-02-20 Havoc Pennington <hp@redhat.com> + + * gtk/gtkaspectframe.c: Convert to new property API, patch from + Lee Mallabone + + * gtk/gtkarrow.c: Convert to new property API, patch from + Lee Mallabone + Tue Feb 20 12:16:12 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtkiconfactory.c (gtk_icon_set_new_from_pixbuf): New diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c index f0ad6b894..2252cbbd2 100644 --- a/gtk/gtkarrow.c +++ b/gtk/gtkarrow.c @@ -18,21 +18,24 @@ */ /* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS + * Modified by the GTK+ Team and others 1997-2001. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ #include "gtkarrow.h" - +#include "gtkintl.h" #define MIN_ARROW_SIZE 11 enum { - ARG_0, - ARG_ARROW_TYPE, - ARG_SHADOW_TYPE + PROP_0, + + PROP_ARROW_TYPE, + PROP_SHADOW_TYPE, + + PROP_LAST }; @@ -40,13 +43,16 @@ static void gtk_arrow_class_init (GtkArrowClass *klass); static void gtk_arrow_init (GtkArrow *arrow); static gint gtk_arrow_expose (GtkWidget *widget, GdkEventExpose *event); -static void gtk_arrow_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void gtk_arrow_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); - +static void gtk_arrow_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec, + const gchar *trailer); +static void gtk_arrow_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec, + const gchar *trailer); GtkType gtk_arrow_get_type (void) @@ -76,65 +82,85 @@ gtk_arrow_get_type (void) static void gtk_arrow_class_init (GtkArrowClass *class) { + GObjectClass *gobject_class; GtkObjectClass *object_class; GtkWidgetClass *widget_class; + gobject_class = (GObjectClass*) class; object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; - gtk_object_add_arg_type ("GtkArrow::arrow_type", GTK_TYPE_ARROW_TYPE, GTK_ARG_READWRITE, ARG_ARROW_TYPE); - gtk_object_add_arg_type ("GtkArrow::shadow_type", GTK_TYPE_SHADOW_TYPE, GTK_ARG_READWRITE, ARG_SHADOW_TYPE); - - object_class->set_arg = gtk_arrow_set_arg; - object_class->get_arg = gtk_arrow_get_arg; - + gobject_class->set_property = gtk_arrow_set_property; + gobject_class->get_property = gtk_arrow_get_property; + + g_object_class_install_property (gobject_class, + PROP_ARROW_TYPE, + g_param_spec_enum ("arrow_type", + _("Arrow direction"), + _("The direction the arrow should point"), + GTK_TYPE_ARROW_TYPE, + GTK_ARROW_RIGHT, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + g_object_class_install_property (gobject_class, + PROP_SHADOW_TYPE, + g_param_spec_enum ("shadow_type", + _("Arrow shadow"), + _("Appearance of the shadow surrounding the arrow"), + GTK_TYPE_SHADOW_TYPE, + GTK_SHADOW_OUT, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + widget_class->expose_event = gtk_arrow_expose; } -static void -gtk_arrow_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) +static void gtk_arrow_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec, + const gchar *trailer) { GtkArrow *arrow; arrow = GTK_ARROW (object); - switch (arg_id) + switch (prop_id) { - case ARG_ARROW_TYPE: + case PROP_ARROW_TYPE: gtk_arrow_set (arrow, - GTK_VALUE_ENUM (*arg), + g_value_get_enum (value), arrow->shadow_type); break; - case ARG_SHADOW_TYPE: + case PROP_SHADOW_TYPE: gtk_arrow_set (arrow, arrow->arrow_type, - GTK_VALUE_ENUM (*arg)); + g_value_get_enum (value)); break; default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } -static void -gtk_arrow_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) + +static void gtk_arrow_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec, + const gchar *trailer) { GtkArrow *arrow; arrow = GTK_ARROW (object); - switch (arg_id) + switch (prop_id) { - case ARG_ARROW_TYPE: - GTK_VALUE_ENUM (*arg) = arrow->arrow_type; + case PROP_ARROW_TYPE: + g_value_set_enum (value, arrow->arrow_type); break; - case ARG_SHADOW_TYPE: - GTK_VALUE_ENUM (*arg) = arrow->shadow_type; + case PROP_SHADOW_TYPE: + g_value_set_enum (value, arrow->shadow_type); break; default: - arg->type = GTK_TYPE_INVALID; + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } @@ -170,15 +196,27 @@ gtk_arrow_set (GtkArrow *arrow, GtkArrowType arrow_type, GtkShadowType shadow_type) { + gboolean changed = FALSE; + g_return_if_fail (arrow != NULL); g_return_if_fail (GTK_IS_ARROW (arrow)); - if (((GtkArrowType) arrow->arrow_type != arrow_type) || - ((GtkShadowType) arrow->shadow_type != shadow_type)) + if ((GtkArrowType) arrow->arrow_type != arrow_type) { arrow->arrow_type = arrow_type; + g_object_notify (G_OBJECT (arrow), "arrow_type"); + changed = TRUE; + } + + if ((GtkShadowType) arrow->shadow_type != shadow_type) + { arrow->shadow_type = shadow_type; + g_object_notify (G_OBJECT (arrow), "shadow_type"); + changed = TRUE; + } + if (changed == TRUE) + { if (GTK_WIDGET_DRAWABLE (arrow)) gtk_widget_queue_clear (GTK_WIDGET (arrow)); } diff --git a/gtk/gtkarrow.h b/gtk/gtkarrow.h index 35d88dcf7..fe7b57e8e 100644 --- a/gtk/gtkarrow.h +++ b/gtk/gtkarrow.h @@ -18,7 +18,7 @@ */ /* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS + * Modified by the GTK+ Team and others 1997-2001. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/. diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c index ced7c6311..604b4fbc2 100644 --- a/gtk/gtkaspectframe.c +++ b/gtk/gtkaspectframe.c @@ -23,30 +23,35 @@ */ /* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS + * Modified by the GTK+ Team and others 1997-2001. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/. */ #include "gtkaspectframe.h" +#include "gtkintl.h" enum { - ARG_0, - ARG_XALIGN, - ARG_YALIGN, - ARG_RATIO, - ARG_OBEY_CHILD + PROP_0, + PROP_XALIGN, + PROP_YALIGN, + PROP_RATIO, + PROP_OBEY_CHILD }; static void gtk_aspect_frame_class_init (GtkAspectFrameClass *klass); static void gtk_aspect_frame_init (GtkAspectFrame *aspect_frame); -static void gtk_aspect_frame_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void gtk_aspect_frame_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); +static void gtk_aspect_frame_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec, + const gchar *trailer); +static void gtk_aspect_frame_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec, + const gchar *trailer); static void gtk_aspect_frame_compute_child_allocation (GtkFrame *frame, GtkAllocation *child_allocation); @@ -83,27 +88,49 @@ gtk_aspect_frame_get_type (void) static void gtk_aspect_frame_class_init (GtkAspectFrameClass *class) { + GObjectClass *gobject_class; GtkObjectClass *object_class; GtkFrameClass *frame_class; parent_class = gtk_type_class (GTK_TYPE_FRAME); - object_class = GTK_OBJECT_CLASS (class); - frame_class = GTK_FRAME_CLASS (class); + gobject_class = (GObjectClass*) class; + object_class = (GtkObjectClass*) class; + frame_class = (GtkFrameClass*) class; - object_class->set_arg = gtk_aspect_frame_set_arg; - object_class->get_arg = gtk_aspect_frame_get_arg; + gobject_class->set_property = gtk_aspect_frame_set_property; + gobject_class->get_property = gtk_aspect_frame_get_property; frame_class->compute_child_allocation = gtk_aspect_frame_compute_child_allocation; - gtk_object_add_arg_type ("GtkAspectFrame::xalign", GTK_TYPE_FLOAT, - GTK_ARG_READWRITE, ARG_XALIGN); - gtk_object_add_arg_type ("GtkAspectFrame::yalign", GTK_TYPE_FLOAT, - GTK_ARG_READWRITE, ARG_YALIGN); - gtk_object_add_arg_type ("GtkAspectFrame::ratio", GTK_TYPE_FLOAT, - GTK_ARG_READWRITE, ARG_RATIO); - gtk_object_add_arg_type ("GtkAspectFrame::obey_child", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_OBEY_CHILD); + g_object_class_install_property (gobject_class, + PROP_XALIGN, + g_param_spec_float ("xalign", + _("Horizontal Alignment"), + _("X alignment of the child"), + 0.0, 1.0, 0.5, + G_PARAM_READABLE | G_PARAM_WRITABLE )); + g_object_class_install_property (gobject_class, + PROP_YALIGN, + g_param_spec_float ("yalign", + _("Vertical Alignment"), + _("Y alignment of the child"), + 0.0, 1.0, 0.5, + G_PARAM_READABLE | G_PARAM_WRITABLE )); + g_object_class_install_property (gobject_class, + PROP_RATIO, + g_param_spec_float ("ratio", + _("Ratio"), + _("Aspect ratio if obey_child is FALSE"), + 0.0, 1.0, 0.5, + G_PARAM_READABLE | G_PARAM_WRITABLE )); + g_object_class_install_property (gobject_class, + PROP_OBEY_CHILD, + g_param_spec_boolean ("obey_child", + _("Obey child"), + _("Force aspect ratio to match that of the frame's child"), + TRUE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); } static void @@ -115,69 +142,75 @@ gtk_aspect_frame_init (GtkAspectFrame *aspect_frame) aspect_frame->obey_child = TRUE; } -static void -gtk_aspect_frame_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) +static void gtk_aspect_frame_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec, + const gchar *trailer) { GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (object); - switch (arg_id) + switch (prop_id) { - case ARG_XALIGN: + /* g_object_notify is handled by the _frame_set function */ + case PROP_XALIGN: gtk_aspect_frame_set (aspect_frame, - GTK_VALUE_FLOAT (*arg), + g_value_get_float (value), aspect_frame->yalign, aspect_frame->ratio, aspect_frame->obey_child); break; - case ARG_YALIGN: + case PROP_YALIGN: gtk_aspect_frame_set (aspect_frame, aspect_frame->xalign, - GTK_VALUE_FLOAT (*arg), + g_value_get_float (value), aspect_frame->ratio, aspect_frame->obey_child); break; - case ARG_RATIO: + case PROP_RATIO: gtk_aspect_frame_set (aspect_frame, aspect_frame->xalign, aspect_frame->yalign, - GTK_VALUE_FLOAT (*arg), + g_value_get_float (value), aspect_frame->obey_child); break; - case ARG_OBEY_CHILD: + case PROP_OBEY_CHILD: gtk_aspect_frame_set (aspect_frame, aspect_frame->xalign, aspect_frame->yalign, aspect_frame->ratio, - GTK_VALUE_BOOL (*arg)); + g_value_get_boolean (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } -static void -gtk_aspect_frame_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) +static void gtk_aspect_frame_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec, + const gchar *trailer) { GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (object); - switch (arg_id) + switch (prop_id) { - case ARG_XALIGN: - GTK_VALUE_FLOAT (*arg) = aspect_frame->xalign; + case PROP_XALIGN: + g_value_set_float (value, aspect_frame->xalign); break; - case ARG_YALIGN: - GTK_VALUE_FLOAT (*arg) = aspect_frame->yalign; + case PROP_YALIGN: + g_value_set_float (value, aspect_frame->yalign); break; - case ARG_RATIO: - GTK_VALUE_FLOAT (*arg) = aspect_frame->ratio; + case PROP_RATIO: + g_value_set_float (value, aspect_frame->ratio); break; - case ARG_OBEY_CHILD: - GTK_VALUE_BOOL (*arg) = aspect_frame->obey_child; + case PROP_OBEY_CHILD: + g_value_set_boolean (value, aspect_frame->obey_child); break; default: - arg->type = GTK_TYPE_INVALID; + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } @@ -210,6 +243,8 @@ gtk_aspect_frame_set (GtkAspectFrame *aspect_frame, gfloat ratio, gboolean obey_child) { + gboolean needs_resize = FALSE; + g_return_if_fail (aspect_frame != NULL); g_return_if_fail (GTK_IS_ASPECT_FRAME (aspect_frame)); @@ -218,20 +253,33 @@ gtk_aspect_frame_set (GtkAspectFrame *aspect_frame, ratio = CLAMP (ratio, MIN_RATIO, MAX_RATIO); obey_child = obey_child != FALSE; - if ((aspect_frame->xalign != xalign) || - (aspect_frame->yalign != yalign) || - (aspect_frame->ratio != ratio) || - (aspect_frame->obey_child != obey_child)) + if (aspect_frame->xalign != xalign) { - GtkWidget *widget = GTK_WIDGET(aspect_frame); - aspect_frame->xalign = xalign; + g_object_notify (G_OBJECT (aspect_frame), "xalign"); + needs_resize = TRUE; + } + if (aspect_frame->yalign != yalign) + { aspect_frame->yalign = yalign; + g_object_notify (G_OBJECT (aspect_frame), "yalign"); + needs_resize = TRUE; + } + if (aspect_frame->ratio != ratio) + { aspect_frame->ratio = ratio; + g_object_notify (G_OBJECT (aspect_frame), "ratio"); + needs_resize = TRUE; + } + if (aspect_frame->obey_child != obey_child) + { aspect_frame->obey_child = obey_child; - - gtk_widget_queue_resize (widget); + g_object_notify (G_OBJECT (aspect_frame), "obey_child"); + needs_resize = TRUE; } + + if (needs_resize == TRUE) + gtk_widget_queue_resize (GTK_WIDGET(aspect_frame)); } static void diff --git a/gtk/gtkaspectframe.h b/gtk/gtkaspectframe.h index 0bb0603b6..5cb058216 100644 --- a/gtk/gtkaspectframe.h +++ b/gtk/gtkaspectframe.h @@ -18,7 +18,7 @@ */ /* - * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS + * Modified by the GTK+ Team and others 1997-2001. See the AUTHORS * file for a list of people on the GTK+ Team. See the ChangeLog * files for a list of changes. These files are distributed with * GTK+ at ftp://ftp.gtk.org/pub/gtk/. |