[glade3] * Another major refactor, tasks accomplished: - Removed GladeApp selection handling, only on the



commit 51f4b3f3c44e3393b1b99e238f29b1f783e1d667
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Mon Jan 3 19:09:29 2011 +0900

    	* Another major refactor, tasks accomplished:
    	  - Removed GladeApp selection handling, only on the project now
    	  - Removed "Copy" as a command, copying widgets no longer dirty documents (bug 546873)
    	  - Removed GladeApp "active_project" concept, every interaction is associated with
    	    a GladeProject
    	  - Simplified GladeClipboard, the clipboard now only has a list of widgets and
    	    not a "selection", everything is removed from the clipboard when new widgets are
    	    added there.
    	  - GladePalette now has a "project" property and does not need to be refreshed
    	    by an external entity.
    
    	19 files changed, 652 insertions(+), 1135 deletions(-)

 ChangeLog                   |   14 ++
 gladeui/glade-app.c         |  506 +------------------------------------------
 gladeui/glade-app.h         |   44 ----
 gladeui/glade-base-editor.c |  108 +++++-----
 gladeui/glade-clipboard.c   |   62 +-----
 gladeui/glade-clipboard.h   |   16 +--
 gladeui/glade-command.c     |  238 ++------------------
 gladeui/glade-command.h     |    7 +-
 gladeui/glade-inspector.c   |   10 +-
 gladeui/glade-palette.c     |  175 ++++++++++-----
 gladeui/glade-palette.h     |   22 +-
 gladeui/glade-popup.c       |  175 ++++++----------
 gladeui/glade-popup.h       |    6 +-
 gladeui/glade-project.c     |  260 +++++++++++++++++++++-
 gladeui/glade-project.h     |   25 ++-
 gladeui/glade-widget.c      |    7 +-
 plugins/gtk+/glade-gtk.c    |   26 +--
 src/glade-window.c          |   80 +++++--
 src/main.c                  |    8 +-
 19 files changed, 654 insertions(+), 1135 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f778850..37436f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,20 @@
 	* plugins/gtk+/gtk+.xml.in: Mark the "preview" action as "important" so it shows
 	  up in the app toolbar automatically.
 
+	* Another major refactor, tasks accomplished:
+	  - Removed GladeApp selection handling, only on the project now
+	  - Removed "Copy" as a command, copying widgets no longer dirty documents (bug 546873)
+	  - Removed GladeApp "active_project" concept, every interaction is associated with
+	    a GladeProject
+	  - Simplified GladeClipboard, the clipboard now only has a list of widgets and
+	    not a "selection", everything is removed from the clipboard when new widgets are
+	    added there.
+	  - GladePalette now has a "project" property and does not need to be refreshed
+	    by an external entity.
+
+	19 files changed, 652 insertions(+), 1135 deletions(-)
+
+
 2011-01-02  Tristan Van Berkom <tristanvb openismus com>
 
 	* gladeui/glade-project.c: Fixed GladeProject to only ever report widgets that are
diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c
index e8e50d8..3828ab7 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -64,7 +64,6 @@ enum
 enum
 {
   PROP_0,
-  PROP_ACTIVE_PROJECT,
   PROP_POINTER_MODE
 };
 
@@ -73,8 +72,6 @@ struct _GladeAppPrivate
   GtkWidget *window;
 
   GladePalette *palette;        /* See glade-palette */
-  GladeProject *active_project; /* Currently active project (if there is at least one
-                                 * project; then this is always valid) */
   GladeEditor *editor;          /* See glade-editor */
   GladeClipboard *clipboard;    /* See glade-clipboard */
   GList *catalogs;              /* See glade-catalog */
@@ -90,8 +87,6 @@ struct _GladeAppPrivate
   GtkAccelGroup *accel_group;   /* Default acceleration group for this app */
 
   GladePointerMode pointer_mode;        /* Current mode for the pointer in the workspace */
-
-  guint selection_changed_id;   /* for queue_selection_changed() */
 };
 
 static guint glade_app_signals[LAST_SIGNAL] = { 0 };
