[glade3] * gladeui/glade-app.[ch]: - Removed "update-ui" signal, This signal was encouraging bad behaviou



commit d4835f028d3dad920ffeb80cc0e58d98bd91de58
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Mon Jan 3 15:29:29 2011 +0900

    	* gladeui/glade-app.[ch]:
    	  - Removed "update-ui" signal, This signal was encouraging bad behaviour and too much
    	    action on every project change.
    	  - Removed glade_app_create_undo/redo_button().
    
    	* gladeui/glade-project.c: Stop calling glade_app_update_ui ().
    
    	* gladeui/glade-window.c:
    	  - Listen to GladeProject::changed instead of update-ui and only update the
    	    undo/redo actions when the active project changes.
    	  - Remove the preview toolbutton
    	  - Add tooltips to important actions
    
    	* plugins/gtk+/gtk+.xml.in: Mark the "preview" action as "important" so it shows
    	  up in the app toolbar automatically.

 ChangeLog                |   18 ++++
 gladeui/glade-app.c      |  205 +++-------------------------------------------
 gladeui/glade-app.h      |   10 +--
 gladeui/glade-project.c  |  146 ++++++++++++++++-----------------
 plugins/gtk+/gtk+.xml.in |    2 +-
 src/glade-window.c       |  172 ++++++++++++---------------------------
 6 files changed, 155 insertions(+), 398 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4848404..f778850 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2011-01-03  Tristan Van Berkom <tristanvb openismus com>
+
+	* gladeui/glade-app.[ch]:
+	  - Removed "update-ui" signal, This signal was encouraging bad behaviour and too much
+	    action on every project change.
+	  - Removed glade_app_create_undo/redo_button().
+
+	* gladeui/glade-project.c: Stop calling glade_app_update_ui ().
+
+	* gladeui/glade-window.c:
+	  - Listen to GladeProject::changed instead of update-ui and only update the
+	    undo/redo actions when the active project changes.
+	  - Remove the preview toolbutton
+	  - Add tooltips to important actions
+
+	* plugins/gtk+/gtk+.xml.in: Mark the "preview" action as "important" so it shows
+	  up in the app toolbar automatically.
+
 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 1b8fbe4..e8e50d8 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -57,7 +57,6 @@
 
 enum
 {
-  UPDATE_UI,
   SIGNAL_EDITOR_CREATED,
   LAST_SIGNAL
 };
@@ -89,7 +88,6 @@ struct _GladeAppPrivate
                                  * GladeWidgets.
                                  */
   GtkAccelGroup *accel_group;   /* Default acceleration group for this app */
-  GList *undo_list, *redo_list; /* Lists of buttons to refresh in update-ui signal */
 
   GladePointerMode pointer_mode;        /* Current mode for the pointer in the workspace */
 
