[glade] GladeWidgetAdaptor: add glade_widget_adaptor_get_display_name()



commit 583e024ef8f3ccdfc2d4aa9886f77aee46cd1caf
Author: Juan Pablo Ugarte <ugarte endlessm com>
Date:   Thu Aug 2 14:08:46 2018 -0300

    GladeWidgetAdaptor: add glade_widget_adaptor_get_display_name()

 gladeui/glade-adaptor-chooser-widget.c |  6 +++---
 gladeui/glade-adaptor-chooser.c        |  2 +-
 gladeui/glade-design-layout.c          |  4 ++--
 gladeui/glade-editor-property.c        |  2 +-
 gladeui/glade-editor-table.c           |  2 +-
 gladeui/glade-editor.c                 |  6 +++---
 gladeui/glade-palette.c                |  2 +-
 gladeui/glade-popup.c                  |  2 +-
 gladeui/glade-private.h                |  6 +-----
 gladeui/glade-project.c                |  2 +-
 gladeui/glade-signal-editor.c          |  2 +-
 gladeui/glade-widget-adaptor.c         | 12 +++++++++---
 gladeui/glade-widget-adaptor.h         |  8 ++++++++
 gladeui/glade-widget.c                 |  6 +++---
 plugins/gtk+/glade-gtk-widget.c        |  2 +-
 15 files changed, 37 insertions(+), 27 deletions(-)
---
diff --git a/gladeui/glade-adaptor-chooser-widget.c b/gladeui/glade-adaptor-chooser-widget.c
index eedde453..71622cd1 100644
--- a/gladeui/glade-adaptor-chooser-widget.c
+++ b/gladeui/glade-adaptor-chooser-widget.c
@@ -170,7 +170,7 @@ normalize_name (const gchar *name)
 static inline void
 store_append_adaptor (GtkListStore *store, GladeWidgetAdaptor *adaptor)
 {
-  gchar *normalized_name = normalize_name (_glade_widget_adaptor_get_real_name (adaptor));
+  gchar *normalized_name = normalize_name (glade_widget_adaptor_get_display_name (adaptor));
 
   gtk_list_store_insert_with_values (store, NULL, -1,
                                      COLUMN_ADAPTOR, adaptor,
@@ -383,7 +383,7 @@ adaptor_text_cell_data_func (GtkTreeViewColumn *tree_column,
   if (adaptor)
     g_object_set (cell,
                   "sensitive", TRUE,
-                  "text", _glade_widget_adaptor_get_real_name (adaptor),
+                  "text", glade_widget_adaptor_get_display_name (adaptor),
                   "style", PANGO_STYLE_NORMAL,
                   NULL);
   else
@@ -412,7 +412,7 @@ glade_adaptor_chooser_widget_drag_begin (GtkWidget      *widget,
       gtk_tree_model_get (model, &iter, COLUMN_ADAPTOR, &adaptor, -1);
       _glade_dnd_set_icon_widget (context,
                                   glade_widget_adaptor_get_icon_name (adaptor),
-                                  glade_widget_adaptor_get_name (adaptor));
+                                  glade_widget_adaptor_get_display_name (adaptor));
     }
 }
 
diff --git a/gladeui/glade-adaptor-chooser.c b/gladeui/glade-adaptor-chooser.c
index 388bbe79..ebe42bcc 100644
--- a/gladeui/glade-adaptor-chooser.c
+++ b/gladeui/glade-adaptor-chooser.c
@@ -291,7 +291,7 @@ glade_adaptor_chooser_update_adaptor (GladeAdaptorChooser *chooser)
                                     glade_widget_adaptor_get_icon_name (adaptor),
                                     GTK_ICON_SIZE_BUTTON);
       gtk_label_set_label (priv->class_label,
-                           glade_widget_adaptor_get_name (adaptor));
+                           glade_widget_adaptor_get_display_name (adaptor));
     }
   else
     {
diff --git a/gladeui/glade-design-layout.c b/gladeui/glade-design-layout.c
index 0b7ee38b..dd885d4f 100644
--- a/gladeui/glade-design-layout.c
+++ b/gladeui/glade-design-layout.c
@@ -954,7 +954,7 @@ update_widget_name (GladeDesignLayout *layout, GladeWidget *gwidget)
       else
         {
           GladeWidgetAdaptor *adaptor = glade_widget_get_adaptor (gwidget);
-          pango_layout_set_text (priv->widget_name, _glade_widget_adaptor_get_real_name (adaptor), -1);
+          pango_layout_set_text (priv->widget_name, glade_widget_adaptor_get_display_name (adaptor), -1);
         }
 
       gtk_widget_queue_resize (GTK_WIDGET (layout));
@@ -1973,7 +1973,7 @@ glade_design_layout_drag_begin (GtkWidget *widget, GdkDragContext *context)
   gwidget = glade_widget_get_from_gobject (priv->drag_source);
   adaptor = glade_widget_get_adaptor (gwidget);
   description = g_strdup_printf ("%s [%s]",
-                                 glade_widget_adaptor_get_name (adaptor),
+                                 glade_widget_adaptor_get_display_name (adaptor),
                                  glade_widget_get_name (gwidget));
 
   _glade_dnd_set_icon_widget (context,
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index c49a07bd..a400078b 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -3429,7 +3429,7 @@ glade_eprop_object_show_dialog (GladeEditorProperty *eprop)
 
       /* translators: Creating 'a widget' for 'a property' of 'a widget' */
       glade_command_push_group (_("Creating %s for %s of %s"),
-                                glade_widget_adaptor_get_name (create_adaptor),
+                                glade_widget_adaptor_get_display_name (create_adaptor),
                                 glade_property_class_get_name (eprop->priv->klass),
                                 glade_widget_get_name (widget));
 
diff --git a/gladeui/glade-editor-table.c b/gladeui/glade-editor-table.c
index 1a58f166..0256d884 100644
--- a/gladeui/glade-editor-table.c
+++ b/gladeui/glade-editor-table.c
@@ -390,7 +390,7 @@ glade_editor_table_load (GladeEditable *editable, GladeWidget *widget)
 
           gtk_widget_set_sensitive (table->priv->composite_check,
                                     !g_str_has_prefix (glade_widget_adaptor_get_name (adaptor),
-                                                       GLADE_WIDGET_INSTANTIABLE_PREFIX));
+                                                       GWA_INSTANTIABLE_PREFIX));
         }
 
       if (table->priv->name_entry)
