diff options
Diffstat (limited to 'gladeui')
-rw-r--r-- | gladeui/glade-project-properties.c | 48 | ||||
-rw-r--r-- | gladeui/glade-project-properties.ui | 164 | ||||
-rw-r--r-- | gladeui/glade-project.c | 74 | ||||
-rw-r--r-- | gladeui/glade-project.h | 4 | ||||
-rw-r--r-- | gladeui/glade-widget.c | 10 |
5 files changed, 203 insertions, 97 deletions
diff --git a/gladeui/glade-project-properties.c b/gladeui/glade-project-properties.c index f517591f..1736a859 100644 --- a/gladeui/glade-project-properties.c +++ b/gladeui/glade-project-properties.c @@ -68,6 +68,8 @@ static void on_css_filechooser_file_set (GtkFileChooserButton *w GladeProjectProperties *properties); static void on_css_checkbutton_toggled (GtkWidget *widget, GladeProjectProperties *properties); +static void on_use_generic_name_checkbutton_toggled (GtkWidget *widget, + GladeProjectProperties *properties); static void on_license_comboboxtext_changed (GtkComboBox *widget, GladeProjectProperties *properties); @@ -91,6 +93,9 @@ static void project_license_changed (GladeProject *p static void project_css_provider_path_changed (GladeProject *project, GParamSpec *pspec, GladeProjectProperties *properties); +static void project_use_generic_name_changed (GladeProject *project, + GParamSpec *pspec, + GladeProjectProperties *properties); struct _GladeProjectPropertiesPrivate { @@ -112,7 +117,9 @@ struct _GladeProjectPropertiesPrivate GtkWidget *css_filechooser; GtkWidget *css_checkbutton; - + + GtkWidget *use_generic_name_checkbutton; + GHashTable *target_radios; /* License */ @@ -187,6 +194,7 @@ glade_project_properties_class_init (GladeProjectPropertiesClass *klass) gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, toolkit_box); gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, css_filechooser); gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, css_checkbutton); + gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, use_generic_name_checkbutton); gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, license_comboboxtext); gtk_widget_class_bind_template_child_private (widget_class, GladeProjectProperties, license_textview); @@ -213,6 +221,7 @@ glade_project_properties_class_init (GladeProjectPropertiesClass *klass) gtk_widget_class_bind_template_callback (widget_class, on_glade_project_properties_hide); gtk_widget_class_bind_template_callback (widget_class, on_css_filechooser_file_set); gtk_widget_class_bind_template_callback (widget_class, on_css_checkbutton_toggled); + gtk_widget_class_bind_template_callback (widget_class, on_use_generic_name_checkbutton_toggled); gtk_widget_class_bind_template_callback (widget_class, on_license_comboboxtext_changed); gtk_widget_class_bind_template_callback (widget_class, on_license_data_changed); } @@ -372,7 +381,9 @@ glade_project_properties_set_project (GladeProjectProperties *properties, g_signal_connect (priv->project, "notify::translation-domain", G_CALLBACK (project_domain_changed), properties); g_signal_connect (priv->project, "notify::css-provider-path", - G_CALLBACK (project_css_provider_path_changed), properties); + G_CALLBACK (project_css_provider_path_changed), properties); + g_signal_connect (priv->project, "notify::use-generic-name", + G_CALLBACK (project_use_generic_name_changed), properties); g_signal_connect (priv->project, "targets-changed", G_CALLBACK (project_targets_changed), properties); g_signal_connect (priv->project, "notify::license", @@ -384,6 +395,7 @@ glade_project_properties_set_project (GladeProjectProperties *properties, project_template_changed (project, NULL, properties); project_domain_changed (project, NULL, properties); project_css_provider_path_changed (project, NULL, properties); + project_use_generic_name_changed (project, NULL, properties); } static void @@ -950,6 +962,25 @@ on_css_checkbutton_toggled (GtkWidget *widget, GladeProjectProperties *propertie } static void +on_use_generic_name_checkbutton_toggled (GtkWidget *widget, GladeProjectProperties *properties) +{ + GladeProjectPropertiesPrivate *priv = properties->priv; + gboolean active; + + if (priv->ignore_ui_cb) + return; + + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + + glade_project_set_use_generic_name (priv->project, active); + + /* TODO: assign names to nameless objects if needed and warn the user + * that once you asign names and save/reload the project + * there is no way to undo the changes! + */ +} + +static void on_css_filechooser_file_set (GtkFileChooserButton *widget, GladeProjectProperties *properties) { @@ -1137,6 +1168,19 @@ project_css_provider_path_changed (GladeProject *project, priv->ignore_ui_cb = FALSE; } +static void +project_use_generic_name_changed (GladeProject *project, + GParamSpec *pspec, + GladeProjectProperties *properties) +{ + GladeProjectPropertiesPrivate *priv = properties->priv; +g_message("%s ", __func__); + priv->ignore_ui_cb = TRUE; + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->use_generic_name_checkbutton), + glade_project_get_use_generic_name (project)); + priv->ignore_ui_cb = FALSE; +} + /* Private API */ void diff --git a/gladeui/glade-project-properties.ui b/gladeui/glade-project-properties.ui index 8c4c6c30..f45cb3cf 100644 --- a/gladeui/glade-project-properties.ui +++ b/gladeui/glade-project-properties.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.0 +<!-- Generated with glade 3.20.0 libgladeui - Glade UI Designer core library Copyright (C) 2013 Tristan Van Berkom <tvb@gnome.org> @@ -25,7 +25,7 @@ Authors: --> <interface domain="glade"> - <!-- interface-requires gtk+ 3.10 --> + <requires lib="gtk+" version="3.20"/> <!-- interface-license-type lgplv2 --> <!-- interface-name libgladeui --> <!-- interface-description Glade UI Designer core library --> @@ -60,6 +60,50 @@ Authors: <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">4</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="verify_button"> + <property name="label">_Verify</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="tooltip_text" translatable="yes">Verify that the project does not use any properties, +signals or widgets which are not available in the target version</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="verify_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + <property name="secondary">True</property> + </packing> + </child> + <child> + <object class="GtkButton" id="close_button"> + <property name="label">gtk-close</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">6</property> + </packing> + </child> <child> <object class="GtkNotebook" id="notebook"> <property name="visible">True</property> @@ -90,14 +134,12 @@ Authors: <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Translation domain:</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -111,8 +153,6 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -138,8 +178,6 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -155,8 +193,6 @@ Authors: <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -170,8 +206,6 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -187,8 +221,22 @@ Authors: <packing> <property name="left_attach">0</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="use_generic_name_checkbutton"> + <property name="label" translatable="yes">Use generic names</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_use_generic_name_checkbutton_toggled" swapped="no"/> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + <property name="width">2</property> </packing> </child> </object> @@ -232,7 +280,6 @@ Authors: <property name="left_attach">0</property> <property name="top_attach">0</property> <property name="width">2</property> - <property name="height">1</property> </packing> </child> <child> @@ -250,8 +297,6 @@ Authors: <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -269,8 +314,6 @@ Authors: <packing> <property name="left_attach">0</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -285,8 +328,6 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -301,8 +342,6 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -395,28 +434,24 @@ Authors: <object class="GtkLabel" id="label7"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Name:</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="label8"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Copyright:</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -431,36 +466,30 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="label9"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Author(s):</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="label6"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">License:</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">4</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -479,8 +508,6 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -499,23 +526,19 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> <object class="GtkLabel" id="label10"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes">Description:</property> <property name="max_width_chars">5</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -530,8 +553,6 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -556,8 +577,6 @@ Authors: <packing> <property name="left_attach">1</property> <property name="top_attach">4</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -617,54 +636,13 @@ Authors: <property name="position">0</property> </packing> </child> - <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area1"> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="verify_button"> - <property name="label">_Verify</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="tooltip_text" translatable="yes">Verify that the project does not use any properties, -signals or widgets which are not available in the target version</property> - <property name="use_underline">True</property> - <signal name="clicked" handler="verify_clicked" swapped="no"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - <property name="secondary">True</property> - </packing> - </child> - <child> - <object class="GtkButton" id="close_button"> - <property name="label">gtk-close</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">6</property> - </packing> - </child> </object> </child> <action-widgets> <action-widget response="-3">close_button</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </template> </interface> diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c index c92e54ab..1fd6cb7d 100644 --- a/gladeui/glade-project.c +++ b/gladeui/glade-project.c @@ -158,6 +158,7 @@ struct _GladeProjectPrivate */ guint writing_preview : 1; /* During serialization, if we are serializing for a preview */ guint pointer_mode : 3; /* The currently effective GladePointerMode */ + guint use_generic_name : 1; /* Whether to use generic names for new widgets or not */ }; typedef struct @@ -197,6 +198,7 @@ enum PROP_RESOURCE_PATH, PROP_LICENSE, PROP_CSS_PROVIDER_PATH, + PROP_USE_GENERIC_NAME, N_PROPERTIES }; @@ -405,6 +407,9 @@ glade_project_get_property (GObject *object, case PROP_CSS_PROVIDER_PATH: g_value_set_string (value, project->priv->css_provider_path); break; + case PROP_USE_GENERIC_NAME: + g_value_set_boolean (value, project->priv->use_generic_name); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -439,6 +444,10 @@ glade_project_set_property (GObject *object, glade_project_set_css_provider_path (GLADE_PROJECT (object), g_value_get_string (value)); break; + case PROP_USE_GENERIC_NAME: + glade_project_set_use_generic_name (GLADE_PROJECT (object), + g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1030,6 +1039,13 @@ glade_project_class_init (GladeProjectClass *klass) NULL, G_PARAM_READWRITE); + glade_project_props[PROP_USE_GENERIC_NAME] = + g_param_spec_boolean ("use-generic-name", + _("Use generic name"), + _("Whether to use generic names for objects in the project or leave them unnamed"), + FALSE, + G_PARAM_READWRITE); + /* Install all properties */ g_object_class_install_properties (object_class, N_PROPERTIES, glade_project_props); } @@ -1619,7 +1635,11 @@ glade_project_read_comment_properties (GladeProject *project, if (gp_comment_strip_property (val, "interface-local-resource-path")) glade_project_set_resource_path (project, val); - else if (gp_comment_strip_property (val, "interface-css-provider-path")) + else if (gp_comment_strip_property (val, "interface-use-generic-name")) + { + glade_project_set_use_generic_name (project, !g_strcmp0 (val, "True")); + } + else if (gp_comment_strip_property (val, "interface-css-provider-path")) { if (g_path_is_absolute (val)) glade_project_set_css_provider_path (project, val); @@ -2319,6 +2339,17 @@ glade_project_write_css_provider_path (GladeProject *project, } static void +glade_project_write_use_generic_name (GladeProject *project, + GladeXmlContext *context, + GladeXmlNode *root) +{ + if (project->priv->use_generic_name) + glade_project_write_comment_property (project, context, root, + "interface-use-generic-name", + "True"); +} + +static void glade_project_write_license_data (GladeProject *project, GladeXmlContext *context, GladeXmlNode *root) @@ -2624,6 +2655,8 @@ glade_project_write (GladeProject *project) glade_project_write_css_provider_path (project, context, root); + glade_project_write_use_generic_name (project, context, root); + glade_project_write_license_data (project, context, root); /* Get sorted toplevels */ @@ -3493,6 +3526,41 @@ glade_project_verify_project_for_ui (GladeProject *project) } /** + * glade_project_get_use_generic_name: + * @project: a #GladeProject + * + */ +gboolean +glade_project_get_use_generic_name (GladeProject *project) +{ + g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE); + return project->priv->use_generic_name; +} + +/** + * glade_project_set_use_generic_name: + * @project: a #GladeProject + * @use_generic: + * + */ +void +glade_project_set_use_generic_name (GladeProject *project, gboolean use_generic) +{ + g_return_if_fail (GLADE_IS_PROJECT (project)); + + if (project->priv->use_generic_name != use_generic) + { + gint major, minor; + glade_project_get_target_version (project, "gtk+", &major, &minor); + + /* Id less object support was introducedin gtk 3.12 */ + project->priv->use_generic_name = (major == 3 && minor < 12) ? TRUE : use_generic; + g_object_notify_by_pspec (G_OBJECT (project), glade_project_props[PROP_USE_GENERIC_NAME]); + } +} + + +/** * glade_project_get_widget_by_name: * @project: a #GladeProject * @name: The user visible name of the widget we are looking for @@ -4132,6 +4200,10 @@ glade_project_set_target_version (GladeProject *project, g_hash_table_insert (project->priv->target_versions_minor, g_strdup (catalog), GINT_TO_POINTER ((int) minor)); + /* Gtk < 3.12 does not support IDless objects */ + if (!g_strcmp0 (catalog, "gtk+") && major == 3 && minor < 12) + glade_project_set_use_generic_name (project, TRUE); + glade_project_verify_project_for_ui (project); g_signal_emit (project, glade_project_signals[TARGETS_CHANGED], 0); diff --git a/gladeui/glade-project.h b/gladeui/glade-project.h index 5e6e6923..2bee6ce5 100644 --- a/gladeui/glade-project.h +++ b/gladeui/glade-project.h @@ -196,6 +196,10 @@ void glade_project_widget_changed (GladeProject *proj GladeWidget *gwidget); /* Widget names */ +gboolean glade_project_get_use_generic_name (GladeProject *project); +void glade_project_set_use_generic_name (GladeProject *project, + gboolean use_generic); + GladeWidget *glade_project_get_widget_by_name (GladeProject *project, const gchar *name); void glade_project_set_widget_name (GladeProject *project, diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c index e2b38744..67a8080a 100644 --- a/gladeui/glade-widget.c +++ b/gladeui/glade-widget.c @@ -868,7 +868,15 @@ glade_widget_constructor (GType type, if (gwidget->priv->name == NULL) { if (gwidget->priv->project) - gwidget->priv->name = glade_project_new_widget_name (gwidget->priv->project, gwidget, GLADE_UNNAMED_PREFIX); + { + const gchar *base_name; + + base_name = (glade_project_get_use_generic_name (gwidget->priv->project)) ? + glade_widget_adaptor_get_generic_name (gwidget->priv->adaptor) : + GLADE_UNNAMED_PREFIX; + + gwidget->priv->name = glade_project_new_widget_name (gwidget->priv->project, gwidget, base_name); + } else gwidget->priv->name = g_strdup (GLADE_UNNAMED_PREFIX); } |