diff --git a/ChangeLog b/ChangeLog index f5dd9bb3e0..57c50d0d21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2001-05-17 Alexander Larsson + + * 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. + Sun May 13 12:01:12 2001 Owen Taylor * autogen.sh (have_automake): Require libtool-1.4, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index f5dd9bb3e0..57c50d0d21 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,33 @@ +2001-05-17 Alexander Larsson + + * 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. + Sun May 13 12:01:12 2001 Owen Taylor * autogen.sh (have_automake): Require libtool-1.4, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f5dd9bb3e0..57c50d0d21 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,33 @@ +2001-05-17 Alexander Larsson + + * 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. + Sun May 13 12:01:12 2001 Owen Taylor * autogen.sh (have_automake): Require libtool-1.4, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index f5dd9bb3e0..57c50d0d21 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,33 @@ +2001-05-17 Alexander Larsson + + * 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. + Sun May 13 12:01:12 2001 Owen Taylor * autogen.sh (have_automake): Require libtool-1.4, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index f5dd9bb3e0..57c50d0d21 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,33 @@ +2001-05-17 Alexander Larsson + + * 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. + Sun May 13 12:01:12 2001 Owen Taylor * autogen.sh (have_automake): Require libtool-1.4, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f5dd9bb3e0..57c50d0d21 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,33 @@ +2001-05-17 Alexander Larsson + + * 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. + Sun May 13 12:01:12 2001 Owen Taylor * autogen.sh (have_automake): Require libtool-1.4, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f5dd9bb3e0..57c50d0d21 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,33 @@ +2001-05-17 Alexander Larsson + + * 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. + Sun May 13 12:01:12 2001 Owen Taylor * autogen.sh (have_automake): Require libtool-1.4, diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c index 51f2bb5e14..81b02d401e 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 29f6321fbf..a59efe8894 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 63fc1c6cc8..9ec6f22c48 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 bc3a99c717..896d1e336a 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 afabbc4f2e..c18b228330 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 a0d75f384e..f73244133e 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 3ba23cbc49..ed8fb0b3b4 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 be31ec3378..d233e985e0 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 f4e7c28f7b..54fb337324 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 8079611f84..345b430db7 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); diff --git a/tests/prop-editor.c b/tests/prop-editor.c index 2c91578155..a8e3cc2610 100644 --- a/tests/prop-editor.c +++ b/tests/prop-editor.c @@ -33,7 +33,7 @@ get_param_specs (GType type, /* We count on the fact we have an instance, or else we'd have * to use g_type_class_ref (); */ - + /* Use private interface for now, fix later */ *specs = class->property_specs; *n_specs = class->n_property_specs; @@ -133,7 +133,8 @@ block_controller (GObject *controller) { ObjectProperty *p = g_object_get_data (controller, "object-property"); - g_signal_handler_block (controller, p->modified_id); + if (p) + g_signal_handler_block (controller, p->modified_id); } static void @@ -141,7 +142,8 @@ unblock_controller (GObject *controller) { ObjectProperty *p = g_object_get_data (controller, "object-property"); - g_signal_handler_unblock (controller, p->modified_id); + if (p) + g_signal_handler_unblock (controller, p->modified_id); } static void @@ -171,6 +173,33 @@ int_changed (GObject *object, GParamSpec *pspec, gpointer data) g_value_unset (&val); } +static void +uint_modified (GtkAdjustment *adj, gpointer data) +{ + ObjectProperty *p = data; + + g_object_set (p->obj, p->prop, (guint) adj->value, NULL); +} + +static void +uint_changed (GObject *object, GParamSpec *pspec, gpointer data) +{ + GtkAdjustment *adj = GTK_ADJUSTMENT (data); + GValue val = { 0, }; + + g_value_init (&val, G_TYPE_UINT); + g_object_get_property (object, pspec->name, &val); + + if (g_value_get_uint (&val) != (guint)adj->value) + { + block_controller (G_OBJECT (adj)); + gtk_adjustment_set_value (adj, g_value_get_uint (&val)); + unblock_controller (G_OBJECT (adj)); + } + + g_value_unset (&val); +} + static void float_modified (GtkAdjustment *adj, gpointer data) { @@ -198,6 +227,33 @@ float_changed (GObject *object, GParamSpec *pspec, gpointer data) g_value_unset (&val); } +static void +double_modified (GtkAdjustment *adj, gpointer data) +{ + ObjectProperty *p = data; + + g_object_set (p->obj, p->prop, (double) adj->value, NULL); +} + +static void +double_changed (GObject *object, GParamSpec *pspec, gpointer data) +{ + GtkAdjustment *adj = GTK_ADJUSTMENT (data); + GValue val = { 0, }; + + g_value_init (&val, G_TYPE_DOUBLE); + g_object_get_property (object, pspec->name, &val); + + if (g_value_get_double (&val) != adj->value) + { + block_controller (G_OBJECT (adj)); + gtk_adjustment_set_value (adj, g_value_get_double (&val)); + unblock_controller (G_OBJECT (adj)); + } + + g_value_unset (&val); +} + static void string_modified (GtkEntry *entry, gpointer data) { @@ -362,6 +418,40 @@ unichar_changed (GObject *object, GParamSpec *pspec, gpointer data) } } +static void +pointer_changed (GObject *object, GParamSpec *pspec, gpointer data) +{ + GtkLabel *label = GTK_LABEL (data); + gchar *str; + gpointer ptr; + + g_object_get (object, pspec->name, &ptr, NULL); + + str = g_strdup_printf ("Pointer: %p", ptr); + gtk_label_set_text (label, str); + g_free (str); +} + +static void +object_changed (GObject *object, GParamSpec *pspec, gpointer data) +{ + GtkLabel *label = GTK_LABEL (data); + gchar *str; + GObject *obj; + const gchar *name; + + g_object_get (object, pspec->name, &obj, NULL); + + if (obj) + name = g_type_name (G_TYPE_FROM_INSTANCE (obj)); + else + name = "unknown"; + str = g_strdup_printf ("Objetct: %p (%s)", obj, name); + + gtk_label_set_text (label, str); + g_free (str); +} + void model_destroy (gpointer data) { @@ -375,43 +465,224 @@ window_destroy (gpointer data) g_object_steal_data (data, "prop-editor-win"); } -GtkWidget* -create_prop_editor (GObject *object, - GType type) +static GtkWidget * +property_widget (GObject *object, GParamSpec *spec, gboolean can_modify) { - GtkWidget *win; - GtkWidget *vbox; - GtkWidget *hbox; - GtkWidget *label; GtkWidget *prop_edit; + GtkAdjustment *adj; + gchar *msg; + + switch (G_PARAM_SPEC_TYPE (spec)) + { + case G_TYPE_PARAM_INT: + adj = GTK_ADJUSTMENT (gtk_adjustment_new (G_PARAM_SPEC_INT (spec)->default_value, + G_PARAM_SPEC_INT (spec)->minimum, + G_PARAM_SPEC_INT (spec)->maximum, + 1, + MAX ((G_PARAM_SPEC_INT (spec)->maximum - + G_PARAM_SPEC_INT (spec)->minimum) / 10, 1), + 0.0)); + + prop_edit = gtk_spin_button_new (adj, 1.0, 0); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (int_changed), + adj, G_OBJECT (adj)); + + if (can_modify) + connect_controller (G_OBJECT (adj), "value_changed", + object, spec->name, (GtkSignalFunc) int_modified); + break; + + case G_TYPE_PARAM_UINT: + adj = GTK_ADJUSTMENT ( + gtk_adjustment_new (G_PARAM_SPEC_UINT (spec)->default_value, + G_PARAM_SPEC_UINT (spec)->minimum, + G_PARAM_SPEC_UINT (spec)->maximum, + 1, + MAX ((G_PARAM_SPEC_UINT (spec)->maximum - + G_PARAM_SPEC_UINT (spec)->minimum) / 10, 1), + 0.0)); + + prop_edit = gtk_spin_button_new (adj, 1.0, 0); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (uint_changed), + adj, G_OBJECT (adj)); + + if (can_modify) + connect_controller (G_OBJECT (adj), "value_changed", + object, spec->name, (GtkSignalFunc) uint_modified); + break; + + case G_TYPE_PARAM_FLOAT: + adj = GTK_ADJUSTMENT (gtk_adjustment_new (G_PARAM_SPEC_FLOAT (spec)->default_value, + G_PARAM_SPEC_FLOAT (spec)->minimum, + G_PARAM_SPEC_FLOAT (spec)->maximum, + 0.1, + MAX ((G_PARAM_SPEC_FLOAT (spec)->maximum - + G_PARAM_SPEC_FLOAT (spec)->minimum) / 10, 0.1), + 0.0)); + + prop_edit = gtk_spin_button_new (adj, 0.1, 2); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (float_changed), + adj, G_OBJECT (adj)); + + if (can_modify) + connect_controller (G_OBJECT (adj), "value_changed", + object, spec->name, (GtkSignalFunc) float_modified); + break; + + case G_TYPE_PARAM_DOUBLE: + adj = GTK_ADJUSTMENT (gtk_adjustment_new (G_PARAM_SPEC_DOUBLE (spec)->default_value, + G_PARAM_SPEC_DOUBLE (spec)->minimum, + G_PARAM_SPEC_DOUBLE (spec)->maximum, + 0.1, + MAX ((G_PARAM_SPEC_DOUBLE (spec)->maximum - + G_PARAM_SPEC_DOUBLE (spec)->minimum) / 10, 0.1), + 0.0)); + + prop_edit = gtk_spin_button_new (adj, 0.1, 2); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (double_changed), + adj, G_OBJECT (adj)); + + if (can_modify) + connect_controller (G_OBJECT (adj), "value_changed", + object, spec->name, (GtkSignalFunc) double_modified); + break; + + case G_TYPE_PARAM_STRING: + prop_edit = gtk_entry_new (); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (string_changed), + prop_edit, G_OBJECT (prop_edit)); + + if (can_modify) + connect_controller (G_OBJECT (prop_edit), "changed", + object, spec->name, (GtkSignalFunc) string_modified); + break; + + case G_TYPE_PARAM_BOOLEAN: + prop_edit = gtk_toggle_button_new_with_label (""); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (bool_changed), + prop_edit, G_OBJECT (prop_edit)); + + if (can_modify) + connect_controller (G_OBJECT (prop_edit), "toggled", + object, spec->name, (GtkSignalFunc) bool_modified); + break; + + case G_TYPE_PARAM_ENUM: + { + GtkWidget *menu; + GEnumClass *eclass; + gint j; + + prop_edit = gtk_option_menu_new (); + + menu = gtk_menu_new (); + + eclass = G_ENUM_CLASS (g_type_class_ref (spec->value_type)); + + j = 0; + while (j < eclass->n_values) + { + GtkWidget *mi; + + mi = gtk_menu_item_new_with_label (eclass->values[j].value_name); + + gtk_widget_show (mi); + + gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); + + ++j; + } + + g_type_class_unref (eclass); + + gtk_option_menu_set_menu (GTK_OPTION_MENU (prop_edit), menu); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (enum_changed), + prop_edit, G_OBJECT (prop_edit)); + + if (can_modify) + connect_controller (G_OBJECT (prop_edit), "changed", + object, spec->name, (GtkSignalFunc) enum_modified); + } + break; + + case G_TYPE_PARAM_UNICHAR: + prop_edit = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (prop_edit), 1); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (unichar_changed), + prop_edit, G_OBJECT (prop_edit)); + + if (can_modify) + connect_controller (G_OBJECT (prop_edit), "changed", + object, spec->name, (GtkSignalFunc) unichar_modified); + break; + + case G_TYPE_PARAM_POINTER: + prop_edit = gtk_label_new (""); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (pointer_changed), + prop_edit, G_OBJECT (prop_edit)); + break; + + case G_TYPE_PARAM_OBJECT: + prop_edit = gtk_label_new (""); + + g_object_connect_property (object, spec->name, + GTK_SIGNAL_FUNC (object_changed), + prop_edit, G_OBJECT (prop_edit)); + break; + + + default: + msg = g_strdup_printf ("uneditable property type: %s", + g_type_name (G_PARAM_SPEC_TYPE (spec))); + prop_edit = gtk_label_new (msg); + g_free (msg); + gtk_misc_set_alignment (GTK_MISC (prop_edit), 0.0, 0.5); + } + + return prop_edit; +} + +static GtkWidget * +properties_from_type (GObject *object, + GType type, + GtkTooltips *tips) +{ + GtkWidget *prop_edit; + GtkWidget *label; GtkWidget *sw; + GtkWidget *vbox; + GtkWidget *table; + int i; gint n_specs = 0; GParamSpec **specs = NULL; - gint i; - GtkAdjustment *adj; - GtkTooltips *tips; - win = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - tips = gtk_tooltips_new (); - gtk_signal_connect_object (GTK_OBJECT (win), "destroy", - GTK_SIGNAL_FUNC (gtk_object_destroy), GTK_OBJECT (tips)); - - /* hold a weak ref to the object we're editing */ - g_object_set_data_full (G_OBJECT (object), "prop-editor-win", win, model_destroy); - g_object_set_data_full (G_OBJECT (win), "model-object", object, window_destroy); - - vbox = gtk_vbox_new (TRUE, 2); - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), vbox); - gtk_container_add (GTK_CONTAINER (win), sw); - get_param_specs (type, &specs, &n_specs); + + if (n_specs == 0) + return NULL; + table = gtk_table_new (n_specs, 2, FALSE); + gtk_table_set_col_spacing (GTK_TABLE (table), 0, 10); + gtk_table_set_row_spacings (GTK_TABLE (table), 3); + i = 0; while (i < n_specs) { @@ -430,184 +701,12 @@ create_prop_editor (GObject *object, continue; } - switch (G_PARAM_SPEC_TYPE (spec)) - { - case G_TYPE_PARAM_INT: - hbox = gtk_hbox_new (FALSE, 10); - label = gtk_label_new (spec->nick); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - adj = GTK_ADJUSTMENT (gtk_adjustment_new (G_PARAM_SPEC_INT (spec)->default_value, - G_PARAM_SPEC_INT (spec)->minimum, - G_PARAM_SPEC_INT (spec)->maximum, - 1, - MAX ((G_PARAM_SPEC_INT (spec)->maximum - - G_PARAM_SPEC_INT (spec)->minimum) / 10, 1), - 0.0)); - - prop_edit = gtk_spin_button_new (adj, 1.0, 0); - gtk_box_pack_end (GTK_BOX (hbox), prop_edit, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - g_object_connect_property (object, spec->name, - GTK_SIGNAL_FUNC (int_changed), - adj, G_OBJECT (adj)); - - if (can_modify) - connect_controller (G_OBJECT (adj), "value_changed", - object, spec->name, (GtkSignalFunc) int_modified); - break; - - case G_TYPE_PARAM_FLOAT: - hbox = gtk_hbox_new (FALSE, 10); - label = gtk_label_new (spec->nick); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - adj = GTK_ADJUSTMENT (gtk_adjustment_new (G_PARAM_SPEC_FLOAT (spec)->default_value, - G_PARAM_SPEC_FLOAT (spec)->minimum, - G_PARAM_SPEC_FLOAT (spec)->maximum, - 0.1, - MAX ((G_PARAM_SPEC_FLOAT (spec)->maximum - - G_PARAM_SPEC_FLOAT (spec)->minimum) / 10, 0.1), - 0.0)); - - prop_edit = gtk_spin_button_new (adj, 0.1, 2); - - gtk_box_pack_end (GTK_BOX (hbox), prop_edit, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - g_object_connect_property (object, spec->name, - GTK_SIGNAL_FUNC (float_changed), - adj, G_OBJECT (adj)); - - if (can_modify) - connect_controller (G_OBJECT (adj), "value_changed", - object, spec->name, (GtkSignalFunc) float_modified); - break; - - case G_TYPE_PARAM_STRING: - hbox = gtk_hbox_new (FALSE, 10); - label = gtk_label_new (spec->nick); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - prop_edit = gtk_entry_new (); - gtk_box_pack_end (GTK_BOX (hbox), prop_edit, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - g_object_connect_property (object, spec->name, - GTK_SIGNAL_FUNC (string_changed), - prop_edit, G_OBJECT (prop_edit)); - - if (can_modify) - connect_controller (G_OBJECT (prop_edit), "changed", - object, spec->name, (GtkSignalFunc) string_modified); - break; - - case G_TYPE_PARAM_BOOLEAN: - hbox = gtk_hbox_new (FALSE, 10); - label = gtk_label_new (spec->nick); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - prop_edit = gtk_toggle_button_new_with_label (""); - gtk_box_pack_end (GTK_BOX (hbox), prop_edit, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - g_object_connect_property (object, spec->name, - GTK_SIGNAL_FUNC (bool_changed), - prop_edit, G_OBJECT (prop_edit)); - - if (can_modify) - connect_controller (G_OBJECT (prop_edit), "toggled", - object, spec->name, (GtkSignalFunc) bool_modified); - break; - - case G_TYPE_PARAM_ENUM: - { - GtkWidget *menu; - GEnumClass *eclass; - gint i; - - hbox = gtk_hbox_new (FALSE, 10); - label = gtk_label_new (spec->nick); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - prop_edit = gtk_option_menu_new (); - - menu = gtk_menu_new (); - - eclass = G_ENUM_CLASS (g_type_class_ref (spec->value_type)); - - i = 0; - while (i < eclass->n_values) - { - GtkWidget *mi; - - mi = gtk_menu_item_new_with_label (eclass->values[i].value_name); - - gtk_widget_show (mi); - - gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - - ++i; - } - - g_type_class_unref (eclass); - - gtk_option_menu_set_menu (GTK_OPTION_MENU (prop_edit), menu); - - gtk_box_pack_end (GTK_BOX (hbox), prop_edit, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - g_object_connect_property (object, spec->name, - GTK_SIGNAL_FUNC (enum_changed), - prop_edit, G_OBJECT (prop_edit)); - - if (can_modify) - connect_controller (G_OBJECT (prop_edit), "changed", - object, spec->name, (GtkSignalFunc) enum_modified); - } - - case G_TYPE_PARAM_UNICHAR: - hbox = gtk_hbox_new (FALSE, 10); - label = gtk_label_new (spec->nick); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - prop_edit = gtk_entry_new (); - gtk_entry_set_max_length (GTK_ENTRY (prop_edit), 1); - gtk_box_pack_end (GTK_BOX (hbox), prop_edit, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - - g_object_connect_property (object, spec->name, - GTK_SIGNAL_FUNC (unichar_changed), - prop_edit, G_OBJECT (prop_edit)); - - if (can_modify) - connect_controller (G_OBJECT (prop_edit), "changed", - object, spec->name, (GtkSignalFunc) unichar_modified); - break; - - default: - { - gchar *msg = g_strdup_printf ("%s: don't know how to edit property type %s", - spec->nick, g_type_name (G_PARAM_SPEC_TYPE (spec))); - hbox = gtk_hbox_new (FALSE, 10); - label = gtk_label_new (msg); - g_free (msg); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - } - } + label = gtk_label_new (spec->nick); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, i, i + 1); + + prop_edit = property_widget (object, spec, can_modify); + gtk_table_attach_defaults (GTK_TABLE (table), prop_edit, 1, 2, i, i + 1); if (prop_edit) { @@ -624,7 +723,81 @@ create_prop_editor (GObject *object, ++i; } - gtk_window_set_default_size (GTK_WINDOW (win), 300, 500); + + vbox = gtk_vbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); + + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), vbox); + return sw; +} + + +/* Pass zero for type if you want all properties */ +GtkWidget* +create_prop_editor (GObject *object, GType type) +{ + GtkWidget *win; + GtkWidget *notebook; + GtkTooltips *tips; + GtkWidget *properties; + GtkWidget *label; + gchar *title; + + if ((win = g_object_get_data (G_OBJECT (object), "prop-editor-win"))) + { + gtk_window_present (GTK_WINDOW (win)); + return win; + } + + win = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + tips = gtk_tooltips_new (); + gtk_signal_connect_object (GTK_OBJECT (win), "destroy", + GTK_SIGNAL_FUNC (gtk_object_destroy), GTK_OBJECT (tips)); + + /* hold a weak ref to the object we're editing */ + g_object_set_data_full (G_OBJECT (object), "prop-editor-win", win, model_destroy); + g_object_set_data_full (G_OBJECT (win), "model-object", object, window_destroy); + + if (type == 0) + { + notebook = gtk_notebook_new (); + gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_LEFT); + + gtk_container_add (GTK_CONTAINER (win), notebook); + + type = G_TYPE_FROM_INSTANCE (object); + + title = g_strdup_printf ("Properties of %s widget", g_type_name (type)); + gtk_window_set_title (GTK_WINDOW (win), title); + g_free (title); + + while (type) + { + properties = properties_from_type (object, type, tips); + if (properties) + { + label = gtk_label_new (g_type_name (type)); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), + properties, label); + } + + type = g_type_parent (type); + } + } + else + { + properties = properties_from_type (object, type, tips); + gtk_container_add (GTK_CONTAINER (win), properties); + title = g_strdup_printf ("Properties of %s", g_type_name (type)); + gtk_window_set_title (GTK_WINDOW (win), title); + } + + gtk_window_set_default_size (GTK_WINDOW (win), -1, 400); gtk_widget_show_all (win); diff --git a/tests/testgtk.c b/tests/testgtk.c index 6b27120bab..edb9741fe1 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -3530,7 +3530,7 @@ static void entry_props_clicked (GtkWidget *button, GObject *entry) { - GtkWidget *window = create_prop_editor (entry, GTK_TYPE_ENTRY); + GtkWidget *window = create_prop_editor (entry, 0); gtk_window_set_title (GTK_WINDOW (window), "Entry Properties"); } @@ -8954,6 +8954,255 @@ create_progress_bar (void) gtk_widget_destroy (pdata->window); } +/* + * Properties + */ + +typedef struct { + int x; + int y; + gboolean found; + gboolean first; + GtkWidget *res_widget; +} FindWidgetData; + +static void +find_widget (GtkWidget *widget, FindWidgetData *data) +{ + GtkAllocation new_allocation; + gint x_offset = 0; + gint y_offset = 0; + + new_allocation = widget->allocation; + + if (data->found || !GTK_WIDGET_MAPPED (widget)) + return; + + /* Note that in the following code, we only count the + * position as being inside a WINDOW widget if it is inside + * widget->window; points that are outside of widget->window + * but within the allocation are not counted. This is consistent + * with the way we highlight drag targets. + */ + if (!GTK_WIDGET_NO_WINDOW (widget)) + { + new_allocation.x = 0; + new_allocation.y = 0; + } + + if (widget->parent && !data->first) + { + GdkWindow *window = widget->window; + while (window != widget->parent->window) + { + gint tx, ty, twidth, theight; + gdk_window_get_size (window, &twidth, &theight); + + if (new_allocation.x < 0) + { + new_allocation.width += new_allocation.x; + new_allocation.x = 0; + } + if (new_allocation.y < 0) + { + new_allocation.height += new_allocation.y; + new_allocation.y = 0; + } + if (new_allocation.x + new_allocation.width > twidth) + new_allocation.width = twidth - new_allocation.x; + if (new_allocation.y + new_allocation.height > theight) + new_allocation.height = theight - new_allocation.y; + + gdk_window_get_position (window, &tx, &ty); + new_allocation.x += tx; + x_offset += tx; + new_allocation.y += ty; + y_offset += ty; + + window = gdk_window_get_parent (window); + } + } + + if ((data->x >= new_allocation.x) && (data->y >= new_allocation.y) && + (data->x < new_allocation.x + new_allocation.width) && + (data->y < new_allocation.y + new_allocation.height)) + { + /* First, check if the drag is in a valid drop site in + * one of our children + */ + if (GTK_IS_CONTAINER (widget)) + { + FindWidgetData new_data = *data; + + new_data.x -= x_offset; + new_data.y -= y_offset; + new_data.found = FALSE; + new_data.first = FALSE; + + gtk_container_forall (GTK_CONTAINER (widget), + (GtkCallback)find_widget, + &new_data); + + data->found = new_data.found; + if (data->found) + data->res_widget = new_data.res_widget; + } + + /* If not, and this widget is registered as a drop site, check to + * emit "drag_motion" to check if we are actually in + * a drop site. + */ + if (!data->found) + { + data->found = TRUE; + data->res_widget = widget; + } + } +} + +static GtkWidget * +find_widget_at_pointer (void) +{ + GtkWidget *widget = NULL; + GdkWindow *pointer_window; + gint x, y; + FindWidgetData data; + + pointer_window = gdk_window_at_pointer (NULL, NULL); + + if (pointer_window) + gdk_window_get_user_data (pointer_window, (gpointer*) &widget); + + if (widget) + { + gdk_window_get_pointer (widget->window, + &x, &y, NULL); + + data.x = x; + data.y = y; + data.found = FALSE; + data.first = TRUE; + + find_widget (widget, &data); + if (data.found) + return data.res_widget; + return widget; + } + return NULL; +} + +struct PropertiesData { + GtkWidget **window; + GdkCursor *cursor; + gboolean in_query; + gint handler; +}; + +static void +destroy_properties (GtkWidget *widget, + struct PropertiesData *data) +{ + *data->window = NULL; + + if (data->cursor) + gdk_cursor_destroy (data->cursor); + + gtk_signal_disconnect (widget, data->handler); + + g_free (data); +} + +static gint +property_query_event (GtkWidget *widget, + GdkEvent *event, + struct PropertiesData *data) +{ + GtkWidget *res_widget = NULL; + + if (!data->in_query) + return FALSE; + + if (event->type == GDK_BUTTON_RELEASE) + { + gtk_grab_remove (widget); + gdk_pointer_ungrab (GDK_CURRENT_TIME); + + res_widget = find_widget_at_pointer (); + if (res_widget) + create_prop_editor (G_OBJECT (res_widget), 0); + + data->in_query = FALSE; + } + return FALSE; +} + + +static void +query_properties (GtkButton *button, + struct PropertiesData *data) +{ + gint failure; + + gtk_signal_connect (GTK_OBJECT (button), "event", + (GtkSignalFunc) property_query_event, data); + + + if (!data->cursor) + data->cursor = gdk_cursor_new (GDK_TARGET); + + failure = gdk_pointer_grab (GTK_WIDGET (button)->window, + TRUE, + GDK_BUTTON_RELEASE_MASK, + NULL, + data->cursor, + GDK_CURRENT_TIME); + + gtk_grab_add (GTK_WIDGET (button)); + + data->in_query = TRUE; +} + +static void +create_properties (void) +{ + static GtkWidget *window = NULL; + GtkWidget *button; + struct PropertiesData *data; + + data = g_new (struct PropertiesData, 1); + data->window = &window; + data->in_query = FALSE; + data->cursor = NULL; + data->handler = 0; + + if (!window) + { + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + data->handler = gtk_signal_connect_object (GTK_OBJECT (window), "destroy", + GTK_SIGNAL_FUNC(destroy_properties), + data); + + gtk_window_set_title (GTK_WINDOW (window), "test properties"); + gtk_container_set_border_width (GTK_CONTAINER (window), 10); + + button = gtk_button_new_with_label ("Query properties"); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC(query_properties), + data); + + + gtk_container_add (GTK_CONTAINER (window), button); + } + + if (!GTK_WIDGET_VISIBLE (window)) + gtk_widget_show_all (window); + else + gtk_widget_destroy (window); + +} + + /* * Color Preview */ @@ -10173,6 +10422,7 @@ create_main_window (void) { "preview color", create_color_preview }, { "preview gray", create_gray_preview }, { "progress bar", create_progress_bar }, + { "properties", create_properties }, { "radio buttons", create_radio_buttons }, { "range controls", create_range_controls }, { "rc file", create_rc_file },