[glade/notebook-actions] Support notebook actions



commit 8e00c137c2f780ea958ba74da1aee4afb50887c5
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Oct 18 00:26:27 2014 -0400

    Support notebook actions

 plugins/gtk+/glade-gtk-notebook.c     |   93 ++++++++++++++++++++++++++++++--
 plugins/gtk+/glade-notebook-editor.ui |   94 ++++++++++++++++++++++++++-------
 plugins/gtk+/gtk+.xml.in              |   14 +++++-
 3 files changed, 174 insertions(+), 27 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-notebook.c b/plugins/gtk+/glade-gtk-notebook.c
index 8f5efc3..4450a45 100644
--- a/plugins/gtk+/glade-gtk-notebook.c
+++ b/plugins/gtk+/glade-gtk-notebook.c
@@ -380,11 +380,25 @@ glade_gtk_notebook_project_changed (GladeWidget * gwidget,
   g_object_set_data (G_OBJECT (gwidget), "notebook-project-ptr", project);
 }
 
+static void
+glade_gtk_notebook_parse_finished (GladeProject * project, GObject * object)
+{
+  GtkWidget *action;
+
+  action = gtk_notebook_get_action_widget (GTK_NOTEBOOK (object), GTK_PACK_START);
+  glade_widget_property_set (glade_widget_get_from_gobject (object),
+                             "has-action-start", action != NULL);
+  action = gtk_notebook_get_action_widget (GTK_NOTEBOOK (object), GTK_PACK_END);
+  glade_widget_property_set (glade_widget_get_from_gobject (object),
+                             "has-action-end", action != NULL);
+}
+
 void
 glade_gtk_notebook_post_create (GladeWidgetAdaptor * adaptor,
                                 GObject * notebook, GladeCreateReason reason)
 {
   GladeWidget *gwidget = glade_widget_get_from_gobject (notebook);
+  GladeProject *project = glade_widget_get_project (gwidget);
 
   gtk_notebook_popup_disable (GTK_NOTEBOOK (notebook));
 
@@ -395,6 +409,11 @@ glade_gtk_notebook_post_create (GladeWidgetAdaptor * adaptor,
 
   g_signal_connect (G_OBJECT (notebook), "switch-page",
                     G_CALLBACK (glade_gtk_notebook_switch_page), NULL);
+
+  if (reason == GLADE_CREATE_LOAD)
+    g_signal_connect (project, "parse-finished",
+                      G_CALLBACK (glade_gtk_notebook_parse_finished),
+                      notebook);
 }
 
 static gint
@@ -533,6 +552,32 @@ glade_gtk_notebook_set_property (GladeWidgetAdaptor * adaptor,
 {
   if (!strcmp (id, "pages"))
     glade_gtk_notebook_set_n_pages (object, value);
+  else if (!strcmp (id, "has-action-start"))
+    {
+      if (g_value_get_boolean (value))
+        {
+          GtkWidget *action = gtk_notebook_get_action_widget (GTK_NOTEBOOK (object), GTK_PACK_START);
+          if (!action)
+            action = glade_placeholder_new ();
+          g_object_set_data (G_OBJECT (action), "special-child-type", "action-start");
+          gtk_notebook_set_action_widget (GTK_NOTEBOOK (object), action, GTK_PACK_START); 
+        }
+      else
+        gtk_notebook_set_action_widget (GTK_NOTEBOOK (object), NULL, GTK_PACK_START); 
+    }
+  else if (!strcmp (id, "has-action-end"))
+    {
+      if (g_value_get_boolean (value))
+        {
+          GtkWidget *action = gtk_notebook_get_action_widget (GTK_NOTEBOOK (object), GTK_PACK_END);
+          if (!action)
+            action = glade_placeholder_new ();
+          g_object_set_data (G_OBJECT (action), "special-child-type", "action-end");
+          gtk_notebook_set_action_widget (GTK_NOTEBOOK (object), action, GTK_PACK_END); 
+        }
+      else
+        gtk_notebook_set_action_widget (GTK_NOTEBOOK (object), NULL, GTK_PACK_END); 
+    }
   else
     GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
                                                       id, value);
@@ -592,10 +637,18 @@ glade_gtk_notebook_add_child (GladeWidgetAdaptor * adaptor,
   num_page = gtk_notebook_get_n_pages (notebook);
   gwidget = glade_widget_get_from_gobject (object);
 
-  /* Just append pages blindly when loading/dupping
-   */
-  if (glade_widget_superuser ())
+  special_child_type = g_object_get_data (child, "special-child-type");
+  if (special_child_type && !strcmp (special_child_type, "action-start"))
     {
+      gtk_notebook_set_action_widget (notebook, GTK_WIDGET (child), GTK_PACK_START);
+    }
+  else if (special_child_type && !strcmp (special_child_type, "action-end"))
+    {
+      gtk_notebook_set_action_widget (notebook, GTK_WIDGET (child), GTK_PACK_END);
+    }
+  else if (glade_widget_superuser ())
+    {
+      /* Just append pages blindly when loading/dupping */
       special_child_type = g_object_get_data (child, "special-child-type");
       if (special_child_type && !strcmp (special_child_type, "tab"))
         {
@@ -674,9 +727,26 @@ glade_gtk_notebook_remove_child (GladeWidgetAdaptor * adaptor,
                                  GObject * object, GObject * child)
 {
   NotebookChildren *nchildren;
+  gchar *special_child_type;
 
   nchildren = glade_gtk_notebook_extract_children (GTK_WIDGET (object));
 
+  special_child_type = g_object_get_data (child, "special-child-type");
+  if (special_child_type && !strcmp (special_child_type, "action-start"))
+    {
+      GtkWidget *placeholder = glade_placeholder_new ();
+      g_object_set_data (G_OBJECT (placeholder), "special-child-type", "action-start");
+      gtk_notebook_set_action_widget (GTK_NOTEBOOK (object), placeholder, GTK_PACK_START);
+      return;
+    }
+  else if (special_child_type && !strcmp (special_child_type, "action-end"))
+    {
+      GtkWidget *placeholder = glade_placeholder_new ();
+      g_object_set_data (G_OBJECT (placeholder), "special-child-type", "action-end");
+      gtk_notebook_set_action_widget (GTK_NOTEBOOK (object), placeholder, GTK_PACK_END);
+      return;
+    }
+
   if (g_list_find (nchildren->children, child))
     {
       nchildren->children = g_list_remove (nchildren->children, child);
@@ -711,9 +781,23 @@ glade_gtk_notebook_replace_child (GladeWidgetAdaptor * adaptor,
   GtkNotebook *notebook;
   GladeWidget *gcurrent, *gnew;
   gint position = 0;
+  gchar *special_child_type;
 
   notebook = GTK_NOTEBOOK (container);
 
+  special_child_type = g_object_get_data (G_OBJECT (current), "special-child-type");
+  g_object_set_data (G_OBJECT (new_widget), "special-child-type", special_child_type);
+  if (!g_strcmp0 (special_child_type, "action-start"))
+    {
+      gtk_notebook_set_action_widget (notebook, GTK_WIDGET (new_widget), GTK_PACK_START);
+      return;
+    }
+  else if (!g_strcmp0 (special_child_type, "action-end"))
+    {
+      gtk_notebook_set_action_widget (notebook, GTK_WIDGET (new_widget), GTK_PACK_END);
+      return;
+    }
+
   if ((gcurrent = glade_widget_get_from_gobject (current)) != NULL)
     glade_widget_pack_property_get (gcurrent, "position", &position);
   else
@@ -725,9 +809,6 @@ glade_gtk_notebook_replace_child (GladeWidgetAdaptor * adaptor,
         }
     }
 
-  if (g_object_get_data (G_OBJECT (current), "special-child-type"))
-    g_object_set_data (G_OBJECT (new_widget), "special-child-type", "tab");
-
   glade_gtk_notebook_remove_child (adaptor,
                                    G_OBJECT (container), G_OBJECT (current));
 
diff --git a/plugins/gtk+/glade-notebook-editor.ui b/plugins/gtk+/glade-notebook-editor.ui
index 962ddc2..efcc266 100644
--- a/plugins/gtk+/glade-notebook-editor.ui
+++ b/plugins/gtk+/glade-notebook-editor.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.0 
+<!-- Generated with glade 3.18.1 
 
 libgladegtk - Glade UI Designer Gtk+ support plugin
 Copyright (C) 2013 Tristan Van Berkom <tvb gnome org>
@@ -43,7 +43,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">0</property>
             <property name="width">6</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -61,7 +60,6 @@ Author: Tristan Van Berkom <tvb gnome org>
             <property name="left_attach">0</property>
             <property name="top_attach">1</property>
             <property name="width">6</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
@@ -76,8 +74,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <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>
@@ -90,8 +86,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <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>
@@ -105,8 +99,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <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>
@@ -121,8 +113,6 @@ Author: Tristan Van Berkom <tvb gnome org>
           <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>
@@ -148,7 +138,6 @@ Author: Tristan Van Berkom <tvb gnome org>
                 <property name="left_attach">0</property>
                 <property name="top_attach">0</property>
                 <property name="width">6</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -163,7 +152,6 @@ Author: Tristan Van Berkom <tvb gnome org>
                 <property name="left_attach">0</property>
                 <property name="top_attach">1</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -177,7 +165,6 @@ Author: Tristan Van Berkom <tvb gnome org>
                 <property name="left_attach">2</property>
                 <property name="top_attach">1</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -192,7 +179,6 @@ Author: Tristan Van Berkom <tvb gnome org>
                 <property name="left_attach">0</property>
                 <property name="top_attach">2</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -206,7 +192,6 @@ Author: Tristan Van Berkom <tvb gnome org>
                 <property name="left_attach">2</property>
                 <property name="top_attach">2</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -222,7 +207,6 @@ Author: Tristan Van Berkom <tvb gnome org>
                 <property name="left_attach">0</property>
                 <property name="top_attach">3</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -237,7 +221,6 @@ Author: Tristan Van Berkom <tvb gnome org>
                 <property name="left_attach">2</property>
                 <property name="top_attach">3</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -261,12 +244,81 @@ Author: Tristan Van Berkom <tvb gnome org>
           </object>
           <packing>
             <property name="left_attach">0</property>
-            <property name="top_attach">4</property>
+            <property name="top_attach">6</property>
             <property name="width">6</property>
-            <property name="height">1</property>
           </packing>
         </child>
         <child>
+          <object class="GladePropertyLabel" id="action_start_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="property_name">has-action-start</property>
+            <property name="custom_text" translatable="yes">Start Action:</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="action_start_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="property_name">has-action-start</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyLabel" id="action_end_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="property_name">has-action-end</property>
+            <property name="custom_text" translatable="yes">End Action:</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">5</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GladePropertyShell" id="action_end_editor">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="property_name">has-action-end</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">5</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
           <placeholder/>
         </child>
         <child>
@@ -309,6 +361,8 @@ Author: Tristan Van Berkom <tvb gnome org>
       <editor id="group_name_editor"/>
       <editor id="scrollable_editor"/>
       <editor id="enable_popup_editor"/>
+      <editor id="action_start_editor"/>
+      <editor id="action_end_editor"/>
     </child-editors>
   </template>
 </interface>
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index be1bb6a..4ffe766 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -2219,7 +2219,7 @@
           <property id="default-height" default="260" optional="True" optional-default="False"/>
           <property id="type-hint" default="GDK_WINDOW_TYPE_HINT_DIALOG" save-always="True"/>
           <!-- We disabled this property until Glade supports GtkHeaderBar editing -->
-          <property id="use-header-bar" since="3.12" disabled="True"/>
+          <property id="use-header-bar" since="3.12" disabled="False"/>
         </properties>
         
       </glade-widget-class>
@@ -2404,8 +2404,20 @@
             </parameter-spec>
             <_tooltip>The number of pages in the notebook</_tooltip>
           </property>
+
+          <property id="has-action-start" _name="Start Action" visible="False" save="False" default="False" 
custom-layout="True">
+            <parameter-spec>
+              <type>GParamBoolean</type>
+            </parameter-spec>
+          </property>
+          <property id="has-action-end" _name="End Action" visible="False" save="False" default="False" 
custom-layout="True">
+            <parameter-spec>
+              <type>GParamBoolean</type>
+            </parameter-spec>
+          </property>
         </properties>
         
+        
         <packing-properties>
           <property id="tab-label" disabled="True"/>
         </packing-properties>


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