[nautilus] ui-utilities: centralize a helper function



commit 7309d5576f28de33e9a5e5653037264110893490
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Feb 15 22:45:40 2011 -0500

    ui-utilities: centralize a helper function

 libnautilus-private/nautilus-ui-utilities.c |   20 ++++++++++++++++++++
 libnautilus-private/nautilus-ui-utilities.h |    2 ++
 src/nautilus-navigation-window-menus.c      |   25 ++-----------------------
 src/nautilus-window-menus.c                 |   12 ++++++------
 4 files changed, 30 insertions(+), 29 deletions(-)
---
diff --git a/libnautilus-private/nautilus-ui-utilities.c b/libnautilus-private/nautilus-ui-utilities.c
index 3a63bfb..cf812f2 100644
--- a/libnautilus-private/nautilus-ui-utilities.c
+++ b/libnautilus-private/nautilus-ui-utilities.c
@@ -156,3 +156,23 @@ nautilus_action_from_menu_item (NautilusMenuItem *item)
 
 	return action;
 }
+
+gboolean
+nautilus_event_should_open_in_new_tab (void)
+{
+	GdkEvent *event;
+
+	event = gtk_get_current_event ();
+
+	if (event == NULL) {
+		return FALSE;
+	}
+
+	if (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) {
+		return event->button.button == 2;
+	}
+
+	gdk_event_free (event);
+
+	return FALSE;
+}
diff --git a/libnautilus-private/nautilus-ui-utilities.h b/libnautilus-private/nautilus-ui-utilities.h
index d1513c7..0338f6d 100644
--- a/libnautilus-private/nautilus-ui-utilities.h
+++ b/libnautilus-private/nautilus-ui-utilities.h
@@ -39,4 +39,6 @@ void        nautilus_ui_prepare_merge_ui           (GtkUIManager      *ui_manage
 GtkAction * nautilus_action_from_menu_item         (NautilusMenuItem  *item);
 const char *nautilus_ui_string_get                 (const char        *filename);
 
+gboolean  nautilus_event_should_open_in_new_tab   (void);
+
 #endif /* NAUTILUS_UI_UTILITIES_H */
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index a20480e..83d9d41 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -75,33 +75,12 @@ action_close_all_windows_callback (GtkAction *action,
 	g_object_unref (app);
 }
 
-static gboolean
-should_open_in_new_tab (void)
-{
-	/* FIXME this is duplicated */
-	GdkEvent *event;
-
-	event = gtk_get_current_event ();
-
-	if (event == NULL) {
-		return FALSE;
-	}
-
-	if (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) {
-		return event->button.button == 2;
-	}
-
-	gdk_event_free (event);
-
-	return FALSE;
-}
-
 static void
 action_back_callback (GtkAction *action, 
 		      gpointer user_data) 
 {
 	nautilus_navigation_window_back_or_forward (NAUTILUS_NAVIGATION_WINDOW (user_data), 
-						    TRUE, 0, should_open_in_new_tab ());
+						    TRUE, 0, nautilus_event_should_open_in_new_tab ());
 }
 
 static void
@@ -109,7 +88,7 @@ action_forward_callback (GtkAction *action,
 			 gpointer user_data) 
 {
 	nautilus_navigation_window_back_or_forward (NAUTILUS_NAVIGATION_WINDOW (user_data), 
-			                            FALSE, 0, should_open_in_new_tab ());
+			                            FALSE, 0, nautilus_event_should_open_in_new_tab ());
 }
 
 static void
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 501a647..967c566 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -282,7 +282,7 @@ action_home_callback (GtkAction *action,
 	slot = nautilus_window_get_active_slot (window);
 
 	nautilus_window_slot_go_home (slot, 
-				      should_open_in_new_tab ());
+				      nautilus_event_should_open_in_new_tab ());
 }
 
 static void
@@ -299,7 +299,7 @@ action_go_to_computer_callback (GtkAction *action,
 	computer = g_file_new_for_uri (COMPUTER_URI);
 	nautilus_window_slot_go_to (slot,
 				    computer,
-				    should_open_in_new_tab ());
+				    nautilus_event_should_open_in_new_tab ());
 	g_object_unref (computer);
 }
 
@@ -317,7 +317,7 @@ action_go_to_network_callback (GtkAction *action,
 	network = g_file_new_for_uri (NETWORK_URI);
 	nautilus_window_slot_go_to (slot,
 				    network,
-				    should_open_in_new_tab ());
+				    nautilus_event_should_open_in_new_tab ());
 	g_object_unref (network);
 }
 
@@ -338,7 +338,7 @@ action_go_to_templates_callback (GtkAction *action,
 	g_free (path);
 	nautilus_window_slot_go_to (slot,
 				    location,
-				    should_open_in_new_tab ());
+				    nautilus_event_should_open_in_new_tab ());
 	g_object_unref (location);
 }
 
@@ -356,7 +356,7 @@ action_go_to_trash_callback (GtkAction *action,
 	trash = g_file_new_for_uri ("trash:///");
 	nautilus_window_slot_go_to (slot,
 				    trash,
-				    should_open_in_new_tab ());
+				    nautilus_event_should_open_in_new_tab ());
 	g_object_unref (trash);
 }
 
@@ -544,7 +544,7 @@ action_up_callback (GtkAction *action,
 	NautilusWindowSlot *slot;
 
 	slot = nautilus_window_get_active_slot (window);
-	nautilus_window_slot_go_up (slot, FALSE, should_open_in_new_tab ());
+	nautilus_window_slot_go_up (slot, FALSE, nautilus_event_should_open_in_new_tab ());
 }
 
 static void



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