[glade] Added GladeEditor:class-field read only property. Update Properties Dock window title with GladeEdit



commit c7eea88f85e78167bc31bafbe6a359b2a434ea69
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Mon Mar 4 21:58:41 2013 -0300

    Added GladeEditor:class-field read only property.
    Update Properties Dock window title with GladeEditor:class-field value

 gladeui/glade-editor.c |   13 +++++++++++++
 src/glade-window.c     |   48 ++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 59 insertions(+), 2 deletions(-)
---
diff --git a/gladeui/glade-editor.c b/gladeui/glade-editor.c
index 21c0448..893a0e2 100644
--- a/gladeui/glade-editor.c
+++ b/gladeui/glade-editor.c
@@ -58,6 +58,7 @@ enum
   PROP_SHOW_INFO,
   PROP_WIDGET,
   PROP_SHOW_CLASS_FIELD,
+  PROP_CLASS_FIELD,
   N_PROPERTIES
 };
 
@@ -198,6 +199,9 @@ glade_editor_get_property (GObject *object,
       case PROP_SHOW_CLASS_FIELD:
         g_value_set_boolean (value, editor->priv->show_class_field);
         break;
+      case PROP_CLASS_FIELD:
+        g_value_set_static_string (value, gtk_label_get_label (GTK_LABEL (editor->priv->class_label)));
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         break;
@@ -253,6 +257,13 @@ glade_editor_class_init (GladeEditorClass *klass)
                           _("Whether to show the class field at the top"),
                           TRUE,
                           G_PARAM_READWRITE);
+
+  properties[PROP_CLASS_FIELD] =
+    g_param_spec_string ("class-field",
+                         _("Class Field"),
+                         _("The class field string"),
+                         NULL,
+                         G_PARAM_READABLE);
   
   /* Install all properties */
   g_object_class_install_properties (object_class, N_PROPERTIES, properties);
@@ -474,6 +485,8 @@ glade_editor_update_class_field (GladeEditor *editor)
       gtk_widget_hide (priv->warning);
       gtk_label_set_text (GTK_LABEL (priv->class_label), _("Properties"));
     }
+
+  g_object_notify_by_pspec (G_OBJECT (editor), properties[PROP_CLASS_FIELD]);
 }
 
 static void
diff --git a/src/glade-window.c b/src/glade-window.c
index 8b10cd5..1f9cdc7 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -1876,9 +1876,34 @@ on_dock_resized (GtkWidget *window, GdkEventConfigure *event, ToolDock *dock)
   return FALSE;
 }
 
+static void
+properties_dock_update_title_from_editor (GtkWidget *toplevel, GladeEditor *editor)
+{
+  GladeWidgetAdaptor *adaptor;
+  GladeWidget *gwidget;
+  gchar *class_field;
+
+  g_object_get (editor,
+                "class-field", &class_field,
+                "widget", &gwidget,
+                NULL);
+
+  if (gwidget == NULL)
+    return;
+
+  gtk_window_set_title (GTK_WINDOW (toplevel), class_field);
+
+  if ((adaptor = glade_widget_get_adaptor (gwidget)))
+    gtk_window_set_icon_name (GTK_WINDOW (toplevel),
+                              glade_widget_adaptor_get_icon_name (adaptor));
+
+  g_free (class_field);
+}
+
 void
 on_dock_action_toggled (GtkAction *action, GladeWindow *window)
 {
+  GladeWindowPrivate *priv = window->priv;
   GtkWidget *toplevel, *alignment;
   ToolDock *dock;
   guint dock_type;
@@ -1888,7 +1913,7 @@ on_dock_action_toggled (GtkAction *action, GladeWindow *window)
                         (G_OBJECT (action), "glade-dock-type"));
   g_return_if_fail (dock_type < N_DOCKS);
 
-  dock = &window->priv->docks[dock_type];
+  dock = &priv->docks[dock_type];
 
   if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
     {
@@ -1943,13 +1968,16 @@ on_dock_action_toggled (GtkAction *action, GladeWindow *window)
           !gtk_paned_get_child2 (GTK_PANED (dock->paned)))
         gtk_widget_hide (dock->paned);
 
-      gtk_window_add_accel_group (GTK_WINDOW (toplevel), window->priv->accelgroup);
+      gtk_window_add_accel_group (GTK_WINDOW (toplevel), priv->accelgroup);
 
       g_signal_connect (G_OBJECT (toplevel), "key-press-event",
                         G_CALLBACK (glade_utils_hijack_key_press), window);
 
       dock->detached = TRUE;
 
+      if (dock_type == DOCK_EDITOR)
+        properties_dock_update_title_from_editor (toplevel, priv->editor);
+
       gtk_window_present (GTK_WINDOW (toplevel));
     }
 }
@@ -2957,6 +2985,19 @@ glade_window_init (GladeWindow *window)
   glade_init ();
 }
 
+static void
+on_editor_class_field_notify (GObject     *gobject,
+                              GParamSpec  *pspec,
+                              GladeWindow *window)
+{
+  GladeWindowPrivate *priv = window->priv;
+  ToolDock *editor = &priv->docks[DOCK_EDITOR];
+  
+  if (editor->detached)
+    properties_dock_update_title_from_editor (gtk_widget_get_toplevel (editor->widget),
+                                              GLADE_EDITOR (gobject));
+}
+
 #define GET_OBJECT(b,c,o) c(gtk_builder_get_object(b,o)) /*;g_warn_if_fail(gtk_builder_get_object(b,o))*/
 
 static void
@@ -3087,6 +3128,9 @@ glade_window_constructed (GObject *object)
 
   gtk_builder_connect_signals (builder, window);
 
+  g_signal_connect (priv->editor, "notify::class-field",
+                    G_CALLBACK (on_editor_class_field_notify), window);
+
   /* Load configuration, we need the list of extra catalog paths before creating
    * the GladeApp
    */


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