Compare commits

...

2 Commits

6 changed files with 191 additions and 17 deletions

View File

@ -244,10 +244,21 @@ resolve_location(FivSidebar *self, const char *text)
// Relative paths produce invalid GFile objects with this function.
// And even if they didn't, we have our own root for them.
GFile *file = g_file_parse_name(text);
if (g_uri_is_valid(text, G_URI_FLAGS_PARSE_RELAXED, NULL) ||
g_file_peek_path(file))
if (g_file_peek_path(file))
return file;
// Neither branch looks like a particularly good solution.
// Though in general, false positives are preferred over negatives.
#if GLIB_CHECK_VERSION(2, 66, 0)
if (g_uri_is_valid(text, G_URI_FLAGS_PARSE_RELAXED, NULL))
return file;
#else
gchar *scheme = g_uri_parse_scheme(text);
g_free(scheme);
if (scheme)
return file;
#endif
GFile *absolute = g_file_get_child_for_display_name(
fiv_io_model_get_location(self->model), text, NULL);
if (!absolute)

View File

@ -22,6 +22,7 @@
#include <webp/mux.h>
#include <glib/gstdio.h>
#include <errno.h>
#include <math.h>
#include <stdbool.h>

35
fiv.c
View File

@ -84,6 +84,7 @@ static struct key_group help_keys_browser[] = {
{"General", help_keys_general},
{"View", (struct key[]) {
{"F9", "Toggle navigation sidebar"},
{"h <control>h", "Toggle hiding unsupported files"},
{}
}},
{"Navigation", (struct key[]) {
@ -274,6 +275,7 @@ struct {
GtkWidget *browser_sidebar;
GtkWidget *plus;
GtkWidget *minus;
GtkWidget *funnel;
GtkWidget *sort_field[FIV_IO_MODEL_SORT_COUNT];
GtkWidget *sort_direction[2];
GtkWidget *browser_scroller;
@ -665,11 +667,11 @@ on_notify_thumbnail_size(
static void
on_notify_filtering(
GObject *object, GParamSpec *param_spec, gpointer user_data)
GObject *object, GParamSpec *param_spec, G_GNUC_UNUSED gpointer user_data)
{
gboolean b = FALSE;
g_object_get(object, g_param_spec_get_name(param_spec), &b, NULL);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(user_data), b);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g.funnel), b);
}
static void
@ -770,8 +772,8 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
break;
case GDK_CONTROL_MASK:
switch (event->keyval) {
case GDK_KEY_o:
on_open();
case GDK_KEY_h:
gtk_button_clicked(GTK_BUTTON(g.funnel));
return TRUE;
case GDK_KEY_l:
fiv_sidebar_show_enter_location(FIV_SIDEBAR(g.browser_sidebar));
@ -779,6 +781,9 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
case GDK_KEY_n:
spawn_uri(g.directory);
return TRUE;
case GDK_KEY_o:
on_open();
return TRUE;
case GDK_KEY_r:
// TODO(p): Reload the image instead, if it's currently visible.
load_directory(NULL);
@ -832,6 +837,9 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
gtk_widget_destroy(g.window);
return TRUE;
case GDK_KEY_h:
gtk_button_clicked(GTK_BUTTON(g.funnel));
return TRUE;
case GDK_KEY_o:
on_open();
return TRUE;
@ -936,8 +944,9 @@ on_button_press_browser_paned(
static GtkWidget *
make_toolbar_button(const gchar *symbolic, const gchar *tooltip)
{
GtkWidget *button =
gtk_button_new_from_icon_name(symbolic, GTK_ICON_SIZE_BUTTON);
GtkWidget *button = gtk_button_new();
gtk_button_set_image(GTK_BUTTON(button),
gtk_image_new_from_icon_name(symbolic, GTK_ICON_SIZE_BUTTON));
gtk_widget_set_tooltip_text(button, tooltip);
gtk_widget_set_focus_on_click(button, FALSE);
gtk_style_context_add_class(
@ -1208,11 +1217,11 @@ make_browser_sidebar(FivIoModel *model)
gtk_box_pack_start(GTK_BOX(zoom_group), g.plus, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(zoom_group), g.minus, FALSE, FALSE, 0);
GtkWidget *funnel = gtk_toggle_button_new();
gtk_container_add(GTK_CONTAINER(funnel),
g.funnel = gtk_toggle_button_new();
gtk_container_add(GTK_CONTAINER(g.funnel),
gtk_image_new_from_icon_name("funnel-symbolic", GTK_ICON_SIZE_BUTTON));
gtk_widget_set_tooltip_text(funnel, "Hide unsupported files");
g_signal_connect(funnel, "toggled",
gtk_widget_set_tooltip_text(g.funnel, "Hide unsupported files");
g_signal_connect(g.funnel, "toggled",
G_CALLBACK(on_filtering_toggled), NULL);
GtkWidget *menu = gtk_menu_new();
@ -1251,7 +1260,7 @@ make_browser_sidebar(FivIoModel *model)
GtkWidget *model_group = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class(
gtk_widget_get_style_context(model_group), GTK_STYLE_CLASS_LINKED);
gtk_box_pack_start(GTK_BOX(model_group), funnel, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(model_group), g.funnel, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(model_group), sort, FALSE, FALSE, 0);
GtkBox *toolbar = fiv_sidebar_get_toolbar(FIV_SIDEBAR(sidebar));
@ -1262,13 +1271,13 @@ make_browser_sidebar(FivIoModel *model)
g_signal_connect(g.browser, "notify::thumbnail-size",
G_CALLBACK(on_notify_thumbnail_size), NULL);
g_signal_connect(model, "notify::filtering",
G_CALLBACK(on_notify_filtering), funnel);
G_CALLBACK(on_notify_filtering), NULL);
g_signal_connect(model, "notify::sort-field",
G_CALLBACK(on_notify_sort_field), NULL);
g_signal_connect(model, "notify::sort-descending",
G_CALLBACK(on_notify_sort_descending), NULL);
on_toolbar_zoom(NULL, (gpointer) 0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(funnel), TRUE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g.funnel), TRUE);
// TODO(p): Invoke sort configuration notifications explicitly.
return sidebar;
}

View File

@ -30,11 +30,13 @@ dependencies = [
dependency('libjpeg', required : get_option('jpeg-qs')),
dependency('libwebp'),
dependency('libwebpdemux'),
dependency('libwebpdecoder'),
dependency('libwebpdecoder', required : false),
dependency('libwebpmux'),
# https://github.com/google/wuffs/issues/58
dependency('spng', version : '>=0.7.0',
default_options: 'default_library=static'),
default_options: 'default_library=static',
# fallback : ['spng', 'spng_dep'],
),
lcms2,
libraw,

150
resources/info-symbolic.svg Normal file
View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<filter id="a" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="b">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.3"/>
</g>
</mask>
<clipPath id="c">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="d">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="e">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="f">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="g">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="h">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="i">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="j">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="k">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="l">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="m">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="n">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="o">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="p">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.3"/>
</g>
</mask>
<clipPath id="q">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="r">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.5"/>
</g>
</mask>
<clipPath id="s">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="t">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.4"/>
</g>
</mask>
<clipPath id="u">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="v">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.4"/>
</g>
</mask>
<clipPath id="w">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="x">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.5"/>
</g>
</mask>
<clipPath id="y">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="z">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.5"/>
</g>
</mask>
<clipPath id="A">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<g clip-path="url(#c)" mask="url(#b)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 562.460938 212.058594 h 10.449218 c -1.183594 0.492187 -1.296875 2.460937 0 3 h -10.449218 z m 0 0" fill="#2e3436"/>
</g>
<path d="m 7.90625 1 c -3.828125 0.050781 -6.90625 3.171875 -6.90625 7 c 0 3.867188 3.132812 7 7 7 s 7 -3.132812 7 -7 s -3.132812 -7 -7 -7 c -0.03125 0 -0.0625 0 -0.09375 0 z m -0.40625 3 h 1 c 0.277344 0 0.5 0.222656 0.5 0.5 v 1 c 0 0.277344 -0.222656 0.5 -0.5 0.5 h -1 c -0.277344 0 -0.5 -0.222656 -0.5 -0.5 v -1 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 z m -0.5 3 h 2 v 5 h -2 z m 0 0" fill="#2e3436"/>
<g clip-path="url(#e)" mask="url(#d)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 16 632 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#g)" mask="url(#f)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 17 631 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#i)" mask="url(#h)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 18 634 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#k)" mask="url(#j)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 16 634 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#m)" mask="url(#l)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 17 635 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#o)" mask="url(#n)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 19 635 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#q)" mask="url(#p)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 136 660 v 7 h 7 v -7 z m 0 0" fill="#2e3436"/>
</g>
<g clip-path="url(#s)" mask="url(#r)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 199 642 h 3 v 12 h -3 z m 0 0" fill="#2e3436"/>
</g>
<g clip-path="url(#u)" mask="url(#t)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 209.5 144.160156 c 0.277344 0 0.5 0.222656 0.5 0.5 v 1 c 0 0.277344 -0.222656 0.5 -0.5 0.5 s -0.5 -0.222656 -0.5 -0.5 v -1 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 z m 0 0" fill="#2e3436"/>
</g>
<g clip-path="url(#w)" mask="url(#v)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 206.5 144.160156 c 0.277344 0 0.5 0.222656 0.5 0.5 v 1 c 0 0.277344 -0.222656 0.5 -0.5 0.5 s -0.5 -0.222656 -0.5 -0.5 v -1 c 0 -0.277344 0.222656 -0.5 0.5 -0.5 z m 0 0" fill="#2e3436"/>
</g>
<g clip-path="url(#y)" mask="url(#x)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 229.5 143.160156 c -0.546875 0 -1 0.457032 -1 1 c 0 0.546875 0.453125 1 1 1 s 1 -0.453125 1 -1 c 0 -0.542968 -0.453125 -1 -1 -1 z m 0 0" fill="#2e3436"/>
</g>
<g clip-path="url(#A)" mask="url(#z)" transform="matrix(1 0 0 1 -660 -222)">
<path d="m 226.453125 143.160156 c -0.519531 0 -0.953125 0.433594 -0.953125 0.953125 v 0.09375 c 0 0.519531 0.433594 0.953125 0.953125 0.953125 h 0.09375 c 0.519531 0 0.953125 -0.433594 0.953125 -0.953125 v -0.09375 c 0 -0.519531 -0.433594 -0.953125 -0.953125 -0.953125 z m 0 0" fill="#2e3436"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -6,5 +6,6 @@
<file preprocess="xml-stripblanks">blend-tool-symbolic.svg</file>
<file preprocess="xml-stripblanks">checkerboard-symbolic.svg</file>
<file preprocess="xml-stripblanks">heal-symbolic.svg</file>
<file preprocess="xml-stripblanks">info-symbolic.svg</file>
</gresource>
</gresources>