Minor URL-related fix-ups
This commit is contained in:
parent
380ddd540b
commit
5f8dc88fa7
27
fastiv.c
27
fastiv.c
@ -318,15 +318,20 @@ show_error_dialog(GError *error)
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
static void
|
||||
set_window_title(const char *uri)
|
||||
{
|
||||
GFile *file = g_file_new_for_uri(uri);
|
||||
gchar *name = g_file_get_parse_name(file);
|
||||
gtk_window_set_title(GTK_WINDOW(g.window), name);
|
||||
g_free(name);
|
||||
g_object_unref(file);
|
||||
}
|
||||
|
||||
static void
|
||||
switch_to_browser(void)
|
||||
{
|
||||
// TODO(p): Use g_file_get_parse_name() or something.
|
||||
GFile *file = g_file_new_for_uri(g.directory);
|
||||
const char *path = g_file_peek_path(file);
|
||||
gtk_window_set_title(GTK_WINDOW(g.window), path ? path : g.directory);
|
||||
g_object_unref(file);
|
||||
|
||||
set_window_title(g.directory);
|
||||
gtk_stack_set_visible_child(GTK_STACK(g.stack), g.browser_paned);
|
||||
gtk_widget_grab_focus(g.browser_scroller);
|
||||
}
|
||||
@ -334,12 +339,7 @@ switch_to_browser(void)
|
||||
static void
|
||||
switch_to_view(const char *uri)
|
||||
{
|
||||
// TODO(p): Use g_file_get_parse_name() or something.
|
||||
GFile *file = g_file_new_for_uri(uri);
|
||||
const char *path = g_file_peek_path(file);
|
||||
gtk_window_set_title(GTK_WINDOW(g.window), path ? path : uri);
|
||||
g_object_unref(file);
|
||||
|
||||
set_window_title(uri);
|
||||
gtk_stack_set_visible_child(GTK_STACK(g.stack), g.view_box);
|
||||
gtk_widget_grab_focus(g.view);
|
||||
}
|
||||
@ -451,8 +451,9 @@ load_directory(const gchar *uri)
|
||||
|
||||
g_ptr_array_sort(g.files, files_compare);
|
||||
update_files_index();
|
||||
} else if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
|
||||
g_error_free(error);
|
||||
} else {
|
||||
// TODO(p): Handle "Operation not supported" silently.
|
||||
show_error_dialog(error);
|
||||
}
|
||||
g_object_unref(file);
|
||||
|
@ -488,7 +488,6 @@ on_thumbnailer_ready(GObject *object, GAsyncResult *res, gpointer user_data)
|
||||
if (succeeded)
|
||||
thumbnailer_reprocess_entry(self, entry);
|
||||
|
||||
// TODO(p): Eliminate high recursion depth with non-paths.
|
||||
thumbnailer_next(self);
|
||||
}
|
||||
|
||||
@ -496,26 +495,17 @@ static void
|
||||
thumbnailer_next(FivBrowser *self)
|
||||
{
|
||||
// TODO(p): At least launch multiple thumbnailers in parallel.
|
||||
// Ideally, try to keep them alive.
|
||||
GList *link = self->thumbnail_queue;
|
||||
if (!link)
|
||||
return;
|
||||
|
||||
const Entry *entry = link->data;
|
||||
GFile *file = g_file_new_for_uri(entry->uri);
|
||||
gchar *uri = g_file_get_uri(file);
|
||||
g_object_unref(file);
|
||||
if (!uri) {
|
||||
// TODO(p): Support thumbnailing non-local URIs in some manner.
|
||||
self->thumbnail_queue = g_list_delete_link(self->thumbnail_queue, link);
|
||||
return;
|
||||
}
|
||||
|
||||
GError *error = NULL;
|
||||
self->thumbnailer = g_subprocess_new(G_SUBPROCESS_FLAGS_NONE, &error,
|
||||
PROJECT_NAME, "--thumbnail",
|
||||
fiv_thumbnail_sizes[self->item_size].thumbnail_spec_name, "--", uri,
|
||||
NULL);
|
||||
g_free(uri);
|
||||
fiv_thumbnail_sizes[self->item_size].thumbnail_spec_name, "--",
|
||||
entry->uri, NULL);
|
||||
if (error) {
|
||||
g_warning("%s", error->message);
|
||||
g_error_free(error);
|
||||
|
@ -220,6 +220,7 @@ complete_path(GFile *location, GtkListStore *model)
|
||||
{
|
||||
// TODO(p): Do not enter directories unless followed by '/'.
|
||||
// This information has already been stripped from `location`.
|
||||
// TODO(p): Try out GFileCompleter.
|
||||
GFile *parent = G_FILE_TYPE_DIRECTORY ==
|
||||
g_file_query_file_type(location, G_FILE_QUERY_INFO_NONE, NULL)
|
||||
? g_object_ref(location)
|
||||
|
@ -223,9 +223,12 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size, GError **error)
|
||||
max_size <= FIV_THUMBNAIL_SIZE_MAX, FALSE);
|
||||
|
||||
// Local files only, at least for now.
|
||||
// TODO(p): Support thumbnailing the trash scheme.
|
||||
const gchar *path = g_file_peek_path(target);
|
||||
if (!path)
|
||||
if (!path) {
|
||||
set_error(error, "only local files are supported");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GMappedFile *mf = g_mapped_file_new(path, FALSE, error);
|
||||
if (!mf)
|
||||
|
Loading…
Reference in New Issue
Block a user