[nautilus] window: convert binding set keybindings into proper actions



commit 4e9c1b9dce05a216d40698a3787b422f6d523173
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Aug 31 23:36:07 2012 -0400

    window: convert binding set keybindings into proper actions
    
    Or reuse already existing actions. Cleans up NautilusWindow a bit.

 src/nautilus-shell-ui.xml     |    2 +
 src/nautilus-window-menus.c   |   16 +++++++++++-
 src/nautilus-window-private.h |    2 +
 src/nautilus-window.c         |   56 +----------------------------------------
 src/nautilus-window.h         |    5 ---
 5 files changed, 20 insertions(+), 61 deletions(-)
---
diff --git a/src/nautilus-shell-ui.xml b/src/nautilus-shell-ui.xml
index 1912902..2fb2961 100644
--- a/src/nautilus-shell-ui.xml
+++ b/src/nautilus-shell-ui.xml
@@ -13,6 +13,8 @@
 <accelerator action="ZoomInAccel"/>
 <accelerator action="ZoomInAccel2"/>
 <accelerator action="ZoomOutAccel"/>
+<accelerator action="PromptLocationAccel"/>
+<accelerator action="ReloadAccel"/>
 <popup name="ViewMenu">
   <placeholder name="Zoom Items Placeholder">
     <menuitem name="Zoom In" action="Zoom In"/>
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index c8d06e5..4eb0e7f 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -429,6 +429,13 @@ action_show_hide_search_callback (GtkAction *action,
 }
 
 static void
+action_prompt_for_location_callback (GtkAction *action,
+				     NautilusWindow *window)
+{
+	nautilus_window_prompt_for_location (window, "/");
+}
+
+static void
 action_view_radio_changed (GtkRadioAction *action,
 			   GtkRadioAction *current,
 			   NautilusWindow *window)
@@ -467,6 +474,10 @@ static const GtkActionEntry main_entries[] = {
   /* label, accelerator */       N_("_Reload"), "<control>R",
   /* tooltip */                  N_("Reload the current location"),
                                  G_CALLBACK (action_reload_callback) },
