aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-11-23 00:37:38 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-11-23 00:38:14 +0100
commit7ab1a6d2465dabc37e3e5f751de6e07011ee4b72 (patch)
treea82aaee6d5b9cd82076f10e261a983f194a47193
parent1e6689aed42d3362ea2d56e6f05376f801b5862b (diff)
downloadfiv-7ab1a6d2465dabc37e3e5f751de6e07011ee4b72.tar.gz
fiv-7ab1a6d2465dabc37e3e5f751de6e07011ee4b72.tar.xz
fiv-7ab1a6d2465dabc37e3e5f751de6e07011ee4b72.zip
Improve browser open handling
-rw-r--r--fastiv-browser.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/fastiv-browser.c b/fastiv-browser.c
index 830abd8..f130473 100644
--- a/fastiv-browser.c
+++ b/fastiv-browser.c
@@ -617,15 +617,25 @@ fastiv_browser_draw(GtkWidget *widget, cairo_t *cr)
}
static gboolean
+open_entry(GtkWidget *self, const Entry *entry, gboolean new_window)
+{
+ g_signal_emit(self, browser_signals[ITEM_ACTIVATED], 0, entry->filename,
+ new_window ? GTK_PLACES_OPEN_NEW_WINDOW : GTK_PLACES_OPEN_NORMAL);
+ return TRUE;
+}
+
+static gboolean
fastiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event)
{
GTK_WIDGET_CLASS(fastiv_browser_parent_class)
->button_press_event(widget, event);
FastivBrowser *self = FASTIV_BROWSER(widget);
- if (event->type != GDK_BUTTON_PRESS || event->state != 0)
+ if (event->type != GDK_BUTTON_PRESS)
return FALSE;
- if (event->button == GDK_BUTTON_PRIMARY &&
+
+ guint state = event->state & gtk_accelerator_get_default_mod_mask();
+ if (event->button == GDK_BUTTON_PRIMARY && state == 0 &&
gtk_widget_get_focus_on_click(widget))
gtk_widget_grab_focus(widget);
@@ -635,13 +645,18 @@ fastiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event)
switch (event->button) {
case GDK_BUTTON_PRIMARY:
- g_signal_emit(widget, browser_signals[ITEM_ACTIVATED], 0,
- entry->filename, GTK_PLACES_OPEN_NORMAL);
- return TRUE;
+ if (state == 0)
+ return open_entry(widget, entry, FALSE);
+ if (state == GDK_CONTROL_MASK)
+ return open_entry(widget, entry, TRUE);
+ return FALSE;
case GDK_BUTTON_MIDDLE:
- g_signal_emit(widget, browser_signals[ITEM_ACTIVATED], 0,
- entry->filename, GTK_PLACES_OPEN_NEW_WINDOW);
- return TRUE;
+ if (state == 0)
+ return open_entry(widget, entry, TRUE);
+ return FALSE;
+ case GDK_BUTTON_SECONDARY:
+ // TODO(p): Context menu.
+ return FALSE;
default:
return FALSE;
}