@@ -250,47 +248,6 @@ glade_app_get_property (GObject * object,
  *                    GladeAppClass                              *
  *****************************************************************/
 static void
-glade_app_refresh_undo_redo_button (GladeApp * app,
-                                    GtkWidget * button, gboolean undo)
-{
-  GladeCommand *command = NULL;
-  GladeProject *project;
-  gchar *desc;
-
-  if ((project = glade_app_get_project ()) != NULL)
-    {
-      if (undo)
-        command = glade_project_next_undo_item (project);
-      else
-        command = glade_project_next_redo_item (project);
-    }
-
-  /* Change tooltips */
-  desc = g_strdup_printf ((undo) ? _("Undo: %s") : _("Redo: %s"),
-                          command ? command->
-                          description : _("the last action"));
-  gtk_widget_set_tooltip_text (button, desc);
-  g_free (desc);
-
-  /* Set sensitivity on the button */
-  gtk_widget_set_sensitive (button, command != NULL);
-}
-
-static void
-glade_app_update_ui_default (GladeApp * app)
-{
-  GList *list;
-
-  for (list = app->priv->undo_list; list; list = list->next)
-    if (list->data)
-      glade_app_refresh_undo_redo_button (app, list->data, TRUE);
-
-  for (list = app->priv->redo_list; list; list = list->next)
-    if (list->data)
-      glade_app_refresh_undo_redo_button (app, list->data, FALSE);
-}
-
-static void
 glade_app_signal_editor_created_default (GladeApp * app,
                                          GladeSignalEditor * signal_editor)
 {
@@ -447,9 +404,6 @@ glade_app_init (GladeApp * app)
 
   /* Load the configuration file */
   app->priv->config = glade_app_config_load (app);
-
-  /* Undo/Redo button list */
-  app->priv->undo_list = app->priv->redo_list = NULL;
 }
 
 static void
@@ -465,35 +419,20 @@ glade_app_class_init (GladeAppClass * klass)
   object_class->get_property = glade_app_get_property;
   object_class->set_property = glade_app_set_property;
 
-  klass->update_ui_signal = glade_app_update_ui_default;
   klass->signal_editor_created = glade_app_signal_editor_created_default;
   klass->show_properties = NULL;
   klass->hide_properties = NULL;
 
-        /**
-	 * GladeApp::update-ui:
-	 * @gladeapp: the #GladeApp which received the signal.
-	 *
-	 * Emitted when a project name changes or a cut/copy/paste/delete occurred.
-	 */
-  glade_app_signals[UPDATE_UI] =
-      g_signal_new ("update-ui",
-                    G_TYPE_FROM_CLASS (object_class),
-                    G_SIGNAL_RUN_FIRST,
-                    G_STRUCT_OFFSET (GladeAppClass,
-                                     update_ui_signal),
-                    NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
-        /**
-	 * GladeApp::signal-editor-created:
-	 * @gladeapp: the #GladeApp which received the signal.
-	 * @signal_editor: the new #GladeSignalEditor.
-	 *
-	 * Emitted when a new signal editor created.
-	 * A tree view is created in the default handler.
-	 * Connect your handler before the default handler for setting a custom column or renderer
-	 * and after it for connecting to the tree view signals
-	 */
+  /**
+   * GladeApp::signal-editor-created:
+   * @gladeapp: the #GladeApp which received the signal.
+   * @signal_editor: the new #GladeSignalEditor.
+   *
+   * Emitted when a new signal editor created.
+   * A tree view is created in the default handler.
+   * Connect your handler before the default handler for setting a custom column or renderer
+   * and after it for connecting to the tree view signals
+   */
   glade_app_signals[SIGNAL_EDITOR_CREATED] =
       g_signal_new ("signal-editor-created",
                     G_TYPE_FROM_CLASS (object_class),
@@ -692,14 +631,6 @@ glade_app_get (void)
 }
 
 void
-glade_app_update_ui (void)
-{
-  GladeApp *app = glade_app_get ();
-
-  g_signal_emit (G_OBJECT (app), glade_app_signals[UPDATE_UI], 0);
-}
-
-void
 glade_app_set_window (GtkWidget * window)
 {
   GladeApp *app = glade_app_get ();
@@ -1021,9 +952,6 @@ glade_app_set_project (GladeProject * project)
   /* refresh palette for active project */
   glade_palette_refresh (glade_app_get_palette ());
 
-  /* Update UI */
-  glade_app_update_ui ();
-
   g_object_notify (G_OBJECT (app), "active-project");
 }
 
@@ -1088,10 +1016,7 @@ glade_app_command_copy (void)
     }
 
   if (failed == FALSE && widgets != NULL)
-    {
-      glade_command_copy (widgets);
-      glade_app_update_ui ();
-    }
+    glade_command_copy (widgets);
   else if (widgets == NULL)
     glade_util_ui_message (glade_app_get_window (),
                            GLADE_UI_INFO, NULL, _("No widget selected."));
@@ -1129,10 +1054,7 @@ glade_app_command_cut (void)
     }
 
   if (failed == FALSE && widgets != NULL)
-    {
-      glade_command_cut (widgets);
-      glade_app_update_ui ();
-    }
+    glade_command_cut (widgets);
   else if (widgets == NULL)
     glade_util_ui_message (glade_app_get_window (),
                            GLADE_UI_INFO, NULL, _("No widget selected."));
@@ -1273,7 +1195,6 @@ glade_app_command_paste (GladePlaceholder * placeholder)
     }
 
   glade_command_paste (clipboard->selection, parent, placeholder);
-  glade_app_update_ui ();
 }
 
 
@@ -1302,10 +1223,7 @@ glade_app_command_delete (void)
     }
 
   if (failed == FALSE && widgets != NULL)
-    {
-      glade_command_delete (widgets);
-      glade_app_update_ui ();
-    }
+    glade_command_delete (widgets);
   else if (widgets == NULL)
     glade_util_ui_message (glade_app_get_window (),
                            GLADE_UI_INFO, NULL, _("No widget selected."));
@@ -1334,34 +1252,6 @@ glade_app_command_delete_clipboard (void)
     }
 
   glade_command_delete (clipboard->selection);