@@ -211,9 +206,6 @@ glade_app_set_property (GObject * object,
 {
   switch (property_id)
     {
-      case PROP_ACTIVE_PROJECT:
-        glade_app_set_project (g_value_get_object (value));
-        break;
       case PROP_POINTER_MODE:
         glade_app_set_pointer_mode (g_value_get_enum (value));
         break;
@@ -232,9 +224,6 @@ glade_app_get_property (GObject * object,
 
   switch (property_id)
     {
-      case PROP_ACTIVE_PROJECT:
-        g_value_set_object (value, app->priv->active_project);
-        break;
       case PROP_POINTER_MODE:
         g_value_set_enum (value, app->priv->pointer_mode);
         break;
@@ -443,12 +432,6 @@ glade_app_class_init (GladeAppClass * klass)
                     glade_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
 
   g_object_class_install_property
-      (object_class, PROP_ACTIVE_PROJECT,
-       g_param_spec_object
-       ("active-project", _("Active Project"),
-        _("The active project"), GLADE_TYPE_PROJECT, G_PARAM_READWRITE));
-
-  g_object_class_install_property
       (object_class, PROP_POINTER_MODE,
        g_param_spec_enum
        ("pointer-mode", _("Pointer Mode"),
@@ -461,29 +444,6 @@ glade_app_class_init (GladeAppClass * klass)
 /*****************************************************************
  *                       Public API                              *
  *****************************************************************/
-static void
-on_project_selection_changed_cb (GladeProject * project, GladeApp * app)
-{
-  GList *list;
-  gint num;
-
-  g_return_if_fail (GLADE_IS_PROJECT (project));
-  g_return_if_fail (GLADE_IS_APP (app));
-
-  /* Only update the editor if the selection has changed on
-   * the currently active project.
-   */
-  if (app->priv->editor && (project == glade_app_get_project ()))
-    {
-      list = glade_project_selection_get (project);
-      num = g_list_length (list);
-      if (num == 1 && !GLADE_IS_PLACEHOLDER (list->data))
-        glade_editor_load_widget (app->priv->editor,
-                                  glade_widget_get_from_gobject (list->data));
-      else
-        glade_editor_load_widget (app->priv->editor, NULL);
-    }
-}
 
 /**
  * glade_app_config_save
@@ -708,21 +668,6 @@ glade_app_get_clipboard (void)
   return app->priv->clipboard;
 }
 
-GladeProject *
-glade_app_get_project (void)
-{
-  GladeApp *app = glade_app_get ();
-  return app->priv->active_project;
-}
-
-GladeProject *
-glade_app_check_get_project (void)
-{
-  if (singleton_app)
-    return glade_app_get_project ();
-  return NULL;
-}
-
 GList *
 glade_app_get_projects (void)
 {
@@ -836,21 +781,10 @@ glade_app_add_project (GladeProject * project)
 
   /* If the project was previously loaded, don't re-load */
   if (g_list_find (app->priv->projects, project) != NULL)
-    {
-      glade_app_set_project (project);
-      return;
-    }
+    return;
 
   /* Take a reference for GladeApp here... */
-  app->priv->projects = g_list_append (app->priv->projects,
-                                       g_object_ref (project));
-
-  /* connect to the project signals so that the editor can be updated */
-  g_signal_connect (G_OBJECT (project), "selection_changed",
-                    G_CALLBACK (on_project_selection_changed_cb), app);
-
-
-  glade_app_set_project (project);
+  app->priv->projects = g_list_append (app->priv->projects, g_object_ref (project));
 
   /* Select the first window in the project */
   if (g_list_length (app->priv->projects) == 1 ||
@@ -877,7 +811,6 @@ glade_app_add_project (GladeProject * project)
   /* XXX I think the palette & editor should detect this by itself */
   gtk_widget_set_sensitive (GTK_WIDGET (app->priv->palette), TRUE);
   gtk_widget_set_sensitive (GTK_WIDGET (app->priv->editor), TRUE);
-
 }
 
 void
@@ -890,10 +823,6 @@ glade_app_remove_project (GladeProject * project)
 
   app->priv->projects = g_list_remove (app->priv->projects, project);
 
-  /* this is needed to prevent clearing the selection of a closed project 
-   */
-  app->priv->active_project = NULL;
-
   /* If no more projects */
   if (app->priv->projects == NULL)
     {
@@ -906,8 +835,6 @@ glade_app_remove_project (GladeProject * project)
       glade_editor_load_widget (app->priv->editor, NULL);
       gtk_widget_set_sensitive (GTK_WIDGET (app->priv->editor), FALSE);
     }
-  else
-    glade_app_set_project (g_list_last (app->priv->projects)->data);
 
   /* Its safe to just release the project as the project emits a
    * "close" signal and everyone is responsable for cleaning up at
@@ -916,46 +843,6 @@ glade_app_remove_project (GladeProject * project)
   g_object_unref (project);
 }
 
-
-/**
- * glade_app_set_project:
- * @project: A #GladeProject
- *
- * Sets the active project in the #GladeApp to @project.
- */
-void
-glade_app_set_project (GladeProject * project)
-{
-  GladeApp *app = glade_app_get ();
-
-  g_return_if_fail (GLADE_IS_PROJECT (project));
-
-  if (app->priv->active_project == project)
-    return;
-
-  if (!g_list_find (app->priv->projects, project))
-    {
-      g_warning ("Could not set project because it could not "
-                 " be found in the app->priv->project list\n");
-      return;
-    }
-
-  /* clear the selection in the previous project */
-  if (app->priv->active_project)
-    glade_project_selection_clear (app->priv->active_project, FALSE);
-
-  app->priv->active_project = project;
-
-  /* (XXX really ?) trigger the selection changed signal to update the editor */
-  glade_project_selection_changed (project);
-
-  /* refresh palette for active project */
-  glade_palette_refresh (glade_app_get_palette ());
-
-  g_object_notify (G_OBJECT (app), "active-project");
-}
-
-
 /**
  * glade_app_set_pointer_mode:
  * @mode: A #GladePointerMode
@@ -988,272 +875,6 @@ glade_app_get_pointer_mode (void)
   return app->priv->pointer_mode;
 }
 
-/**
- * glade_app_command_copy:
- * @app: A #GladeApp
- *
- * Copy the active project's selection (the new copies
- * will end up on the clipboard and will be set as
- * the clipboards selection).
- */
-void
-glade_app_command_copy (void)
-{
-  GladeApp *app;
-  GList *widgets = NULL, *list;
-  GladeWidget *widget;
-  gboolean failed = FALSE;
-
-  app = glade_app_get ();
-  if (app->priv->active_project == NULL ||
-      glade_project_is_loading (app->priv->active_project))
-    return;
-
-  for (list = glade_app_get_selection (); list && list->data; list = list->next)
-    {
-      widget = glade_widget_get_from_gobject (list->data);
-      widgets = g_list_prepend (widgets, widget);
-    }
-
-  if (failed == FALSE && widgets != NULL)
-    glade_command_copy (widgets);
-  else if (widgets == NULL)
-    glade_util_ui_message (glade_app_get_window (),
-                           GLADE_UI_INFO, NULL, _("No widget selected."));
-
-  if (widgets)
-    g_list_free (widgets);
-
-}
-
-/**
- * glade_app_command_cut:
- * @app: A #GladeApp
- *
- * Cut the active project's selection (the cut objects
- * will end up on the clipboard and will be set as
- * the clipboards selection).
- */
-void
-glade_app_command_cut (void)
-{
-  GladeApp *app;
-  GList *widgets = NULL, *list;
-  GladeWidget *widget;
-  gboolean failed = FALSE;
-
-  app = glade_app_get ();
-  if (app->priv->active_project == NULL ||
-      glade_project_is_loading (app->priv->active_project))
-    return;
-
-  for (list = glade_app_get_selection (); list && list->data; list = list->next)
-    {
-      widget = glade_widget_get_from_gobject (list->data);
-      widgets = g_list_prepend (widgets, widget);
-    }
-
-  if (failed == FALSE && widgets != NULL)
-    glade_command_cut (widgets);
-  else if (widgets == NULL)
-    glade_util_ui_message (glade_app_get_window (),
-                           GLADE_UI_INFO, NULL, _("No widget selected."));
-
-  if (widgets)
-    g_list_free (widgets);
-
-}
-
-/**
- * glade_app_command_paste:
- * @placeholder: A #GladePlaceholder
- *
- * Paste the clipboard selection to the active project's 
- * selection (the project must have only one object selected).
- */
-void
-glade_app_command_paste (GladePlaceholder * placeholder)
-{
-  GladeApp *app;
-  GladeClipboard *clipboard;
-  GList *list;
-  GladeWidget *widget = NULL, *parent;
-  gint placeholder_relations = 0;
-  GladeFixed *fixed = NULL;
-
-  app = glade_app_get ();
-  if (app->priv->active_project == NULL ||
-      glade_project_is_loading (app->priv->active_project))
-    return;
-
-  if (placeholder)
-    {
-      if (glade_placeholder_get_project (placeholder) == NULL ||
-          glade_project_is_loading (glade_placeholder_get_project (placeholder)))
-        return;
-    }
-
-  list = glade_project_selection_get (app->priv->active_project);
-  clipboard = glade_app_get_clipboard ();
-
-  /* If there is a selection, paste in to the selected widget, otherwise
-   * paste into the placeholder's parent, or at the toplevel
-   */
-  parent = list ? glade_widget_get_from_gobject (list->data) :
-      (placeholder) ? glade_placeholder_get_parent (placeholder) : NULL;
-
-  widget = clipboard->selection ? clipboard->selection->data : NULL;
-
-  /* Ignore parent argument if we are pasting a toplevel
-   */
-  if (g_list_length (clipboard->selection) == 1 &&
-      widget && GWA_IS_TOPLEVEL (glade_widget_get_adaptor (widget)))
-    parent = NULL;
-
-  if (parent && GLADE_IS_FIXED (parent))
-    fixed = GLADE_FIXED (parent);
-
-  /* Check if parent is actually a container of any sort */
-  if (parent && !glade_widget_adaptor_is_container (glade_widget_get_adaptor (parent)))
-    {
-      glade_util_ui_message (glade_app_get_window (),
-                             GLADE_UI_INFO, NULL,
-                             _("Unable to paste to the selected parent"));
-      return;
-    }
-
-  /* Check if selection is good */
-  if ((list = glade_app_get_selection ()) != NULL)
-    {
-      if (g_list_length (list) != 1)
-        {
-          glade_util_ui_message (glade_app_get_window (),
-                                 GLADE_UI_INFO, NULL,
-                                 _("Unable to paste to multiple widgets"));
-
-          return;
-        }
-
-    }
-
-  /* Abort operation when adding a non scrollable widget to any kind of GtkScrolledWindow. */
-  if (parent && widget &&
-      glade_util_check_and_warn_scrollable (parent, glade_widget_get_adaptor (widget),
-                                            glade_app_get_window ()))
-    return;
-
-  /* Check if we have anything to paste */
-  if (g_list_length (clipboard->selection) == 0)
-    {
-      glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL,
-                             _("No widget selected on the clipboard"));
-
-      return;
-    }
-
-  /* Check that we have compatible heirarchies */
-  for (list = clipboard->selection; list && list->data; list = list->next)
-    {
-      widget = list->data;
-
-      if (!GWA_IS_TOPLEVEL (glade_widget_get_adaptor (widget)) && parent)
-        {
-          /* Count placeholder relations
-           */
-          if (glade_widget_placeholder_relation (parent, widget))
-            placeholder_relations++;
-        }
-    }
-
-  g_assert (widget);
-
-  /* A GladeFixed that doesnt use placeholders can only paste one
-   * at a time
-   */
-  if (GTK_IS_WIDGET (glade_widget_get_object (widget)) &&
-      parent && fixed && 
-      !GWA_USE_PLACEHOLDERS (glade_widget_get_adaptor (parent)) &&
-      g_list_length (clipboard->selection) != 1)
-    {
-      glade_util_ui_message (glade_app_get_window (),
-                             GLADE_UI_INFO, NULL,
-                             _("Only one widget can be pasted at a "
-                               "time to this container"));
-      return;
-    }
-
-  /* Check that enough placeholders are available */
-  if (parent &&
-      GWA_USE_PLACEHOLDERS (glade_widget_get_adaptor (parent)) &&
-      glade_util_count_placeholders (parent) < placeholder_relations)
-    {
-      glade_util_ui_message (glade_app_get_window (),
-                             GLADE_UI_INFO, NULL,
-                             _("Insufficient amount of placeholders in "
-                               "target container"));
-      return;
-    }
-
-  glade_command_paste (clipboard->selection, parent, placeholder);
-}
-
-
-/**
- * glade_app_command_delete:
- *
- * Delete the active project's selection.
- */
-void
-glade_app_command_delete (void)
-{
-  GladeApp *app;
-  GList *widgets = NULL, *list;
-  GladeWidget *widget;
-  gboolean failed = FALSE;
-
-  app = glade_app_get ();
-  if (app->priv->active_project == NULL ||
-      glade_project_is_loading (app->priv->active_project))
-    return;
-
-  for (list = glade_app_get_selection (); list && list->data; list = list->next)
-    {
-      widget = glade_widget_get_from_gobject (list->data);
-      widgets = g_list_prepend (widgets, widget);
-    }
-
-  if (failed == FALSE && widgets != NULL)
-    glade_command_delete (widgets);
-  else if (widgets == NULL)
-    glade_util_ui_message (glade_app_get_window (),
-                           GLADE_UI_INFO, NULL, _("No widget selected."));
-
-  if (widgets)
-    g_list_free (widgets);
-}
-
-/**
- * glade_app_command_delete_clipboard:
- *
- * Delete the clipboard's selection.
- */
-void
-glade_app_command_delete_clipboard (void)
-{
-  GladeClipboard *clipboard;
-
-  clipboard = glade_app_get_clipboard ();
-
-  if (clipboard->selection == NULL)
-    {
-      glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL,
-                             _("No widget selected on the clipboard"));
-      return;
-    }
-
-  glade_command_delete (clipboard->selection);
-}
-
 /*
  * glade_app_set_accel_group:
  *
@@ -1278,129 +899,6 @@ glade_app_get_accel_group (void)
   return glade_app_get ()->priv->accel_group;
 }
 
-GList *
-glade_app_get_selection (void)
-{
-  GList *selection = NULL, *list;
-  GladeProject *project;
-
-  for (list = glade_app_get_projects (); list && list->data; list = list->next)
-    {
-      /* Only one project may have selection at a time
-       */
-      project = list->data;
-      if (glade_project_selection_get (project))
-        {
-          selection = glade_project_selection_get (project);
-          break;
-        }
-    }
-  return selection;
-}
-
-
-gboolean
-glade_app_is_selected (GObject * object)
-{
-  return (g_list_find (glade_app_get_selection (), object) != NULL);
-}
-
-void
-glade_app_selection_set (GObject * object, gboolean emit_signal)
-{
-  GList *list;
-  GladeProject *project;
-
-  for (list = glade_app_get_projects (); list && list->data; list = list->next)
-    {
-      project = list->data;
-      if (glade_project_has_object (project, object))
-        glade_project_selection_set (project, object, emit_signal);
-      else
-        glade_project_selection_clear (project, emit_signal);
-    }
-
-  /* Instead of calling selection_set after all
-   * the selection_clear calls (lazy).
-   */
-  if (GTK_IS_WIDGET (object))
-    glade_util_add_selection (GTK_WIDGET (object));
-}
-
-void
-glade_app_selection_add (GObject * object, gboolean emit_signal)
-{
-  GList *list;
-  GladeWidget *widget = glade_widget_get_from_gobject (object), *selected;
-  GladeProject *project = glade_widget_get_project (widget);
-
-  /* Ignore request if the there is a selection 
-   * from another project.
-   */
-  if ((list = glade_app_get_selection ()) != NULL)
-    {
-      selected = glade_widget_get_from_gobject (list->data);
-      if (glade_widget_get_project (selected) != project)
-        return;
-    }
-  glade_project_selection_add (project, object, emit_signal);
-}
-
-void
-glade_app_selection_remove (GObject * object, gboolean emit_signal)
-{
-  GladeWidget *widget = glade_widget_get_from_gobject (object);
-  GladeProject *project = glade_widget_get_project (widget);;
-
-  glade_project_selection_remove (project, object, emit_signal);
-}
-
-void
-glade_app_selection_clear (gboolean emit_signal)
-{
-  GList *list;
-  GladeProject *project;
-
-  glade_util_clear_selection ();
-  for (list = glade_app_get_projects (); list && list->data; list = list->next)
-    {
-      project = list->data;
-      glade_project_selection_clear (project, emit_signal);
-    }
-}
-
-void
-glade_app_selection_changed (void)
-{
-  GList *list;
-  GladeProject *project;
-
-  for (list = glade_app_get_projects (); list && list->data; list = list->next)
-    {
-      project = list->data;
-      glade_project_selection_changed (project);
-    }
-}
-
-static gboolean
-selection_change_idle (GladeApp * app)
-{
-  glade_app_selection_changed ();
-  app->priv->selection_changed_id = 0;
-  return FALSE;
-}
-
-void
-glade_app_queue_selection_changed (void)
-{
-  GladeApp *app = glade_app_get ();
-
-  if (app->priv->selection_changed_id == 0)
-    app->priv->selection_changed_id =
-        g_idle_add ((GSourceFunc) selection_change_idle, app);
-}
-
-
 GladeApp *
 glade_app_new (void)
 {
diff --git a/gladeui/glade-app.h b/gladeui/glade-app.h
index 5ffed38..1732ef0 100644
--- a/gladeui/glade-app.h
+++ b/gladeui/glade-app.h
@@ -108,12 +108,6 @@ GladePalette*      glade_app_get_palette (void);
 
 GladeClipboard*    glade_app_get_clipboard (void);
 
-GladeProject*      glade_app_get_project (void);
-
-GladeProject*      glade_app_check_get_project (void);
- 
-void               glade_app_set_project (GladeProject *project);
-
 GladePointerMode   glade_app_get_pointer_mode (void);
  
 void               glade_app_set_pointer_mode (GladePointerMode mode);
@@ -133,22 +127,6 @@ GladeProject*      glade_app_get_project_by_path (const gchar *project_path);
 void               glade_app_show_properties (gboolean raise);
  
 void               glade_app_hide_properties (void);
-
- 
-void               glade_app_command_copy (void);
- 
-void               glade_app_command_cut (void);
- 
-void               glade_app_command_paste (GladePlaceholder *placeholder);
- 
-void               glade_app_command_delete (void);
-
-void               glade_app_command_delete_clipboard (void);
- 
-void               glade_app_command_undo (void);
- 
-void               glade_app_command_redo (void);
-
  
 gint               glade_app_config_save (void);
  
@@ -162,28 +140,6 @@ GtkAccelGroup     *glade_app_get_accel_group (void);
 
 GList             *glade_app_get_selection (void);
 
-
-/* These handle selection on a global scope and take care
- * of multiple project logic.
- */
- 
-gboolean           glade_app_is_selected       (GObject  *object);
- 
-void               glade_app_selection_set     (GObject  *object,
-					        gboolean  emit_signal);
- 
-void               glade_app_selection_add     (GObject  *object,
-					        gboolean  emit_signal);
- 
-void               glade_app_selection_remove  (GObject  *object,
-					        gboolean  emit_signal);
- 
-void               glade_app_selection_clear   (gboolean  emit_signal);
- 
-void               glade_app_selection_changed (void);
-
-void               glade_app_queue_selection_changed (void);
-
 /* package paths */
 
 const gchar       *glade_app_get_catalogs_dir  (void) G_GNUC_CONST;
diff --git a/gladeui/glade-base-editor.c b/gladeui/glade-base-editor.c
index 90bdabc..8fa9397 100644
--- a/gladeui/glade-base-editor.c
+++ b/gladeui/glade-base-editor.c
@@ -1457,17 +1457,17 @@ glade_base_editor_class_init (GladeBaseEditorClass * klass)
                                     ("The container object this editor is currently editing"),
                                     G_TYPE_OBJECT, G_PARAM_READWRITE));
 
-        /**
-	 * GladeBaseEditor::child-selected:
-	 * @gladebaseeditor: the #GladeBaseEditor which received the signal.
-	 * @gchild: the selected #GladeWidget.
-	 *
-	 * Emited when the user selects a child in the editor's treeview.
-	 * You can add the relevant child properties here using 
-	 * glade_base_editor_add_default_properties() and glade_base_editor_add_properties() 
-	 * You can also add labels with glade_base_editor_add_label to make the
-	 * editor look pretty.
-	 */
+  /**
+   * GladeBaseEditor::child-selected:
+   * @gladebaseeditor: the #GladeBaseEditor which received the signal.
+   * @gchild: the selected #GladeWidget.
+   *
+   * Emited when the user selects a child in the editor's treeview.
+   * You can add the relevant child properties here using 
+   * glade_base_editor_add_default_properties() and glade_base_editor_add_properties() 
+   * You can also add labels with glade_base_editor_add_label to make the
+   * editor look pretty.
+   */
   glade_base_editor_signals[SIGNAL_CHILD_SELECTED] =
       g_signal_new ("child-selected",
                     G_TYPE_FROM_CLASS (object_class),
@@ -1476,14 +1476,14 @@ glade_base_editor_class_init (GladeBaseEditorClass * klass)
                     NULL, NULL,
                     glade_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT);
 
-        /**
-	 * GladeBaseEditor::child-change-type:
-	 * @gladebaseeditor: the #GladeBaseEditor which received the signal.
-	 * @child: the #GObject being changed.
-         * @type: the new type for @child.
-	 *
-	 * Returns: TRUE to stop signal emision.
-	 */
+  /**
+   * GladeBaseEditor::child-change-type:
+   * @gladebaseeditor: the #GladeBaseEditor which received the signal.
+   * @child: the #GObject being changed.
+   * @type: the new type for @child.
+   *
+   * Returns: TRUE to stop signal emision.
+   */
   glade_base_editor_signals[SIGNAL_CHANGE_TYPE] =
       g_signal_new ("change-type",
                     G_TYPE_FROM_CLASS (object_class),
@@ -1493,14 +1493,14 @@ glade_base_editor_class_init (GladeBaseEditorClass * klass)
                     glade_marshal_BOOLEAN__OBJECT_UINT,
                     G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT, G_TYPE_UINT);
 
-        /**
-	 * GladeBaseEditor::get-display-name:
-	 * @gladebaseeditor: the #GladeBaseEditor which received the signal.
-	 * @gchild: the child to get display name string to show in @gladebaseeditor
-	 * treeview.
-	 *
-	 * Returns: a newly allocated string.
-	 */
+  /**
+   * GladeBaseEditor::get-display-name:
+   * @gladebaseeditor: the #GladeBaseEditor which received the signal.
+   * @gchild: the child to get display name string to show in @gladebaseeditor
+   * treeview.
+   *
+   * Returns: a newly allocated string.
+   */
   glade_base_editor_signals[SIGNAL_GET_DISPLAY_NAME] =
       g_signal_new ("get-display-name",
                     G_TYPE_FROM_CLASS (object_class),
@@ -1510,17 +1510,17 @@ glade_base_editor_class_init (GladeBaseEditorClass * klass)
                     glade_marshal_STRING__OBJECT,
                     G_TYPE_STRING, 1, G_TYPE_OBJECT);
 
-        /**
-	 * GladeBaseEditor::build-child:
-	 * @gladebaseeditor: the #GladeBaseEditor which received the signal.
-	 * @gparent: the parent of the new child
-	 * @type: the #GType of the child
-	 *
-	 * Create a child widget here if something else must be done other than
-	 * calling glade_command_create() such as creating an intermediate parent.
-	 *
-	 * Returns: the newly created #GladeWidget or NULL if child cant be created
-	 */
+  /**
+   * GladeBaseEditor::build-child:
+   * @gladebaseeditor: the #GladeBaseEditor which received the signal.
+   * @gparent: the parent of the new child
+   * @type: the #GType of the child
+   *
+   * Create a child widget here if something else must be done other than
+   * calling glade_command_create() such as creating an intermediate parent.
+   *
+   * Returns: the newly created #GladeWidget or NULL if child cant be created
+   */
   glade_base_editor_signals[SIGNAL_BUILD_CHILD] =
       g_signal_new ("build-child",
                     G_TYPE_FROM_CLASS (object_class),
@@ -1530,12 +1530,12 @@ glade_base_editor_class_init (GladeBaseEditorClass * klass)
                     glade_marshal_OBJECT__OBJECT_UINT,
                     G_TYPE_OBJECT, 2, G_TYPE_OBJECT, G_TYPE_UINT);
 
-        /**
-	 * GladeBaseEditor::delete-child:
-	 * @gladebaseeditor: the #GladeBaseEditor which received the signal.
-	 * @gparent: the parent
-	 * @gchild: the child to delete
-	 */
+  /**
+   * GladeBaseEditor::delete-child:
+   * @gladebaseeditor: the #GladeBaseEditor which received the signal.
+   * @gparent: the parent
+   * @gchild: the child to delete
+   */
   glade_base_editor_signals[SIGNAL_DELETE_CHILD] =
       g_signal_new ("delete-child",
                     G_TYPE_FROM_CLASS (object_class),
@@ -1545,16 +1545,16 @@ glade_base_editor_class_init (GladeBaseEditorClass * klass)
                     glade_marshal_BOOLEAN__OBJECT_OBJECT,
                     G_TYPE_BOOLEAN, 2, G_TYPE_OBJECT, G_TYPE_OBJECT);
 
-        /**
-	 * GladeBaseEditor::move-child:
-	 * @gladebaseeditor: the #GladeBaseEditor which received the signal.
-	 * @gparent: the new parent of @gchild
-	 * @gchild: the #GladeWidget to move
-	 *
-	 * Move child here if something else must be done other than cut & paste.
-	 *
-	 * Returns: wheater child has been sucessfully moved or not.
-	 */
+  /**
+   * GladeBaseEditor::move-child:
+   * @gladebaseeditor: the #GladeBaseEditor which received the signal.
+   * @gparent: the new parent of @gchild
+   * @gchild: the #GladeWidget to move
+   *
+   * Move child here if something else must be done other than cut & paste.
+   *
+   * Returns: wheater child has been sucessfully moved or not.
+   */
   glade_base_editor_signals[SIGNAL_MOVE_CHILD] =
       g_signal_new ("move-child",
                     G_TYPE_FROM_CLASS (object_class),
diff --git a/gladeui/glade-clipboard.c b/gladeui/glade-clipboard.c
index 4df38fc..a9731c8 100644
--- a/gladeui/glade-clipboard.c
+++ b/gladeui/glade-clipboard.c
@@ -85,7 +85,6 @@ static void
 glade_clipboard_init (GladeClipboard * clipboard)
 {
   clipboard->widgets = NULL;
-  clipboard->selection = NULL;
   clipboard->has_selection = FALSE;
 }
 
@@ -168,10 +167,7 @@ glade_clipboard_add (GladeClipboard * clipboard, GList * widgets)
   GladeWidget *widget;
   GList *list;
 
-  /*
-   * Clear selection for the new widgets.
-   */
-  glade_clipboard_selection_clear (clipboard);
+  glade_clipboard_clear (clipboard);
 
   /*
    * Add the widgets to the list of children.
@@ -180,73 +176,33 @@ glade_clipboard_add (GladeClipboard * clipboard, GList * widgets)
     {
       widget = list->data;
       clipboard->widgets =
-          g_list_prepend (clipboard->widgets, g_object_ref (G_OBJECT (widget)));
-
-      glade_clipboard_selection_add (clipboard, widget);
+          g_list_prepend (clipboard->widgets, g_object_ref_sink (G_OBJECT (widget)));
     }
 
+  glade_clipboard_set_has_selection (clipboard, TRUE);
 }
 
 /**
- * glade_clipboard_remove:
+ * glade_clipboard_clear:
  * @clipboard: a #GladeClipboard
- * @widgets: a #GList of #GladeWidgets
  * 
- * Removes @widgets from @clipboard.
+ * Removes all widgets from the @clipboard.
  */
 void
-glade_clipboard_remove (GladeClipboard * clipboard, GList * widgets)
+glade_clipboard_clear (GladeClipboard * clipboard)
 {
   GladeWidget *widget;
   GList *list;
 
-  for (list = widgets; list && list->data; list = list->next)
+  for (list = clipboard->widgets; list && list->data; list = list->next)
     {
       widget = list->data;
 
-      clipboard->widgets = g_list_remove (clipboard->widgets, widget);
-      glade_clipboard_selection_remove (clipboard, widget);
-
       g_object_unref (G_OBJECT (widget));
     }
 
-  /* 
-   * Only default selection if nescisary
-   */
-  if ((g_list_length (clipboard->selection) < 1) &&
-      (list = g_list_first (clipboard->widgets)) != NULL)
-    {
-      glade_clipboard_selection_add (clipboard, GLADE_WIDGET (list->data));
-    }
-}
-
-void
-glade_clipboard_selection_add (GladeClipboard * clipboard, GladeWidget * widget)
-{
-  g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
-  g_return_if_fail (GLADE_IS_WIDGET (widget));
-  clipboard->selection = g_list_prepend (clipboard->selection, widget);
-
-  glade_clipboard_set_has_selection (clipboard, TRUE);
-}
-
-void
-glade_clipboard_selection_remove (GladeClipboard * clipboard,
-                                  GladeWidget * widget)
-{
-  g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
-  g_return_if_fail (GLADE_IS_WIDGET (widget));
-  clipboard->selection = g_list_remove (clipboard->selection, widget);
-
-  if (g_list_length (clipboard->selection) == 0)
-    glade_clipboard_set_has_selection (clipboard, FALSE);
-}
-
-void
-glade_clipboard_selection_clear (GladeClipboard * clipboard)
-{
-  g_return_if_fail (GLADE_IS_CLIPBOARD (clipboard));
-  clipboard->selection = (g_list_free (clipboard->selection), NULL);
+  clipboard->widgets = 
+    (g_list_free (clipboard->widgets), NULL);
 
   glade_clipboard_set_has_selection (clipboard, FALSE);
 }
diff --git a/gladeui/glade-clipboard.h b/gladeui/glade-clipboard.h
index ec39102..329d9fe 100644
--- a/gladeui/glade-clipboard.h
+++ b/gladeui/glade-clipboard.h
@@ -16,8 +16,7 @@ struct _GladeClipboard
 {
 	GObject    parent_instance;
 
-	GList     *widgets;     /* A list of GladeWidget's on the clipboard */
-	GList     *selection;   /* Selection list of GladeWidget's */
+	GList     *widgets;       /* A list of GladeWidget's on the clipboard */
 	gboolean   has_selection; /* TRUE if clipboard has selection */
 };
 
@@ -27,7 +26,6 @@ struct _GladeClipboardClass
 };
 
 
-
 GType           glade_clipboard_get_type         (void);
 
 GladeClipboard *glade_clipboard_new              (void);
@@ -35,20 +33,10 @@ GladeClipboard *glade_clipboard_new              (void);
 void            glade_clipboard_add              (GladeClipboard *clipboard, 
 						  GList          *widgets);
 
-void            glade_clipboard_remove           (GladeClipboard *clipboard, 
-						  GList          *widgets);
-
-void            glade_clipboard_selection_add    (GladeClipboard *clipboard, 
-						  GladeWidget    *widget);
-
-void            glade_clipboard_selection_remove (GladeClipboard *clipboard, 
-						  GladeWidget    *widget);
-
-void            glade_clipboard_selection_clear  (GladeClipboard *clipboard);
+void            glade_clipboard_clear            (GladeClipboard *clipboard);
 
 gboolean        glade_clipboard_get_has_selection  (GladeClipboard *clipboard);
 
-
 G_END_DECLS
 
 #endif				/* __GLADE_CLIPBOARD_H__ */
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c
index 4ab639a..7a64824 100644
--- a/gladeui/glade-command.c
+++ b/gladeui/glade-command.c
@@ -969,9 +969,11 @@ get_all_parentless_reffed_widgets (GList * reffed, GladeWidget * widget)
  *
  */
 static void
-glade_command_add (GList * widgets,
-                   GladeWidget * parent,
-                   GladePlaceholder * placeholder, gboolean pasting)
+glade_command_add (GList            *widgets,
+                   GladeWidget      *parent,
+                   GladePlaceholder *placeholder, 
+		   GladeProject     *project,
+		   gboolean          pasting)
 {
   GladeCommandAddRemove *me;
   GladeCommand *cmd;
@@ -999,7 +1001,7 @@ glade_command_add (GList * widgets,
   if (placeholder && GWA_IS_TOPLEVEL (adaptor) == FALSE)
     cmd->project = glade_placeholder_get_project (placeholder);
   else
-    cmd->project = glade_app_get_project ();
+    cmd->project = project;
 
   GLADE_COMMAND (me)->description =
       g_strdup_printf (_("Add %s"), g_list_length (widgets) == 1 ?
@@ -1268,10 +1270,7 @@ glade_command_add_execute (GladeCommandAddRemove * me)
 
   if (me->widgets)
     {
-      /* XXX FIXME: Selection here should be specific to the project
-       * related to this command
-       */
-      glade_app_selection_clear (FALSE);
+      glade_project_selection_clear (GLADE_COMMAND (me)->project, FALSE);
 
       for (list = me->widgets; list && list->data; list = list->next)
         {
@@ -1387,11 +1386,13 @@ glade_command_add_execute (GladeCommandAddRemove * me)
                                         glade_widget_get_object (reffed));
             }
 
-          glade_app_selection_add (glade_widget_get_object (cdata->widget), FALSE);
+	  glade_project_selection_add (GLADE_COMMAND (me)->project, 
+				       glade_widget_get_object (cdata->widget), FALSE);
 
           glade_widget_show (cdata->widget);
         }
-      glade_app_queue_selection_changed ();
+
+      glade_project_queue_selection_changed (GLADE_COMMAND (me)->project);
     }
   return TRUE;
 }                               /* end of glade_command_add_execute() */
@@ -1508,177 +1509,6 @@ glade_command_add_remove_collapse (GladeCommand * this_cmd,
 
 /******************************************************************************
  * 
- * clipboard_add/clipboard_remove
- * 
- * These canonical commands add/remove a widget list to/from the clipboard.
- * 
- *****************************************************************************/
-
-typedef struct
-{
-  GladeCommand parent;
-  GList *widgets;
-  gboolean add;
-} GladeCommandClipboardAddRemove;
-
-
-GLADE_MAKE_COMMAND (GladeCommandClipboardAddRemove,
-                    glade_command_clipboard_add_remove);
-#define GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE			(glade_command_clipboard_add_remove_get_type ())
-#define GLADE_COMMAND_CLIPBOARD_ADD_REMOVE(o)	  		(G_TYPE_CHECK_INSTANCE_CAST ((o), GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE, GladeCommandClipboardAddRemove))
-#define GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST ((k), GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE, GladeCommandClipboardAddRemoveClass))
-#define GLADE_IS_COMMAND_CLIPBOARD_ADD_REMOVE(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE))
-#define GLADE_IS_COMMAND_CLIPBOARD_ADD_REMOVE_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE))
-
-static void
-glade_command_clipboard_add_remove_common (GList * widgets, gboolean add)
-{
-  GladeCommandClipboardAddRemove *me;
-  GladeWidget *widget = NULL;
-  GList *list;
-
-  g_return_if_fail (widgets && widgets->data);
-
-  me = g_object_new (GLADE_COMMAND_CLIPBOARD_ADD_REMOVE_TYPE, NULL);
-  for (list = widgets; list && list->data; list = list->next)
-    {
-      widget = g_object_ref (G_OBJECT (list->data));
-      me->widgets = g_list_prepend (me->widgets, widget);
-    }
-  me->add = add;
-  if (add)
-    {
-      if (g_list_length (widgets) == 1)
-        GLADE_COMMAND (me)->description =
-	  g_strdup_printf (_("Clipboard add %s"), glade_widget_get_name (widget));
-      else
-        GLADE_COMMAND (me)->description = g_strdup (_("Clipboard add multiple"));
-    }
-  else
-    {
-      if (g_list_length (widgets) == 1)
-        GLADE_COMMAND (me)->description =
-	  g_strdup_printf (_("Clipboard remove %s"), glade_widget_get_name (widget));
-      else
-        GLADE_COMMAND (me)->description = g_strdup (_("Clipboard remove multiple"));
-    }
-
-  glade_command_check_group (GLADE_COMMAND (me));
-
-  if (glade_command_clipboard_add_remove_execute (GLADE_COMMAND (me)))
-    {
-      glade_project_push_undo (glade_app_get_project (), GLADE_COMMAND (me));
-    }
-  else
-    {
-      g_object_unref (G_OBJECT (me));
-    }
-}
-
-/**
- * glade_command_clipboard_add:
- * @widgets: a #GList
- *
- * Performs an add command on all widgets in @widgets to the clipboard.
- */
-static void
-glade_command_clipboard_add (GList * widgets)
-{
-  glade_command_clipboard_add_remove_common (widgets, TRUE);
-}
-
-static gboolean
-glade_command_clipboard_add_execute (GladeCommandClipboardAddRemove * me)
-{
-  GList *list, *widgets = NULL;
-
-  for (list = me->widgets; list && list->data; list = list->next)
-    {
-      widgets = g_list_prepend (widgets, list->data);
-    }
-  if (widgets)
-    {
-      glade_clipboard_add (glade_app_get_clipboard (), widgets);
-      g_list_free (widgets);
-    }
-
-  return TRUE;
-}
-
-static gboolean
-glade_command_clipboard_remove_execute (GladeCommandClipboardAddRemove * me)
-{
-  GList *list, *widgets = NULL;
-
-  for (list = me->widgets; list && list->data; list = list->next)
-    {
-      widgets = g_list_prepend (widgets, list->data);
-    }
-  if (widgets)
-    {
-      glade_clipboard_remove (glade_app_get_clipboard (), widgets);
-      g_list_free (widgets);
-    }
-
-  return TRUE;
-}
-
-static gboolean
-glade_command_clipboard_add_remove_execute (GladeCommand * cmd)
-{
-  GladeCommandClipboardAddRemove *me = (GladeCommandClipboardAddRemove *) cmd;
-  gboolean retval;
-
-  if (me->add)
-    retval = glade_command_clipboard_add_execute (me);
-  else
-    retval = glade_command_clipboard_remove_execute (me);
-
-  me->add = !me->add;
-
-  return retval;
-}
-
-static gboolean
-glade_command_clipboard_add_remove_undo (GladeCommand * cmd)
-{
-  return glade_command_clipboard_add_remove_execute (cmd);
-}
-
-static void
-glade_command_clipboard_add_remove_finalize (GObject * obj)
-{
-  GladeCommandClipboardAddRemove *cmd;
-  GList *list;
-
-  g_return_if_fail (GLADE_IS_COMMAND_CLIPBOARD_ADD_REMOVE (obj));
-
-  cmd = GLADE_COMMAND_CLIPBOARD_ADD_REMOVE (obj);
-
-  for (list = cmd->widgets; list && list->data; list = list->next)
-    if (list->data)
-      g_object_unref (G_OBJECT (list->data));
-  g_list_free (cmd->widgets);
-
-  glade_command_finalize (obj);
-}
-
-static gboolean
-glade_command_clipboard_add_remove_unifies (GladeCommand * this_cmd,
-                                            GladeCommand * other_cmd)
-{
-  return FALSE;
-}
-
-static void
-glade_command_clipboard_add_remove_collapse (GladeCommand * this_cmd,
-                                             GladeCommand * other_cmd)
-{
-  g_return_if_reached ();
-}
-
-/******************************************************************************
- * 
  * The following are command aliases.  Their implementations are the actual 
  * glade commands.
  * 
@@ -1716,7 +1546,7 @@ glade_command_create (GladeWidgetAdaptor * adaptor, GladeWidget * parent,
     }
   widgets = g_list_prepend (widgets, widget);
   glade_command_push_group (_("Create %s"), glade_widget_get_name (widget));
-  glade_command_add (widgets, parent, placeholder, FALSE);
+  glade_command_add (widgets, parent, placeholder, project, FALSE);
   glade_command_pop_group ();
 
   g_list_free (widgets);
@@ -1768,37 +1598,9 @@ glade_command_cut (GList * widgets)
                             g_list_length (widgets) == 1 ? 
 			    glade_widget_get_name (widget) : _("multiple"));
   glade_command_remove (widgets);
-  glade_command_clipboard_add (widgets);
-  glade_command_pop_group ();
-}
-
-/**
- * glade_command_copy:
- * @widgets: a #GList of #GladeWidgets
- *
- * Copies the list of widgets and adds them to the clipboard.
- */
-void
-glade_command_copy (GList * widgets)
-{
-  GList *list, *copied_widgets = NULL;
-  GladeWidget *copied_widget = NULL;
-
-  g_return_if_fail (widgets != NULL);
-
-  for (list = widgets; list && list->data; list = list->next)
-    {
-      copied_widget = glade_widget_dup (list->data, FALSE);
-      copied_widgets = g_list_prepend (copied_widgets, copied_widget);
-    }
-  glade_command_push_group (_("Copy %s"),
-                            g_list_length (widgets) == 1 ? 
-			    glade_widget_get_name (copied_widget) : _("multiple"));
-  glade_command_clipboard_add (copied_widgets);
   glade_command_pop_group ();
 
-  if (copied_widgets)
-    g_list_free (copied_widgets);
+  glade_clipboard_add (glade_app_get_clipboard (), widgets);
 }
 
 #if 0
@@ -1875,7 +1677,8 @@ glade_command_break_references (GladeProject * project, GList * widgets)
  */
 void
 glade_command_paste (GList * widgets, GladeWidget * parent,
-                     GladePlaceholder * placeholder)
+                     GladePlaceholder * placeholder,
+		     GladeProject *project)
 {
   GList *list, *copied_widgets = NULL;
   GladeWidget *copied_widget = NULL;
@@ -1897,7 +1700,7 @@ glade_command_paste (GList * widgets, GladeWidget * parent,
                             g_list_length (widgets) == 1 ? 
 			    glade_widget_get_name (copied_widget) : _("multiple"));
 
-  glade_command_add (copied_widgets, parent, placeholder, TRUE);
+  glade_command_add (copied_widgets, parent, placeholder, project, TRUE);
   glade_command_pop_group ();
 
   if (copied_widgets)
@@ -1919,8 +1722,15 @@ glade_command_dnd (GList * widgets, GladeWidget * parent,
                    GladePlaceholder * placeholder)
 {
   GladeWidget *widget;
+  GladeProject *project;
 
   g_return_if_fail (widgets != NULL);
+  g_return_if_fail (parent || placeholder);
+
+  if (parent)
+    project = glade_widget_get_project (parent);
+  else
+    project = glade_placeholder_get_project (placeholder);
 
   widget = widgets->data;
   glade_command_push_group (_("Drag-n-Drop from %s to %s"),
@@ -1928,7 +1738,7 @@ glade_command_dnd (GList * widgets, GladeWidget * parent,
                             g_list_length (widgets) == 1 ? 
 			    glade_widget_get_name (widget) : _("multiple"));
   glade_command_remove (widgets);
-  glade_command_add (widgets, parent, placeholder, TRUE);
+  glade_command_add (widgets, parent, placeholder, project, TRUE);
   glade_command_pop_group ();
 }
 
diff --git a/gladeui/glade-command.h b/gladeui/glade-command.h
index 82205ab..bde55cd 100644
--- a/gladeui/glade-command.h
+++ b/gladeui/glade-command.h
@@ -128,15 +128,14 @@ GladeWidget   *glade_command_create        (GladeWidgetAdaptor *adaptor,
 					    GladePlaceholder   *placeholder,
 					    GladeProject       *project);
 
-/************************ cut/copy/paste ******************************/
+/************************ cut/paste/dnd ******************************/
 
 void           glade_command_cut           (GList             *widgets);
 
-void           glade_command_copy          (GList             *widgets);
-
 void           glade_command_paste         (GList             *widgets,
 					    GladeWidget       *parent,
-					    GladePlaceholder  *placeholder);
+					    GladePlaceholder  *placeholder,
+					    GladeProject      *project);
 
 void           glade_command_dnd           (GList             *widgets,
 					    GladeWidget       *parent,
diff --git a/gladeui/glade-inspector.c b/gladeui/glade-inspector.c
index bbaa7a5..b817df7 100644
--- a/gladeui/glade-inspector.c
+++ b/gladeui/glade-inspector.c
@@ -604,10 +604,10 @@ selection_changed_cb (GtkTreeSelection * selection, GladeInspector * inspector)
                                    G_CALLBACK (project_selection_changed_cb),
                                    inspector);
 
-  glade_app_selection_clear (FALSE);
+  glade_project_selection_clear (inspector->priv->project, FALSE);
   for (l = sel; l; l = l->next)
-    glade_app_selection_add (G_OBJECT (l->data), FALSE);
-  glade_app_selection_changed ();
+    glade_project_selection_add (inspector->priv->project, G_OBJECT (l->data), FALSE);
+  glade_project_selection_changed (inspector->priv->project);
   g_list_free (sel);
 
   g_signal_handlers_unblock_by_func (inspector->priv->project,
@@ -657,7 +657,7 @@ button_press_cb (GtkWidget * widget,
                 glade_popup_widget_pop (glade_widget_get_from_gobject (object),
                                         event, TRUE);
               else
-                glade_popup_simple_pop (event);
+                glade_popup_simple_pop (priv->project, event);
 
               handled = TRUE;
 
@@ -666,7 +666,7 @@ button_press_cb (GtkWidget * widget,
         }
       else
         {
-          glade_popup_simple_pop (event);
+          glade_popup_simple_pop (priv->project, event);
           handled = TRUE;
         }
     }
diff --git a/gladeui/glade-palette.c b/gladeui/glade-palette.c
index 5858baf..fa0cb52 100644
--- a/gladeui/glade-palette.c
+++ b/gladeui/glade-palette.c
@@ -57,6 +57,8 @@ struct _GladePalettePrivate
 {
   const GList *catalogs;        /* List of widget catalogs */
 
+  GladeProject *project;
+
   GtkWidget *selector_hbox;
   GtkWidget *selector_button;
   GtkWidget *create_root_button;
@@ -83,20 +85,23 @@ enum
   PROP_ITEM_APPEARANCE,
   PROP_USE_SMALL_ITEM_ICONS,
   PROP_SHOW_SELECTOR_BUTTON,
-  PROP_CATALOGS
+  PROP_CATALOGS,
+  PROP_PROJECT
 };
 
 static guint glade_palette_signals[LAST_SIGNAL] = { 0 };
 
 static void glade_palette_append_item_group (GladePalette * palette,
                                              GladeWidgetGroup * group);
+static void glade_palette_refresh           (GladePalette * palette);
 
 static void glade_palette_update_appearance (GladePalette * palette);
 
 G_DEFINE_TYPE (GladePalette, glade_palette, GTK_TYPE_VBOX)
-     static void
-         selector_button_toggled_cb (GtkToggleButton * button,
-                                     GladePalette * palette)
+
+static void
+selector_button_toggled_cb (GtkToggleButton * button,
+			    GladePalette * palette)
 {
   if (gtk_toggle_button_get_active (button))
     {
@@ -131,7 +136,46 @@ glade_palette_set_catalogs (GladePalette * palette, GList * catalogs)
             glade_palette_append_item_group (palette, group);
         }
     }
+}
 
+GladeProject *
+glade_palette_get_project (GladePalette *palette)
+{
+  g_return_val_if_fail (GLADE_IS_PALETTE (palette), NULL);
+
+  return palette->priv->project;
+}
+
+void
+glade_palette_set_project (GladePalette *palette,
+			   GladeProject *project)
+{
+  g_return_if_fail (GLADE_IS_PALETTE (palette));
+
+  if (palette->priv->project != project)
+    {
+
+      if (palette->priv->project)
+	{
+	  g_signal_handlers_disconnect_by_func (G_OBJECT (palette->priv->project),
+						G_CALLBACK (glade_palette_refresh),
+						palette);
+	}
+
+      palette->priv->project = project;
+
+      if (palette->priv->project)
+	{
+	  g_signal_connect_swapped (G_OBJECT (palette->priv->project), "targets-changed",
+				    G_CALLBACK (glade_palette_refresh), palette);
+	  g_signal_connect_swapped (G_OBJECT (palette->priv->project), "parse-finished",
+				    G_CALLBACK (glade_palette_refresh), palette);
+	}
+
+      glade_palette_refresh (palette);
+
+      g_object_notify (G_OBJECT (palette), "project");
+    }
 }
 
 /**
@@ -146,7 +190,9 @@ glade_palette_set_item_appearance (GladePalette * palette,
                                    GladeItemAppearance item_appearance)
 {
   GladePalettePrivate *priv;
+
   g_return_if_fail (GLADE_IS_PALETTE (palette));
+
   priv = palette->priv;
 
   if (priv->item_appearance != item_appearance)
@@ -232,23 +278,26 @@ glade_palette_set_property (GObject * object,
 
   switch (prop_id)
     {
-      case PROP_USE_SMALL_ITEM_ICONS:
-        glade_palette_set_use_small_item_icons (palette,
-                                                g_value_get_boolean (value));
-        break;
-      case PROP_ITEM_APPEARANCE:
-        glade_palette_set_item_appearance (palette, g_value_get_enum (value));
-        break;
-      case PROP_SHOW_SELECTOR_BUTTON:
-        glade_palette_set_show_selector_button (palette,
-                                                g_value_get_boolean (value));
-        break;
-      case PROP_CATALOGS:
-        glade_palette_set_catalogs (palette, g_value_get_pointer (value));
-        break;
-      default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-        break;
+    case PROP_PROJECT:
+      glade_palette_set_project (palette, (GladeProject *)g_value_get_object (value));
+      break;
+    case PROP_USE_SMALL_ITEM_ICONS:
+      glade_palette_set_use_small_item_icons (palette,
+					      g_value_get_boolean (value));
+      break;
+    case PROP_ITEM_APPEARANCE:
+      glade_palette_set_item_appearance (palette, g_value_get_enum (value));
+      break;
+    case PROP_SHOW_SELECTOR_BUTTON:
+      glade_palette_set_show_selector_button (palette,
+					      g_value_get_boolean (value));
+      break;
+    case PROP_CATALOGS:
+      glade_palette_set_catalogs (palette, g_value_get_pointer (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
     }
 }
 
@@ -261,31 +310,34 @@ glade_palette_get_property (GObject * object,
 
   switch (prop_id)
     {
-      case PROP_CURRENT_ITEM:
-        if (priv->current_item)
-          g_value_set_pointer (value, g_object_get_data
-                               (G_OBJECT (priv->current_item),
-                                "glade-widget-adaptor"));
-        else
-          g_value_set_pointer (value, NULL);
-
-        break;
-      case PROP_USE_SMALL_ITEM_ICONS:
-        g_value_set_boolean (value, priv->use_small_item_icons);
-        break;
-      case PROP_SHOW_SELECTOR_BUTTON:
-        g_value_set_boolean (value,
-                             gtk_widget_get_visible (priv->selector_button));
-        break;
-      case PROP_ITEM_APPEARANCE:
-        g_value_set_enum (value, priv->item_appearance);
-        break;
-      case PROP_CATALOGS:
-        g_value_set_pointer (value, (gpointer) priv->catalogs);
-        break;
-      default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-        break;
+    case PROP_PROJECT:
+      g_value_set_object (value, priv->project);
+      break;
+    case PROP_CURRENT_ITEM:
+      if (priv->current_item)
+	g_value_set_pointer (value, g_object_get_data
+			     (G_OBJECT (priv->current_item),
+			      "glade-widget-adaptor"));
+      else
+	g_value_set_pointer (value, NULL);
+      
+      break;
+    case PROP_USE_SMALL_ITEM_ICONS:
+      g_value_set_boolean (value, priv->use_small_item_icons);
+      break;
+    case PROP_SHOW_SELECTOR_BUTTON:
+      g_value_set_boolean (value,
+			   gtk_widget_get_visible (priv->selector_button));
+      break;
+    case PROP_ITEM_APPEARANCE:
+      g_value_set_enum (value, priv->item_appearance);
+      break;
+    case PROP_CATALOGS:
+      g_value_set_pointer (value, (gpointer) priv->catalogs);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
     }
 }
 
@@ -363,6 +415,14 @@ glade_palette_class_init (GladePaletteClass * klass)
                     NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
   g_object_class_install_property (object_class,
+                                   PROP_PROJECT,
+                                   g_param_spec_object ("project",
+							"Project",
+							"This palette's current project",
+							GLADE_TYPE_PROJECT,
+							G_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class,
                                    PROP_ITEM_APPEARANCE,
                                    g_param_spec_enum ("item-appearance",
                                                       "Item Appearance",
@@ -413,8 +473,7 @@ glade_palette_create_root_widget (GladePalette * palette,
 
   /* Dont deselect palette if create is canceled by user in query dialog */
   if ((widget =
-       glade_command_create (adaptor, NULL, NULL,
-                             glade_app_get_project ())) != NULL)
+       glade_command_create (adaptor, NULL, NULL, palette->priv->project)) != NULL)
     glade_palette_deselect_current_item (palette, FALSE);
 
   return widget;
@@ -502,7 +561,8 @@ glade_palette_on_button_toggled (GtkWidget * button, GladePalette * palette)
 
 
 static void
-glade_palette_item_refresh (GtkWidget * item)
+glade_palette_item_refresh (GladePalette *palette, 
+			    GtkWidget    *item)
 {
   GladeProject *project;
   GladeSupportMask support;
@@ -512,7 +572,7 @@ glade_palette_item_refresh (GtkWidget * item)
   adaptor = g_object_get_data (G_OBJECT (item), "glade-widget-adaptor");
   g_assert (adaptor);
 
-  if ((project = glade_app_check_get_project ()) &&
+  if ((project = palette->priv->project) &&
       (warning =
        glade_project_verify_widget_adaptor (project, adaptor,
                                             &support)) != NULL)
@@ -548,15 +608,17 @@ glade_palette_item_refresh (GtkWidget * item)
 
 static gint
 glade_palette_item_button_press (GtkWidget * button,
-                                 GdkEventButton * event, GladePalette * item)
+                                 GdkEventButton * event, GtkToolItem * item)
 {
   if (glade_popup_is_popup_event (event))
     {
       GladeWidgetAdaptor *adaptor;
+      GladePalette       *palette;
 
       adaptor = g_object_get_data (G_OBJECT (item), "glade-widget-adaptor");
+      palette = g_object_get_data (G_OBJECT (item), "glade-palette");
 
-      glade_popup_palette_pop (adaptor, event);
+      glade_popup_palette_pop (palette, adaptor, event);
       return TRUE;
     }
 
@@ -570,6 +632,7 @@ glade_palette_new_item (GladePalette * palette, GladeWidgetAdaptor * adaptor)
 
   item = (GtkWidget *) gtk_toggle_tool_button_new ();
   g_object_set_data (G_OBJECT (item), "glade-widget-adaptor", adaptor);
+  g_object_set_data (G_OBJECT (item), "glade-palette", palette);
 
   button = gtk_bin_get_child (GTK_BIN (item));
   g_assert (GTK_IS_BUTTON (button));
@@ -582,15 +645,15 @@ glade_palette_new_item (GladePalette * palette, GladeWidgetAdaptor * adaptor)
   gtk_widget_show (box);
   gtk_container_add (GTK_CONTAINER (box), label);
   gtk_tool_button_set_label_widget (GTK_TOOL_BUTTON (item), box);
-  glade_palette_item_refresh (item);
+  glade_palette_item_refresh (palette, item);
 
   /* Update selection when the item is pushed */
   g_signal_connect (G_OBJECT (item), "toggled",
                     G_CALLBACK (glade_palette_on_button_toggled), palette);
 
   /* Update palette item when active project state changes */
-  g_signal_connect_swapped (G_OBJECT (palette), "refresh",
-                            G_CALLBACK (glade_palette_item_refresh), item);
+  g_signal_connect (G_OBJECT (palette), "refresh",
+		    G_CALLBACK (glade_palette_item_refresh), item);
 
   /* Fire Glade palette popup menus */
   g_signal_connect (G_OBJECT (button), "button-press-event",
@@ -913,7 +976,7 @@ glade_palette_get_show_selector_button (GladePalette * palette)
  *
  * Refreshes project dependant states of palette buttons
  */
-void
+static void
 glade_palette_refresh (GladePalette * palette)
 {
   g_return_if_fail (GLADE_IS_PALETTE (palette));
diff --git a/gladeui/glade-palette.h b/gladeui/glade-palette.h
index 373fbb9..64aab95 100644
--- a/gladeui/glade-palette.h
+++ b/gladeui/glade-palette.h
@@ -47,24 +47,24 @@ typedef struct _GladePaletteClass    GladePaletteClass;
 
 struct _GladePalette
 {
-	GtkVBox parent_instance;
+  GtkVBox parent_instance;
 
-	GladePalettePrivate *priv;
+  GladePalettePrivate *priv;
 };
 
 struct _GladePaletteClass
 {
-	GtkVBoxClass parent_class;
+  GtkVBoxClass parent_class;
 
-	void    (* toggled)    (GladePalette *palette);
-	void    (* refresh)    (GladePalette *palette);
+  void    (* toggled)    (GladePalette *palette);
+  void    (* refresh)    (GladePalette *palette);
 };
 
 typedef enum
 {
-	GLADE_ITEM_ICON_AND_LABEL,
-	GLADE_ITEM_ICON_ONLY,
-	GLADE_ITEM_LABEL_ONLY
+  GLADE_ITEM_ICON_AND_LABEL,
+  GLADE_ITEM_ICON_ONLY,
+  GLADE_ITEM_LABEL_ONLY
 } GladeItemAppearance;
 
 
@@ -72,6 +72,10 @@ GType                glade_palette_get_type                 (void) G_GNUC_CONST;
 
 GtkWidget           *glade_palette_new                      (const GList  *catalogs);
 
+GladeProject        *glade_palette_get_project              (GladePalette *palette);
+void                 glade_palette_set_project              (GladePalette *palette,
+							     GladeProject *project);
+
 void                 glade_palette_deselect_current_item    (GladePalette *palette,
 							     gboolean      sticky_aware);
 
@@ -92,8 +96,6 @@ void		     glade_palette_set_show_selector_button (GladePalette *palette,
 							     
 gboolean             glade_palette_get_show_selector_button (GladePalette *palette);
 
-void                 glade_palette_refresh                  (GladePalette *palette);
-
 GladeWidget         *glade_palette_create_root_widget       (GladePalette *palette,
 							     GladeWidgetAdaptor *adaptor);
 
diff --git a/gladeui/glade-popup.c b/gladeui/glade-popup.c
index 1de6874..0e08abd 100644
--- a/gladeui/glade-popup.c
+++ b/gladeui/glade-popup.c
@@ -36,6 +36,20 @@
 #include "glade-project.h"
 #include "glade-app.h"
 
+static void
+glade_popup_docs_cb (GtkMenuItem * item, GladeWidgetAdaptor * adaptor)
+{
+  gchar *book;
+
+  g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+
+  g_object_get (adaptor, "book", &book, NULL);
+  glade_editor_search_doc_search (glade_app_get_editor (), book, 
+				  glade_widget_adaptor_get_name (adaptor),
+                                  NULL);
+  g_free (book);
+}
+
 /********************************************************
                       WIDGET POPUP
  *******************************************************/
@@ -43,7 +57,8 @@ static void
 glade_popup_select_cb (GtkMenuItem * item, GladeWidget * widget)
 {
   glade_util_clear_selection ();
-  glade_app_selection_set (glade_widget_get_object (widget), TRUE);
+  glade_project_selection_set (glade_widget_get_project (widget),
+			       glade_widget_get_object (widget), TRUE);
 }
 
 static GladePlaceholder *
@@ -115,59 +130,70 @@ glade_popup_root_add_cb (GtkMenuItem * item, gpointer * user_data)
 static void
 glade_popup_cut_cb (GtkMenuItem * item, GladeWidget * widget)
 {
-  GladeProject *project = glade_app_get_project ();
+  GladeProject *project = glade_widget_get_project (widget);
 
   glade_util_clear_selection ();
 
-  /* Assign selection first */
-  if (glade_project_is_selected
-      (project, glade_widget_get_object (widget)) == FALSE)
-    {
-      glade_app_selection_set (glade_widget_get_object (widget), FALSE);
-    }
-  glade_app_command_cut ();
+  /* Assign selection first only if its not already assigned (it may be a delete
+   * of multiple widgets) */
+  if (!glade_project_is_selected (project, glade_widget_get_object (widget)))
+    glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);
+
+  glade_project_command_cut (project);
 }
 
 static void
 glade_popup_copy_cb (GtkMenuItem * item, GladeWidget * widget)
 {
-  GladeProject *project = glade_app_get_project ();
+  GladeProject *project = glade_widget_get_project (widget);
 
   glade_util_clear_selection ();
 
   /* Assign selection first */
-  if (glade_project_is_selected
-      (project, glade_widget_get_object (widget)) == FALSE)
-    glade_app_selection_set (glade_widget_get_object (widget), FALSE);
+  if (glade_project_is_selected (project, glade_widget_get_object (widget)) == FALSE)
+    glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);
 
-  glade_app_command_copy ();
+  glade_project_copy_selection (project);
 }
 
 static void
-glade_popup_paste_cb (GtkMenuItem * item, GladeWidget * widget)
+glade_popup_paste_cb (GtkMenuItem * item, gpointer data)
 {
+  GladeWidget  *widget = NULL;
+  GladeProject *project;
+
+  if (GLADE_IS_WIDGET (data))
+    {
+      widget  = GLADE_WIDGET (data);
+      project = glade_widget_get_project (widget);
+    }
+  else if (GLADE_IS_PROJECT (data))
+    project = GLADE_PROJECT (data);
+  else
+    g_return_if_reached ();
+
   glade_util_clear_selection ();
 
   /* The selected widget is the paste destination */
   if (widget)
-    glade_app_selection_set (glade_widget_get_object (widget), FALSE);
+    glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);
   else
-    glade_app_selection_clear (FALSE);
+    glade_project_selection_clear (project, FALSE);
 
-  glade_app_command_paste (NULL);
+  glade_project_command_paste (project, NULL);
 }
 
 static void
 glade_popup_delete_cb (GtkMenuItem * item, GladeWidget * widget)
 {
-  GladeProject *project = glade_app_get_project ();
+  GladeProject *project = glade_widget_get_project (widget);
 
   /* Assign selection first */
   if (glade_project_is_selected
       (project, glade_widget_get_object (widget)) == FALSE)
-    glade_app_selection_set (glade_widget_get_object (widget), FALSE);
+    glade_project_selection_set (project, glade_widget_get_object (widget), FALSE);
 
-  glade_app_command_delete ();
+  glade_project_command_delete (project);
 }
 
 /********************************************************
@@ -177,46 +203,16 @@ static void
 glade_popup_placeholder_paste_cb (GtkMenuItem * item,
                                   GladePlaceholder * placeholder)
 {
-  glade_util_clear_selection ();
-  glade_app_selection_clear (FALSE);
-
-  glade_app_command_paste (placeholder);
-}
+  GladeProject *project;
 
+  project = glade_placeholder_get_project (placeholder);
 
-/********************************************************
-                    CLIPBOARD POPUP
- *******************************************************/
-static void
-glade_popup_clipboard_paste_cb (GtkMenuItem * item, GladeWidget * widget)
-{
   glade_util_clear_selection ();
-  glade_app_selection_clear (FALSE);
-
-  glade_app_command_paste (NULL);
-}
-
-static void
-glade_popup_clipboard_delete_cb (GtkMenuItem * item, GladeWidget * widget)
-{
-  glade_app_command_delete_clipboard ();
-}
-
-static void
-glade_popup_docs_cb (GtkMenuItem * item, GladeWidgetAdaptor * adaptor)
-{
-  gchar *book;
-
-  g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
+  glade_project_selection_clear (project, FALSE);
 
-  g_object_get (adaptor, "book", &book, NULL);
-  glade_editor_search_doc_search (glade_app_get_editor (), book, 
-				  glade_widget_adaptor_get_name (adaptor),
-                                  NULL);
-  g_free (book);
+  glade_project_command_paste (project, placeholder);
 }
 
-
 /********************************************************
                     POPUP BUILDING
  *******************************************************/
@@ -415,8 +411,10 @@ glade_popup_action_populate_menu (GtkWidget * menu,
 }
 
 static GtkWidget *
-glade_popup_create_menu (GladeWidget * widget,
-                         GladePlaceholder * placeholder, gboolean packing)
+glade_popup_create_menu (GladeWidget      *widget,
+                         GladePlaceholder *placeholder, 
+			 GladeProject     *project,
+			 gboolean          packing)
 {
   GtkWidget *popup_menu;
   GtkWidget *separator;
@@ -533,26 +531,6 @@ glade_popup_create_menu (GladeWidget * widget,
   return popup_menu;
 }
 
-static GtkWidget *
-glade_popup_create_clipboard_menu (GladeWidget * widget)
-{
-  GtkWidget *popup_menu;
-
-  popup_menu = gtk_menu_new ();
-
-  if (gtk_widget_is_toplevel (GTK_WIDGET (glade_widget_get_object (widget))))
-    {
-      glade_popup_append_item (popup_menu, GTK_STOCK_PASTE,
-                               NULL, NULL, TRUE,
-                               glade_popup_clipboard_paste_cb, NULL);
-    }
-
-  glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, NULL, TRUE,
-                           glade_popup_clipboard_delete_cb, widget);
-
-  return popup_menu;
-}
-
 void
 glade_popup_widget_pop (GladeWidget * widget,
                         GdkEventButton * event, gboolean packing)
@@ -563,7 +541,7 @@ glade_popup_widget_pop (GladeWidget * widget,
 
   g_return_if_fail (GLADE_IS_WIDGET (widget) || widget == NULL);
 
-  popup_menu = glade_popup_create_menu (widget, NULL, packing);
+  popup_menu = glade_popup_create_menu (widget, NULL, glade_widget_get_project (widget), packing);
 
   if (event)
     {
@@ -592,33 +570,8 @@ glade_popup_placeholder_pop (GladePlaceholder * placeholder,
 
   widget = glade_placeholder_get_parent (placeholder);
 
-  popup_menu = glade_popup_create_menu (widget, placeholder, TRUE);
-
-  if (event)
-    {
-      button = event->button;
-      event_time = event->time;
-    }
-  else
-    {
-      button = 0;
-      event_time = gtk_get_current_event_time ();
-    }
-
-  gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
-                  NULL, NULL, button, event_time);
-}
-
-void
-glade_popup_clipboard_pop (GladeWidget * widget, GdkEventButton * event)
-{
-  GtkWidget *popup_menu;
-  gint button;
-  gint event_time;
-
-  g_return_if_fail (GLADE_IS_WIDGET (widget));
-
-  popup_menu = glade_popup_create_clipboard_menu (widget);
+  popup_menu = glade_popup_create_menu (widget, placeholder, 
+					glade_widget_get_project (widget), TRUE);
 
   if (event)
     {
@@ -636,7 +589,9 @@ glade_popup_clipboard_pop (GladeWidget * widget, GdkEventButton * event)
 }
 
 void
-glade_popup_palette_pop (GladeWidgetAdaptor * adaptor, GdkEventButton * event)
+glade_popup_palette_pop (GladePalette       *palette, 
+			 GladeWidgetAdaptor *adaptor, 
+			 GdkEventButton     *event)
 {
   GladeProject *project;
   GtkWidget *popup_menu;
@@ -648,7 +603,7 @@ glade_popup_palette_pop (GladeWidgetAdaptor * adaptor, GdkEventButton * event)
 
   popup_menu = gtk_menu_new ();
 
-  project = glade_app_get_project ();
+  project = glade_palette_get_project (palette);
 
   glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL,
                            TRUE, glade_popup_root_add_cb, adaptor);
@@ -761,15 +716,15 @@ glade_popup_property_pop (GladeProperty * property, GdkEventButton * event)
                   NULL, NULL, button, event_time);
 }
 
-
 void
-glade_popup_simple_pop (GdkEventButton * event)
+glade_popup_simple_pop (GladeProject   *project,
+			GdkEventButton *event)
 {
   GtkWidget *popup_menu;
   gint button;
   gint event_time;
 
-  popup_menu = glade_popup_create_menu (NULL, NULL, FALSE);
+  popup_menu = glade_popup_create_menu (NULL, NULL, project, FALSE);
   if (!popup_menu)
     return;
 
diff --git a/gladeui/glade-popup.h b/gladeui/glade-popup.h
index 0547d62..78b1c67 100644
--- a/gladeui/glade-popup.h
+++ b/gladeui/glade-popup.h
@@ -13,7 +13,8 @@ void glade_popup_placeholder_pop      (GladePlaceholder *placeholder,
 void glade_popup_clipboard_pop        (GladeWidget *widget,
 				       GdkEventButton *event);
 
-void glade_popup_palette_pop          (GladeWidgetAdaptor *adaptor,
+void glade_popup_palette_pop          (GladePalette       *palette,
+				       GladeWidgetAdaptor *adaptor,
 				       GdkEventButton     *event);
 
 gint glade_popup_action_populate_menu (GtkWidget *menu,
@@ -21,7 +22,8 @@ gint glade_popup_action_populate_menu (GtkWidget *menu,
 				       GladeWidgetAction *action,
 				       gboolean packing);
 
-void glade_popup_simple_pop           (GdkEventButton *event);
+void glade_popup_simple_pop           (GladeProject   *project,
+				       GdkEventButton *event);
 
 void glade_popup_property_pop         (GladeProperty  *property,
 				       GdkEventButton *event);
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index c66df3c..0ba09ef 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -106,12 +106,13 @@ struct _GladeProjectPrivate
                                  * not want to loose the selection. This is a list
                                  * of #GtkWidget items.
                                  */
+  guint selection_changed_id;
+  gboolean has_selection;       /* Whether the project has a selection */
 
   GladeNameContext *toplevel_names;     /* Context for uniqueness of names at the toplevel */
   GList *toplevels;             /* List of toplevels with thier own naming contexts */
 
 
-  gboolean has_selection;       /* Whether the project has a selection */
 
   GList *undo_stack;            /* A stack with the last executed commands */
   GList *prev_redo_item;        /* Points to the item previous to the redo items */
@@ -284,6 +285,10 @@ glade_project_dispose (GObject * object)
   /* Emit close signal */
   g_signal_emit (object, glade_project_signals[CLOSE], 0);
 
+  if (project->priv->selection_changed_id > 0)
+    project->priv->selection_changed_id = 
+      (g_source_remove (project->priv->selection_changed_id), 0);
+
   glade_project_selection_clear (project, TRUE);
 
   glade_project_list_unref (project->priv->undo_stack);
@@ -2467,10 +2472,6 @@ glade_project_verify_project_for_ui (GladeProject * project)
 
       glade_project_verify_properties (widget);
     }
-
-  /* refresh palette if this is the active project */
-  if (project == glade_app_get_project ())
-    glade_palette_refresh (glade_app_get_palette ());
 }
 
 /*******************************************************************
@@ -2611,9 +2612,9 @@ glade_project_release_widget_name (GladeProject * project,
   if (context && glade_name_context_n_names (context) == 0)
     {
       glade_name_context_destroy (context);
-      g_free (tinfo);
       project->priv->toplevels =
           g_list_remove (project->priv->toplevels, tinfo);
+      g_free (tinfo);
     }
 
 }
@@ -3181,6 +3182,24 @@ glade_project_selection_changed (GladeProject * project)
                  glade_project_signals[SELECTION_CHANGED], 0);
 }
 
+static gboolean
+selection_change_idle (GladeProject *project)
+{
+  glade_project_selection_changed (project);
+  project->priv->selection_changed_id = 0;
+  return FALSE;
+}
+
+void
+glade_project_queue_selection_changed (GladeProject *project)
+{
+  g_return_if_fail (GLADE_IS_PROJECT (project));
+
+  if (project->priv->selection_changed_id == 0)
+    project->priv->selection_changed_id = 
+      g_idle_add ((GSourceFunc) selection_change_idle, project);
+}
+
 static void
 glade_project_set_has_selection (GladeProject * project, gboolean has_selection)
 {
@@ -3299,12 +3318,17 @@ glade_project_selection_add (GladeProject * project,
 
   if (glade_project_is_selected (project, object) == FALSE)
     {
+      gboolean toggle_has_selection = (project->priv->selection == NULL);
+
       if (GTK_IS_WIDGET (object))
         glade_util_add_selection (GTK_WIDGET (object));
-      if (project->priv->selection == NULL)
-        glade_project_set_has_selection (project, TRUE);
+
       project->priv->selection =
-          g_list_prepend (project->priv->selection, object);
+	g_list_prepend (project->priv->selection, object);
+
+      if (toggle_has_selection)
+        glade_project_set_has_selection (project, TRUE);
+
       if (emit_signal)
         glade_project_selection_changed (project);
     }
@@ -3331,9 +3355,6 @@ glade_project_selection_set (GladeProject * project,
   if (!glade_project_has_object (project, object))
     return;
 
-  if (project->priv->selection == NULL)
-    glade_project_set_has_selection (project, TRUE);
-
   if (glade_project_is_selected (project, object) == FALSE ||
       g_list_length (project->priv->selection) != 1)
     {
@@ -4833,3 +4854,218 @@ gtk_tree_model_iface_init (GtkTreeModelIface * iface)
   iface->iter_nth_child = glade_project_model_iter_nth_child;
   iface->iter_parent = glade_project_model_iter_parent;
 }
+
+
+/*************************************************
+ *                Command Central                *
+ *************************************************/
+void
+glade_project_copy_selection (GladeProject *project)
+{
+  GList       *widgets = NULL, *list;
+  GladeWidget *widget;
+
+  g_return_if_fail (GLADE_IS_PROJECT (project));
+
+  if (glade_project_is_loading (project))
+    return;
+
+  if (!project->priv->selection)
+    {
+      glade_util_ui_message (glade_app_get_window (),
+			     GLADE_UI_INFO, NULL, _("No widget selected."));
+      return;
+    }
+
+  for (list = project->priv->selection; list && list->data; list = list->next)
+    {
+      widget = glade_widget_get_from_gobject (list->data);
+      widget = glade_widget_dup (widget, FALSE);
+
+      widgets = g_list_prepend (widgets, widget);
+    }
+
+  glade_clipboard_add (glade_app_get_clipboard (), widgets);
+  g_list_free (widgets);
+}
+
+void
+glade_project_command_cut (GladeProject     *project)
+{
+  GList *widgets = NULL, *list;
+  GladeWidget *widget;
+  gboolean failed = FALSE;
+
+  g_return_if_fail (GLADE_IS_PROJECT (project));
+
+  if (glade_project_is_loading (project))
+    return;
+
+  for (list = project->priv->selection; list && list->data; list = list->next)
+    {
+      widget  = glade_widget_get_from_gobject (list->data);
+      widgets = g_list_prepend (widgets, widget);
+    }
+
+  if (failed == FALSE && widgets != NULL)
+    glade_command_cut (widgets);
+  else if (widgets == NULL)
+    glade_util_ui_message (glade_app_get_window (),
+                           GLADE_UI_INFO, NULL, _("No widget selected."));
+
+  if (widgets)
+    g_list_free (widgets);
+}
+
+void
+glade_project_command_paste (GladeProject     *project, 
+			     GladePlaceholder *placeholder)
+{
+  GladeClipboard *clipboard;
+  GList *list;
+  GladeWidget *widget = NULL, *parent;
+  gint placeholder_relations = 0;
+  GladeFixed *fixed = NULL;
+
+  g_return_if_fail (GLADE_IS_PROJECT (project));
+
+  if (glade_project_is_loading (project))
+    return;
+
+  if (placeholder)
+    {
+      if (glade_placeholder_get_project (placeholder) == NULL ||
+          glade_project_is_loading (glade_placeholder_get_project (placeholder)))
+        return;
+    }
+
+  list      = project->priv->selection;
+  clipboard = glade_app_get_clipboard ();
+
+  /* If there is a selection, paste in to the selected widget, otherwise
+   * paste into the placeholder's parent, or at the toplevel
+   */
+  parent = list ? glade_widget_get_from_gobject (list->data) :
+      (placeholder) ? glade_placeholder_get_parent (placeholder) : NULL;
+
+  widget = clipboard->widgets ? clipboard->widgets->data : NULL;
+
+  /* Ignore parent argument if we are pasting a toplevel
+   */
+  if (g_list_length (clipboard->widgets) == 1 &&
+      widget && GWA_IS_TOPLEVEL (glade_widget_get_adaptor (widget)))
+    parent = NULL;
+
+  if (parent && GLADE_IS_FIXED (parent))
+    fixed = GLADE_FIXED (parent);
+
+  /* Check if parent is actually a container of any sort */
+  if (parent && !glade_widget_adaptor_is_container (glade_widget_get_adaptor (parent)))
+    {
+      glade_util_ui_message (glade_app_get_window (),
+                             GLADE_UI_INFO, NULL,
+                             _("Unable to paste to the selected parent"));
+      return;
+    }
+
+  /* Check if selection is good */
+  if (project->priv->selection)
+    {
+      if (g_list_length (project->priv->selection) != 1)
+        {
+          glade_util_ui_message (glade_app_get_window (),
+                                 GLADE_UI_INFO, NULL,
+                                 _("Unable to paste to multiple widgets"));
+
+          return;
+        }
+    }
+
+  /* Abort operation when adding a non scrollable widget to any kind of GtkScrolledWindow. */
+  if (parent && widget &&
+      glade_util_check_and_warn_scrollable (parent, glade_widget_get_adaptor (widget),
+                                            glade_app_get_window ()))
+    return;
+
+  /* Check if we have anything to paste */
+  if (g_list_length (clipboard->widgets) == 0)
+    {
+      glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL,
+                             _("No widget on the clipboard"));
+
+      return;
+    }
+
+  /* Check that we have compatible heirarchies */
+  for (list = clipboard->widgets; list && list->data; list = list->next)
+    {
+      widget = list->data;
+
+      if (!GWA_IS_TOPLEVEL (glade_widget_get_adaptor (widget)) && parent)
+        {
+          /* Count placeholder relations
+           */
+          if (glade_widget_placeholder_relation (parent, widget))
+            placeholder_relations++;
+        }
+    }
+
+  g_assert (widget);
+
+  /* A GladeFixed that doesnt use placeholders can only paste one
+   * at a time
+   */
+  if (GTK_IS_WIDGET (glade_widget_get_object (widget)) &&
+      parent && fixed && 
+      !GWA_USE_PLACEHOLDERS (glade_widget_get_adaptor (parent)) &&
+      g_list_length (clipboard->widgets) != 1)
+    {
+      glade_util_ui_message (glade_app_get_window (),
+                             GLADE_UI_INFO, NULL,
+                             _("Only one widget can be pasted at a "
+                               "time to this container"));
+      return;
+    }
+
+  /* Check that enough placeholders are available */
+  if (parent &&
+      GWA_USE_PLACEHOLDERS (glade_widget_get_adaptor (parent)) &&
+      glade_util_count_placeholders (parent) < placeholder_relations)
+    {
+      glade_util_ui_message (glade_app_get_window (),
+                             GLADE_UI_INFO, NULL,
+                             _("Insufficient amount of placeholders in "
+                               "target container"));
+      return;
+    }
+
+  glade_command_paste (clipboard->widgets, parent, placeholder, project);
+}
+
+void
+glade_project_command_delete (GladeProject     *project)
+{
+  GList *widgets = NULL, *list;
+  GladeWidget *widget;
+  gboolean failed = FALSE;
+
+  g_return_if_fail (GLADE_IS_PROJECT (project));
+
+  if (glade_project_is_loading (project))
+    return;
+
+  for (list = project->priv->selection; list && list->data; list = list->next)
+    {
+      widget  = glade_widget_get_from_gobject (list->data);
+      widgets = g_list_prepend (widgets, widget);
+    }
+
+  if (failed == FALSE && widgets != NULL)
+    glade_command_delete (widgets);
+  else if (widgets == NULL)
+    glade_util_ui_message (glade_app_get_window (),
+                           GLADE_UI_INFO, NULL, _("No widget selected."));
+
+  if (widgets)
+    g_list_free (widgets);
+}
diff --git a/gladeui/glade-project.h b/gladeui/glade-project.h
index f3384fa..fa64862 100644
--- a/gladeui/glade-project.h
+++ b/gladeui/glade-project.h
@@ -150,24 +150,25 @@ gboolean       glade_project_available_widget_name (GladeProject *project, Glade
 /* Selection */
 
 gboolean       glade_project_is_selected         (GladeProject *project,
-						 GObject      *object);
+						  GObject      *object);
 
 void           glade_project_selection_set       (GladeProject *project,
-						 GObject      *object,
-						 gboolean      emit_signal);
+						  GObject      *object,
+						  gboolean      emit_signal);
 
 void           glade_project_selection_add       (GladeProject *project,
-						 GObject      *object,
-						 gboolean      emit_signal);
+						  GObject      *object,
+						  gboolean      emit_signal);
 
 void           glade_project_selection_remove    (GladeProject *project,
-						 GObject      *object,
-						 gboolean      emit_signal);
+						  GObject      *object,
+						  gboolean      emit_signal);
 
 void           glade_project_selection_clear     (GladeProject *project,
-						 gboolean      emit_signal);
+						  gboolean      emit_signal);
 
 void           glade_project_selection_changed   (GladeProject *project);