diff --git a/gladeui/glade-editor.c b/gladeui/glade-editor.c
index 11b56db8..e081cb8c 100644
--- a/gladeui/glade-editor.c
+++ b/gladeui/glade-editor.c
@@ -324,7 +324,7 @@ glade_editor_update_class_field (GladeEditor *editor)
            */
           text = g_strdup_printf (_("%s Properties - %s [%s]"),
                                   glade_widget_adaptor_get_title (priv->loaded_adaptor),
-                                  glade_widget_adaptor_get_name (priv->loaded_adaptor), 
+                                  glade_widget_adaptor_get_display_name (priv->loaded_adaptor),
                                  glade_widget_get_display_name (widget));
         }
       else
@@ -334,7 +334,7 @@ glade_editor_update_class_field (GladeEditor *editor)
            */
           text = g_strdup_printf (_("%s Properties - %s"),
                                   glade_widget_adaptor_get_title (priv->loaded_adaptor),
-                                  glade_widget_adaptor_get_name (priv->loaded_adaptor));
+                                  glade_widget_adaptor_get_display_name (priv->loaded_adaptor));
        }
                 
       gtk_label_set_text (GTK_LABEL (priv->class_label), text);
@@ -772,7 +772,7 @@ glade_editor_query_dialog (GladeWidget *widget)
   
   adaptor = glade_widget_get_adaptor (widget);
 