-  glade_app_update_ui ();
-}
-
-
-void
-glade_app_command_undo (void)
-{
-  GladeApp *app = glade_app_get ();
-  if (app->priv->active_project)
-    {
-      glade_project_undo (app->priv->active_project);
-      glade_editor_refresh (app->priv->editor);
-      /* Update UI. */
-      glade_app_update_ui ();
-    }
-}
-
-void
-glade_app_command_redo (void)
-{
-  GladeApp *app = glade_app_get ();
-  if (app->priv->active_project)
-    {
-      glade_project_redo (app->priv->active_project);
-      glade_editor_refresh (app->priv->editor);
-      /* Update UI. */
-      glade_app_update_ui ();
-    }
 }
 
 /*
@@ -1388,75 +1278,6 @@ glade_app_get_accel_group (void)
   return glade_app_get ()->priv->accel_group;
 }
 
-static gboolean
-glade_app_undo_button_destroyed (GtkWidget * button, GladeApp * app)
-{
-  app->priv->undo_list = g_list_remove (app->priv->undo_list, button);
-  return FALSE;
-}
-
-static gboolean
-glade_app_redo_button_destroyed (GtkWidget * button, GladeApp * app)
-{
-  app->priv->redo_list = g_list_remove (app->priv->redo_list, button);
-  return FALSE;
-}
-
-static GtkWidget *
-glade_app_undo_redo_button_new (GladeApp * app, gboolean undo)
-{
-  GtkWidget *button;
-
-  button = gtk_button_new_from_stock ((undo) ? GTK_STOCK_UNDO : GTK_STOCK_REDO);
-
-  g_signal_connect_swapped (button, "clicked",
-                            (undo) ? G_CALLBACK (glade_app_command_undo) :
-                            G_CALLBACK (glade_app_command_redo), app);
-
-  if (undo)
-    {
-      app->priv->undo_list = g_list_prepend (app->priv->undo_list, button);
-      g_signal_connect (button, "destroy",
-                        G_CALLBACK (glade_app_undo_button_destroyed), app);
-    }
-  else
-    {
-      app->priv->redo_list = g_list_prepend (app->priv->redo_list, button);
-      g_signal_connect (button, "destroy",
-                        G_CALLBACK (glade_app_redo_button_destroyed), app);
-    }
-
-  glade_app_refresh_undo_redo_button (app, button, undo);
-
-  return button;
-}
-
-/*
- * glade_app_undo_button_new:
- *
- * Creates a new GtkButton undo widget.
- * The button will be automatically updated with @app's undo stack.
- */
-GtkWidget *
-glade_app_undo_button_new (void)
-{
-  GladeApp *app = glade_app_get ();
-  return glade_app_undo_redo_button_new (app, TRUE);
-}
-
-/*
- * glade_app_redo_button_new:
- *
- * Creates a new GtkButton redo widget.
- * The button will be automatically updated with @app's redo stack.
- */
-GtkWidget *
-glade_app_redo_button_new (void)
-{
-  GladeApp *app = glade_app_get ();
-  return glade_app_undo_redo_button_new (app, FALSE);
-}
-
 GList *
 glade_app_get_selection (void)
 {
diff --git a/gladeui/glade-app.h b/gladeui/glade-app.h
index 3498e1c..5ffed38 100644
--- a/gladeui/glade-app.h
+++ b/gladeui/glade-app.h
@@ -80,8 +80,7 @@ struct _GladeAppClass
 	void   (*  hide_properties) (GladeApp* app);
 
 	/* signals */
-	void   (* update_ui_signal) (GladeApp    *app);
-	void   (* signal_editor_created) (GladeApp *app, GladeSignalEditor *signal_editor);
+	void   (*  signal_editor_created) (GladeApp *app, GladeSignalEditor *signal_editor);
 };
 
  
@@ -93,8 +92,6 @@ GType              glade_pointer_mode_get_type (void) G_GNUC_CONST;
 
 GladeApp*          glade_app_get        (void);
 
-void               glade_app_update_ui  (void);
-
 void               glade_app_set_window (GtkWidget *window);
  
 GtkWidget*         glade_app_get_window (void);
@@ -162,12 +159,7 @@ GtkWindow         *glade_app_get_transient_parent (void);
 void               glade_app_set_accel_group (GtkAccelGroup *accel_group);
 
 GtkAccelGroup     *glade_app_get_accel_group (void);
- 
-GtkWidget         *glade_app_undo_button_new (void);
- 
-GtkWidget         *glade_app_redo_button_new (void);
 