+  /* name, stock id */         { "ReloadAccel", NULL,
+  /* label, accelerator */       "ReloadAccel", "F5",
+  /* tooltip */                  NULL,
+                                 G_CALLBACK (action_reload_callback) },
   /* name, stock id */         { NAUTILUS_ACTION_HELP, GTK_STOCK_HELP,
   /* label, accelerator */       N_("_All Topics"), "F1",
   /* tooltip */                  N_("Display Nautilus help"),
@@ -563,7 +574,10 @@ static const GtkActionEntry main_entries[] = {
   /* label, accelerator */       N_("P_roperties"), NULL,
   /* tooltip */                  N_("View or modify the properties of this folder"),
 				 G_CALLBACK (action_location_properties_callback) },
-
+  /* name, stock id */         { "PromptLocationAccel", NULL,
+  /* label, accelerator */       "PromptLocationAccel", "slash",
+  /* tooltip */                  NULL,
+				 G_CALLBACK (action_prompt_for_location_callback) },
 };
 
 static const GtkToggleActionEntry main_toggle_entries[] = {
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index e1cdd5e..e908a79 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -102,6 +102,8 @@ NautilusWindowSlot *nautilus_window_get_slot_for_view                    (Nautil
 void                 nautilus_window_set_active_slot                     (NautilusWindow    *window,
 									  NautilusWindowSlot *slot);
 
+void                 nautilus_window_prompt_for_location                 (NautilusWindow *window,
+                                                                          const char     *initial);
 
 /* sync window GUI with current slot. Used when changing slots,
  * and when updating the slot state.
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 843b0dc..c088556 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -99,9 +99,6 @@ enum {
 };
 
 enum {
-	GO_UP,
-	RELOAD,
-	PROMPT_FOR_LOCATION,
 	LOADING_URI,
 	SLOT_ADDED,
 	SLOT_REMOVED,
@@ -157,12 +154,6 @@ nautilus_window_go_to_full (NautilusWindow *window,
 						 location, 0, NULL, callback, user_data);
 }
 
-static void
-nautilus_window_go_up_signal (NautilusWindow *window)
-{
-	nautilus_window_slot_go_up (nautilus_window_get_active_slot (window), 0);
-}
-
 static int
 bookmark_list_get_uri_index (GList *list, GFile *location)
 {
@@ -449,7 +440,7 @@ nautilus_window_sync_allow_stop (NautilusWindow *window,
 	}
 }
 
-static void
+void
 nautilus_window_prompt_for_location (NautilusWindow *window,
 				     const char     *initial)
 {
@@ -1882,15 +1873,6 @@ nautilus_window_get_slots (NautilusWindow *window)
 	return window->details->slots;
 }
 
-static void
-nautilus_window_reload (NautilusWindow *window)
-{
-	NautilusWindowSlot *active_slot;
-
-	active_slot = nautilus_window_get_active_slot (window);
-	nautilus_window_slot_reload (active_slot);
-}
-
 static gboolean
 nautilus_window_state_event (GtkWidget *widget,
 			     GdkEventWindowState *event)
@@ -2019,7 +2001,6 @@ real_window_close (NautilusWindow *window)
 static void
 nautilus_window_class_init (NautilusWindowClass *class)
 {
-	GtkBindingSet *binding_set;
 	GObjectClass *oclass = G_OBJECT_CLASS (class);
 	GtkWidgetClass *wclass = GTK_WIDGET_CLASS (class);
 
@@ -2050,30 +2031,6 @@ nautilus_window_class_init (NautilusWindowClass *class)
 				      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
 				      G_PARAM_STATIC_STRINGS);
 
-	signals[GO_UP] =
-		g_signal_new ("go-up",
-			      G_TYPE_FROM_CLASS (class),
-			      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-			      G_STRUCT_OFFSET (NautilusWindowClass, go_up),
-			      NULL, NULL,
-			      g_cclosure_marshal_generic,
-			      G_TYPE_NONE, 0);
-	signals[RELOAD] =
-		g_signal_new ("reload",
-			      G_TYPE_FROM_CLASS (class),
-			      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-			      G_STRUCT_OFFSET (NautilusWindowClass, reload),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__VOID,
-			      G_TYPE_NONE, 0);
-	signals[PROMPT_FOR_LOCATION] =
-		g_signal_new ("prompt-for-location",
-			      G_TYPE_FROM_CLASS (class),
-			      G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-			      G_STRUCT_OFFSET (NautilusWindowClass, prompt_for_location),
-			      NULL, NULL,
-			      g_cclosure_marshal_VOID__STRING,
-			      G_TYPE_NONE, 1, G_TYPE_STRING);
 	signals[LOADING_URI] =
 		g_signal_new ("loading_uri",
 			      G_TYPE_FROM_CLASS (class),
@@ -2100,17 +2057,6 @@ nautilus_window_class_init (NautilusWindowClass *class)
 			      g_cclosure_marshal_VOID__OBJECT,
 			      G_TYPE_NONE, 1, NAUTILUS_TYPE_WINDOW_SLOT);
 
-	binding_set = gtk_binding_set_by_class (class);
-	gtk_binding_entry_add_signal (binding_set, GDK_KEY_F5, 0,
-				      "reload", 0);
-	gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, 0,
-				      "prompt-for-location", 1,
-				      G_TYPE_STRING, "/");
-
-	class->reload = nautilus_window_reload;
-	class->go_up = nautilus_window_go_up_signal;
-	class->prompt_for_location = nautilus_window_prompt_for_location;
-
 	g_signal_connect_swapped (nautilus_preferences,
 				  "changed::" NAUTILUS_PREFERENCES_MOUSE_BACK_BUTTON,
 				  G_CALLBACK(mouse_back_button_changed),
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 6e7ed63..406fb64 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -76,12 +76,7 @@ typedef struct {
         NautilusIconInfo * (* get_icon) (NautilusWindow *window,
                                          NautilusWindowSlot *slot);
 
-        void   (* prompt_for_location) (NautilusWindow *window, const char *initial);
         void   (* close) (NautilusWindow *window);
-
-        /* Signals used only for keybindings */
-        void   (* go_up)  (NautilusWindow *window);
-	void   (* reload) (NautilusWindow *window);
 } NautilusWindowClass;
 
 struct NautilusWindow {



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