-  title = g_strdup_printf (_("Create a %s"), glade_widget_adaptor_get_name (adaptor));
+  title = g_strdup_printf (_("Create a %s"), glade_widget_adaptor_get_display_name (adaptor));
   dialog = gtk_dialog_new_with_buttons (title, NULL,
                                         GTK_DIALOG_MODAL |
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
diff --git a/gladeui/glade-palette.c b/gladeui/glade-palette.c
index 3bcde297..1530d4d9 100644
--- a/gladeui/glade-palette.c
+++ b/gladeui/glade-palette.c
@@ -272,7 +272,7 @@ glade_palette_drag_begin (GtkWidget *widget,
 {
   _glade_dnd_set_icon_widget (context,
                               glade_widget_adaptor_get_icon_name (adaptor),
-                              glade_widget_adaptor_get_name (adaptor));
+                              glade_widget_adaptor_get_display_name (adaptor));
 }
 
 static void
diff --git a/gladeui/glade-popup.c b/gladeui/glade-popup.c
index 4b28e189..56b46f4e 100644
--- a/gladeui/glade-popup.c
+++ b/gladeui/glade-popup.c
@@ -42,7 +42,7 @@ glade_popup_docs_cb (GtkMenuItem *item, GladeWidgetAdaptor *adaptor)
   g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
 
   glade_app_search_docs (glade_widget_adaptor_get_book (adaptor),
-                         glade_widget_adaptor_get_name (adaptor),
+                         glade_widget_adaptor_get_display_name (adaptor),
                          NULL);
 }
 
diff --git a/gladeui/glade-private.h b/gladeui/glade-private.h
index 48cc2ac7..35a57562 100644
--- a/gladeui/glade-private.h
+++ b/gladeui/glade-private.h
@@ -33,16 +33,12 @@
 
 G_BEGIN_DECLS
 
-#define GLADE_WIDGET_INSTANTIABLE_PREFIX "GladeInstantiable"
-#define GLADE_WIDGET_INSTANTIABLE_PREFIX_LEN 17
+#define GWA_INSTANTIABLE_PREFIX_LEN 17
 
 /* glade-widget.c */
 
 GList *_glade_widget_peek_prop_refs (GladeWidget *widget);
 
