mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-06-30 23:46:35 +00:00
toolbar: Import location entry actions
To make them reusable in the upcoming FileChooser window. Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3413
This commit is contained in:
parent
2a22055d92
commit
f35402d5e2
|
@ -1219,7 +1219,7 @@ make_button_data (NautilusPathBar *self,
|
|||
gtk_widget_add_css_class (button_data->button, "current-dir");
|
||||
gtk_widget_set_hexpand (button_data->button, TRUE);
|
||||
gtk_widget_set_halign (button_data->label, GTK_ALIGN_START);
|
||||
gtk_actionable_set_action_name (GTK_ACTIONABLE (button_data->button), "win.enter-location");
|
||||
gtk_actionable_set_action_name (GTK_ACTIONABLE (button_data->button), "toolbar.edit-location");
|
||||
}
|
||||
|
||||
if (button_data->label != NULL)
|
||||
|
|
|
@ -111,7 +111,7 @@ toolbar_update_appearance (NautilusToolbar *self)
|
|||
search_global ? self->history_controls_placeholder : self->history_controls);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nautilus_toolbar_open_location_entry (NautilusToolbar *self,
|
||||
const char *special_text)
|
||||
{
|
||||
|
@ -216,6 +216,36 @@ on_location_entry_location_changed (NautilusLocationEntry *entry,
|
|||
nautilus_window_slot_open_location_full (self->window_slot, location, 0, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
action_edit_location (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameter)
|
||||
{
|
||||
NautilusToolbar *self = NAUTILUS_TOOLBAR (widget);
|
||||
|
||||
nautilus_toolbar_open_location_entry (self, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
action_prompt_root_location (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameter)
|
||||
{
|
||||
NautilusToolbar *self = NAUTILUS_TOOLBAR (widget);
|
||||
|
||||
nautilus_toolbar_open_location_entry (self, "/");
|
||||
}
|
||||
|
||||
static void
|
||||
action_prompt_home_location (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameter)
|
||||
{
|
||||
NautilusToolbar *self = NAUTILUS_TOOLBAR (widget);
|
||||
|
||||
nautilus_toolbar_open_location_entry (self, "~");
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_toolbar_init (NautilusToolbar *self)
|
||||
{
|
||||
|
@ -226,6 +256,23 @@ nautilus_toolbar_init (NautilusToolbar *self)
|
|||
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
GtkShortcutController *shortcuts = GTK_SHORTCUT_CONTROLLER (gtk_shortcut_controller_new ());
|
||||
|
||||
gtk_shortcut_controller_set_scope (shortcuts, GTK_SHORTCUT_SCOPE_MANAGED);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (shortcuts));
|
||||
|
||||
#define ADD_SHORTCUT_FOR_ACTION(controller, action, trigger) \
|
||||
(gtk_shortcut_controller_add_shortcut ((controller), \
|
||||
gtk_shortcut_new (gtk_shortcut_trigger_parse_string ((trigger)), \
|
||||
gtk_named_action_new ((action)))))
|
||||
|
||||
ADD_SHORTCUT_FOR_ACTION (shortcuts, "toolbar.edit-location", "<control>l|Go|OpenURL");
|
||||
ADD_SHORTCUT_FOR_ACTION (shortcuts, "toolbar.prompt-root-location", "slash|KP_Divide");
|
||||
/* Support keyboard layouts which have a dead tilde key but not a tilde key. */
|
||||
ADD_SHORTCUT_FOR_ACTION (shortcuts, "toolbar.prompt-home-location", "asciitilde|dead_tilde");
|
||||
|
||||
#undef ADD_SHORTCUT_FOR_ACTION
|
||||
|
||||
/* Setup path bar */
|
||||
g_signal_connect_object (self->path_bar, "open-location",
|
||||
G_CALLBACK (on_path_bar_open_location), self,
|
||||
|
@ -428,6 +475,10 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
|
|||
gtk_widget_class_bind_template_callback (widget_class, nautilus_toolbar_close_location_entry);
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_TOOLBAR);
|
||||
|
||||
gtk_widget_class_install_action (widget_class, "toolbar.edit-location", NULL, action_edit_location);
|
||||
gtk_widget_class_install_action (widget_class, "toolbar.prompt-root-location", NULL, action_prompt_root_location);
|
||||
gtk_widget_class_install_action (widget_class, "toolbar.prompt-home-location", NULL, action_prompt_home_location);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
|
|
@ -38,9 +38,6 @@ GtkWidget *nautilus_toolbar_new (void);
|
|||
|
||||
void nautilus_toolbar_show_current_location_menu (NautilusToolbar *self);
|
||||
|
||||
void nautilus_toolbar_open_location_entry (NautilusToolbar *self,
|
||||
const char *special_text);
|
||||
|
||||
void nautilus_toolbar_set_active_slot (NautilusToolbar *toolbar,
|
||||
NautilusWindowSlot *slot);
|
||||
|
||||
|
|
|
@ -272,16 +272,6 @@ action_new_tab (GSimpleAction *action,
|
|||
nautilus_window_new_tab (NAUTILUS_WINDOW (user_data));
|
||||
}
|
||||
|
||||
static void
|
||||
action_enter_location (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusWindow *self = user_data;
|
||||
|
||||
nautilus_toolbar_open_location_entry (NAUTILUS_TOOLBAR (self->toolbar), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
action_tab_move_left (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
|
@ -321,26 +311,6 @@ action_go_to_tab (GSimpleAction *action,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
action_prompt_for_location_root (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusWindow *self = NAUTILUS_WINDOW (user_data);
|
||||
|
||||
nautilus_toolbar_open_location_entry (NAUTILUS_TOOLBAR (self->toolbar), "/");
|
||||
}
|
||||
|
||||
static void
|
||||
action_prompt_for_location_home (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusWindow *self = NAUTILUS_WINDOW (user_data);
|
||||
|
||||
nautilus_toolbar_open_location_entry (NAUTILUS_TOOLBAR (self->toolbar), "~");
|
||||
}
|
||||
|
||||
static void
|
||||
action_redo (GSimpleAction *action,
|
||||
GVariant *state,
|
||||
|
@ -1238,7 +1208,6 @@ const GActionEntry win_entries[] =
|
|||
{
|
||||
{ .name = "current-location-menu", .activate = action_show_current_location_menu },
|
||||
{ .name = "new-tab", .activate = action_new_tab },
|
||||
{ .name = "enter-location", .activate = action_enter_location },
|
||||
{ .name = "bookmark-current-location", .activate = action_bookmark_current_location },
|
||||
{ .name = "star-current-location", .activate = action_star_current_location },
|
||||
{ .name = "unstar-current-location", .activate = action_unstar_current_location },
|
||||
|
@ -1251,8 +1220,6 @@ const GActionEntry win_entries[] =
|
|||
{ .name = "tab-move-left", .activate = action_tab_move_left },
|
||||
{ .name = "tab-move-right", .activate = action_tab_move_right },
|
||||
{ .name = "tab-move-new-window", .activate = action_tab_move_new_window },
|
||||
{ .name = "prompt-root-location", .activate = action_prompt_for_location_root },
|
||||
{ .name = "prompt-home-location", .activate = action_prompt_for_location_home },
|
||||
{ .name = "go-to-tab", .parameter_type = "i", .state = "0", .change_state = action_go_to_tab },
|
||||
{ .name = "restore-tab", .activate = action_restore_tab },
|
||||
{ .name = "toggle-sidebar", .activate = action_toggle_sidebar },
|
||||
|
@ -1274,7 +1241,6 @@ nautilus_window_initialize_actions (NautilusWindow *window)
|
|||
#define ACCELS(...) ((const char *[]) { __VA_ARGS__, NULL })
|
||||
|
||||
app = g_application_get_default ();
|
||||
nautilus_application_set_accelerators (app, "win.enter-location", ACCELS ("<control>l", "Go", "OpenURL"));
|
||||
nautilus_application_set_accelerator (app, "win.new-tab", "<control>t");
|
||||
nautilus_application_set_accelerator (app, "win.close-current-view", "<control>w");
|
||||
|
||||
|
@ -1284,9 +1250,6 @@ nautilus_window_initialize_actions (NautilusWindow *window)
|
|||
nautilus_application_set_accelerators (app, "win.bookmark-current-location", ACCELS ("<control>d", "AddFavorite"));
|
||||
nautilus_application_set_accelerator (app, "win.tab-move-left", "<shift><control>Page_Up");
|
||||
nautilus_application_set_accelerator (app, "win.tab-move-right", "<shift><control>Page_Down");
|
||||
nautilus_application_set_accelerators (app, "win.prompt-root-location", ACCELS ("slash", "KP_Divide"));
|
||||
/* Support keyboard layouts which have a dead tilde key but not a tilde key. */
|
||||
nautilus_application_set_accelerators (app, "win.prompt-home-location", ACCELS ("asciitilde", "dead_tilde"));
|
||||
nautilus_application_set_accelerator (app, "win.current-location-menu", "F10");
|
||||
nautilus_application_set_accelerator (app, "win.restore-tab", "<shift><control>t");
|
||||
nautilus_application_set_accelerator (app, "win.toggle-sidebar", "F9");
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">Edit _Location</attribute>
|
||||
<attribute name="action">win.enter-location</attribute>
|
||||
<attribute name="action">toolbar.edit-location</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Copy Location</attribute>
|
||||
|
|
Loading…
Reference in New Issue
Block a user