aboutsummaryrefslogtreecommitdiff
path: root/fiv-browser.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-12-20 10:15:15 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-12-20 10:15:46 +0100
commitdfa1fed18b3e55b8244c0c35d2cb511f1ad36c1a (patch)
tree3be8ff8a28e7ff6822ff620e20b5dc5f29a55e30 /fiv-browser.c
parent58d11ebbff902f0fd8dcc155840c1ab0e9e836ae (diff)
downloadfiv-dfa1fed18b3e55b8244c0c35d2cb511f1ad36c1a.tar.gz
fiv-dfa1fed18b3e55b8244c0c35d2cb511f1ad36c1a.tar.xz
fiv-dfa1fed18b3e55b8244c0c35d2cb511f1ad36c1a.zip
Add a context menu to opened directories
So that they can be opened with, e.g., Thunar.
Diffstat (limited to 'fiv-browser.c')
-rw-r--r--fiv-browser.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fiv-browser.c b/fiv-browser.c
index 345913b..2dfd70e 100644
--- a/fiv-browser.c
+++ b/fiv-browser.c
@@ -45,6 +45,7 @@ struct _FivBrowser {
int item_height; ///< Thumbnail height in pixels
int item_spacing; ///< Space between items in pixels
+ char *path; ///< Current path
GArray *entries; ///< [Entry]
GArray *layouted_rows; ///< [Row]
int selected;
@@ -626,6 +627,7 @@ static void
fiv_browser_finalize(GObject *gobject)
{
FivBrowser *self = FIV_BROWSER(gobject);
+ g_free(self->path);
g_array_free(self->entries, TRUE);
g_array_free(self->layouted_rows, TRUE);
cairo_surface_destroy(self->glow);
@@ -804,6 +806,12 @@ fiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event)
gtk_widget_grab_focus(widget);
const Entry *entry = entry_at(self, event->x, event->y);
+ if (!entry && event->button == GDK_BUTTON_SECONDARY) {
+ gchar *uri = g_filename_to_uri(self->path, NULL, NULL);
+ show_context_menu(widget, uri);
+ g_free(uri);
+ return TRUE;
+ }
if (!entry)
return FALSE;
@@ -1038,8 +1046,9 @@ fiv_browser_load(
{
g_array_set_size(self->entries, 0);
g_array_set_size(self->layouted_rows, 0);
+ g_clear_pointer(&self->path, g_free);
- GFile *file = g_file_new_for_path(path);
+ GFile *file = g_file_new_for_path((self->path = g_strdup(path)));
GFileEnumerator *enumerator = g_file_enumerate_children(file,
G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE, NULL, NULL);