+void           glade_project_queue_selection_changed (GladeProject *project);
 
 GList         *glade_project_selection_get       (GladeProject *project);
 
@@ -216,6 +217,14 @@ void          glade_project_push_progress (GladeProject *project);
 gboolean      glade_project_load_cancelled (GladeProject *project);
 void          glade_project_cancel_load (GladeProject *project);
 
+
+/* Command central */
+void          glade_project_copy_selection (GladeProject     *project);
+void          glade_project_command_cut    (GladeProject     *project); 
+void          glade_project_command_paste  (GladeProject     *project, 
+					    GladePlaceholder *placeholder);
+void          glade_project_command_delete (GladeProject     *project);
+
 G_END_DECLS
 
 #endif /* __GLADE_PROJECT_H__ */
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 7a372b6..f894a2b 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -427,16 +427,17 @@ glade_widget_button_press_event_impl (GladeWidget * gwidget,
       if (event->state & GDK_CONTROL_MASK)
         {
           if (glade_project_is_selected (gwidget->priv->project, gwidget->priv->object))
-            glade_app_selection_remove (gwidget->priv->object, TRUE);
+            glade_project_selection_remove (gwidget->priv->project, gwidget->priv->object, TRUE);
           else
-            glade_app_selection_add (gwidget->priv->object, TRUE);
+            glade_project_selection_add (gwidget->priv->project, gwidget->priv->object, TRUE);
           handled = TRUE;
         }
       else if (glade_project_is_selected (gwidget->priv->project,
                                           gwidget->priv->object) == FALSE)
         {
           glade_util_clear_selection ();
-          glade_app_selection_set (gwidget->priv->object, TRUE);
+          glade_project_selection_set (gwidget->priv->project, 
+				       gwidget->priv->object, TRUE);
 
           /* Add selection without interrupting event flow 
            * when shift is down, this allows better behaviour
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index d606a85..3249cec 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -771,9 +771,7 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
                                   GObject * object, const gchar * action_path)
 {
   GladeWidget *gwidget = glade_widget_get_from_gobject (object), *gparent;
-  GList this_widget = { 0, }, that_widget =
-  {
-  0,};
+  GList this_widget = { 0, }, that_widget = { 0,};
   GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (object));
   GladeProject *project;
 
@@ -782,9 +780,10 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
   else
     gparent = NULL;
 
+  project = glade_widget_get_project (gwidget);
+
   if (strcmp (action_path, "preview") == 0)
     {
-      project = glade_widget_get_project (gwidget);
       glade_project_preview (project,
                              glade_widget_get_from_gobject ((gpointer) object));
     }
@@ -811,7 +810,7 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
       glade_command_delete (&that_widget);
 
       /* Add "this" widget to the new parent */
-      glade_command_paste (&this_widget, new_gparent, NULL);
+      glade_command_paste (&this_widget, new_gparent, NULL, project);
 
       glade_command_pop_group ();
     }
@@ -850,7 +849,6 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
           GladeWidgetAdaptor *adaptor =
               glade_widget_adaptor_get_by_type (new_type);
           GList *saved_props, *prop_cmds;
-          GladeProject *project;
 
           /* Dont add non-scrollable widgets to scrolled windows... */
           if (gparent &&
@@ -871,11 +869,6 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
           this_widget.data = gwidget;
           glade_command_cut (&this_widget);
 
-          if (gparent)
-            project = glade_widget_get_project (gparent);
-          else
-            project = glade_app_get_project ();
-
           /* Create new widget and put it where the placeholder was */
           if ((that_widget.data =
                glade_command_create (adaptor, gparent, NULL, project)) != NULL)
@@ -902,16 +895,16 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor * adaptor,
 
               /* Apply the properties in an undoable way */
               if (prop_cmds)
-                glade_command_set_properties_list (glade_widget_get_project
-                                                   (gparent), prop_cmds);
+                glade_command_set_properties_list 
+		  (glade_widget_get_project (gparent), prop_cmds);
 
               /* Add "this" widget to the new parent */
               glade_command_paste (&this_widget,
-                                   GLADE_WIDGET (that_widget.data), NULL);
+                                   GLADE_WIDGET (that_widget.data), NULL, project);
             }
           else
             /* Create parent was cancelled, paste back to parent */