- 
 GList             *glade_app_get_selection (void);
 
 
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index b522779..c66df3c 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -537,7 +537,6 @@ glade_project_push_undo_impl (GladeProject * project, GladeCommand * cmd)
     {
       GladeCommand *cmd1 = priv->prev_redo_item->data;
 
-
       if (glade_command_unifies (cmd1, cmd))
         {
           glade_command_collapse (cmd1, cmd);
@@ -550,10 +549,12 @@ glade_project_push_undo_impl (GladeProject * project, GladeCommand * cmd)
               glade_project_free_undo_item (project, tmp_redo_item);
               priv->undo_stack =
                   g_list_delete_link (priv->undo_stack, tmp_redo_item);
+
+	      cmd1 = NULL;
             }
 
           g_signal_emit (G_OBJECT (project),
-                         glade_project_signals[CHANGED], 0, NULL, TRUE);
+                         glade_project_signals[CHANGED], 0, cmd1, TRUE);
           return;
         }
     }
@@ -566,7 +567,6 @@ glade_project_push_undo_impl (GladeProject * project, GladeCommand * cmd)
   else
     priv->prev_redo_item = g_list_next (priv->prev_redo_item);
 
-
   g_signal_emit (G_OBJECT (project),
                  glade_project_signals[CHANGED], 0, cmd, TRUE);
 }
@@ -649,7 +649,6 @@ glade_project_changed_impl (GladeProject * project,
       else
         glade_project_set_modified (project, TRUE);
     }
-  glade_app_update_ui ();
 }
 
 
@@ -744,13 +743,13 @@ glade_project_class_init (GladeProjectClass * klass)
   klass->close = glade_project_close_impl;
   klass->changed = glade_project_changed_impl;
 
