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



commit 7562be851ec98bd37be89b09a4381985c3883443
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Thu Dec 30 23:37:01 2010 +0900

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

 ChangeLog                |    3 ++
 plugins/gtk+/glade-gtk.c |   73 ++++++++++++++++++++++++++++++++++++++++++++-
 plugins/gtk+/gtk+.xml.in |    9 ++++++
 3 files changed, 83 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index adb20ae..38a3733 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,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  Tristan Van Berkom <tristanvb openismus com>
 
 	* gladeui/glade-design-view.c: Made loading progress bar nicer looking and ellipsizing.
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 31aff06..f1df3b7 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -11889,6 +11889,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, 
@@ -11902,6 +11904,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 ---------------------------------*/
@@ -11925,6 +11930,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);
 	}
 }
 
@@ -11937,7 +11943,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");
@@ -11948,7 +11953,9 @@ 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);
 	}
 }
 
@@ -12018,3 +12025,65 @@ 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);
+
+	if (GTK_IS_CELL_RENDERER (child))
+	{
+		glade_base_editor_add_label (editor, _("Common Properties and Attributes"));
+		glade_base_editor_add_editable (editor, gchild, GLADE_PAGE_COMMON);
+	}
+}
+
+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, _("Tree View 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 2506313..333bd32 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -1975,6 +1975,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"/>
@@ -2013,6 +2018,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]