-            glade_command_paste (&this_widget, gparent, NULL);
+            glade_command_paste (&this_widget, gparent, NULL, project);
 
           glade_command_pop_group ();
         }
@@ -4053,7 +4046,8 @@ glade_gtk_box_notebook_child_insert_remove_action (GladeWidgetAdaptor * adaptor,
       gtab = glade_gtk_notebook_generate_tab (parent, new_pos + 1);
       list.data = gtab;
 
-      glade_command_paste (&list, parent, GLADE_PLACEHOLDER (tab_placeholder));
+      glade_command_paste (&list, parent, GLADE_PLACEHOLDER (tab_placeholder),
+			   glade_widget_get_project (parent));
     }
 
   g_list_foreach (children, (GFunc) g_object_unref, NULL);
diff --git a/src/glade-window.c b/src/glade-window.c
index 7f3b000..6d63862 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -149,9 +149,10 @@ static void glade_window_config_save (GladeWindow * window);
 
 
 G_DEFINE_TYPE (GladeWindow, glade_window, GTK_TYPE_WINDOW)
+
 /* the following functions are taken from gedit-utils.c */
-     static gchar *str_middle_truncate (const gchar * string,
-                                        guint truncate_length)
+static gchar *str_middle_truncate (const gchar * string,
+				   guint truncate_length)
 {
   GString *truncated;
   guint length;
@@ -461,9 +462,13 @@ add_actions (GladeWindow * window, GladeWidget * widget, GList * actions)
 static void
 project_selection_changed_cb (GladeProject * project, GladeWindow * window)
 {
-  GladeWidget *glade_widget = NULL;
-  GList *list;
-  gint num;
+  GladeProject *active_project = NULL;
+  GladeWidget  *glade_widget = NULL;
+  GList        *list;
+  gint          num;
+
+  if (window->priv->active_view)
+    active_project = glade_design_view_get_project (window->priv->active_view);
 
   /* This is sometimes called with a NULL project (to make the label
    * insensitive with no projects loaded)
@@ -473,7 +478,7 @@ project_selection_changed_cb (GladeProject * project, GladeWindow * window)
   /* Only update the toolbar & workspace if the selection has changed on
    * the currently active project.
    */
-  if (project && (project == glade_app_get_project ()))
+  if (project == active_project)
     {
       list = glade_project_selection_get (project);
       num = g_list_length (list);
@@ -489,6 +494,8 @@ project_selection_changed_cb (GladeProject * project, GladeWindow * window)
             add_actions (window, glade_widget, glade_widget_get_actions (glade_widget));
         }
     }
+
+  glade_editor_load_widget (glade_app_get_editor (), glade_widget);
 }
 
 static GladeDesignView *