-        /**
-	 * GladeProject::add-widget:
-	 * @gladeproject: the #GladeProject which received the signal.
-	 * @arg1: the #GladeWidget that was added to @gladeproject.
-	 *
-	 * Emitted when a widget is added to a project.
-	 */
+  /**
+   * GladeProject::add-widget:
+   * @gladeproject: the #GladeProject which received the signal.
+   * @arg1: the #GladeWidget that was added to @gladeproject.
+   *
+   * Emitted when a widget is added to a project.
+   */
   glade_project_signals[ADD_WIDGET] =
       g_signal_new ("add_widget",
                     G_TYPE_FROM_CLASS (object_class),
@@ -760,13 +759,13 @@ glade_project_class_init (GladeProjectClass * klass)
                     g_cclosure_marshal_VOID__OBJECT,
                     G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
 
-        /**
-	 * GladeProject::remove-widget:
-	 * @gladeproject: the #GladeProject which received the signal.
-	 * @arg1: the #GladeWidget that was removed from @gladeproject.
-	 * 
-	 * Emitted when a widget is removed from a project.
-	 */
+  /**
+   * GladeProject::remove-widget:
+   * @gladeproject: the #GladeProject which received the signal.
+   * @arg1: the #GladeWidget that was removed from @gladeproject.
+   * 
+   * Emitted when a widget is removed from a project.
+   */
   glade_project_signals[REMOVE_WIDGET] =
       g_signal_new ("remove_widget",
                     G_TYPE_FROM_CLASS (object_class),
@@ -777,13 +776,13 @@ glade_project_class_init (GladeProjectClass * klass)
                     G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
 
 
-        /**
-	 * GladeProject::widget-name-changed:
-	 * @gladeproject: the #GladeProject which received the signal.
-	 * @arg1: the #GladeWidget who's name changed.
-	 *
-	 * Emitted when @gwidget's name changes.
-	 */
+  /**
+   * GladeProject::widget-name-changed:
+   * @gladeproject: the #GladeProject which received the signal.
+   * @arg1: the #GladeWidget who's name changed.
+   *
+   * Emitted when @gwidget's name changes.
+   */
   glade_project_signals[WIDGET_NAME_CHANGED] =
       g_signal_new ("widget_name_changed",
                     G_TYPE_FROM_CLASS (object_class),
@@ -794,12 +793,12 @@ glade_project_class_init (GladeProjectClass * klass)
                     G_TYPE_NONE, 1, GLADE_TYPE_WIDGET);
 
 
-        /** 
-	 * GladeProject::selection-changed:
-	 * @gladeproject: the #GladeProject which received the signal.
-	 *
-	 * Emitted when @gladeproject selection list changes.
-	 */
+  /** 
+   * GladeProject::selection-changed:
+   * @gladeproject: the #GladeProject which received the signal.
+   *
+   * Emitted when @gladeproject selection list changes.
+   */
   glade_project_signals[SELECTION_CHANGED] =
       g_signal_new ("selection_changed",
                     G_TYPE_FROM_CLASS (object_class),
@@ -808,13 +807,13 @@ glade_project_class_init (GladeProjectClass * klass)
                     NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
 
-        /**
-	 * GladeProject::close:
-	 * @gladeproject: the #GladeProject which received the signal.
-	 *
-	 * Emitted when a project is closing (a good time to clean up
-	 * any associated resources).
-	 */
+  /**
+   * GladeProject::close:
+   * @gladeproject: the #GladeProject which received the signal.
+   *
+   * Emitted when a project is closing (a good time to clean up
+   * any associated resources).
+   */
   glade_project_signals[CLOSE] =
       g_signal_new ("close",
                     G_TYPE_FROM_CLASS (object_class),
@@ -822,14 +821,14 @@ glade_project_class_init (GladeProjectClass * klass)
                     G_STRUCT_OFFSET (GladeProjectClass, close),
                     NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
-        /**
-	 * GladeProject::changed:
-	 * @gladeproject: the #GladeProject which received the signal.
-	 * @arg1: the #GladeCommand that was executed
-	 * @arg2: whether the command was executed or undone.
-	 *
-	 * Emitted when a @gladeproject's state changes via a #GladeCommand.
-	 */
+  /**
+   * GladeProject::changed:
+   * @gladeproject: the #GladeProject which received the signal.
+   * @arg1: the #GladeCommand that was executed
+   * @arg2: whether the command was executed or undone.
+   *
+   * Emitted when a @gladeproject's state changes via a #GladeCommand.
+   */
   glade_project_signals[CHANGED] =
       g_signal_new ("changed",
                     G_TYPE_FROM_CLASS (object_class),
@@ -839,12 +838,12 @@ glade_project_class_init (GladeProjectClass * klass)
                     glade_marshal_VOID__OBJECT_BOOLEAN,
                     G_TYPE_NONE, 2, GLADE_TYPE_COMMAND, G_TYPE_BOOLEAN);
 
-        /**
-	 * GladeProject::parse-began:
-	 * @gladeproject: the #GladeProject which received the signal.
-	 *
-	 * Emitted when @gladeproject parsing starts.
-	 */
+  /**
+   * GladeProject::parse-began:
+   * @gladeproject: the #GladeProject which received the signal.
+   *
+   * Emitted when @gladeproject parsing starts.
+   */
   glade_project_signals[PARSE_BEGAN] =
       g_signal_new ("parse-began",
                     G_TYPE_FROM_CLASS (object_class),
@@ -852,12 +851,12 @@ glade_project_class_init (GladeProjectClass * klass)
                     0, NULL, NULL,
                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
-        /**
-	 * GladeProject::parse-finished:
-	 * @gladeproject: the #GladeProject which received the signal.
-	 *
-	 * Emitted when @gladeproject parsing has finished.
-	 */
+  /**
+   * GladeProject::parse-finished:
+   * @gladeproject: the #GladeProject which received the signal.
+   *
+   * Emitted when @gladeproject parsing has finished.
+   */
   glade_project_signals[PARSE_FINISHED] =
       g_signal_new ("parse-finished",
                     G_TYPE_FROM_CLASS (object_class),
@@ -865,12 +864,12 @@ glade_project_class_init (GladeProjectClass * klass)
                     G_STRUCT_OFFSET (GladeProjectClass, parse_finished),
                     NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
-        /**
-	 * GladeProject::targets-changed:
-         * @gladeproject: the #GladeProject which received the signal.
-         *
-         * Emitted when @gladeproject target versions change.
-         */
+  /**
+   * GladeProject::targets-changed:
+   * @gladeproject: the #GladeProject which received the signal.
+   *
+   * Emitted when @gladeproject target versions change.
+   */
   glade_project_signals[TARGETS_CHANGED] =
       g_signal_new ("targets-changed",
                     G_TYPE_FROM_CLASS (object_class),
@@ -878,14 +877,14 @@ glade_project_class_init (GladeProjectClass * klass)
                     0, NULL, NULL,
                     g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
 
-        /**
-	 * GladeProject::load-progress:
-	 * @gladeproject: the #GladeProject which received the signal.
-	 * @objects_total: the total amount of objects to load
-	 * @objects_loaded: the current amount of loaded objects
-	 *
-	 * Emitted while @project is loading.
-	 */
+  /**
+   * GladeProject::load-progress:
+   * @gladeproject: the #GladeProject which received the signal.
+   * @objects_total: the total amount of objects to load
+   * @objects_loaded: the current amount of loaded objects
+   *
+   * Emitted while @project is loading.
+   */
   glade_project_signals[LOAD_PROGRESS] =
       g_signal_new ("load-progress",
                     G_TYPE_FROM_CLASS (object_class),
@@ -1542,9 +1541,6 @@ glade_project_load_internal (GladeProject * project)
    */
   glade_project_verify_project_for_ui (project);
 
-  /* Update various things in the UI */
-  glade_app_update_ui ();
-
   return TRUE;
 
 }
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 74c1bb7..78a15a7 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -28,7 +28,7 @@
       </signals>
 
       <actions>
-	<action id="preview" _name="Preview snapshot"/>
+	<action id="preview" _name="Preview snapshot" stock="gtk-execute" important="True"/>
         <action id="edit_separate" _name="Edit Separately" stock="gtk-edit"/>
         <action id="remove_parent" _name="Remove Parent" stock="gtk-remove"/>
         <action id="add_parent" _name="Add Parent" stock="gtk-add">
diff --git a/src/glade-window.c b/src/glade-window.c
index a755b07..7f3b000 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -120,7 +120,6 @@ struct _GladeWindowPrivate
   gchar *default_path;          /* the default path for open/save operations */
 
   GtkToggleToolButton *selector_button; /* the widget selector button (replaces the one in the palette) */
-  GtkToolButton *preview_button;        /* the project preview button (replaces the one in the palette) */
   GtkToggleToolButton *drag_resize_button;      /* sets the pointer to drag/resize mode */
   gboolean setting_pointer_mode;        /* avoid feedback signal loops */
 
@@ -139,7 +138,7 @@ struct _GladeWindowPrivate
   ToolDock docks[N_DOCKS];
 };
 
-static void refresh_undo_redo (GladeWindow * window);
+static void refresh_undo_redo (GladeWindow *window, GladeProject *project);
 
 static void recent_chooser_item_activated_cb (GtkRecentChooser * chooser,
                                               GladeWindow * window);
@@ -427,11 +426,12 @@ add_actions (GladeWindow * window, GladeWidget * widget, GList * actions)
           continue;
         }
 
-      item =
-          gtk_tool_button_new_from_stock ((a->klass->stock) ? a->klass->
-                                          stock : "gtk-execute");
+      item = gtk_tool_button_new_from_stock ((a->klass->stock) ? a->klass->stock : "gtk-execute");
       if (a->klass->label)
-        gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), a->klass->label);
+	{
+	  gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), a->klass->label);
+	  gtk_widget_set_tooltip_text (GTK_WIDGET (item), a->klass->label);
+	}
 
       g_object_set_data (G_OBJECT (item), "glade-widget", widget);
 
@@ -601,6 +601,20 @@ project_targets_changed_cb (GladeProject * project, GladeWindow * window)
 }
 
 static void
