Compare commits

..

No commits in common. "8b1a14decbd065e43c30a7dede4b0350116b4242" and "5fea2245f119029f6b2699dda11aaf8f5e461e4e" have entirely different histories.

6 changed files with 29 additions and 61 deletions

View File

@ -614,7 +614,7 @@ fastiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event)
FastivBrowser *self = FASTIV_BROWSER(widget);
if (event->type != GDK_BUTTON_PRESS || event->state != 0)
return FALSE;
if (event->button == GDK_BUTTON_PRIMARY)
if (event->button == 1)
gtk_widget_grab_focus(widget);
const Entry *entry = entry_at(self, event->x, event->y);
@ -622,11 +622,11 @@ fastiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event)
return FALSE;
switch (event->button) {
case GDK_BUTTON_PRIMARY:
case 1:
g_signal_emit(widget, browser_signals[ITEM_ACTIVATED], 0,
entry->filename, GTK_PLACES_OPEN_NORMAL);
return TRUE;
case GDK_BUTTON_MIDDLE:
case 2:
g_signal_emit(widget, browser_signals[ITEM_ACTIVATED], 0,
entry->filename, GTK_PLACES_OPEN_NEW_WINDOW);
return TRUE;
@ -768,19 +768,6 @@ fastiv_browser_init(FastivBrowser *self)
// --- Public interface --------------------------------------------------------
static gint
entry_compare(gconstpointer a, gconstpointer b)
{
const Entry *entry1 = a;
const Entry *entry2 = b;
GFile *location1 = g_file_new_for_path(entry1->filename);
GFile *location2 = g_file_new_for_path(entry2->filename);
gint result = fastiv_io_filecmp(location1, location2);
g_object_unref(location1);
g_object_unref(location2);
return result;
}
void
fastiv_browser_load(
FastivBrowser *self, FastivBrowserFilterCallback cb, const char *path)
@ -804,6 +791,8 @@ fastiv_browser_load(
break;
if (g_file_info_get_file_type(info) == G_FILE_TYPE_DIRECTORY)
continue;
// TODO(p): Support being passed a sort function.
if (cb && !cb(g_file_info_get_name(info)))
continue;
@ -812,8 +801,6 @@ fastiv_browser_load(
}
g_object_unref(enumerator);
// TODO(p): Support being passed a sort function.
g_array_sort(self->entries, entry_compare);
// TODO(p): Sort the entries before.
reload_thumbnails(self);
}

View File

@ -1048,19 +1048,3 @@ fastiv_io_lookup_thumbnail(const gchar *target, FastivIoThumbnailSize size)
g_free(uri);
return result;
}
int
fastiv_io_filecmp(GFile *location1, GFile *location2)
{
if (g_file_has_prefix(location1, location2))
return +1;
if (g_file_has_prefix(location2, location1))
return -1;
gchar *name1 = g_file_get_parse_name(location1);
gchar *name2 = g_file_get_parse_name(location2);
int result = g_utf8_collate(name1, name2);
g_free(name1);
g_free(name2);
return result;
}

View File

@ -57,5 +57,3 @@ cairo_surface_t *fastiv_io_open_from_data(
const char *data, size_t len, const gchar *path, GError **error);
cairo_surface_t *fastiv_io_lookup_thumbnail(
const gchar *target, FastivIoThumbnailSize size);
int fastiv_io_filecmp(GFile *f1, GFile *f2);

View File

@ -17,7 +17,6 @@
#include <gtk/gtk.h>
#include "fastiv-io.h" // fastiv_io_filecmp
#include "fastiv-sidebar.h"
struct _FastivSidebar {
@ -108,12 +107,24 @@ create_row(GFile *file, const char *icon_name)
}
static gint
listbox_compare(
listbox_sort(
GtkListBoxRow *row1, GtkListBoxRow *row2, G_GNUC_UNUSED gpointer user_data)
{
return fastiv_io_filecmp(
g_object_get_qdata(G_OBJECT(row1), fastiv_sidebar_location_quark()),
g_object_get_qdata(G_OBJECT(row2), fastiv_sidebar_location_quark()));
GFile *location1 =
g_object_get_qdata(G_OBJECT(row1), fastiv_sidebar_location_quark());
GFile *location2 =
g_object_get_qdata(G_OBJECT(row2), fastiv_sidebar_location_quark());
if (g_file_has_prefix(location1, location2))
return +1;
if (g_file_has_prefix(location2, location1))
return -1;
gchar *name1 = g_file_get_parse_name(location1);
gchar *name2 = g_file_get_parse_name(location2);
gint result = g_utf8_collate(name1, name2);
g_free(name1);
g_free(name2);
return result;
}
static void
@ -360,7 +371,7 @@ fastiv_sidebar_init(FastivSidebar *self)
g_signal_connect(self->listbox, "row-activated",
G_CALLBACK(on_open_breadcrumb), self);
gtk_list_box_set_sort_func(
GTK_LIST_BOX(self->listbox), listbox_compare, self, NULL);
GTK_LIST_BOX(self->listbox), listbox_sort, self, NULL);
// Fill up what would otherwise be wasted space,
// as it is in the examples of Nautilus and Thunar.

View File

@ -331,7 +331,7 @@ fastiv_view_key_press_event(GtkWidget *widget, GdkEventKey *event)
return set_scale(self, self->scale * SCALE_STEP);
case GDK_KEY_minus:
return set_scale(self, self->scale / SCALE_STEP);
case GDK_KEY_F:
case GDK_KEY_f:
return set_scale_to_fit(self, !self->scale_to_fit);
}
return FALSE;

View File

@ -355,16 +355,6 @@ on_notify_thumbnail_size(
gtk_widget_set_sensitive(g.minus, size > FASTIV_IO_THUMBNAIL_SIZE_MIN);
}
static void
toggle_fullscreen(void)
{
if (gdk_window_get_state(gtk_widget_get_window(g.window)) &
GDK_WINDOW_STATE_FULLSCREEN)
gtk_window_unfullscreen(GTK_WINDOW(g.window));
else
gtk_window_fullscreen(GTK_WINDOW(g.window));
}
// Cursor keys, e.g., simply cannot be bound through accelerators
// (and GtkWidget::keynav-failed would arguably be an awful solution).
//
@ -420,7 +410,11 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
case GDK_KEY_F11:
case GDK_KEY_f:
toggle_fullscreen();
if (gdk_window_get_state(gtk_widget_get_window(g.window)) &
GDK_WINDOW_STATE_FULLSCREEN)
gtk_window_unfullscreen(GTK_WINDOW(g.window));
else
gtk_window_fullscreen(GTK_WINDOW(g.window));
return TRUE;
}
}
@ -465,12 +459,6 @@ on_button_press_view(G_GNUC_UNUSED GtkWidget *widget, GdkEventButton *event)
case 8: // back
gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned);
return TRUE;
case GDK_BUTTON_PRIMARY:
if (event->type == GDK_2BUTTON_PRESS) {
toggle_fullscreen();
return TRUE;
}
return FALSE;
default:
return FALSE;
}