[nautilus] canvas-view: move Stretch and Unstretch actions to the desktop view



commit 99383a5baf52fc6a978db63f17d7b96f20c9a2ec
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Sep 6 16:07:30 2012 -0400

    canvas-view: move Stretch and Unstretch actions to the desktop view

 src/nautilus-canvas-view-ui.xml         |    3 -
 src/nautilus-canvas-view.c              |   93 -------------------------------
 src/nautilus-desktop-canvas-view-ui.xml |    1 +
 src/nautilus-desktop-canvas-view.c      |   89 +++++++++++++++++++++++++++---
 4 files changed, 82 insertions(+), 104 deletions(-)
---
diff --git a/src/nautilus-canvas-view-ui.xml b/src/nautilus-canvas-view-ui.xml
index 11cf914..88db9ce 100644
--- a/src/nautilus-canvas-view-ui.xml
+++ b/src/nautilus-canvas-view-ui.xml
@@ -19,7 +19,4 @@
       <menuitem name="Unstretch" action="Unstretch"/>
     </placeholder>
   </popup>
-  <popup name="selection">
-    <placeholder name="Canvas Appearance Items"/>
-  </popup>
 </ui>
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 1c593c9..8ffca38 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -64,8 +64,6 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
-#define POPUP_PATH_CANVAS_APPEARANCE		"/selection/Canvas Appearance Items"
-
 enum 
 {
 	PROP_SUPPORTS_AUTO_LAYOUT = 1,
@@ -328,26 +326,6 @@ clear_sort_criterion (NautilusCanvasView *canvas_view)
 	real_set_sort_criterion (canvas_view, NULL, TRUE, TRUE);
 }
 
-static void
-action_stretch_callback (GtkAction *action,
-			 gpointer callback_data)
-{
-	g_assert (NAUTILUS_IS_CANVAS_VIEW (callback_data));
-
-	nautilus_canvas_container_show_stretch_handles
-		(get_canvas_container (NAUTILUS_CANVAS_VIEW (callback_data)));
-}
-
-static void
-action_unstretch_callback (GtkAction *action,
-			   gpointer callback_data)
-{
-	g_assert (NAUTILUS_IS_CANVAS_VIEW (callback_data));
-
-	nautilus_canvas_container_unstretch
-		(get_canvas_container (NAUTILUS_CANVAS_VIEW (callback_data)));
-}
-
 void
 nautilus_canvas_view_clean_up_by_name (NautilusCanvasView *canvas_view)
 {
@@ -1170,18 +1148,6 @@ nautilus_canvas_view_start_renaming_file (NautilusView *view,
 		(get_canvas_container (NAUTILUS_CANVAS_VIEW (view)), select_all);
 }
 
-static const GtkActionEntry canvas_view_entries[] = {
-  /* name, stock id, label */  { "Arrange Items", NULL, N_("Arran_ge Items") }, 
-  /* name, stock id */         { "Stretch", NULL,
-  /* label, accelerator */       N_("Resize Icon..."), NULL,
-  /* tooltip */                  N_("Make the selected icons resizable"),
-                                 G_CALLBACK (action_stretch_callback) },
-  /* name, stock id */         { "Unstretch", NULL,
-  /* label, accelerator */       N_("Restore Icons' Original Si_zes"), NULL,
-  /* tooltip */                  N_("Restore each selected icons to its original size"),
-                                 G_CALLBACK (action_unstretch_callback) },
-};
-
 static const GtkToggleActionEntry canvas_view_toggle_entries[] = {
   /* name, stock id */      { "Reversed Order", NULL,
   /* label, accelerator */    N_("Re_versed Order"), NULL,
@@ -1228,7 +1194,6 @@ nautilus_canvas_view_merge_menus (NautilusView *view)
 	NautilusCanvasView *canvas_view;
 	GtkUIManager *ui_manager;
 	GtkActionGroup *action_group;
-	GtkAction *action;
 	
         g_assert (NAUTILUS_IS_CANVAS_VIEW (view));
 
@@ -1241,9 +1206,6 @@ nautilus_canvas_view_merge_menus (NautilusView *view)
 	action_group = gtk_action_group_new ("CanvasViewActions");
 	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
 	canvas_view->details->canvas_action_group = action_group;
-	gtk_action_group_add_actions (action_group,
-				      canvas_view_entries, G_N_ELEMENTS (canvas_view_entries),
-				      canvas_view);
 	gtk_action_group_add_toggle_actions (action_group, 
 					     canvas_view_toggle_entries, G_N_ELEMENTS (canvas_view_toggle_entries),
 					     canvas_view);
@@ -1260,32 +1222,6 @@ nautilus_canvas_view_merge_menus (NautilusView *view)
 	canvas_view->details->canvas_merge_id =
 		gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-canvas-view-ui.xml", NULL);
 
-	/* Do one-time state-setting here; context-dependent state-setting
-	 * is done in update_menus.
-	 */
-	if (!nautilus_canvas_view_supports_auto_layout (canvas_view)) {
-		action = gtk_action_group_get_action (action_group,
-						      NAUTILUS_ACTION_ARRANGE_ITEMS);
-		gtk_action_set_visible (action, FALSE);
-	}
-
-	if (nautilus_canvas_view_supports_scaling (canvas_view)) {
-		gtk_ui_manager_add_ui (ui_manager,
-				       canvas_view->details->canvas_merge_id,
-				       POPUP_PATH_CANVAS_APPEARANCE,
-				       NAUTILUS_ACTION_STRETCH,
-				       NAUTILUS_ACTION_STRETCH,
-				       GTK_UI_MANAGER_MENUITEM,
-				       FALSE);
-		gtk_ui_manager_add_ui (ui_manager,
-				       canvas_view->details->canvas_merge_id,
-				       POPUP_PATH_CANVAS_APPEARANCE,
-				       NAUTILUS_ACTION_UNSTRETCH,
-				       NAUTILUS_ACTION_UNSTRETCH,
-				       GTK_UI_MANAGER_MENUITEM,
-				       FALSE);
-	}
-
 	update_layout_menus (canvas_view);
 }
 
@@ -1311,42 +1247,13 @@ static void
 nautilus_canvas_view_update_menus (NautilusView *view)
 {
 	NautilusCanvasView *canvas_view;
-        int selection_count;
 	GtkAction *action;
-        NautilusCanvasContainer *canvas_container;
 	gboolean editable;
 
         canvas_view = NAUTILUS_CANVAS_VIEW (view);
 
 	NAUTILUS_VIEW_CLASS (nautilus_canvas_view_parent_class)->update_menus(view);
 
-        selection_count = nautilus_view_get_selection_count (view);
-        canvas_container = get_canvas_container (canvas_view);
-
-	action = gtk_action_group_get_action (canvas_view->details->canvas_action_group,
-					      NAUTILUS_ACTION_STRETCH);
-	gtk_action_set_sensitive (action,
-				  selection_count == 1
-				  && canvas_container != NULL
-				  && !nautilus_canvas_container_has_stretch_handles (canvas_container));
-
-	gtk_action_set_visible (action,
-				nautilus_canvas_view_supports_scaling (canvas_view));
-
-	action = gtk_action_group_get_action (canvas_view->details->canvas_action_group,
-					      NAUTILUS_ACTION_UNSTRETCH);
-	g_object_set (action, "label",
-		      (selection_count > 1)
-		      ? _("Restore Icons' Original Si_zes")
-		      : _("Restore Icon's Original Si_ze"),
-		      NULL);
-	gtk_action_set_sensitive (action,
-				  canvas_container != NULL
-				  && nautilus_canvas_container_is_stretched (canvas_container));
-
-	gtk_action_set_visible (action,
-				nautilus_canvas_view_supports_scaling (canvas_view));
-
 	editable = nautilus_view_is_editable (view);
 	action = gtk_action_group_get_action (canvas_view->details->canvas_action_group,
 					      NAUTILUS_ACTION_MANUAL_LAYOUT);
diff --git a/src/nautilus-desktop-canvas-view-ui.xml b/src/nautilus-desktop-canvas-view-ui.xml
index 9348a92..ae8beeb 100644
--- a/src/nautilus-desktop-canvas-view-ui.xml
+++ b/src/nautilus-desktop-canvas-view-ui.xml
@@ -20,5 +20,6 @@
   <placeholder name="Empty Trash Holder">
     <menuitem name="Empty Trash" action="Empty Trash Conditional"/>
   </placeholder>
+  <placeholder name="Canvas Appearance Items"/>
 </popup>
 </ui>
diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index 1129bb4..e0c9ca5 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -93,6 +93,8 @@ static time_t desktop_dir_modify_time;
 
 #define get_canvas_container(w) nautilus_canvas_view_get_canvas_container(NAUTILUS_CANVAS_VIEW (w))
 
+#define POPUP_PATH_CANVAS_APPEARANCE		"/selection/Canvas Appearance Items"
+
 static void
 canvas_container_set_workarea (NautilusCanvasContainer *canvas_container,
 			     GdkScreen             *screen,
@@ -648,6 +650,28 @@ action_empty_trash_conditional_callback (GtkAction *action,
 	nautilus_file_operations_empty_trash (GTK_WIDGET (data));
 }
 
+static void
+action_stretch_callback (GtkAction *action,
+			 gpointer callback_data)
+{
+	nautilus_canvas_container_show_stretch_handles
+		(get_canvas_container (callback_data));
+}
+
+static void
+action_unstretch_callback (GtkAction *action,
+			   gpointer callback_data)
+{
+	nautilus_canvas_container_unstretch (get_canvas_container (callback_data));
+}
+
+static void
+action_clean_up_callback (GtkAction *action,
+			  gpointer callback_data)
+{
+	nautilus_canvas_view_clean_up_by_name (NAUTILUS_CANVAS_VIEW (callback_data));
+}
+
 static gboolean
 trash_link_is_selection (NautilusView *view)
 {
@@ -678,19 +702,14 @@ trash_link_is_selection (NautilusView *view)
 }
 
 static void
-action_clean_up_callback (GtkAction *action,
-			  gpointer callback_data)
-{
-	nautilus_canvas_view_clean_up_by_name (NAUTILUS_CANVAS_VIEW (callback_data));
-}
-
-static void
 real_update_menus (NautilusView *view)
 {
 	NautilusDesktopCanvasView *desktop_view;
-	char *label;
+        NautilusCanvasContainer *canvas_container;
 	gboolean include_empty_trash;
+	char *label;
 	GtkAction *action;
+        int selection_count;
 
 	g_assert (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view));
 
@@ -711,6 +730,31 @@ real_update_menus (NautilusView *view)
 					  !nautilus_trash_monitor_is_empty ());
 		g_free (label);
 	}
+
+	/* Stretch */
+        selection_count = nautilus_view_get_selection_count (view);
+        canvas_container = get_canvas_container (desktop_view);
+
+	action = gtk_action_group_get_action (desktop_view->details->desktop_action_group,
+					      NAUTILUS_ACTION_STRETCH);
+	gtk_action_set_sensitive (action,
+				  selection_count == 1
+				  && canvas_container != NULL
+				  && !nautilus_canvas_container_has_stretch_handles (canvas_container));
+	gtk_action_set_visible (action, TRUE);
+
+	/* Unstretch */
+	action = gtk_action_group_get_action (desktop_view->details->desktop_action_group,
+					      NAUTILUS_ACTION_UNSTRETCH);
+	g_object_set (action, "label",
+		      (selection_count > 1)
+		      ? _("Restore Icons' Original Si_zes")
+		      : _("Restore Icon's Original Si_ze"),
+		      NULL);
+	gtk_action_set_sensitive (action,
+				  canvas_container != NULL
+				  && nautilus_canvas_container_is_stretched (canvas_container));
+	gtk_action_set_visible (action, TRUE);
 }
 
 static const GtkActionEntry desktop_view_entries[] = {
@@ -735,6 +779,20 @@ static const GtkActionEntry desktop_view_entries[] = {
 	  /* tooltip */
 	  N_("Reposition icons to better fit in the window and avoid overlapping"),
 	  G_CALLBACK (action_clean_up_callback) },
+	/* name, stock id */
+         { "Stretch", NULL,
+	   /* label, accelerator */
+	   N_("Resize Icon..."), NULL,
+	   /* tooltip */
+	   N_("Make the selected icons resizable"),
+	   G_CALLBACK (action_stretch_callback) },
+	/* name, stock id */
+	{ "Unstretch", NULL,
+	  /* label, accelerator */
+	  N_("Restore Icons' Original Si_zes"), NULL,
+	  /* tooltip */
+	  N_("Restore each selected icons to its original size"),
+	  G_CALLBACK (action_unstretch_callback) },
 };
 
 static void
@@ -762,6 +820,21 @@ real_merge_menus (NautilusView *view)
 
 	desktop_view->details->desktop_merge_id =
 		gtk_ui_manager_add_ui_from_resource (ui_manager, "/org/gnome/nautilus/nautilus-desktop-canvas-view-ui.xml", NULL);
+
+	gtk_ui_manager_add_ui (ui_manager,
+			       desktop_view->details->desktop_merge_id,
+			       POPUP_PATH_CANVAS_APPEARANCE,
+			       NAUTILUS_ACTION_STRETCH,
+			       NAUTILUS_ACTION_STRETCH,
+			       GTK_UI_MANAGER_MENUITEM,
+			       FALSE);
+	gtk_ui_manager_add_ui (ui_manager,
+			       desktop_view->details->desktop_merge_id,
+			       POPUP_PATH_CANVAS_APPEARANCE,
+			       NAUTILUS_ACTION_UNSTRETCH,
+			       NAUTILUS_ACTION_UNSTRETCH,
+			       GTK_UI_MANAGER_MENUITEM,
+			       FALSE);
 }
 
 static NautilusView *



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