+project_changed_cb (GladeProject *project, 
+		    GladeCommand *command,
+		    gboolean      execute,
+		    GladeWindow  *window)
+{
+  GladeProject *active_project;
+
+  active_project = glade_design_view_get_project (window->priv->active_view);
+  
+  if (project == active_project)
+    refresh_undo_redo (window, project);
+}
+
+static void
 refresh_projects_list_item (GladeWindow * window, GladeProject * project)
 {
   GtkAction *action;
@@ -753,50 +767,6 @@ on_selector_button_toggled (GtkToggleToolButton * button, GladeWindow * window)
 }
 
 static void
-on_preview_button_clicked (GtkToggleToolButton * button, GladeWindow * window)
-{
-  GladeProject *project;
-
-  const GList *objects;
-
-  GtkWidget *widget = NULL;
-  GtkWidget *window_to_preview = NULL;
-  GladeWidget *glade_widget = NULL;
-
-  project = glade_design_view_get_project (window->priv->active_view);
-
-  if (project == NULL)
-    return;
-
-  objects = glade_project_get_objects (project);
-
-  while (objects != NULL)
-    {
-      if (GTK_IS_WIDGET (objects->data))
-        {
-          widget = GTK_WIDGET (objects->data);
-          if (GTK_IS_WINDOW (widget))
-            {
-              window_to_preview = widget;
-              break;
-            }
-        }
-      objects = objects->next;
-    }
-
-  if (widget != NULL)
-    {
-      glade_widget = glade_widget_get_from_gobject (G_OBJECT (widget));
-    }
-
-  if (window_to_preview != NULL)
-    widget = window_to_preview;
-  glade_project_preview (project,
-                         glade_widget_get_from_gobject ((gpointer) widget));
-}
-
-
-static void
 on_drag_resize_button_toggled (GtkToggleToolButton * button,
                                GladeWindow * window)
 {
@@ -1265,9 +1235,8 @@ save_as (GladeWindow * window)
                                        real_path);
 
       gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                                _
