[glade3] * plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Added editor to edit GtkAction/GtkActionGr



commit bd16621dd5632ed6c9e1380e64b3c47ae3f0f894
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Thu Dec 30 23:42:14 2010 +0900

    	* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Added editor to edit
    	  GtkAction/GtkActionGroup hierarchies.
    
    Conflicts:
    
    	ChangeLog
    	plugins/gtk+/glade-gtk.c

 ChangeLog                |    3 ++
 plugins/gtk+/glade-gtk.c |   71 ++++++++++++++++++++++++++++++++++++++++++---
 plugins/gtk+/gtk+.xml.in |    9 ++++++
 3 files changed, 78 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ff3fe11..b393b84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,9 @@
 
 	* gladeui/glade-base-editor.c: Remove restriction for only GtkContainer widgets.
 
+	* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Added editor to edit
+	  GtkAction/GtkActionGroup hierarchies.
+
 2010-12-29  Javier Jardón <jjardon gnome org>
 
 	* configure.ac: Use upstream gettext
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index bcb9698..6d94249 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -10896,6 +10896,8 @@ glade_gtk_adjustment_write_widget (GladeWidgetAdaptor * adaptor,
 
 
 /*--------------------------- GtkAction ---------------------------------*/
+#define ACTION_ACCEL_INSENSITIVE_MSG _("The accelerator can only be set when inside an Action Group.")
+
 void
 glade_gtk_action_post_create (GladeWidgetAdaptor * adaptor,
                               GObject * object, GladeCreateReason reason)
@@ -10908,6 +10910,9 @@ glade_gtk_action_post_create (GladeWidgetAdaptor * adaptor,
   if (!gtk_action_get_name (GTK_ACTION (object)))
     glade_widget_property_set (gwidget, "name", "untitled");
 
+  glade_widget_set_action_sensitive (gwidget, "launch_editor", FALSE);
+  glade_widget_property_set_sensitive (gwidget, "accelerator", FALSE, 
+				       ACTION_ACCEL_INSENSITIVE_MSG);
 }
 
 /*--------------------------- GtkActionGroup ---------------------------------*/
@@ -10930,6 +10935,7 @@ glade_gtk_action_group_add_child (GladeWidgetAdaptor * adaptor,
                               (GDestroyNotify) g_list_free);
 
       glade_widget_property_set_sensitive (gaction, "accelerator", TRUE, NULL);
+      glade_widget_set_action_sensitive (gaction, "launch_editor", TRUE);
     }
 }
 
@@ -10941,8 +10947,6 @@ glade_gtk_action_group_remove_child (GladeWidgetAdaptor * adaptor,
     {
       /* Dont really add/remove actions (because name conflicts inside groups)
        */
-      const gchar *insensitive_msg =
-          _("The accelerator can only be set when inside an Action Group.");
       GladeWidget *ggroup = glade_widget_get_from_gobject (container);
       GladeWidget *gaction = glade_widget_get_from_gobject (child);
       GList *actions = g_object_get_data (G_OBJECT (ggroup), "glade-actions");
@@ -10952,9 +10956,10 @@ glade_gtk_action_group_remove_child (GladeWidgetAdaptor * adaptor,
 
       g_object_set_data_full (G_OBJECT (ggroup), "glade-actions", actions,
                               (GDestroyNotify) g_list_free);
-
-      glade_widget_property_set_sensitive (gaction, "accelerator", FALSE,
-                                           insensitive_msg);
+      
+      glade_widget_property_set_sensitive (gaction, "accelerator", FALSE, 
+					   ACTION_ACCEL_INSENSITIVE_MSG);
+      glade_widget_set_action_sensitive (gaction, "launch_editor", FALSE);
     }
 }
 
@@ -11021,3 +11026,59 @@ glade_gtk_action_group_write_child (GladeWidgetAdaptor * adaptor,
   /* Write accelerator here  */
   glade_gtk_write_accels (widget, context, child_node, FALSE);
 }
+
+static void
+glade_gtk_action_child_selected (GladeBaseEditor *editor,
+				 GladeWidget *gchild,
+				 gpointer data)
+{
+  GObject *child = glade_widget_get_object (gchild);
+	
+  glade_base_editor_add_label (editor, _("Action"));
+	
+  glade_base_editor_add_default_properties (editor, gchild);
+	
+  glade_base_editor_add_label (editor, _("Properties"));
+  glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_GENERAL);
+}
+
+static void
+glade_gtk_action_launch_editor (GObject  *action)
+{
+  GladeWidget *widget = glade_widget_get_from_gobject (action);
+  GladeBaseEditor *editor;
+  GladeEditable *action_editor;
+  GtkWidget *window;
+
+  /* Make sure we get the group here */
+  widget = glade_widget_get_toplevel (widget);
+
+  action_editor = glade_widget_adaptor_create_editable (widget->adaptor, GLADE_PAGE_GENERAL);
+
+  /* Editor */
+  editor = glade_base_editor_new (widget->object, action_editor,
+				  _("Action"), GTK_TYPE_ACTION,
+				  _("Toggle"), GTK_TYPE_TOGGLE_ACTION,
+				  _("Radio"), GTK_TYPE_RADIO_ACTION,
+				  _("Recent"), GTK_TYPE_RECENT_ACTION,
+				  NULL);
+
+  g_signal_connect (editor, "child-selected", G_CALLBACK (glade_gtk_action_child_selected), NULL);
+
+  gtk_widget_show (GTK_WIDGET (editor));
+	
+  window = glade_base_editor_pack_new_window (editor, _("Action Group Editor"), NULL);
+  gtk_widget_show (window);
+}
+
+
+void
+glade_gtk_action_action_activate (GladeWidgetAdaptor *adaptor,
+				  GObject *object,
+				  const gchar *action_path)
+{
+  if (strcmp (action_path, "launch_editor") == 0)
+    {
+      glade_gtk_action_launch_editor (object);
+    }
+}
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index b2d7d1a..56c7ea1 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1780,6 +1780,11 @@ embedded in another object</_tooltip>
       <post-create-function>glade_gtk_action_post_create</post-create-function>
       <create-editor-property-function>glade_gtk_widget_create_eprop</create-editor-property-function>
       <string-from-value-function>glade_gtk_widget_string_from_value</string-from-value-function>
+      <action-activate-function>glade_gtk_action_action_activate</action-activate-function>
+      <actions>
+        <action id="launch_editor" _name="Edit&#8230;" stock="gtk-edit" important="True"/>
+      </actions>
+
       <properties>
 	<property id="name" disabled="True"/>
 	<property id="label" translatable="True"/>
@@ -1815,6 +1820,10 @@ embedded in another object</_tooltip>
       <replace-child-function>glade_gtk_action_group_replace_child</replace-child-function>
       <read-child-function>glade_gtk_action_group_read_child</read-child-function>
       <write-child-function>glade_gtk_action_group_write_child</write-child-function>
+      <action-activate-function>glade_gtk_action_action_activate</action-activate-function>
+      <actions>
+        <action id="launch_editor" _name="Edit&#8230;" stock="gtk-edit" important="True"/>
+      </actions>
     </glade-widget-class>
 
     <glade-widget-class name="GtkEntryCompletion" generic-name="entrycompletion" _title="Entry Completion" 



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