Fully support GNOME's inode/directory mechanism
This commit is contained in:
parent
f632510d2a
commit
757bc9beaa
|
@ -1550,12 +1550,9 @@ on_model_files_changed(FivIoModel *model, FivBrowser *self)
|
||||||
{
|
{
|
||||||
g_return_if_fail(model == self->model);
|
g_return_if_fail(model == self->model);
|
||||||
|
|
||||||
int selected = -1;
|
|
||||||
gchar *selected_uri = NULL;
|
gchar *selected_uri = NULL;
|
||||||
if (self->selected) {
|
if (self->selected)
|
||||||
selected_uri = g_strdup(self->selected->uri);
|
selected_uri = g_strdup(self->selected->uri);
|
||||||
self->selected = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(p): Later implement arguments.
|
// TODO(p): Later implement arguments.
|
||||||
thumbnailers_abort(self);
|
thumbnailers_abort(self);
|
||||||
|
@ -1566,16 +1563,12 @@ on_model_files_changed(FivIoModel *model, FivBrowser *self)
|
||||||
for (guint i = 0; i < files->len; i++) {
|
for (guint i = 0; i < files->len; i++) {
|
||||||
g_array_append_val(self->entries,
|
g_array_append_val(self->entries,
|
||||||
((Entry) {.thumbnail = NULL, .uri = files->pdata[i]}));
|
((Entry) {.thumbnail = NULL, .uri = files->pdata[i]}));
|
||||||
if (!g_strcmp0(selected_uri, files->pdata[i]))
|
|
||||||
selected = i;
|
|
||||||
files->pdata[i] = NULL;
|
files->pdata[i] = NULL;
|
||||||
}
|
}
|
||||||
g_ptr_array_free(files, TRUE);
|
g_ptr_array_free(files, TRUE);
|
||||||
|
|
||||||
// Beware that the pointer may shift with the storage.
|
fiv_browser_select(self, selected_uri);
|
||||||
g_free(selected_uri);
|
g_free(selected_uri);
|
||||||
if (selected >= 0)
|
|
||||||
self->selected = &g_array_index(self->entries, Entry, selected);
|
|
||||||
|
|
||||||
reload_thumbnails(self);
|
reload_thumbnails(self);
|
||||||
thumbnailers_start(self);
|
thumbnailers_start(self);
|
||||||
|
@ -1594,3 +1587,24 @@ fiv_browser_new(FivIoModel *model)
|
||||||
on_model_files_changed(self->model, self);
|
on_model_files_changed(self->model, self);
|
||||||
return GTK_WIDGET(self);
|
return GTK_WIDGET(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fiv_browser_select(FivBrowser *self, const char *uri)
|
||||||
|
{
|
||||||
|
g_return_if_fail(FIV_IS_BROWSER(self));
|
||||||
|
|
||||||
|
self->selected = NULL;
|
||||||
|
gtk_widget_queue_draw(GTK_WIDGET(self));
|
||||||
|
if (!uri)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (guint i = 0; i < self->entries->len; i++) {
|
||||||
|
const Entry *entry = &g_array_index(self->entries, Entry, i);
|
||||||
|
if (!g_strcmp0(entry->uri, uri)) {
|
||||||
|
self->selected = entry;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(p): Scroll to selection.
|
||||||
|
}
|
||||||
|
|
|
@ -25,3 +25,4 @@
|
||||||
G_DECLARE_FINAL_TYPE(FivBrowser, fiv_browser, FIV, BROWSER, GtkWidget)
|
G_DECLARE_FINAL_TYPE(FivBrowser, fiv_browser, FIV, BROWSER, GtkWidget)
|
||||||
|
|
||||||
GtkWidget *fiv_browser_new(FivIoModel *model);
|
GtkWidget *fiv_browser_new(FivIoModel *model);
|
||||||
|
void fiv_browser_select(FivBrowser *self, const char *uri);
|
||||||
|
|
5
fiv.c
5
fiv.c
|
@ -880,11 +880,12 @@ open_any_file(GFile *file, gboolean force_browser)
|
||||||
} else if (type == G_FILE_TYPE_DIRECTORY) {
|
} else if (type == G_FILE_TYPE_DIRECTORY) {
|
||||||
load_directory(uri);
|
load_directory(uri);
|
||||||
} else if (force_browser) {
|
} else if (force_browser) {
|
||||||
// GNOME, e.g., invokes this as a hint to focus the particular file,
|
// GNOME, e.g., invokes this as a hint to focus the particular file.
|
||||||
// which we can't currently do yet.
|
|
||||||
gchar *parent = parent_uri(file);
|
gchar *parent = parent_uri(file);
|
||||||
load_directory(parent);
|
load_directory(parent);
|
||||||
g_free(parent);
|
g_free(parent);
|
||||||
|
|
||||||
|
fiv_browser_select(FIV_BROWSER(g.browser), uri);
|
||||||
} else {
|
} else {
|
||||||
open(uri);
|
open(uri);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue