Compare commits
2 Commits
3e9a388537
...
2b8350eceb
Author | SHA1 | Date | |
---|---|---|---|
2b8350eceb | |||
75994cd85a |
@ -413,16 +413,25 @@ static gboolean
|
|||||||
fastiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event)
|
fastiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event)
|
||||||
{
|
{
|
||||||
FastivBrowser *self = FASTIV_BROWSER(widget);
|
FastivBrowser *self = FASTIV_BROWSER(widget);
|
||||||
if (event->type != GDK_BUTTON_PRESS || event->button != 1 ||
|
if (event->type != GDK_BUTTON_PRESS || event->state != 0)
|
||||||
event->state != 0)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
const Entry *entry = entry_at(self, event->x, event->y);
|
const Entry *entry = entry_at(self, event->x, event->y);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
g_signal_emit(widget, browser_signals[ITEM_ACTIVATED], 0, entry->filename);
|
switch (event->button) {
|
||||||
return TRUE;
|
case 1:
|
||||||
|
g_signal_emit(widget, browser_signals[ITEM_ACTIVATED], 0,
|
||||||
|
entry->filename, GTK_PLACES_OPEN_NORMAL);
|
||||||
|
return TRUE;
|
||||||
|
case 2:
|
||||||
|
g_signal_emit(widget, browser_signals[ITEM_ACTIVATED], 0,
|
||||||
|
entry->filename, GTK_PLACES_OPEN_NEW_WINDOW);
|
||||||
|
return TRUE;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -516,9 +525,9 @@ fastiv_browser_class_init(FastivBrowserClass *klass)
|
|||||||
widget_class->motion_notify_event = fastiv_browser_motion_notify_event;
|
widget_class->motion_notify_event = fastiv_browser_motion_notify_event;
|
||||||
widget_class->style_updated = fastiv_browser_style_updated;
|
widget_class->style_updated = fastiv_browser_style_updated;
|
||||||
|
|
||||||
browser_signals[ITEM_ACTIVATED] =
|
browser_signals[ITEM_ACTIVATED] = g_signal_new("item-activated",
|
||||||
g_signal_new("item-activated", G_TYPE_FROM_CLASS(klass), 0, 0,
|
G_TYPE_FROM_CLASS(klass), 0, 0, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING);
|
G_TYPE_NONE, 2, G_TYPE_STRING, GTK_TYPE_PLACES_OPEN_FLAGS);
|
||||||
|
|
||||||
// TODO(p): Later override "screen_changed", recreate Pango layouts there,
|
// TODO(p): Later override "screen_changed", recreate Pango layouts there,
|
||||||
// if we get to have any, or otherwise reflect DPI changes.
|
// if we get to have any, or otherwise reflect DPI changes.
|
||||||
|
@ -198,7 +198,6 @@ fastiv_view_realize(GtkWidget *widget)
|
|||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
// FIXME: This causes some flicker while scrolling, because it disables
|
// FIXME: This causes some flicker while scrolling, because it disables
|
||||||
// double buffering, see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2560
|
// double buffering, see: https://gitlab.gnome.org/GNOME/gtk/-/issues/2560
|
||||||
// FIXME: It also breaks Tab-switching at the start of program.
|
|
||||||
//
|
//
|
||||||
// If GTK+'s OpenGL integration fails to deliver, we need to use the window
|
// If GTK+'s OpenGL integration fails to deliver, we need to use the window
|
||||||
// directly, sidestepping the toolkit entirely.
|
// directly, sidestepping the toolkit entirely.
|
||||||
@ -214,16 +213,18 @@ fastiv_view_realize(GtkWidget *widget)
|
|||||||
static gboolean
|
static gboolean
|
||||||
fastiv_view_draw(GtkWidget *widget, cairo_t *cr)
|
fastiv_view_draw(GtkWidget *widget, cairo_t *cr)
|
||||||
{
|
{
|
||||||
FastivView *self = FASTIV_VIEW(widget);
|
// Placed here due to our using a native GdkWindow on X11,
|
||||||
if (!self->surface ||
|
// which makes the widget have no double buffering or default background.
|
||||||
!gtk_cairo_should_draw_window(cr, gtk_widget_get_window(widget)))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
gtk_widget_get_allocation(widget, &allocation);
|
gtk_widget_get_allocation(widget, &allocation);
|
||||||
gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0,
|
gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0,
|
||||||
allocation.width, allocation.height);
|
allocation.width, allocation.height);
|
||||||
|
|
||||||
|
FastivView *self = FASTIV_VIEW(widget);
|
||||||
|
if (!self->surface ||
|
||||||
|
!gtk_cairo_should_draw_window(cr, gtk_widget_get_window(widget)))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
get_display_dimensions(self, &w, &h);
|
get_display_dimensions(self, &w, &h);
|
||||||
|
|
||||||
|
34
fastiv.c
34
fastiv.c
@ -146,6 +146,10 @@ load_directory(const gchar *dirname)
|
|||||||
// XXX: When something outside the filtered entries is open, the index is
|
// XXX: When something outside the filtered entries is open, the index is
|
||||||
// kept at -1, and browsing doesn't work. How to behave here?
|
// kept at -1, and browsing doesn't work. How to behave here?
|
||||||
// Should we add it to the pointer array as an exception?
|
// Should we add it to the pointer array as an exception?
|
||||||
|
if (dirname) {
|
||||||
|
gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned);
|
||||||
|
gtk_widget_grab_focus(g.browser_scroller);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -168,9 +172,6 @@ open(const gchar *path)
|
|||||||
g_free(uri);
|
g_free(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_set_title(GTK_WINDOW(g.window), path);
|
|
||||||
gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_scroller);
|
|
||||||
|
|
||||||
gchar *basename = g_path_get_basename(path);
|
gchar *basename = g_path_get_basename(path);
|
||||||
g_free(g.basename);
|
g_free(g.basename);
|
||||||
g.basename = basename;
|
g.basename = basename;
|
||||||
@ -187,6 +188,9 @@ open(const gchar *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_free(dirname);
|
g_free(dirname);
|
||||||
|
|
||||||
|
gtk_window_set_title(GTK_WINDOW(g.window), path);
|
||||||
|
gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_scroller);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
@ -265,13 +269,6 @@ on_next(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
on_item_activated(G_GNUC_UNUSED FastivBrowser *browser, const char *path,
|
|
||||||
G_GNUC_UNUSED gpointer data)
|
|
||||||
{
|
|
||||||
open(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spawn_path(const char *path)
|
spawn_path(const char *path)
|
||||||
{
|
{
|
||||||
@ -282,6 +279,16 @@ spawn_path(const char *path)
|
|||||||
g_clear_error(&error);
|
g_clear_error(&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_item_activated(G_GNUC_UNUSED FastivBrowser *browser, const char *path,
|
||||||
|
GtkPlacesOpenFlags flags, G_GNUC_UNUSED gpointer data)
|
||||||
|
{
|
||||||
|
if (flags == GTK_PLACES_OPEN_NEW_WINDOW)
|
||||||
|
spawn_path(path);
|
||||||
|
else
|
||||||
|
open(path);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
open_any_path(const char *path)
|
open_any_path(const char *path)
|
||||||
{
|
{
|
||||||
@ -295,14 +302,7 @@ open_any_path(const char *path)
|
|||||||
load_directory(canonical);
|
load_directory(canonical);
|
||||||
else
|
else
|
||||||
open(canonical);
|
open(canonical);
|
||||||
|
|
||||||
g_free(canonical);
|
g_free(canonical);
|
||||||
if (g.files_index < 0) {
|
|
||||||
gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned);
|
|
||||||
gtk_widget_grab_focus(g.browser_scroller);
|
|
||||||
} else {
|
|
||||||
gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_scroller);
|
|
||||||
}
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user