diff options
author | Alexander Larsson <alla@lysator.liu.se> | 2001-05-17 16:22:06 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2001-05-17 16:22:06 +0000 |
commit | 6ee1ae13adafbb6a0ac5a75a948f0a9bc8f0e751 (patch) | |
tree | bd9689851eabea933a0ef00c0ad9c97c376b62cd /gtk | |
parent | be277ae41303b9d5ba92a911360e66f197c82eba (diff) | |
download | gdk-pixbuf-6ee1ae13adafbb6a0ac5a75a948f0a9bc8f0e751.tar.gz |
Add properties, based on patch by Lee Mallabone.GTK_MULTIHEAD_MERGE1
2001-05-17 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkbbox.c:
Add properties, based on patch by Lee Mallabone.
* gtk/gtknotebook.c:
* gtk/gtktoolbar.c:
Convert from GtkArg to GParam, based on patch by John Margaglione.
* gtk/gtkhscale.c:
* gtk/gtkvscale.c:
* gtk/gtkhscrollbar.c:
* gtk/gtkvscrollbar.c:
* gtk/gtkrange.c:
Move adjustment property to GtkRange.
* gtk/gtklabel.c:
Setup mnemonics on property changes
* gtk/gtkwidget.c (gtk_widget_get_property):
GdkExtensionMode is an enum, not a flag. Set it with
g_value_set_enum ().
* tests/prop-editor.c:
Better propery editor.
* tests/testgtk.c:
Add new property test. Pass zero to the property editor to
get properties from all derived types.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkbbox.c | 70 | ||||
-rw-r--r-- | gtk/gtkhscale.c | 17 | ||||
-rw-r--r-- | gtk/gtkhscrollbar.c | 19 | ||||
-rw-r--r-- | gtk/gtklabel.c | 10 | ||||
-rw-r--r-- | gtk/gtknotebook.c | 255 | ||||
-rw-r--r-- | gtk/gtkrange.c | 18 | ||||
-rw-r--r-- | gtk/gtktoolbar.c | 91 | ||||
-rw-r--r-- | gtk/gtkvscale.c | 18 | ||||
-rw-r--r-- | gtk/gtkvscrollbar.c | 16 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 4 |
10 files changed, 334 insertions, 184 deletions
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c index 51f2bb5e1..81b02d401 100644 --- a/gtk/gtkbbox.c +++ b/gtk/gtkbbox.c @@ -27,9 +27,22 @@ #include "gtkbbox.h" #include "gtkintl.h" +enum { + PROP_0, + PROP_LAYOUT_STYLE, + PROP_LAST +}; static void gtk_button_box_class_init (GtkButtonBoxClass *klass); static void gtk_button_box_init (GtkButtonBox *box); +static void gtk_button_box_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_button_box_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); #define DEFAULT_CHILD_MIN_WIDTH 85 #define DEFAULT_CHILD_MIN_HEIGHT 27 @@ -65,9 +78,14 @@ static void gtk_button_box_class_init (GtkButtonBoxClass *class) { GtkWidgetClass *widget_class; + GObjectClass *gobject_class; + gobject_class = G_OBJECT_CLASS (class); widget_class = (GtkWidgetClass*) class; + gobject_class->set_property = gtk_button_box_set_property; + gobject_class->get_property = gtk_button_box_get_property; + /* FIXME we need to override the "spacing" property on GtkBox once * libgobject allows that. */ @@ -107,6 +125,14 @@ gtk_button_box_class_init (GtkButtonBoxClass *class) G_MAXINT, DEFAULT_CHILD_IPAD_Y, G_PARAM_READABLE)); + g_object_class_install_property (gobject_class, + PROP_LAYOUT_STYLE, + g_param_spec_enum ("layout_style", + _("Layout style"), + _("How to layout the buttons in the box. Possible values are default, spread, edge, start and end"), + GTK_TYPE_BUTTON_BOX_STYLE, + GTK_BUTTONBOX_DEFAULT_STYLE, + G_PARAM_READWRITE)); } static void @@ -120,6 +146,43 @@ gtk_button_box_init (GtkButtonBox *button_box) button_box->layout_style = GTK_BUTTONBOX_DEFAULT_STYLE; } +static void +gtk_button_box_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + case PROP_LAYOUT_STYLE: + gtk_button_box_set_layout (GTK_BUTTON_BOX (object), + g_value_get_enum (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gtk_button_box_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + case PROP_LAYOUT_STYLE: + g_value_set_enum (value, GTK_BUTTON_BOX (object)->layout_style); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + + /* set per widget values for spacing, child size and child internal padding */ void gtk_button_box_set_child_size (GtkButtonBox *widget, gint width, gint height) @@ -141,7 +204,12 @@ void gtk_button_box_set_layout (GtkButtonBox *widget, g_return_if_fail (layout_style >= GTK_BUTTONBOX_DEFAULT_STYLE && layout_style <= GTK_BUTTONBOX_END); - widget->layout_style = layout_style; + if (widget->layout_style != layout_style) + { + widget->layout_style = layout_style; + g_object_notify (G_OBJECT (widget), "layout_style"); + gtk_widget_queue_resize (GTK_WIDGET (widget)); + } } diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c index 29f6321fb..a59efe889 100644 --- a/gtk/gtkhscale.c +++ b/gtk/gtkhscale.c @@ -35,8 +35,7 @@ #define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w) enum { - PROP_0, - PROP_ADJUSTMENT + PROP_0 }; static void gtk_hscale_class_init (GtkHScaleClass *klass); @@ -132,13 +131,6 @@ gtk_hscale_class_init (GtkHScaleClass *class) scale_class->draw_value = gtk_hscale_draw_value; - g_object_class_install_property (gobject_class, - PROP_ADJUSTMENT, - g_param_spec_object ("adjustment", - _("Adjustment"), - _("The GtkAdjustment that determines the values to use for this HScale."), - GTK_TYPE_ADJUSTMENT, - G_PARAM_READWRITE)); binding_set = gtk_binding_set_by_class (object_class); add_slider_binding (binding_set, GDK_Left, 0, @@ -192,9 +184,6 @@ gtk_hscale_set_property (GObject *object, switch (prop_id) { - case PROP_ADJUSTMENT: - gtk_range_set_adjustment (GTK_RANGE (hscale), g_value_get_object (value)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -213,10 +202,6 @@ gtk_hscale_get_property (GObject *object, switch (prop_id) { - case PROP_ADJUSTMENT: - g_value_set_object (value, - G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (hscale)))); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gtk/gtkhscrollbar.c b/gtk/gtkhscrollbar.c index 63fc1c6cc..9ec6f22c4 100644 --- a/gtk/gtkhscrollbar.c +++ b/gtk/gtkhscrollbar.c @@ -35,8 +35,7 @@ #define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w) enum { - PROP_0, - PROP_ADJUSTMENT + PROP_0 }; static void gtk_hscrollbar_class_init (GtkHScrollbarClass *klass); @@ -109,15 +108,6 @@ gtk_hscrollbar_class_init (GtkHScrollbarClass *class) range_class->slider_update = gtk_hscrollbar_slider_update; range_class->trough_click = _gtk_range_default_htrough_click; range_class->motion = _gtk_range_default_hmotion; - - g_object_class_install_property (gobject_class, - PROP_ADJUSTMENT, - g_param_spec_object ("adjustment", - _("Adjustment"), - _("The GtkAdjustment that determines the values to use for this scrollbar."), - GTK_TYPE_ADJUSTMENT, - G_PARAM_READWRITE)); - } static void @@ -132,10 +122,6 @@ gtk_hscrollbar_set_property (GObject *object, switch (prop_id) { - case PROP_ADJUSTMENT: - gtk_range_set_adjustment (GTK_RANGE (hscrollbar), - g_value_get_object (value)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -154,9 +140,6 @@ gtk_hscrollbar_get_property (GObject *object, switch (prop_id) { - case PROP_ADJUSTMENT: - g_value_set_object (value, G_OBJECT (hscrollbar)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index bc3a99c71..896d1e336 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -125,6 +125,8 @@ static void gtk_label_select_region_index (GtkLabel *label, static gboolean gtk_label_mnemonic_activate (GtkWidget *widget, gboolean group_cycling); +static void gtk_label_setup_mnemonic (GtkLabel *label, + guint last_key); static GtkMiscClass *parent_class = NULL; @@ -272,8 +274,10 @@ gtk_label_set_property (GObject *object, GParamSpec *pspec) { GtkLabel *label; - + guint last_keyval; + label = GTK_LABEL (object); + last_keyval = label->mnemonic_keyval; switch (prop_id) { @@ -281,6 +285,8 @@ gtk_label_set_property (GObject *object, gtk_label_set_label_internal (label, g_strdup (g_value_get_string (value))); gtk_label_recalculate (label); + if (last_keyval != label->mnemonic_keyval) + gtk_label_setup_mnemonic (label, last_keyval); break; case PROP_ATTRIBUTES: gtk_label_set_attributes (label, g_value_get_boxed (value)); @@ -292,6 +298,8 @@ gtk_label_set_property (GObject *object, case PROP_USE_UNDERLINE: gtk_label_set_use_underline_internal (label, g_value_get_boolean (value)); gtk_label_recalculate (label); + if (label->use_underline) + gtk_label_setup_mnemonic (label, last_keyval); break; case PROP_JUSTIFY: gtk_label_set_justify (label, g_value_get_enum (value)); diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index afabbc4f2..c18b22833 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -58,17 +58,17 @@ enum { }; enum { - ARG_0, - ARG_TAB_POS, - ARG_SHOW_TABS, - ARG_SHOW_BORDER, - ARG_SCROLLABLE, - ARG_TAB_BORDER, - ARG_TAB_HBORDER, - ARG_TAB_VBORDER, - ARG_PAGE, - ARG_ENABLE_POPUP, - ARG_HOMOGENEOUS + PROP_0, + PROP_TAB_POS, + PROP_SHOW_TABS, + PROP_SHOW_BORDER, + PROP_SCROLLABLE, + PROP_TAB_BORDER, + PROP_TAB_HBORDER, + PROP_TAB_VBORDER, + PROP_PAGE, + PROP_ENABLE_POPUP, + PROP_HOMOGENEOUS }; enum { @@ -121,12 +121,14 @@ static void gtk_notebook_focus_tab (GtkNotebook *notebook, /*** GtkObject Methods ***/ static void gtk_notebook_destroy (GtkObject *object); -static void gtk_notebook_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void gtk_notebook_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); +static void gtk_notebook_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_notebook_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); /*** GtkWidget Methods ***/ static void gtk_notebook_map (GtkWidget *widget); @@ -277,19 +279,21 @@ gtk_notebook_get_type (void) static void gtk_notebook_class_init (GtkNotebookClass *class) { + GObjectClass *gobject_class; GtkObjectClass *object_class; GtkWidgetClass *widget_class; GtkContainerClass *container_class; GtkBindingSet *binding_set; + gobject_class = G_OBJECT_CLASS (class); object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; parent_class = gtk_type_class (gtk_container_get_type ()); - object_class->set_arg = gtk_notebook_set_arg; - object_class->get_arg = gtk_notebook_get_arg; + gobject_class->set_property = gtk_notebook_set_property; + gobject_class->get_property = gtk_notebook_get_property; object_class->destroy = gtk_notebook_destroy; widget_class->map = gtk_notebook_map; @@ -321,16 +325,94 @@ gtk_notebook_class_init (GtkNotebookClass *class) class->focus_tab = gtk_notebook_focus_tab; class->select_page = gtk_notebook_select_page; - gtk_object_add_arg_type ("GtkNotebook::page", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_PAGE); - gtk_object_add_arg_type ("GtkNotebook::tab_pos", GTK_TYPE_POSITION_TYPE, GTK_ARG_READWRITE, ARG_TAB_POS); - gtk_object_add_arg_type ("GtkNotebook::tab_border", GTK_TYPE_UINT, GTK_ARG_WRITABLE, ARG_TAB_BORDER); - gtk_object_add_arg_type ("GtkNotebook::tab_hborder", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_TAB_HBORDER); - gtk_object_add_arg_type ("GtkNotebook::tab_vborder", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_TAB_VBORDER); - gtk_object_add_arg_type ("GtkNotebook::show_tabs", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SHOW_TABS); - gtk_object_add_arg_type ("GtkNotebook::show_border", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SHOW_BORDER); - gtk_object_add_arg_type ("GtkNotebook::scrollable", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_SCROLLABLE); - gtk_object_add_arg_type ("GtkNotebook::enable_popup", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ENABLE_POPUP); - gtk_object_add_arg_type ("GtkNotebook::homogeneous", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HOMOGENEOUS); + g_object_class_install_property (gobject_class, + PROP_PAGE, + g_param_spec_int ("page", + _("Page"), + _("The index of the current page"), + 0, + G_MAXINT, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_TAB_POS, + g_param_spec_enum ("tab_pos", + _("Tab Position"), + _("Which side of the notebook holds the tabs"), + GTK_TYPE_POSITION_TYPE, + GTK_POS_TOP, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_TAB_BORDER, + g_param_spec_uint ("tab_border", + _("Tab Border"), + _("Width of the border around the tab labels"), + 0, + G_MAXUINT, + 2, + G_PARAM_WRITABLE)); + + g_object_class_install_property (gobject_class, + PROP_TAB_HBORDER, + g_param_spec_uint ("tab_hborder", + _("Horizontal Tab Border"), + _("Width of the horizontal border of tab labels"), + 0, + G_MAXUINT, + 2, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_TAB_VBORDER, + g_param_spec_uint ("tab_vborder", + _("Vertical Tab Border"), + _("Width of the vertical border of tab labels"), + 0, + G_MAXUINT, + 2, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_SHOW_TABS, + g_param_spec_boolean ("show_tabs", + _("Show Tabs"), + _("Whether tabs should be shown or not"), + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_SHOW_BORDER, + g_param_spec_boolean ("show_border", + _("Show Border"), + _("Whether the border should be shown or not"), + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_SCROLLABLE, + g_param_spec_boolean ("scrollable", + _("Scrollable"), + _("If TRUE, scroll arrows are added if there are to many tabs to fit"), + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_ENABLE_POPUP, + g_param_spec_boolean ("enable_popup", + _("Enable Popup"), + _("If TRUE, pressing the right mouse button on the notebook pops up a menu that you can use to go to a page"), + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_HOMOGENEOUS, + g_param_spec_boolean ("homogeneous", + _("Homogeneous"), + _("Whether tabs should have homogeneous sizes"), + FALSE, + G_PARAM_READWRITE)); gtk_container_add_child_arg_type ("GtkNotebook::tab_label", GTK_TYPE_STRING, GTK_ARG_READWRITE, CHILD_ARG_TAB_LABEL); gtk_container_add_child_arg_type ("GtkNotebook::menu_label", GTK_TYPE_STRING, GTK_ARG_READWRITE, CHILD_ARG_MENU_LABEL); @@ -495,48 +577,49 @@ gtk_notebook_destroy (GtkObject *object) } static void -gtk_notebook_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) +gtk_notebook_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { GtkNotebook *notebook; notebook = GTK_NOTEBOOK (object); - switch (arg_id) + switch (prop_id) { - case ARG_SHOW_TABS: - gtk_notebook_set_show_tabs (notebook, GTK_VALUE_BOOL (*arg)); + case PROP_SHOW_TABS: + gtk_notebook_set_show_tabs (notebook, g_value_get_boolean (value)); break; - case ARG_SHOW_BORDER: - gtk_notebook_set_show_border (notebook, GTK_VALUE_BOOL (*arg)); + case PROP_SHOW_BORDER: + gtk_notebook_set_show_border (notebook, g_value_get_boolean (value)); break; - case ARG_SCROLLABLE: - gtk_notebook_set_scrollable (notebook, GTK_VALUE_BOOL (*arg)); + case PROP_SCROLLABLE: + gtk_notebook_set_scrollable (notebook, g_value_get_boolean (value)); break; - case ARG_ENABLE_POPUP: - if (GTK_VALUE_BOOL (*arg)) + case PROP_ENABLE_POPUP: + if (g_value_get_boolean (value)) gtk_notebook_popup_enable (notebook); else gtk_notebook_popup_disable (notebook); break; - case ARG_HOMOGENEOUS: - gtk_notebook_set_homogeneous_tabs (notebook, GTK_VALUE_BOOL (*arg)); + case PROP_HOMOGENEOUS: + gtk_notebook_set_homogeneous_tabs (notebook, g_value_get_boolean (value)); break; - case ARG_PAGE: - gtk_notebook_set_page (notebook, GTK_VALUE_INT (*arg)); + case PROP_PAGE: + gtk_notebook_set_page (notebook, g_value_get_int (value)); break; - case ARG_TAB_POS: - gtk_notebook_set_tab_pos (notebook, GTK_VALUE_ENUM (*arg)); + case PROP_TAB_POS: + gtk_notebook_set_tab_pos (notebook, g_value_get_enum (value)); break; - case ARG_TAB_BORDER: - gtk_notebook_set_tab_border (notebook, GTK_VALUE_UINT (*arg)); + case PROP_TAB_BORDER: + gtk_notebook_set_tab_border (notebook, g_value_get_uint (value)); break; - case ARG_TAB_HBORDER: - gtk_notebook_set_tab_hborder (notebook, GTK_VALUE_UINT (*arg)); + case PROP_TAB_HBORDER: + gtk_notebook_set_tab_hborder (notebook, g_value_get_uint (value)); break; - case ARG_TAB_VBORDER: - gtk_notebook_set_tab_vborder (notebook, GTK_VALUE_UINT (*arg)); + case PROP_TAB_VBORDER: + gtk_notebook_set_tab_vborder (notebook, g_value_get_uint (value)); break; default: break; @@ -544,45 +627,46 @@ gtk_notebook_set_arg (GtkObject *object, } static void -gtk_notebook_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) +gtk_notebook_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { GtkNotebook *notebook; notebook = GTK_NOTEBOOK (object); - switch (arg_id) + switch (prop_id) { - case ARG_SHOW_TABS: - GTK_VALUE_BOOL (*arg) = notebook->show_tabs; + case PROP_SHOW_TABS: + g_value_set_boolean (value, notebook->show_tabs); break; - case ARG_SHOW_BORDER: - GTK_VALUE_BOOL (*arg) = notebook->show_border; + case PROP_SHOW_BORDER: + g_value_set_boolean (value, notebook->show_border); break; - case ARG_SCROLLABLE: - GTK_VALUE_BOOL (*arg) = notebook->scrollable; + case PROP_SCROLLABLE: + g_value_set_boolean (value, notebook->scrollable); break; - case ARG_ENABLE_POPUP: - GTK_VALUE_BOOL (*arg) = notebook->menu != NULL; + case PROP_ENABLE_POPUP: + g_value_set_boolean (value, notebook->menu != NULL); break; - case ARG_HOMOGENEOUS: - GTK_VALUE_BOOL (*arg) = notebook->homogeneous; + case PROP_HOMOGENEOUS: + g_value_set_boolean (value, notebook->homogeneous); break; - case ARG_PAGE: - GTK_VALUE_INT (*arg) = gtk_notebook_get_current_page (notebook); + case PROP_PAGE: + g_value_set_int (value, gtk_notebook_get_current_page (notebook)); break; - case ARG_TAB_POS: - GTK_VALUE_ENUM (*arg) = notebook->tab_pos; + case PROP_TAB_POS: + g_value_set_enum (value, notebook->tab_pos); break; - case ARG_TAB_HBORDER: - GTK_VALUE_UINT (*arg) = notebook->tab_hborder; + case PROP_TAB_HBORDER: + g_value_set_uint (value, notebook->tab_hborder); break; - case ARG_TAB_VBORDER: - GTK_VALUE_UINT (*arg) = notebook->tab_vborder; + case PROP_TAB_VBORDER: + g_value_set_uint (value, notebook->tab_vborder); break; default: - arg->type = GTK_TYPE_INVALID; + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } @@ -3343,6 +3427,7 @@ gtk_notebook_real_switch_page (GtkNotebook *notebook, gtk_widget_map (notebook->cur_page->child); gtk_widget_queue_resize (GTK_WIDGET (notebook)); + g_object_notify (G_OBJECT (notebook), "page"); } /* Private GtkNotebook Page Switch Functions: @@ -4080,6 +4165,8 @@ gtk_notebook_set_show_border (GtkNotebook *notebook, if (GTK_WIDGET_VISIBLE (notebook)) gtk_widget_queue_resize (GTK_WIDGET (notebook)); + + g_object_notify (G_OBJECT (notebook), "show_border"); } } @@ -4134,6 +4221,8 @@ gtk_notebook_set_show_tabs (GtkNotebook *notebook, gtk_notebook_update_labels (notebook); } gtk_widget_queue_resize (GTK_WIDGET (notebook)); + + g_object_notify (G_OBJECT (notebook), "show_tabs"); } /** @@ -4156,6 +4245,8 @@ gtk_notebook_set_tab_pos (GtkNotebook *notebook, if (GTK_WIDGET_VISIBLE (notebook)) gtk_widget_queue_resize (GTK_WIDGET (notebook)); } + + g_object_notify (G_OBJECT (notebook), "tab_pos"); } /** @@ -4176,6 +4267,8 @@ gtk_notebook_set_homogeneous_tabs (GtkNotebook *notebook, notebook->homogeneous = homogeneous; gtk_widget_queue_resize (GTK_WIDGET (notebook)); + + g_object_notify (G_OBJECT (notebook), "homogeneous"); } /** @@ -4199,6 +4292,8 @@ gtk_notebook_set_tab_border (GtkNotebook *notebook, if (GTK_WIDGET_VISIBLE (notebook) && notebook->show_tabs) gtk_widget_queue_resize (GTK_WIDGET (notebook)); + + g_object_notify (G_OBJECT (notebook), "tab_hborder"); } /** @@ -4221,6 +4316,8 @@ gtk_notebook_set_tab_hborder (GtkNotebook *notebook, if (GTK_WIDGET_VISIBLE (notebook) && notebook->show_tabs) gtk_widget_queue_resize (GTK_WIDGET (notebook)); + + g_object_notify (G_OBJECT (notebook), "tab_vborder"); } /** @@ -4282,6 +4379,8 @@ gtk_notebook_set_scrollable (GtkNotebook *notebook, if (GTK_WIDGET_VISIBLE (notebook)) gtk_widget_queue_resize (GTK_WIDGET (notebook)); + + g_object_notify (G_OBJECT (notebook), "scrollable"); } } @@ -4319,6 +4418,8 @@ gtk_notebook_popup_enable (GtkNotebook *notebook) gtk_menu_attach_to_widget (GTK_MENU (notebook->menu), GTK_WIDGET (notebook), gtk_notebook_menu_detacher); + + g_object_notify (G_OBJECT (notebook), "enable_popup"); } /** @@ -4338,6 +4439,8 @@ gtk_notebook_popup_disable (GtkNotebook *notebook) gtk_container_foreach (GTK_CONTAINER (notebook->menu), (GtkCallback) gtk_notebook_menu_label_unparent, NULL); gtk_widget_destroy (notebook->menu); + + g_object_notify (G_OBJECT (notebook), "enable_popup"); } /* Public GtkNotebook Page Properties Functions: diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index a0d75f384..f73244133 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -40,7 +40,8 @@ enum { PROP_0, - PROP_UPDATE_POLICY + PROP_UPDATE_POLICY, + PROP_ADJUSTMENT }; enum { @@ -197,6 +198,14 @@ gtk_range_class_init (GtkRangeClass *class) GTK_UPDATE_CONTINUOUS, G_PARAM_READWRITE)); + g_object_class_install_property (gobject_class, + PROP_ADJUSTMENT, + g_param_spec_object ("adjustment", + _("Adjustment"), + _("The GtkAdjustment that contains the current value of this range object"), + GTK_TYPE_ADJUSTMENT, + G_PARAM_READWRITE)); + gtk_widget_class_install_style_property (widget_class, g_param_spec_int ("slider_width", _("Slider Width"), @@ -246,6 +255,9 @@ gtk_range_set_property (GObject *object, case PROP_UPDATE_POLICY: gtk_range_set_update_policy (range, g_value_get_enum (value)); break; + case PROP_ADJUSTMENT: + gtk_range_set_adjustment (range, g_value_get_object (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -267,6 +279,9 @@ gtk_range_get_property (GObject *object, case PROP_UPDATE_POLICY: g_value_set_enum (value, range->policy); break; + case PROP_ADJUSTMENT: + g_value_set_object (value, G_OBJECT (range->adjustment)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -363,6 +378,7 @@ gtk_range_set_adjustment (GtkRange *range, range->old_page_size = adjustment->page_size; gtk_range_adjustment_changed (adjustment, (gpointer) range); + g_object_notify (G_OBJECT (range), "adjustment"); } } diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index 3ba23cbc4..ed8fb0b3b 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -48,12 +48,9 @@ #define SPACE_LINE_END 7 enum { - ARG_0, - ARG_ORIENTATION, - ARG_TOOLBAR_STYLE, - ARG_SPACE_SIZE, - ARG_SPACE_STYLE, - ARG_RELIEF + PROP_0, + PROP_ORIENTATION, + PROP_TOOLBAR_STYLE, }; enum { @@ -72,12 +69,14 @@ struct _GtkToolbarChildSpace static void gtk_toolbar_class_init (GtkToolbarClass *class); static void gtk_toolbar_init (GtkToolbar *toolbar); -static void gtk_toolbar_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void gtk_toolbar_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); +static void gtk_toolbar_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void gtk_toolbar_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); static void gtk_toolbar_destroy (GtkObject *object); static void gtk_toolbar_map (GtkWidget *widget); static void gtk_toolbar_unmap (GtkWidget *widget); @@ -164,10 +163,12 @@ gtk_toolbar_get_type (void) static void gtk_toolbar_class_init (GtkToolbarClass *class) { + GObjectClass *gobject_class; GtkObjectClass *object_class; GtkWidgetClass *widget_class; GtkContainerClass *container_class; + gobject_class = G_OBJECT_CLASS (class); object_class = (GtkObjectClass *) class; widget_class = (GtkWidgetClass *) class; container_class = (GtkContainerClass *) class; @@ -175,8 +176,8 @@ gtk_toolbar_class_init (GtkToolbarClass *class) parent_class = gtk_type_class (gtk_container_get_type ()); object_class->destroy = gtk_toolbar_destroy; - object_class->set_arg = gtk_toolbar_set_arg; - object_class->get_arg = gtk_toolbar_get_arg; + gobject_class->set_property = gtk_toolbar_set_property; + gobject_class->get_property = gtk_toolbar_get_property; widget_class->map = gtk_toolbar_map; widget_class->unmap = gtk_toolbar_unmap; @@ -210,10 +211,24 @@ gtk_toolbar_class_init (GtkToolbarClass *class) GTK_TYPE_NONE, 1, GTK_TYPE_INT); - gtk_object_add_arg_type ("GtkToolbar::orientation", GTK_TYPE_ORIENTATION, - GTK_ARG_READWRITE, ARG_ORIENTATION); - gtk_object_add_arg_type ("GtkToolbar::toolbar_style", GTK_TYPE_TOOLBAR_STYLE, - GTK_ARG_READWRITE, ARG_TOOLBAR_STYLE); + g_object_class_install_property (gobject_class, + PROP_ORIENTATION, + g_param_spec_enum ("orientation", + _("Orientation"), + _("The orientation of the toolbar"), + GTK_TYPE_ORIENTATION, + GTK_ORIENTATION_HORIZONTAL, + G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_TOOLBAR_STYLE, + g_param_spec_enum ("toolbar_style", + _("Toolbar Style"), + _("How to draw the toolbar"), + GTK_TYPE_TOOLBAR_STYLE, + GTK_TOOLBAR_ICONS, + G_PARAM_READWRITE)); + gtk_widget_class_install_style_property (widget_class, g_param_spec_int ("space_size", @@ -258,40 +273,42 @@ gtk_toolbar_init (GtkToolbar *toolbar) } static void -gtk_toolbar_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) +gtk_toolbar_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { GtkToolbar *toolbar = GTK_TOOLBAR (object); - switch (arg_id) + switch (prop_id) { - case ARG_ORIENTATION: - gtk_toolbar_set_orientation (toolbar, GTK_VALUE_ENUM (*arg)); + case PROP_ORIENTATION: + gtk_toolbar_set_orientation (toolbar, g_value_get_enum (value)); break; - case ARG_TOOLBAR_STYLE: - gtk_toolbar_set_style (toolbar, GTK_VALUE_ENUM (*arg)); + case PROP_TOOLBAR_STYLE: + gtk_toolbar_set_style (toolbar, g_value_get_enum (value)); break; } } static void -gtk_toolbar_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) +gtk_toolbar_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { GtkToolbar *toolbar = GTK_TOOLBAR (object); - switch (arg_id) + switch (prop_id) { - case ARG_ORIENTATION: - GTK_VALUE_ENUM (*arg) = toolbar->orientation; + case PROP_ORIENTATION: + g_value_set_enum (value, toolbar->orientation); break; - case ARG_TOOLBAR_STYLE: - GTK_VALUE_ENUM (*arg) = toolbar->style; + case PROP_TOOLBAR_STYLE: + g_value_set_enum (value, toolbar->style); break; default: - arg->type = GTK_TYPE_INVALID; + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } @@ -1262,6 +1279,7 @@ gtk_real_toolbar_orientation_changed (GtkToolbar *toolbar, { toolbar->orientation = orientation; gtk_widget_queue_resize (GTK_WIDGET (toolbar)); + g_object_notify (G_OBJECT (toolbar), "orientation"); } } @@ -1400,8 +1418,9 @@ gtk_real_toolbar_style_changed (GtkToolbar *toolbar, g_assert_not_reached (); } } - + gtk_widget_queue_resize (GTK_WIDGET (toolbar)); + g_object_notify (G_OBJECT (toolbar), "toolbar_style"); } } diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c index be31ec337..d233e985e 100644 --- a/gtk/gtkvscale.c +++ b/gtk/gtkvscale.c @@ -36,8 +36,7 @@ #define RANGE_CLASS(w) GTK_RANGE_GET_CLASS (w) enum { - PROP_0, - PROP_ADJUSTMENT + PROP_0 }; static void gtk_vscale_class_init (GtkVScaleClass *klass); @@ -131,14 +130,6 @@ gtk_vscale_class_init (GtkVScaleClass *class) scale_class->draw_value = gtk_vscale_draw_value; - g_object_class_install_property (gobject_class, - PROP_ADJUSTMENT, - g_param_spec_object ("adjustment", - _("Adjustment"), - _("The GtkAdjustment that determines the values to use for this VScale."), - GTK_TYPE_ADJUSTMENT, - G_PARAM_READWRITE)); - binding_set = gtk_binding_set_by_class (object_class); add_slider_binding (binding_set, GDK_Up, 0, @@ -204,9 +195,6 @@ gtk_vscale_set_property (GObject *object, switch (prop_id) { - case PROP_ADJUSTMENT: - gtk_range_set_adjustment (GTK_RANGE (vscale), g_value_get_object (value)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -225,10 +213,6 @@ gtk_vscale_get_property (GObject *object, switch (prop_id) { - case PROP_ADJUSTMENT: - g_value_set_object (value, - G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (vscale)))); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gtk/gtkvscrollbar.c b/gtk/gtkvscrollbar.c index f4e7c28f7..54fb33732 100644 --- a/gtk/gtkvscrollbar.c +++ b/gtk/gtkvscrollbar.c @@ -36,7 +36,6 @@ enum { PROP_0, - PROP_ADJUSTMENT }; static void gtk_vscrollbar_class_init (GtkVScrollbarClass *klass); @@ -107,15 +106,6 @@ gtk_vscrollbar_class_init (GtkVScrollbarClass *class) range_class->slider_update = gtk_vscrollbar_slider_update; range_class->trough_click = _gtk_range_default_vtrough_click; range_class->motion = _gtk_range_default_vmotion; - - g_object_class_install_property (gobject_class, - PROP_ADJUSTMENT, - g_param_spec_object ("adjustment", - _("Adjustment"), - _("The GtkAdjustment that determines the values to use for this scrollbar."), - GTK_TYPE_ADJUSTMENT, - G_PARAM_READWRITE)); - } static void @@ -130,9 +120,6 @@ gtk_vscrollbar_set_property (GObject *object, switch (prop_id) { - case PROP_ADJUSTMENT: - gtk_range_set_adjustment (GTK_RANGE (vscrollbar), g_value_get_object (value)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -151,9 +138,6 @@ gtk_vscrollbar_get_property (GObject *object, switch (prop_id) { - case PROP_ADJUSTMENT: - g_value_set_object (value, G_OBJECT (vscrollbar)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 8079611f8..345b430db 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -1231,9 +1231,9 @@ gtk_widget_get_property (GObject *object, case PROP_EXTENSION_EVENTS: modep = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_extension_event_mode); if (!modep) - g_value_set_flags (value, 0); + g_value_set_enum (value, 0); else - g_value_set_flags (value, (GdkExtensionMode) *modep); + g_value_set_enum (value, (GdkExtensionMode) *modep); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |