[glade/glade-3-8] * gladeui/glade-command.[ch]: Exposed glade_command_add() internal command so that plugins can cre



commit d8cbb8a2c1515e739a0148a029021c26734506ac
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Jan 9 11:40:12 2011 +0900

    	* gladeui/glade-command.[ch]: Exposed glade_command_add() internal command so that
    	plugins can create command groups that play with adding/removing widgets inline without
    	creating copies of them.

 ChangeLog               |    4 +++
 gladeui/glade-command.c |   48 ++++++++++++++++++++++++++++++----------------
 gladeui/glade-command.h |    9 +++++++-
 3 files changed, 43 insertions(+), 18 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a40f875..7b4dc21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,10 @@
 	* gladeui/glade-widget-adaptor.c: Implemented a generic ->depends() routine
 	to ensure that liststores are serialized before treemodelfilters which refer to them (bug 657164).
 
+	* gladeui/glade-command.[ch]: Exposed glade_command_add() internal command so that
+	plugins can create command groups that play with adding/removing widgets inline without
+	creating copies of them.
+
 2011-04-29  Javier JardÃn <jjardon gnome org>
 
 	* gladeui/glade-utils.c: Correctly detect the required devhelp version
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c
index 8ec8207..c0eb9b8 100644
--- a/gladeui/glade-command.c
+++ b/gladeui/glade-command.c
@@ -973,10 +973,11 @@ get_all_parentless_reffed_widgets (GList *reffed, GladeWidget *widget)
  * while newly added widgets will prefer packing defaults.
  *
  */
-static void
-glade_command_add (GList            *widgets, 
-		   GladeWidget      *parent, 
-		   GladePlaceholder *placeholder,
+void
+glade_command_add (GList            *widgets,
+                   GladeWidget      *parent,
+                   GladePlaceholder *placeholder, 
+		   GladeProject     *project,
 		   gboolean          pasting)
 {
 	GladeCommandAddRemove	*me;
@@ -1709,7 +1710,7 @@ glade_command_clipboard_add_remove_collapse (GladeCommand *this_cmd, GladeComman
  * @adaptor:		A #GladeWidgetAdaptor
  * @parent:             the parent #GladeWidget to add the new widget to.
  * @placeholder:	the placeholder which will be substituted by the widget
- * @project:            the project his widget belongs to.
+ * @project:            the project this widget belongs to.
  *
  * Creates a new widget using @adaptor and put in place of the @placeholder
  * in the @project
@@ -1736,7 +1737,7 @@ glade_command_create(GladeWidgetAdaptor *adaptor, GladeWidget *parent, GladePlac
 	}
 	widgets = g_list_prepend(widgets, widget);
 	glade_command_push_group(_("Create %s"), widget->name);
-	glade_command_add(widgets, parent, placeholder, FALSE);
+	glade_command_add(widgets, parent, placeholder, project, FALSE);
 	glade_command_pop_group();
 
 	g_list_free(widgets);
@@ -1890,17 +1891,20 @@ glade_command_paste(GList *widgets, GladeWidget *parent, GladePlaceholder *place
 {
 	GList *list, *copied_widgets = NULL;
 	GladeWidget *copied_widget = NULL;
-/* 	GladeProject  *target_project; */
+	GladeProject  *target_project;
+	GladeWidget  *placeholder_parent = NULL;
 	gboolean exact;
 	
 	g_return_if_fail (widgets != NULL);
+
+	placeholder_parent = placeholder ? glade_placeholder_get_parent (placeholder) : NULL;
 	
-/* 	if (placeholder && GTK_IS_WINDOW (widget->object) == FALSE) */
-/* 		target_project = glade_placeholder_get_project (placeholder); */
-/* 	else if (parent && GTK_IS_WINDOW (widget->object) == FALSE) */
-/* 		target_project = glade_widget_get_project (parent); */
-/* 	else  */
-/* 		target_project = glade_app_get_project(); */
+	if (placeholder_parent && GTK_IS_WINDOW (placeholder_parent->object) == FALSE)
+		target_project = glade_placeholder_get_project (placeholder);
+	else if (parent && GTK_IS_WINDOW (parent->object) == FALSE)
+		target_project = glade_widget_get_project (parent);
+	else
+		target_project = glade_app_get_project();
 
 	for (list = widgets; list && list->data; list = list->next)
 	{
@@ -1916,8 +1920,7 @@ glade_command_paste(GList *widgets, GladeWidget *parent, GladePlaceholder *place
 	 * are not satisfied by the paste list.
 	 */
 
-
-	glade_command_add(copied_widgets, parent, placeholder, TRUE);
+	glade_command_add(copied_widgets, parent, placeholder, target_project, TRUE);
 	glade_command_pop_group();
 	
 	if (copied_widgets)
@@ -1937,15 +1940,26 @@ glade_command_paste(GList *widgets, GladeWidget *parent, GladePlaceholder *place
 void
 glade_command_dnd(GList *widgets, GladeWidget *parent, GladePlaceholder *placeholder)
 {
-	GladeWidget *widget;
+	GladeWidget  *widget;
+	GladeWidget  *placeholder_parent;
+	GladeProject *target_project;
 	
 	g_return_if_fail (widgets != NULL);
+
+	placeholder_parent = placeholder ? glade_placeholder_get_parent (placeholder) : NULL;
+	
+	if (placeholder_parent && GTK_IS_WINDOW (placeholder_parent->object) == FALSE)
+		target_project = glade_placeholder_get_project (placeholder);
+	else if (parent && GTK_IS_WINDOW (parent->object) == FALSE)
+		target_project = glade_widget_get_project (parent);
+	else
+		target_project = glade_app_get_project();
 	
 	widget = widgets->data;
 	glade_command_push_group(_("Drag-n-Drop from %s to %s"),
 				 parent->name, g_list_length (widgets) == 1 ? widget->name : _("multiple"));
 	glade_command_remove(widgets);
-	glade_command_add(widgets, parent, placeholder, TRUE);
+	glade_command_add(widgets, parent, placeholder, target_project, TRUE);
 	glade_command_pop_group();
 }
 
diff --git a/gladeui/glade-command.h b/gladeui/glade-command.h
index 405589e..55baf55 100644
--- a/gladeui/glade-command.h
+++ b/gladeui/glade-command.h
@@ -121,7 +121,14 @@ void           glade_command_lock_widget   (GladeWidget   *widget,
 
 void           glade_command_unlock_widget (GladeWidget   *widget);
 
-/************************ create/delete ******************************/
+
+/************************ create/add/delete ******************************/
+
+void           glade_command_add           (GList              *widgets,
+					    GladeWidget        *parent,
+					    GladePlaceholder   *placeholder, 
+					    GladeProject       *project,
+					    gboolean            pasting);
 
 void           glade_command_delete        (GList              *widgets);
 



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