diff options
author | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2011-03-31 20:52:11 -0300 |
---|---|---|
committer | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2011-03-31 20:52:11 -0300 |
commit | 6846485c0d39f6c7791a78179b0f893c8a3cdd2a (patch) | |
tree | 44262da5cdb5434cacb24f18ec4f6d9ba8cefcf1 /gladeui | |
parent | fd2be3bd491010fc9c05fd3fdf07fc03b0c7eeb8 (diff) | |
download | glade-6846485c0d39f6c7791a78179b0f893c8a3cdd2a.tar.gz |
* gladeui/glade-base-editor.c,
gladeui/glade-cell-renderer-icon.c,
gladeui/glade-clipboard.c,
gladeui/glade-editor.c,
gladeui/glade-inspector.c,
gladeui/glade-palette.c,
gladeui/glade-project.c,
gladeui/glade-property.c,
gladeui/glade-signal.c,
gladeui/glade-widget-action.c,
gladeui/glade-widget.c:
Replaced g_object_notify() with g_object_notify_by_spec()
Diffstat (limited to 'gladeui')
-rw-r--r-- | gladeui/glade-base-editor.c | 22 | ||||
-rw-r--r-- | gladeui/glade-cell-renderer-icon.c | 37 | ||||
-rw-r--r-- | gladeui/glade-clipboard.c | 23 | ||||
-rw-r--r-- | gladeui/glade-editor.c | 43 | ||||
-rw-r--r-- | gladeui/glade-inspector.c | 25 | ||||
-rw-r--r-- | gladeui/glade-palette.c | 75 | ||||
-rw-r--r-- | gladeui/glade-project.c | 114 | ||||
-rw-r--r-- | gladeui/glade-property.c | 111 | ||||
-rw-r--r-- | gladeui/glade-signal.c | 94 | ||||
-rw-r--r-- | gladeui/glade-widget-action.c | 55 | ||||
-rw-r--r-- | gladeui/glade-widget.c | 99 |
11 files changed, 359 insertions, 339 deletions
diff --git a/gladeui/glade-base-editor.c b/gladeui/glade-base-editor.c index af4d7674..578cbd09 100644 --- a/gladeui/glade-base-editor.c +++ b/gladeui/glade-base-editor.c @@ -110,9 +110,10 @@ enum { PROP_0, PROP_CONTAINER, + N_PROPERTIES }; - +static GParamSpec *properties[N_PROPERTIES]; static guint glade_base_editor_signals[LAST_SIGNAL] = { 0 }; static GtkVBoxClass *parent_class = NULL; @@ -1230,7 +1231,7 @@ glade_base_editor_set_container (GladeBaseEditor * editor, GObject * container) glade_signal_editor_load_widget (e->signal_editor, NULL); - g_object_notify (G_OBJECT (editor), "container"); + g_object_notify_by_pspec (G_OBJECT (editor), properties[PROP_CONTAINER]); return; } @@ -1257,7 +1258,7 @@ glade_base_editor_set_container (GladeBaseEditor * editor, GObject * container) g_signal_connect (e->project, "changed", G_CALLBACK (glade_base_editor_project_changed), editor); - g_object_notify (G_OBJECT (editor), "container"); + g_object_notify_by_pspec (G_OBJECT (editor), properties[PROP_CONTAINER]); } /*************************** GladeBaseEditor Class ****************************/ @@ -1474,12 +1475,15 @@ glade_base_editor_class_init (GladeBaseEditorClass * klass) klass->delete_child = glade_base_editor_delete_child_impl; klass->move_child = glade_base_editor_move_child; - g_object_class_install_property (object_class, PROP_CONTAINER, - g_param_spec_object - ("container", _("Container"), - _ - ("The container object this editor is currently editing"), - G_TYPE_OBJECT, G_PARAM_READWRITE)); + properties[PROP_CONTAINER] = + g_param_spec_object ("container", + _("Container"), + _("The container object this editor is currently editing"), + G_TYPE_OBJECT, + G_PARAM_READWRITE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); /** * GladeBaseEditor::child-selected: diff --git a/gladeui/glade-cell-renderer-icon.c b/gladeui/glade-cell-renderer-icon.c index 69947457..6ba93bbf 100644 --- a/gladeui/glade-cell-renderer-icon.c +++ b/gladeui/glade-cell-renderer-icon.c @@ -58,8 +58,10 @@ enum PROP_0, PROP_ACTIVATABLE, PROP_ACTIVE, + N_PROPERTIES }; +static GParamSpec *properties[N_PROPERTIES]; static guint icon_cell_signals[LAST_SIGNAL] = { 0 }; @@ -91,22 +93,21 @@ glade_cell_renderer_icon_class_init (GladeCellRendererIconClass * class) cell_class->activate = glade_cell_renderer_icon_activate; - g_object_class_install_property (object_class, - PROP_ACTIVE, - g_param_spec_boolean ("active", "Icon state", - "The icon state of the button", - FALSE, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - - g_object_class_install_property (object_class, - PROP_ACTIVATABLE, - g_param_spec_boolean ("activatable", - "Activatable", - "The icon button can be activated", - TRUE, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); + properties[PROP_ACTIVE] = + g_param_spec_boolean ("active", "Icon state", + "The icon state of the button", + FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE); + + properties[PROP_ACTIVATABLE] = + g_param_spec_boolean ("activatable", + "Activatable", + "The icon button can be activated", + TRUE, + G_PARAM_READABLE | G_PARAM_WRITABLE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); icon_cell_signals[ACTIVATE] = g_signal_new ("activate", @@ -206,7 +207,7 @@ glade_cell_renderer_icon_set_active (GladeCellRendererIcon * icon, if (icon->priv->active != setting) { icon->priv->active = setting ? TRUE : FALSE; - g_object_notify (G_OBJECT (icon), "active"); + g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_ACTIVE]); } } @@ -227,6 +228,6 @@ glade_cell_renderer_icon_set_activatable (GladeCellRendererIcon * icon, if (icon->priv->activatable != setting) { icon->priv->activatable = setting ? TRUE : FALSE; - g_object_notify (G_OBJECT (icon), "activatable"); + g_object_notify_by_pspec (G_OBJECT (icon), properties[PROP_ACTIVATABLE]); } } diff --git a/gladeui/glade-clipboard.c b/gladeui/glade-clipboard.c index 0363b38f..392f48df 100644 --- a/gladeui/glade-clipboard.c +++ b/gladeui/glade-clipboard.c @@ -49,9 +49,12 @@ struct _GladeClipboardPrivate enum { PROP_0, - PROP_HAS_SELECTION + PROP_HAS_SELECTION, + N_PROPERTIES }; +static GParamSpec *properties[N_PROPERTIES]; + G_DEFINE_TYPE (GladeClipboard, glade_clipboard, G_TYPE_OBJECT); static void @@ -80,13 +83,15 @@ glade_clipboard_class_init (GladeClipboardClass * klass) object_class->get_property = glade_project_get_property; - g_object_class_install_property (object_class, - PROP_HAS_SELECTION, - g_param_spec_boolean ("has-selection", - "Has Selection", - "Whether clipboard has a selection of items to paste", - FALSE, - G_PARAM_READABLE)); + properties[PROP_HAS_SELECTION] = + g_param_spec_boolean ("has-selection", + "Has Selection", + "Whether clipboard has a selection of items to paste", + FALSE, + G_PARAM_READABLE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); g_type_class_add_private (klass, sizeof (GladeClipboardPrivate)); } @@ -110,7 +115,7 @@ glade_clipboard_set_has_selection (GladeClipboard * clipboard, if (clipboard->priv->has_selection != has_selection) { clipboard->priv->has_selection = has_selection; - g_object_notify (G_OBJECT (clipboard), "has-selection"); + g_object_notify_by_pspec (G_OBJECT (clipboard), properties[PROP_HAS_SELECTION]); } } diff --git a/gladeui/glade-editor.c b/gladeui/glade-editor.c index 8cf4c903..6eedcf65 100644 --- a/gladeui/glade-editor.c +++ b/gladeui/glade-editor.c @@ -56,7 +56,8 @@ enum { PROP_0, PROP_SHOW_INFO, - PROP_WIDGET + PROP_WIDGET, + N_PROPERTIES }; static GtkVBoxClass *parent_class = NULL; @@ -134,6 +135,7 @@ struct _GladeEditorPrivate gboolean show_info; /* Whether or not to show an informational button */ }; +static GParamSpec *properties[N_PROPERTIES]; static void glade_editor_reset_dialog (GladeEditor * editor); @@ -210,20 +212,23 @@ glade_editor_class_init (GladeEditorClass * klass) object_class->get_property = glade_editor_get_property; /* Properties */ - g_object_class_install_property - (object_class, PROP_SHOW_INFO, - g_param_spec_boolean ("show-info", - _("Show info"), - _("Whether to show an informational " - "button for the loaded widget"), - FALSE, G_PARAM_READABLE)); - - g_object_class_install_property - (object_class, PROP_WIDGET, - g_param_spec_object ("widget", - _("Widget"), - _("The currently loaded widget in this editor"), - GLADE_TYPE_WIDGET, G_PARAM_READWRITE)); + properties[PROP_SHOW_INFO] = + g_param_spec_boolean ("show-info", + _("Show info"), + _("Whether to show an informational " + "button for the loaded widget"), + FALSE, + G_PARAM_READABLE); + + properties[PROP_WIDGET] = + g_param_spec_object ("widget", + _("Widget"), + _("The currently loaded widget in this editor"), + GLADE_TYPE_WIDGET, + G_PARAM_READWRITE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); g_type_class_add_private (klass, sizeof (GladeEditorPrivate)); } @@ -817,7 +822,7 @@ glade_editor_load_widget_real (GladeEditor * editor, GladeWidget * widget) /* Clear class header */ glade_editor_update_class_field (editor); - g_object_notify (G_OBJECT (editor), "widget"); + g_object_notify_by_pspec (G_OBJECT (editor), properties[PROP_WIDGET]); return; } @@ -858,7 +863,7 @@ glade_editor_load_widget_real (GladeEditor * editor, GladeWidget * widget) G_CALLBACK (glade_editor_update_widget_name_cb), editor); - g_object_notify (G_OBJECT (editor), "widget"); + g_object_notify_by_pspec (G_OBJECT (editor), properties[PROP_WIDGET]); } @@ -1394,7 +1399,7 @@ glade_editor_show_info (GladeEditor * editor) editor->priv->show_info = TRUE; gtk_widget_show (editor->priv->info_button); - g_object_notify (G_OBJECT (editor), "show-info"); + g_object_notify_by_pspec (G_OBJECT (editor), properties[PROP_SHOW_INFO]); } } @@ -1408,7 +1413,7 @@ glade_editor_hide_info (GladeEditor * editor) editor->priv->show_info = FALSE; gtk_widget_hide (editor->priv->info_button); - g_object_notify (G_OBJECT (editor), "show-info"); + g_object_notify_by_pspec (G_OBJECT (editor), properties[PROP_SHOW_INFO]); } } diff --git a/gladeui/glade-inspector.c b/gladeui/glade-inspector.c index b8eb8dab..922c1c1b 100644 --- a/gladeui/glade-inspector.c +++ b/gladeui/glade-inspector.c @@ -59,7 +59,8 @@ enum { PROP_0, - PROP_PROJECT + PROP_PROJECT, + N_PROPERTIES }; enum @@ -82,7 +83,7 @@ struct _GladeInspectorPrivate gboolean search_disabled; }; - +static GParamSpec *properties[N_PROPERTIES]; static guint glade_inspector_signals[LAST_SIGNAL] = { 0 }; @@ -174,15 +175,15 @@ glade_inspector_class_init (GladeInspectorClass * klass) G_STRUCT_OFFSET (GladeInspectorClass, item_activated), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_object_class_install_property (object_class, - PROP_PROJECT, - g_param_spec_object ("project", - _("Project"), - _ - ("The project being inspected"), - GLADE_TYPE_PROJECT, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); + properties[PROP_PROJECT] = + g_param_spec_object ("project", + _("Project"), + _("The project being inspected"), + GLADE_TYPE_PROJECT, + G_PARAM_READABLE | G_PARAM_WRITABLE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); g_type_class_add_private (klass, sizeof (GladeInspectorPrivate)); } @@ -832,7 +833,7 @@ glade_inspector_set_project (GladeInspector * inspector, GladeProject * project) update_project_completion (project, NULL, inspector); - g_object_notify (G_OBJECT (inspector), "project"); + g_object_notify_by_pspec (G_OBJECT (inspector), properties[PROP_PROJECT]); } /** diff --git a/gladeui/glade-palette.c b/gladeui/glade-palette.c index e9396fe1..2c13f017 100644 --- a/gladeui/glade-palette.c +++ b/gladeui/glade-palette.c @@ -83,9 +83,11 @@ enum PROP_ITEM_APPEARANCE, PROP_USE_SMALL_ITEM_ICONS, PROP_SHOW_SELECTOR_BUTTON, - PROP_PROJECT + PROP_PROJECT, + N_PROPERTIES }; +static GParamSpec *properties[N_PROPERTIES]; static guint glade_palette_signals[LAST_SIGNAL] = { 0 }; static void glade_palette_append_item_group (GladePalette *palette, @@ -589,38 +591,37 @@ glade_palette_class_init (GladePaletteClass * klass) G_STRUCT_OFFSET (GladePaletteClass, refresh), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_object_class_install_property (object_class, - PROP_PROJECT, - g_param_spec_object ("project", - "Project", - "This palette's current project", - GLADE_TYPE_PROJECT, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_ITEM_APPEARANCE, - g_param_spec_enum ("item-appearance", - "Item Appearance", - "The appearance of the palette items", - GLADE_TYPE_ITEM_APPEARANCE, - GLADE_ITEM_ICON_ONLY, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_ITEM_APPEARANCE, - g_param_spec_boolean ("use-small-item-icons", - "Use Small Item Icons", - "Whether to use small icons to represent items", - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_ITEM_APPEARANCE, - g_param_spec_boolean ("show-selector-button", - "Show Selector Button", - "Whether to show the internal selector button", - TRUE, - G_PARAM_READWRITE)); + properties[PROP_PROJECT] = + g_param_spec_object ("project", + "Project", + "This palette's current project", + GLADE_TYPE_PROJECT, + G_PARAM_READWRITE); + + properties[PROP_ITEM_APPEARANCE] = + g_param_spec_enum ("item-appearance", + "Item Appearance", + "The appearance of the palette items", + GLADE_TYPE_ITEM_APPEARANCE, + GLADE_ITEM_ICON_ONLY, + G_PARAM_READWRITE); + + properties[PROP_USE_SMALL_ITEM_ICONS] = + g_param_spec_boolean ("use-small-item-icons", + "Use Small Item Icons", + "Whether to use small icons to represent items", + FALSE, + G_PARAM_READWRITE); + + properties[PROP_SHOW_SELECTOR_BUTTON] = + g_param_spec_boolean ("show-selector-button", + "Show Selector Button", + "Whether to show the internal selector button", + TRUE, + G_PARAM_READWRITE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); g_type_class_add_private (object_class, sizeof (GladePalettePrivate)); } @@ -745,7 +746,7 @@ glade_palette_set_project (GladePalette *palette, glade_palette_refresh (palette); - g_object_notify (G_OBJECT (palette), "project"); + g_object_notify_by_pspec (G_OBJECT (palette), properties[PROP_PROJECT]); } } @@ -772,7 +773,7 @@ glade_palette_set_item_appearance (GladePalette * palette, glade_palette_update_appearance (palette); - g_object_notify (G_OBJECT (palette), "item-appearance"); + g_object_notify_by_pspec (G_OBJECT (palette), properties[PROP_ITEM_APPEARANCE]); } } @@ -797,7 +798,7 @@ glade_palette_set_use_small_item_icons (GladePalette * palette, glade_palette_update_appearance (palette); - g_object_notify (G_OBJECT (palette), "use-small-item-icons"); + g_object_notify_by_pspec (G_OBJECT (palette), properties[PROP_USE_SMALL_ITEM_ICONS]); } @@ -825,7 +826,7 @@ glade_palette_set_show_selector_button (GladePalette * palette, else gtk_widget_hide (priv->selector_hbox); - g_object_notify (G_OBJECT (palette), "show-selector-button"); + g_object_notify_by_pspec (G_OBJECT (palette), properties[PROP_SHOW_SELECTOR_BUTTON]); } diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c index 8f7fd3e3..24d133bc 100644 --- a/gladeui/glade-project.c +++ b/gladeui/glade-project.c @@ -78,9 +78,12 @@ enum PROP_PATH, PROP_READ_ONLY, PROP_ADD_ITEM, - PROP_POINTER_MODE + PROP_POINTER_MODE, + N_PROPERTIES }; +static GParamSpec *properties[N_PROPERTIES]; + struct _GladeProjectPrivate { gchar *path; /* The full canonical path of the glade file for this project */ @@ -416,7 +419,7 @@ glade_project_set_modified (GladeProject *project, gboolean modified) priv->first_modification_is_na = FALSE; } - g_object_notify (G_OBJECT (project), "modified"); + g_object_notify_by_pspec (G_OBJECT (project), properties[PROP_MODIFIED]); } } @@ -445,7 +448,7 @@ glade_project_set_pointer_mode (GladeProject *project, GladePointerMode mode) { project->priv->pointer_mode = mode; - g_object_notify (G_OBJECT (project), "pointer-mode"); + g_object_notify_by_pspec (G_OBJECT (project), properties[PROP_POINTER_MODE]); } } @@ -471,7 +474,7 @@ glade_project_set_add_item (GladeProject *project, GladeWidgetAdaptor *adaptor) { priv->add_item = adaptor; - g_object_notify (G_OBJECT (project), "add-item"); + g_object_notify_by_pspec (G_OBJECT (project), properties[PROP_ADD_ITEM]); } } @@ -946,55 +949,52 @@ glade_project_class_init (GladeProjectClass *klass) 0, NULL, NULL, _glade_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2, GLADE_TYPE_WIDGET, G_TYPE_BOOLEAN); - - g_object_class_install_property (object_class, - PROP_MODIFIED, - g_param_spec_boolean ("modified", - "Modified", - _("Whether project has been modified since it was last saved"), - FALSE, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_HAS_SELECTION, - g_param_spec_boolean ("has-selection", - _("Has Selection"), - _("Whether project has a selection"), - FALSE, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_PATH, - g_param_spec_string ("path", - _("Path"), - _("The filesystem path of the project"), - NULL, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_READ_ONLY, - g_param_spec_boolean ("read-only", - _("Read Only"), - _("Whether project is read-only"), - FALSE, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_ADD_ITEM, - g_param_spec_object ("add-item", - _("Add Item"), - _("The current item to add to the project"), - GLADE_TYPE_WIDGET_ADAPTOR, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_POINTER_MODE, - g_param_spec_enum ("pointer-mode", - _("Pointer Mode"), - _("The currently effective GladePointerMode"), - GLADE_TYPE_POINTER_MODE, - GLADE_POINTER_SELECT, - G_PARAM_READABLE)); + + properties[PROP_MODIFIED] = + g_param_spec_boolean ("modified", + "Modified", + _("Whether project has been modified since it was last saved"), + FALSE, + G_PARAM_READABLE); + + properties[PROP_HAS_SELECTION] = + g_param_spec_boolean ("has-selection", + _("Has Selection"), + _("Whether project has a selection"), + FALSE, + G_PARAM_READABLE); + + properties[PROP_PATH] = + g_param_spec_string ("path", + _("Path"), + _("The filesystem path of the project"), + NULL, + G_PARAM_READABLE); + + properties[PROP_READ_ONLY] = + g_param_spec_boolean ("read-only", + _("Read Only"), + _("Whether project is read-only"), + FALSE, + G_PARAM_READABLE); + + properties[PROP_ADD_ITEM] = + g_param_spec_object ("add-item", + _("Add Item"), + _("The current item to add to the project"), + GLADE_TYPE_WIDGET_ADAPTOR, + G_PARAM_READABLE); + + properties[PROP_POINTER_MODE] = + g_param_spec_enum ("pointer-mode", + _("Pointer Mode"), + _("The currently effective GladePointerMode"), + GLADE_TYPE_POINTER_MODE, + GLADE_POINTER_SELECT, + G_PARAM_READABLE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); g_type_class_add_private (klass, sizeof (GladeProjectPrivate)); } @@ -1553,7 +1553,7 @@ glade_project_load_from_file (GladeProject *project, const gchar *path) g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE); project->priv->path = glade_util_canonical_path (path); - g_object_notify (G_OBJECT (project), "path"); + g_object_notify_by_pspec (G_OBJECT (project), properties[PROP_PATH]); retval = glade_project_load_internal (project); @@ -1833,7 +1833,7 @@ glade_project_save (GladeProject *project, const gchar *path, GError **error) project->priv->path = (g_free (project->priv->path), g_strdup (canonical_path)); - g_object_notify (G_OBJECT (project), "path"); + g_object_notify_by_pspec (G_OBJECT (project), properties[PROP_PATH]); /* Update prefs dialogs here... */ name = glade_project_get_name (project); @@ -2929,7 +2929,7 @@ glade_project_set_readonly (GladeProject *project, gboolean readonly) if (project->priv->readonly != readonly) { project->priv->readonly = readonly; - g_object_notify (G_OBJECT (project), "read-only"); + g_object_notify_by_pspec (G_OBJECT (project), properties[PROP_READ_ONLY]); } } @@ -3023,7 +3023,7 @@ glade_project_set_has_selection (GladeProject *project, gboolean has_selection) if (project->priv->has_selection != has_selection) { project->priv->has_selection = has_selection; - g_object_notify (G_OBJECT (project), "has-selection"); + g_object_notify_by_pspec (G_OBJECT (project), properties[PROP_HAS_SELECTION]); } } diff --git a/gladeui/glade-property.c b/gladeui/glade-property.c index 25ecb2cc..2380697d 100644 --- a/gladeui/glade-property.c +++ b/gladeui/glade-property.c @@ -129,9 +129,11 @@ enum PROP_I18N_TRANSLATABLE, PROP_I18N_CONTEXT, PROP_I18N_COMMENT, - PROP_STATE + PROP_STATE, + N_PROPERTIES }; +static GParamSpec *properties[N_PROPERTIES]; static guint glade_property_signals[LAST_SIGNAL] = { 0 }; static GObjectClass *parent_class = NULL; @@ -281,7 +283,7 @@ glade_property_fix_state (GladeProperty * property) if (property->priv->support_disabled) property->priv->state |= GLADE_STATE_SUPPORT_DISABLED; - g_object_notify (G_OBJECT (property), "state"); + g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_STATE]); } @@ -620,51 +622,56 @@ glade_property_klass_init (GladePropertyKlass * prop_class) prop_class->tooltip_changed = NULL; /* Properties */ - g_object_class_install_property - (object_class, PROP_CLASS, - g_param_spec_pointer - ("class", _("Class"), - _("The GladePropertyClass for this property"), - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); - - g_object_class_install_property - (object_class, PROP_ENABLED, - g_param_spec_boolean - ("enabled", _("Enabled"), - _("If the property is optional, this is its enabled state"), - TRUE, G_PARAM_READWRITE)); - - g_object_class_install_property - (object_class, PROP_SENSITIVE, - g_param_spec_boolean - ("sensitive", _("Sensitive"), - _("This gives backends control to set property sensitivity"), - TRUE, G_PARAM_READWRITE)); - - g_object_class_install_property - (object_class, PROP_I18N_CONTEXT, - g_param_spec_string - ("i18n-context", _("Context"), - _("Context for translation"), NULL, G_PARAM_READWRITE)); - - g_object_class_install_property - (object_class, PROP_I18N_COMMENT, - g_param_spec_string - ("i18n-comment", _("Comment"), - _("Comment for translators"), NULL, G_PARAM_READWRITE)); - - g_object_class_install_property - (object_class, PROP_I18N_TRANSLATABLE, - g_param_spec_boolean - ("i18n-translatable", _("Translatable"), - _("Whether this property is translatable"), TRUE, G_PARAM_READWRITE)); - - g_object_class_install_property - (object_class, PROP_STATE, - g_param_spec_int - ("state", _("Visual State"), - _("Priority information for the property editor to act on"), - GLADE_STATE_NORMAL, G_MAXINT, GLADE_STATE_NORMAL, G_PARAM_READABLE)); + properties[PROP_CLASS] = + g_param_spec_pointer ("class", + _("Class"), + _("The GladePropertyClass for this property"), + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + + properties[PROP_ENABLED] = + g_param_spec_boolean ("enabled", + _("Enabled"), + _("If the property is optional, this is its enabled state"), + TRUE, G_PARAM_READWRITE); + + properties[PROP_SENSITIVE] = + g_param_spec_boolean ("sensitive", + _("Sensitive"), + _("This gives backends control to set property sensitivity"), + TRUE, G_PARAM_READWRITE); + + properties[PROP_I18N_CONTEXT] = + g_param_spec_string ("i18n-context", + _("Context"), + _("Context for translation"), + NULL, + G_PARAM_READWRITE); + + properties[PROP_I18N_COMMENT] = + g_param_spec_string ("i18n-comment", + _("Comment"), + _("Comment for translators"), + NULL, + G_PARAM_READWRITE); + + properties[PROP_I18N_TRANSLATABLE] = + g_param_spec_boolean ("i18n-translatable", + _("Translatable"), + _("Whether this property is translatable"), + TRUE, + G_PARAM_READWRITE); + + properties[PROP_STATE] = + g_param_spec_int ("state", + _("Visual State"), + _("Priority information for the property editor to act on"), + GLADE_STATE_NORMAL, + G_MAXINT, + GLADE_STATE_NORMAL, + G_PARAM_READABLE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); /* Signal */ glade_property_signals[VALUE_CHANGED] = @@ -1333,7 +1340,7 @@ glade_property_i18n_set_comment (GladeProperty * property, const gchar * str) g_free (property->priv->i18n_comment); property->priv->i18n_comment = g_strdup (str); - g_object_notify (G_OBJECT (property), "i18n-comment"); + g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_I18N_COMMENT]); } G_CONST_RETURN gchar * @@ -1351,7 +1358,7 @@ glade_property_i18n_set_context (GladeProperty * property, const gchar * str) g_free (property->priv->i18n_context); property->priv->i18n_context = g_strdup (str); - g_object_notify (G_OBJECT (property), "i18n-context"); + g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_I18N_CONTEXT]); } G_CONST_RETURN gchar * @@ -1367,7 +1374,7 @@ glade_property_i18n_set_translatable (GladeProperty * property, { g_return_if_fail (GLADE_IS_PROPERTY (property)); property->priv->i18n_translatable = translatable; - g_object_notify (G_OBJECT (property), "i18n-translatable"); + g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_I18N_TRANSLATABLE]); } gboolean @@ -1407,7 +1414,7 @@ glade_property_set_sensitive (GladeProperty * property, property->priv->insensitive_tooltip, property->priv->support_warning); } - g_object_notify (G_OBJECT (property), "sensitive"); + g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_SENSITIVE]); } G_CONST_RETURN gchar * @@ -1501,7 +1508,7 @@ glade_property_set_enabled (GladeProperty * property, gboolean enabled) glade_property_fix_state (property); - g_object_notify (G_OBJECT (property), "enabled"); + g_object_notify_by_pspec (G_OBJECT (property), properties[PROP_ENABLED]); } gboolean diff --git a/gladeui/glade-signal.c b/gladeui/glade-signal.c index 031e4c04..1b2c5d5f 100644 --- a/gladeui/glade-signal.c +++ b/gladeui/glade-signal.c @@ -47,11 +47,14 @@ enum { PROP_CLASS, PROP_HANDLER, PROP_USERDATA, - PROP_SUPPORT, + PROP_SUPPORT_WARNING, PROP_AFTER, - PROP_SWAPPED + PROP_SWAPPED, + N_PROPERTIES }; +static GParamSpec *properties[N_PROPERTIES]; + static GObjectClass *parent_class; static void @@ -84,7 +87,7 @@ glade_signal_get_property (GObject * object, case PROP_USERDATA: g_value_set_string (value, signal->priv->userdata); break; - case PROP_SUPPORT: + case PROP_SUPPORT_WARNING: g_value_set_string (value, signal->priv->support_warning); break; case PROP_AFTER: @@ -117,7 +120,7 @@ glade_signal_set_property (GObject * object, case PROP_USERDATA: glade_signal_set_userdata (signal, g_value_get_string (value)); break; - case PROP_SUPPORT: + case PROP_SUPPORT_WARNING: glade_signal_set_support_warning (signal, g_value_get_string (value)); break; case PROP_AFTER: @@ -153,41 +156,44 @@ glade_signal_klass_init (GladeSignalKlass *klass) object_class->finalize = glade_signal_finalize; /* Properties */ - g_object_class_install_property (object_class, PROP_CLASS, - g_param_spec_pointer - ("class", _("SignalClass"), - _("The signal class of this signal"), - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_HANDLER, - g_param_spec_string - ("handler", _("Handler"), - _("The handler for this signal"), - NULL, G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_USERDATA, - g_param_spec_string - ("userdata", _("User Data"), - _("The user data for this signal"), - NULL, G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_SUPPORT, - g_param_spec_string - ("support-warning", _("Support Warning"), - _("The versioning support warning for this signal"), - NULL, G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_AFTER, - g_param_spec_boolean - ("after", _("After"), - _("Whether this signal is run after default handlers"), - FALSE, G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_SWAPPED, - g_param_spec_boolean - ("swapped", _("Swapped"), - _("Whether the user data is swapped with the instance for the handler"), - FALSE, G_PARAM_READWRITE)); + properties[PROP_CLASS] = + g_param_spec_pointer ("class", + _("SignalClass"), + _("The signal class of this signal"), + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + + properties[PROP_HANDLER] = + g_param_spec_string ("handler", + _("Handler"), + _("The handler for this signal"), + NULL, G_PARAM_READWRITE); + + properties[PROP_USERDATA] = + g_param_spec_string ("userdata", + _("User Data"), + _("The user data for this signal"), + NULL, G_PARAM_READWRITE); + + properties[PROP_SUPPORT_WARNING] = + g_param_spec_string ("support-warning", + _("Support Warning"), + _("The versioning support warning for this signal"), + NULL, G_PARAM_READWRITE); + + properties[PROP_AFTER] = + g_param_spec_boolean ("after", + _("After"), + _("Whether this signal is run after default handlers"), + FALSE, G_PARAM_READWRITE); + + properties[PROP_SWAPPED] = + g_param_spec_boolean ("swapped", + _("Swapped"), + _("Whether the user data is swapped with the instance for the handler"), + FALSE, G_PARAM_READWRITE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); g_type_class_add_private (klass, sizeof (GladeSignalPrivate)); } @@ -436,7 +442,7 @@ glade_signal_set_handler (GladeSignal *signal, signal->priv->handler = handler ? g_strdup (handler) : NULL; - g_object_notify (G_OBJECT (signal), "handler"); + g_object_notify_by_pspec (G_OBJECT (signal), properties[PROP_HANDLER]); } } @@ -460,7 +466,7 @@ glade_signal_set_userdata (GladeSignal *signal, signal->priv->userdata = userdata ? g_strdup (userdata) : NULL; - g_object_notify (G_OBJECT (signal), "userdata"); + g_object_notify_by_pspec (G_OBJECT (signal), properties[PROP_USERDATA]); } } @@ -482,7 +488,7 @@ glade_signal_set_after (GladeSignal *signal, { signal->priv->after = after; - g_object_notify (G_OBJECT (signal), "after"); + g_object_notify_by_pspec (G_OBJECT (signal), properties[PROP_AFTER]); } } @@ -504,7 +510,7 @@ glade_signal_set_swapped (GladeSignal *signal, { signal->priv->swapped = swapped; - g_object_notify (G_OBJECT (signal), "swapped"); + g_object_notify_by_pspec (G_OBJECT (signal), properties[PROP_SWAPPED]); } } @@ -528,7 +534,7 @@ glade_signal_set_support_warning (GladeSignal *signal, signal->priv->support_warning = support_warning ? g_strdup (support_warning) : NULL; - g_object_notify (G_OBJECT (signal), "support-warning"); + g_object_notify_by_pspec (G_OBJECT (signal), properties[PROP_SUPPORT_WARNING]); } } diff --git a/gladeui/glade-widget-action.c b/gladeui/glade-widget-action.c index 5ed1a0ea..9961b537 100644 --- a/gladeui/glade-widget-action.c +++ b/gladeui/glade-widget-action.c @@ -39,7 +39,8 @@ enum PROP_CLASS, PROP_SENSITIVE, - PROP_VISIBLE + PROP_VISIBLE, + N_PROPERTIES }; struct _GladeWidgetActionPrivate @@ -50,6 +51,8 @@ struct _GladeWidgetActionPrivate guint visible : 1; /* If this action is visible or not */ }; +static GParamSpec *properties[N_PROPERTIES]; + G_DEFINE_TYPE (GladeWidgetAction, glade_widget_action, G_TYPE_OBJECT); static void @@ -176,30 +179,28 @@ glade_widget_action_class_init (GladeWidgetActionClass * klass) object_class->set_property = glade_widget_action_set_property; object_class->get_property = glade_widget_action_get_property; - g_object_class_install_property (object_class, - PROP_CLASS, - g_param_spec_pointer ("class", - _("class"), - _ - ("GladeWidgetActionClass structure pointer"), - G_PARAM_CONSTRUCT_ONLY - | G_PARAM_WRITABLE)); - - g_object_class_install_property (object_class, - PROP_SENSITIVE, - g_param_spec_boolean ("sensitive", - _("Sensitive"), - _("Whether this action is sensitive"), - TRUE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_VISIBLE, - g_param_spec_boolean ("visible", - _("Visible"), - _("Whether this action is visible"), - TRUE, - G_PARAM_READWRITE)); + properties[PROP_CLASS] = + g_param_spec_pointer ("class", + _("class"), + _("GladeWidgetActionClass structure pointer"), + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE); + + properties[PROP_SENSITIVE] = + g_param_spec_boolean ("sensitive", + _("Sensitive"), + _("Whether this action is sensitive"), + TRUE, + G_PARAM_READWRITE); + + properties[PROP_VISIBLE] = + g_param_spec_boolean ("visible", + _("Visible"), + _("Whether this action is visible"), + TRUE, + G_PARAM_READWRITE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); g_type_class_add_private (klass, sizeof (GladeWidgetActionPrivate)); } @@ -219,7 +220,7 @@ glade_widget_action_set_sensitive (GladeWidgetAction * action, g_return_if_fail (GLADE_IS_WIDGET_ACTION (action)); action->priv->sensitive = sensitive; - g_object_notify (G_OBJECT (action), "sensitive"); + g_object_notify_by_pspec (G_OBJECT (action), properties[PROP_SENSITIVE]); } gboolean @@ -237,7 +238,7 @@ glade_widget_action_set_visible (GladeWidgetAction *action, g_return_if_fail (GLADE_IS_WIDGET_ACTION (action)); action->priv->visible = visible; - g_object_notify (G_OBJECT (action), "visible"); + g_object_notify_by_pspec (G_OBJECT (action), properties[PROP_VISIBLE]); } gboolean diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c index 30bfe1b8..7d906a5b 100644 --- a/gladeui/glade-widget.c +++ b/gladeui/glade-widget.c @@ -191,9 +191,11 @@ enum PROP_TOPLEVEL_WIDTH, PROP_TOPLEVEL_HEIGHT, PROP_SUPPORT_WARNING, - PROP_VISIBLE + PROP_VISIBLE, + N_PROPERTIES }; +static GParamSpec *properties[N_PROPERTIES]; static guint glade_widget_signals[LAST_SIGNAL] = { 0 }; static GQuark glade_widget_name_quark = 0; @@ -1202,115 +1204,102 @@ glade_widget_class_init (GladeWidgetClass * klass) klass->button_release_event = NULL; klass->motion_notify_event = NULL; - g_object_class_install_property - (object_class, PROP_NAME, + properties[PROP_NAME] = g_param_spec_string ("name", _("Name"), _("The name of the widget"), - NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT); - g_object_class_install_property - (object_class, PROP_INTERNAL, + properties[PROP_INTERNAL] = g_param_spec_string ("internal", _("Internal name"), _("The internal name of the widget"), - NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT); - g_object_class_install_property - (object_class, PROP_ANARCHIST, + properties[PROP_ANARCHIST] = g_param_spec_boolean ("anarchist", _("Anarchist"), _("Whether this composite child is " "an ancestral child or an anarchist child"), FALSE, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property - (object_class, PROP_OBJECT, + properties[PROP_OBJECT] = g_param_spec_object ("object", _("Object"), _("The object associated"), G_TYPE_OBJECT, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); - g_object_class_install_property - (object_class, PROP_ADAPTOR, + properties[PROP_ADAPTOR] = g_param_spec_object ("adaptor", _("Adaptor"), _("The class adaptor for the associated widget"), GLADE_TYPE_WIDGET_ADAPTOR, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property - (object_class, PROP_PROJECT, + properties[PROP_PROJECT] = g_param_spec_object ("project", _("Project"), _("The glade project that " "this widget belongs to"), GLADE_TYPE_PROJECT, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); - g_object_class_install_property - (object_class, PROP_PROPERTIES, + properties[PROP_PROPERTIES] = g_param_spec_pointer ("properties", _("Properties"), _("A list of GladeProperties"), - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property - (object_class, PROP_PARENT, + properties[PROP_PARENT] = g_param_spec_object ("parent", _("Parent"), _("A pointer to the parenting GladeWidget"), GLADE_TYPE_WIDGET, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); - g_object_class_install_property - (object_class, PROP_INTERNAL_NAME, + properties[PROP_INTERNAL_NAME] = g_param_spec_string ("internal-name", _("Internal Name"), _("A generic name prefix for internal widgets"), - NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE)); + NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE); - g_object_class_install_property - (object_class, PROP_TEMPLATE, + properties[PROP_TEMPLATE] = g_param_spec_object ("template", _("Template"), _("A GladeWidget template to base a new widget on"), GLADE_TYPE_WIDGET, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE)); + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE); - g_object_class_install_property - (object_class, PROP_TEMPLATE_EXACT, + properties[PROP_TEMPLATE_EXACT] = g_param_spec_boolean ("template-exact", _("Exact Template"), _ ("Whether we are creating an exact duplicate when using a template"), - FALSE, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + FALSE, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property - (object_class, PROP_REASON, + properties[PROP_REASON] = g_param_spec_int ("reason", _("Reason"), _("A GladeCreateReason for this creation"), GLADE_CREATE_USER, GLADE_CREATE_REASONS - 1, GLADE_CREATE_USER, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE)); + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE); - g_object_class_install_property - (object_class, PROP_TOPLEVEL_WIDTH, + properties[PROP_TOPLEVEL_WIDTH] = g_param_spec_int ("toplevel-width", _("Toplevel Width"), _("The width of the widget when toplevel in " "the GladeDesignLayout"), - -1, G_MAXINT, -1, G_PARAM_READWRITE)); + -1, G_MAXINT, -1, G_PARAM_READWRITE); - g_object_class_install_property - (object_class, PROP_TOPLEVEL_HEIGHT, + properties[PROP_TOPLEVEL_HEIGHT] = g_param_spec_int ("toplevel-height", _("Toplevel Height"), _("The height of the widget when toplevel in " "the GladeDesignLayout"), - -1, G_MAXINT, -1, G_PARAM_READWRITE)); + -1, G_MAXINT, -1, G_PARAM_READWRITE); - g_object_class_install_property - (object_class, PROP_SUPPORT_WARNING, + properties[PROP_SUPPORT_WARNING] = g_param_spec_string ("support warning", _("Support Warning"), _("A warning string about version mismatches"), - NULL, G_PARAM_READABLE)); + NULL, G_PARAM_READABLE); - g_object_class_install_property - (object_class, PROP_VISIBLE, + properties[PROP_VISIBLE] = g_param_spec_boolean ("visible", _("Visible"), _("Wether the widget is visible or not"), - FALSE, G_PARAM_READABLE)); + FALSE, G_PARAM_READABLE); + + /* Install all properties */ + g_object_class_install_properties (object_class, N_PROPERTIES, properties); /** * GladeWidget::add-signal-handler: @@ -2564,7 +2553,7 @@ glade_widget_set_name (GladeWidget * widget, const gchar * name) g_free (widget->priv->name); widget->priv->name = g_strdup (name); - g_object_notify (G_OBJECT (widget), "name"); + g_object_notify_by_pspec (G_OBJECT (widget), properties[PROP_NAME]); } } @@ -2596,7 +2585,7 @@ glade_widget_set_internal (GladeWidget * widget, const gchar * internal) { g_free (widget->priv->internal); widget->priv->internal = g_strdup (internal); - g_object_notify (G_OBJECT (widget), "internal"); + g_object_notify_by_pspec (G_OBJECT (widget), properties[PROP_INTERNAL]); } } @@ -2639,7 +2628,7 @@ glade_widget_set_project (GladeWidget * widget, GladeProject * project) if (widget->priv->project != project) { widget->priv->project = project; - g_object_notify (G_OBJECT (widget), "project"); + g_object_notify_by_pspec (G_OBJECT (widget), properties[PROP_PROJECT]); } } @@ -3407,7 +3396,7 @@ glade_widget_set_object (GladeWidget * gwidget, GObject * new_object, } } - g_object_notify (G_OBJECT (gwidget), "object"); + g_object_notify_by_pspec (G_OBJECT (gwidget), properties[PROP_OBJECT]); } /** @@ -3470,7 +3459,7 @@ glade_widget_set_parent (GladeWidget * widget, GladeWidget * parent) if (parent) glade_widget_set_packing_actions (widget, parent); - g_object_notify (G_OBJECT (widget), "parent"); + g_object_notify_by_pspec (G_OBJECT (widget), properties[PROP_PARENT]); } /** @@ -4325,7 +4314,7 @@ glade_widget_set_support_warning (GladeWidget * widget, const gchar * warning) g_free (widget->priv->support_warning); widget->priv->support_warning = g_strdup (warning); - g_object_notify (G_OBJECT (widget), "support-warning"); + g_object_notify_by_pspec (G_OBJECT (widget), properties[PROP_SUPPORT_WARNING]); } G_CONST_RETURN gchar * |