@@ -698,7 +705,10 @@ static void
 project_notify_handler_cb (GladeProject * project, GParamSpec * spec,
                            GladeWindow * window)
 {
-  GtkAction *action;
+  GladeProject *active_project;
+  GtkAction    *action;
+
+  active_project = glade_design_view_get_project (window->priv->active_view);
 
   if (strcmp (spec->name, "path") == 0 || strcmp (spec->name, "format") == 0)
     refresh_notebook_tab_for_project (window, project);
@@ -716,8 +726,7 @@ project_notify_handler_cb (GladeProject * project, GParamSpec * spec,
           gtk_action_group_get_action (window->priv->project_actions, "Save");
       gtk_action_set_sensitive (action, !glade_project_get_readonly (project));
     }
-  else if (strcmp (spec->name, "has-selection") == 0 &&
-           (project == glade_app_get_project ()))
+  else if (strcmp (spec->name, "has-selection") == 0 && (project == active_project))
     {
       action =
           gtk_action_group_get_action (window->priv->project_actions, "Cut");
@@ -1503,30 +1512,53 @@ quit_cb (GtkAction * action, GladeWindow * window)
 static void
 copy_cb (GtkAction * action, GladeWindow * window)
 {
-  glade_app_command_copy ();
+  GladeProject *project;
+
+  if (!window->priv->active_view)
+    return;
+
+  project = glade_design_view_get_project (window->priv->active_view);
+
+  glade_project_copy_selection (project);
 }
 
 static void
 cut_cb (GtkAction * action, GladeWindow * window)
 {
-  glade_app_command_cut ();
+  GladeProject *project;
+
+  if (!window->priv->active_view)
+    return;
+
+  project = glade_design_view_get_project (window->priv->active_view);
+
+  glade_project_command_cut (project);
 }
 
 static void
 paste_cb (GtkAction * action, GladeWindow * window)
 {
-  glade_app_command_paste (NULL);
+  GladeProject *project;
+
+  if (!window->priv->active_view)
+    return;
+
+  project = glade_design_view_get_project (window->priv->active_view);
+
+  glade_project_command_paste (project, NULL);
 }
 
 static void
 delete_cb (GtkAction * action, GladeWindow * window)
 {
-  if (!glade_app_get_project ())
-    {
-      g_warning ("delete should not be sensitive: we don't have a project");
-      return;
-    }
-  glade_app_command_delete ();
+  GladeProject *project;
+
+  if (!window->priv->active_view)
+    return;
+
+  project = glade_design_view_get_project (window->priv->active_view);
+
+  glade_project_command_delete (project);
 }
 
 static void
@@ -1612,8 +1644,7 @@ notebook_switch_page_cb (GtkNotebook * notebook,
 
   project = glade_design_view_get_project (view);
 
-  /* FIXME: this does not feel good */
-  glade_app_set_project (project);
+  glade_palette_set_project (glade_app_get_palette (), project);
 
   refresh_title (window);
   set_sensitivity_according_to_project (window, project);
@@ -1638,6 +1669,9 @@ notebook_switch_page_cb (GtkNotebook * notebook,
   g_free (action_name);
 
   refresh_undo_redo (window, project);
+
+  /* Refresh the editor and some of the actions */
+  project_selection_changed_cb (project, window);
 }
 
 static void
@@ -1691,15 +1725,12 @@ notebook_tab_added_cb (GtkNotebook * notebook,
   gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->inspectors_notebook),
                             inspector, NULL);
 
-
   set_sensitivity_according_to_project (window, project);
 
   refresh_projects_list_menu (window);
 
   refresh_title (window);
 
-  project_selection_changed_cb (glade_app_get_project (), window);
-
   if (window->priv->num_tabs > 0)
     gtk_action_group_set_sensitive (window->priv->project_actions, TRUE);
 
@@ -1746,7 +1777,8 @@ notebook_tab_removed_cb (GtkNotebook     *notebook,
 
   refresh_title (window);
 
-  project_selection_changed_cb (glade_app_get_project (), window);
+  /* Refresh the editor and some of the actions */
+  project_selection_changed_cb (project, window);
 
   if (window->priv->active_view)
     set_sensitivity_according_to_project (window,
diff --git a/src/main.c b/src/main.c
index e7b440b..a1e44bb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -73,6 +73,7 @@ main (int argc, char *argv[])
   GOptionContext *option_context;
   GOptionGroup *option_group;
   GError *error = NULL;
+  gboolean opened_project = FALSE;
 
   if (!g_thread_supported ())
     g_thread_init (NULL);
@@ -170,7 +171,10 @@ main (int argc, char *argv[])
       for (i = 0; files[i]; ++i)
         {
           if (g_file_test (files[i], G_FILE_TEST_EXISTS) != FALSE)
-            glade_window_open_project (window, files[i]);
+	    {
+	      if (glade_window_open_project (window, files[i]))
+		opened_project = TRUE;
+	    }
           else
             g_warning (_("Unable to open '%s', the file does not exist.\n"),
                        files[i]);
@@ -178,7 +182,7 @@ main (int argc, char *argv[])
       g_strfreev (files);
     }
 
-  if (glade_app_get_project () == NULL)
+  if (!opened_project)
     glade_window_new_project (window);
 
   gtk_main ();



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