-                                                ("You do not have the permissions "
-                                                 "necessary to save the file."));
+						_("You do not have the permissions "
+						  "necessary to save the file."));
 
       gtk_window_set_title (GTK_WINDOW (dialog), "");
 
@@ -1352,9 +1321,7 @@ confirm_close_project (GladeWindow * window, GladeProject * project)
                                    GTK_MESSAGE_WARNING,
                                    GTK_BUTTONS_NONE, "%s", msg);
   gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                            "%s",
-                                            _
-                                            ("Your changes will be lost if you don't save them."));
+                                            "%s", _("Your changes will be lost if you don't save them."));
   gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
 
   gtk_dialog_add_buttons (GTK_DIALOG (dialog),
@@ -1578,23 +1545,31 @@ preferences_cb (GtkAction * action, GladeWindow * window)
 static void
 undo_cb (GtkAction * action, GladeWindow * window)
 {
-  if (!glade_app_get_project ())
+  GladeProject *active_project;
+
+  if (!window->priv->active_view)
     {
       g_warning ("undo should not be sensitive: we don't have a project");
       return;
     }
-  glade_app_command_undo ();
+
+  active_project = glade_design_view_get_project (window->priv->active_view);
+  glade_project_undo (active_project);
 }
 
 static void
 redo_cb (GtkAction * action, GladeWindow * window)
 {
-  if (!glade_app_get_project ())
+  GladeProject *active_project;
+
+  if (!window->priv->active_view)
     {
       g_warning ("redo should not be sensitive: we don't have a project");
       return;
     }
-  glade_app_command_redo ();
+
+  active_project = glade_design_view_get_project (window->priv->active_view);
+  glade_project_redo (active_project);
 }
 
 static void
@@ -1661,6 +1636,8 @@ notebook_switch_page_cb (GtkNotebook * notebook,
     gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
 
   g_free (action_name);
+
+  refresh_undo_redo (window, project);
 }
 
 static void
@@ -1695,6 +1672,8 @@ notebook_tab_added_cb (GtkNotebook * notebook,
                     G_CALLBACK (project_selection_changed_cb), window);
   g_signal_connect (G_OBJECT (project), "targets-changed",
                     G_CALLBACK (project_targets_changed_cb), window);
+  g_signal_connect (G_OBJECT (project), "changed",
+                    G_CALLBACK (project_changed_cb), window);
 
   /* create inspector */
   inspector = glade_inspector_new ();
@@ -1727,9 +1706,10 @@ notebook_tab_added_cb (GtkNotebook * notebook,
 }
 
 static void
-notebook_tab_removed_cb (GtkNotebook * notebook,
-                         GladeDesignView * view,
-                         guint page_num, GladeWindow * window)
+notebook_tab_removed_cb (GtkNotebook     *notebook,
+                         GladeDesignView *view,
+                         guint            page_num, 
+			 GladeWindow     *window)
 {
   GladeProject *project;
 
@@ -1744,11 +1724,14 @@ notebook_tab_removed_cb (GtkNotebook * notebook,
                                         G_CALLBACK (project_notify_handler_cb),
                                         window);
   g_signal_handlers_disconnect_by_func (G_OBJECT (project),
-                                        G_CALLBACK
-                                        (project_selection_changed_cb), window);
+                                        G_CALLBACK (project_selection_changed_cb), 
+					window);
   g_signal_handlers_disconnect_by_func (G_OBJECT (project),
                                         G_CALLBACK (project_targets_changed_cb),
                                         window);
+  g_signal_handlers_disconnect_by_func (G_OBJECT (project),
+                                        G_CALLBACK (project_changed_cb),
+                                        window);
 
 
   gtk_notebook_remove_page (GTK_NOTEBOOK (window->priv->inspectors_notebook),
@@ -2436,22 +2419,6 @@ create_selector_tool_button (GtkToolbar * toolbar)
 }
 
 static GtkWidget *
-create_preview_tool_button (GtkToolbar * toolbar)
-{
-  GtkToolItem *button;
-  button = gtk_tool_button_new_from_stock (GTK_STOCK_EXECUTE);
-  gtk_tool_button_set_label (GTK_TOOL_BUTTON (button), _("Preview snapshot"));
-
-  gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (button),
-                                  _("Previews snapshot of project"));
-
-  gtk_widget_show (GTK_WIDGET (button));
-
-  return GTK_WIDGET (button);
-}
-
-
-static GtkWidget *
 create_drag_resize_tool_button (GtkToolbar * toolbar)
 {
   GtkToolItem *button;
@@ -2601,9 +2568,6 @@ add_project (GladeWindow * window, GladeProject * project, gboolean for_file)
   g_object_set_data (G_OBJECT (view), "view-added-while-loading",
                      GINT_TO_POINTER (for_file));
 
-  /* Update preview button */
-  gtk_widget_set_sensitive (GTK_WIDGET (window->priv->preview_button), FALSE);
-
   /* Pass ownership of the project to the app */
   glade_app_add_project (project);
   g_object_unref (project);
@@ -2776,8 +2740,6 @@ glade_window_open_project (GladeWindow * window, const gchar * path)
     }
 }
 
