mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-06-30 23:46:35 +00:00
files-view: Don't add accels to application
Same change as for NautilusWindowSlot. Refer to parent commit. Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3411
This commit is contained in:
parent
9dbe8569c3
commit
13ae2e6fd3
|
@ -233,6 +233,7 @@ typedef struct
|
|||
GtkWidget *background_menu;
|
||||
|
||||
GActionGroup *view_action_group;
|
||||
GtkShortcutController *shortcuts;
|
||||
|
||||
/* Empty states */
|
||||
GtkWidget *empty_view_page;
|
||||
|
@ -5439,8 +5440,9 @@ add_script_to_scripts_menus (NautilusFilesView *view,
|
|||
|
||||
if ((shortcut = g_hash_table_lookup (script_accels, name)))
|
||||
{
|
||||
nautilus_application_set_accelerator (g_application_get_default (),
|
||||
detailed_action_name, shortcut);
|
||||
gtk_shortcut_controller_add_shortcut (priv->shortcuts,
|
||||
gtk_shortcut_new (gtk_shortcut_trigger_parse_string (shortcut),
|
||||
gtk_named_action_new (detailed_action_name)));
|
||||
}
|
||||
|
||||
g_free (action_name);
|
||||
|
@ -9664,28 +9666,6 @@ nautilus_files_view_init (NautilusFilesView *view)
|
|||
GtkShortcut *shortcut;
|
||||
gchar *templates_uri;
|
||||
GdkClipboard *clipboard;
|
||||
GApplication *app;
|
||||
const gchar *zoom_in_accels[] =
|
||||
{
|
||||
"<control>equal",
|
||||
"<control>plus",
|
||||
"<control>KP_Add",
|
||||
"ZoomIn",
|
||||
NULL
|
||||
};
|
||||
const gchar *zoom_out_accels[] =
|
||||
{
|
||||
"<control>minus",
|
||||
"<control>KP_Subtract",
|
||||
"ZoomOut",
|
||||
NULL
|
||||
};
|
||||
const gchar *zoom_standard_accels[] =
|
||||
{
|
||||
"<control>0",
|
||||
"<control>KP_0",
|
||||
NULL
|
||||
};
|
||||
|
||||
priv = nautilus_files_view_get_instance_private (view);
|
||||
|
||||
|
@ -9794,30 +9774,39 @@ nautilus_files_view_init (NautilusFilesView *view)
|
|||
g_signal_connect_object (priv->view_action_group, "action-state-changed::sort",
|
||||
G_CALLBACK (on_sort_action_state_changed), view, 0);
|
||||
|
||||
app = g_application_get_default ();
|
||||
|
||||
/* NOTE: Please do not add any key here that could interfere with
|
||||
* the rest of the app's use of those keys. Some example of keys set here
|
||||
* that broke keynav include Enter/Return, Menu, F2 and Delete keys.
|
||||
* The accelerators below are set on the whole app level for the sole purpose
|
||||
* The accelerators below are set on the window level for the sole purpose
|
||||
* of making it more convenient when you don't have the focus exactly on the
|
||||
* files view, but some keys are used in a contextual way, and those should
|
||||
* should be added in nautilus_files_view_class_init() above instead of a
|
||||
* global accelerator, unless it really makes sense to have them globally
|
||||
* managed accelerator, unless it really makes sense to have them managed
|
||||
* (e.g. Zoom in/out shortcuts).
|
||||
*/
|
||||
nautilus_application_set_accelerators (app, "view.zoom-in", zoom_in_accels);
|
||||
nautilus_application_set_accelerators (app, "view.zoom-out", zoom_out_accels);
|
||||
nautilus_application_set_accelerator (app, "view.show-hidden-files", "<control>h");
|
||||
#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)))))
|
||||
|
||||
priv->shortcuts = GTK_SHORTCUT_CONTROLLER (gtk_shortcut_controller_new ());
|
||||
|
||||
gtk_shortcut_controller_set_scope (priv->shortcuts, GTK_SHORTCUT_SCOPE_MANAGED);
|
||||
gtk_widget_add_controller (GTK_WIDGET (view), GTK_EVENT_CONTROLLER (priv->shortcuts));
|
||||
|
||||
ADD_SHORTCUT_FOR_ACTION (priv->shortcuts, "view.zoom-in", "<control>equal|<control>plus|<control>KP_Add|ZoomIn");
|
||||
ADD_SHORTCUT_FOR_ACTION (priv->shortcuts, "view.zoom-out", "<control>minus|<control>KP_Subtract|ZoomOut");
|
||||
ADD_SHORTCUT_FOR_ACTION (priv->shortcuts, "view.show-hidden-files", "<control>h");
|
||||
/* Despite putting copy/cut at the widget scope instead of the global one,
|
||||
* we're putting paste globally so that it's easy to switch between apps
|
||||
* we're putting paste "managed" so that it's easy to switch between apps
|
||||
* with e.g. Alt+Tab and paste directly the copied file without having to
|
||||
* make sure the focus is on the files view.
|
||||
*/
|
||||
nautilus_application_set_accelerator (app, "view.paste_accel", "<control>v");
|
||||
nautilus_application_set_accelerator (app, "view.new-folder", "<control><shift>n");
|
||||
nautilus_application_set_accelerator (app, "view.select-pattern", "<control>s");
|
||||
nautilus_application_set_accelerators (app, "view.zoom-standard", zoom_standard_accels);
|
||||
ADD_SHORTCUT_FOR_ACTION (priv->shortcuts, "view.paste_accel", "<control>v");
|
||||
ADD_SHORTCUT_FOR_ACTION (priv->shortcuts, "view.new-folder", "<control><shift>n");
|
||||
ADD_SHORTCUT_FOR_ACTION (priv->shortcuts, "view.select-pattern", "<control>s");
|
||||
ADD_SHORTCUT_FOR_ACTION (priv->shortcuts, "view.zoom-standard", "<control>0|<control>KP_0");
|
||||
#undef ADD_SHORTCUT_FOR_ACTION
|
||||
|
||||
/* This one should have been a keybinding, because it should trigger only
|
||||
* when the view is focused. Unfortunately, children can override bindings,
|
||||
|
|
|
@ -258,7 +258,7 @@
|
|||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes" context="shortcut window">Show/Hide Hidden Files</property>
|
||||
<property name="action-name">view.show-hidden-files</property>
|
||||
<property name="accelerator"><Primary>H</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -321,7 +321,7 @@
|
|||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes" context="shortcut window">Create Folder</property>
|
||||
<property name="action-name">view.new-folder</property>
|
||||
<property name="accelerator"><Primary><shift>N</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -369,7 +369,7 @@
|
|||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes" context="shortcut window">Paste</property>
|
||||
<property name="action-name">view.paste_accel</property>
|
||||
<property name="accelerator"><Primary>V</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -387,7 +387,7 @@
|
|||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="title" translatable="yes" context="shortcut window">Select Items Matching</property>
|
||||
<property name="action-name">view.select-pattern</property>
|
||||
<property name="accelerator"><Primary>S</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
|
Loading…
Reference in New Issue
Block a user