-/* glade-widget-adaptor.c */
-G_CONST_RETURN gchar *_glade_widget_adaptor_get_real_name (GladeWidgetAdaptor *adaptor);
-
 /* glade-catalog.c */
 
 GladeCatalog *_glade_catalog_get_catalog (const gchar *name);
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 95fa429e..b86be762 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -1110,7 +1110,7 @@ glade_project_model_get_value (GtkTreeModel *model,
       case GLADE_PROJECT_MODEL_COLUMN_TYPE_NAME:
         {
           GladeWidgetAdaptor *adaptor = glade_widget_get_adaptor (widget);
-          g_value_set_static_string (value, _glade_widget_adaptor_get_real_name (adaptor));
+          g_value_set_static_string (value, glade_widget_adaptor_get_display_name (adaptor));
           break;
         }
       case GLADE_PROJECT_MODEL_COLUMN_OBJECT:
diff --git a/gladeui/glade-signal-editor.c b/gladeui/glade-signal-editor.c
index 407251fa..67d3443f 100644
--- a/gladeui/glade-signal-editor.c
+++ b/gladeui/glade-signal-editor.c
@@ -629,7 +629,7 @@ glade_signal_editor_devhelp (GtkCellRenderer *cell,
 
   search = g_strdup_printf ("The %s signal", glade_signal_get_name (signal));
 
-  glade_app_search_docs (book, glade_widget_adaptor_get_name (adaptor), search);
+  glade_app_search_docs (book, glade_widget_adaptor_get_display_name (adaptor), search);
 
   g_free (search);
   g_free (book);
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 0de99c58..e33f6ffa 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -1787,13 +1787,19 @@ glade_widget_adaptor_get_name (GladeWidgetAdaptor *adaptor)
   return adaptor->priv->name;
 }
 
+/**
+ * glade_widget_adaptor_get_display_name
+ * @adaptor: a #GladeWidgetAdaptor
+ *
+ * Returns the name of the adaptor without GWA_INSTANTIABLE_PREFIX
+ */
 G_CONST_RETURN gchar *
-_glade_widget_adaptor_get_real_name (GladeWidgetAdaptor *adaptor)
+glade_widget_adaptor_get_display_name (GladeWidgetAdaptor *adaptor)
 {
   g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
 
-  if (g_str_has_prefix (adaptor->priv->name, GLADE_WIDGET_INSTANTIABLE_PREFIX))
-    return &adaptor->priv->name[GLADE_WIDGET_INSTANTIABLE_PREFIX_LEN];
+  if (g_str_has_prefix (adaptor->priv->name, GWA_INSTANTIABLE_PREFIX))
+    return &adaptor->priv->name[GWA_INSTANTIABLE_PREFIX_LEN];
 
   return adaptor->priv->name;
 }
diff --git a/gladeui/glade-widget-adaptor.h b/gladeui/glade-widget-adaptor.h
index da02f257..69d89af2 100644
--- a/gladeui/glade-widget-adaptor.h
+++ b/gladeui/glade-widget-adaptor.h
@@ -176,6 +176,13 @@ typedef struct _GladeWidgetAdaptorClass   GladeWidgetAdaptorClass;
 
 #define GLADE_VALID_CREATE_REASON(reason) (reason >= 0 && reason < GLADE_CREATE_REASONS)
 
+/**
+ * GWA_INSTANTIABLE_PREFIX:
+ *
+ * Class prefix used for abstract classes (ie GtkBin -> GladeInstantiableGtkBin)
+ */
+#define GWA_INSTANTIABLE_PREFIX "GladeInstantiable"
+
 /**
  * GladeCreateReason:
  * @GLADE_CREATE_USER: Was created at the user's request
@@ -735,6 +742,7 @@ GType                 glade_widget_adaptor_get_type         (void) G_GNUC_CONST;
 GType                 glade_widget_adaptor_get_object_type  (GladeWidgetAdaptor   *adaptor);
 G_CONST_RETURN gchar *glade_widget_adaptor_get_name         (GladeWidgetAdaptor   *adaptor);
 G_CONST_RETURN gchar *glade_widget_adaptor_get_generic_name (GladeWidgetAdaptor   *adaptor);
+G_CONST_RETURN gchar *glade_widget_adaptor_get_display_name (GladeWidgetAdaptor   *adaptor);
 G_CONST_RETURN gchar *glade_widget_adaptor_get_title        (GladeWidgetAdaptor   *adaptor);
 G_CONST_RETURN gchar *glade_widget_adaptor_get_icon_name    (GladeWidgetAdaptor   *adaptor);
 G_CONST_RETURN gchar *glade_widget_adaptor_get_missing_icon (GladeWidgetAdaptor   *adaptor);
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index a0d772fd..563f86e7 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -947,7 +947,7 @@ glade_widget_constructor (GType                  type,
   glade_widget_verify (gwidget);
 
   if (g_str_has_prefix (glade_widget_adaptor_get_name (gwidget->priv->adaptor),
-                        GLADE_WIDGET_INSTANTIABLE_PREFIX))
+                        GWA_INSTANTIABLE_PREFIX))
     glade_widget_set_is_composite (gwidget, TRUE);
 
   return ret_obj;
@@ -4078,7 +4078,7 @@ glade_widget_read (GladeProject *project,
           /* Check if there is an instantiable version for this abstract class */
           if (G_TYPE_IS_ABSTRACT (template_type))
             {
-              gchar *instantiable = g_strconcat (GLADE_WIDGET_INSTANTIABLE_PREFIX,
+              gchar *instantiable = g_strconcat (GWA_INSTANTIABLE_PREFIX,
                                                  template_parent,
                                                  NULL);
               if (glade_util_get_type_from_name (instantiable, FALSE))
@@ -4363,7 +4363,7 @@ glade_widget_write (GladeWidget     *widget,
 
       glade_xml_node_set_property_string (widget_node,
                                           GLADE_TAG_PARENT,
-                                          _glade_widget_adaptor_get_real_name (widget->priv->adaptor));
+                                          glade_widget_adaptor_get_display_name (widget->priv->adaptor));
     }
   else
     {
diff --git a/plugins/gtk+/glade-gtk-widget.c b/plugins/gtk+/glade-gtk-widget.c
index 48eb8ce4..49f4e28f 100644
--- a/plugins/gtk+/glade-gtk-widget.c
+++ b/plugins/gtk+/glade-gtk-widget.c
@@ -979,7 +979,7 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
   else if (strcmp (action_path, "read_documentation") == 0)
     {
       glade_app_search_docs (glade_widget_adaptor_get_book (adaptor),
-                             glade_widget_adaptor_get_name (adaptor),
+                             glade_widget_adaptor_get_display_name (adaptor),
                              NULL);
     }
   else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]