-
-
 static void
 change_menu_label (GladeWindow * window,
                    const gchar * path,
@@ -2810,14 +2772,11 @@ change_menu_label (GladeWindow * window,
 }
 
 static void
-refresh_undo_redo (GladeWindow * window)
+refresh_undo_redo (GladeWindow *window, GladeProject *project)
 {
   GladeCommand *undo = NULL, *redo = NULL;
-  GladeProject *project;
-  GtkAction *action;
-  gchar *tooltip;
-
-  project = glade_app_get_project ();
+  GtkAction    *action;
+  gchar        *tooltip;
 
   if (project != NULL)
     {
@@ -2862,22 +2821,6 @@ refresh_undo_redo (GladeWindow * window)
 }
 
 static void
-update_ui (GladeApp * app, GladeWindow * window)
-{
-  GladeProject *project;
-
-  if (window->priv->active_view)
-    {
-      project = glade_design_view_get_project (window->priv->active_view);
-      gtk_widget_set_sensitive (GTK_WIDGET (window->priv->preview_button),
-                                glade_project_get_previewable (project));
-      gtk_widget_queue_draw (GTK_WIDGET (window->priv->active_view));
-    }
-
-  refresh_undo_redo (window);
-}
-
-static void
 glade_window_dispose (GObject * object)
 {
   GladeWindow *window = GLADE_WINDOW (object);
@@ -3436,13 +3379,6 @@ glade_window_init (GladeWindow * window)
   gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
                       GTK_TOOL_ITEM (priv->selector_button), -1);
 
-  priv->preview_button =
-      GTK_TOOL_BUTTON (create_preview_tool_button
-                       (GTK_TOOLBAR (priv->toolbar)));
-  gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
-                      GTK_TOOL_ITEM (priv->preview_button), -1);
-  gtk_widget_set_sensitive (GTK_WIDGET (priv->preview_button), FALSE);
-
   priv->drag_resize_button =
       GTK_TOGGLE_TOOL_BUTTON (create_drag_resize_tool_button
                               (GTK_TOOLBAR (priv->toolbar)));
@@ -3454,8 +3390,6 @@ glade_window_init (GladeWindow * window)
 
   g_signal_connect (G_OBJECT (priv->selector_button), "toggled",
                     G_CALLBACK (on_selector_button_toggled), window);
-  g_signal_connect (G_OBJECT (priv->preview_button), "clicked",
-                    G_CALLBACK (on_preview_button_clicked), window);
   g_signal_connect (G_OBJECT (priv->drag_resize_button), "toggled",
                     G_CALLBACK (on_drag_resize_button_toggled), window);
   g_signal_connect (G_OBJECT (glade_app_get ()), "notify::pointer-mode",
@@ -3489,10 +3423,6 @@ glade_window_init (GladeWindow * window)
   g_signal_connect (G_OBJECT (window), "key-press-event",
                     G_CALLBACK (glade_utils_hijack_key_press), window);
 
-  /* GladeApp signals */
-  g_signal_connect (G_OBJECT (priv->app), "update-ui",
-                    G_CALLBACK (update_ui), window);
-
   /* Clipboard signals */
   g_signal_connect (G_OBJECT (glade_app_get_clipboard ()),
                     "notify::has-selection",



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