[file-roller/wip/jtojnar/search-jump] Add context menu item to navigate to a file from search
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/wip/jtojnar/search-jump] Add context menu item to navigate to a file from search
- Date: Mon, 16 May 2022 00:34:48 +0000 (UTC)
commit fb73d9de7fe57f5dee9cf125582a427f6cb53f37
Author: Jan Tojnar <jtojnar gmail com>
Date: Mon May 16 02:33:59 2022 +0200
Add context menu item to navigate to a file from search
src/fr-window-actions-callbacks.c | 16 ++++++++++++++++
src/fr-window-actions-callbacks.h | 1 +
src/fr-window-actions-entries.h | 1 +
src/fr-window.c | 1 +
src/ui/menus.ui | 5 +++++
5 files changed, 24 insertions(+)
---
diff --git a/src/fr-window-actions-callbacks.c b/src/fr-window-actions-callbacks.c
index c02e8d79..d1c18c4f 100644
--- a/src/fr-window-actions-callbacks.c
+++ b/src/fr-window-actions-callbacks.c
@@ -216,6 +216,22 @@ fr_window_activate_rename (GSimpleAction *action,
}
+void
+fr_window_activate_navigate_to (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ FrWindow *window = FR_WINDOW (user_data);
+ g_autofree GList *file_list = fr_window_get_file_list_selection (window, FALSE, NULL);
+ char *selected_file_path = file_list->data;
+ g_autofree char *selected_location = g_path_get_dirname (selected_file_path);
+ g_autofree char *selected_location_abs = g_strdup_printf ("/%s", selected_location);
+
+ fr_window_go_to_location (window, selected_location_abs, TRUE);
+ fr_window_find (window, FALSE);
+}
+
+
void
fr_window_activate_new (GSimpleAction *action,
GVariant *parameter,
diff --git a/src/fr-window-actions-callbacks.h b/src/fr-window-actions-callbacks.h
index 139be8a3..f63d41e9 100644
--- a/src/fr-window-actions-callbacks.h
+++ b/src/fr-window-actions-callbacks.h
@@ -41,6 +41,7 @@ DEF_ACTION_CALLBACK (fr_window_activate_find)
DEF_ACTION_CALLBACK (fr_window_activate_go_back)
DEF_ACTION_CALLBACK (fr_window_activate_go_forward)
DEF_ACTION_CALLBACK (fr_window_activate_go_home)
+DEF_ACTION_CALLBACK (fr_window_activate_navigate_to)
DEF_ACTION_CALLBACK (fr_window_activate_new)
DEF_ACTION_CALLBACK (fr_window_activate_open)
DEF_ACTION_CALLBACK (fr_window_activate_open_folder)
diff --git a/src/fr-window-actions-entries.h b/src/fr-window-actions-entries.h
index 08c8f3b0..4d32e384 100644
--- a/src/fr-window-actions-entries.h
+++ b/src/fr-window-actions-entries.h
@@ -41,6 +41,7 @@ static const GActionEntry fr_window_actions[] = {
{ "go-back", fr_window_activate_go_back },
{ "go-forward", fr_window_activate_go_forward },
{ "go-home", fr_window_activate_go_home },
+ { "navigate-to", fr_window_activate_navigate_to },
{ "open-folder", fr_window_activate_open_folder },
{ "open-with", fr_window_activate_open_with },
{ "reload", fr_window_activate_reload },
diff --git a/src/fr-window.c b/src/fr-window.c
index 0c06cb65..2268ac12 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -1172,6 +1172,7 @@ fr_window_update_sensitivity (FrWindow *window)
fr_window_enable_action (window, "edit-password", ! running && (! no_archive &&
window->archive->propPassword));
fr_window_enable_action (window, "extract-files", file_op);
fr_window_enable_action (window, "find", ! no_archive);
+ fr_window_enable_action (window, "navigate-to", ! no_archive && window->priv->filter_mode &&
one_file_selected && ! dir_selected);
fr_window_enable_action (window, "open-folder", file_op && one_file_selected && dir_selected);
fr_window_enable_action (window, "open-with", file_op && sel_not_null && ! dir_selected);
fr_window_enable_action (window, "rename", ! no_archive && ! ro && ! running && can_store_many_files
&& one_file_selected);
diff --git a/src/ui/menus.ui b/src/ui/menus.ui
index 69b33f2e..6a9ce7da 100644
--- a/src/ui/menus.ui
+++ b/src/ui/menus.ui
@@ -11,6 +11,11 @@
<attribute name="label" translatable="yes">_Open With…</attribute>
<attribute name="action">win.open-with</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">_Navigate to</attribute>
+ <attribute name="hidden-when">action-disabled</attribute>
+ <attribute name="action">win.navigate-to</attribute>
+ </item>
</section>
<section>
<item>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]