[gthumb/ext] allow to open the file folder from the catalog list
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext] allow to open the file folder from the catalog list
- Date: Tue, 8 Sep 2009 09:08:04 +0000 (UTC)
commit 4e42732973c7539e5e672e8763f8f899c439c9cf
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Sep 8 11:06:54 2009 +0200
allow to open the file folder from the catalog list
extensions/catalogs/actions.c | 25 +++++++++++
extensions/catalogs/actions.h | 1 +
extensions/catalogs/callbacks.c | 9 ++++
extensions/catalogs/dlg-add-to-catalog.c | 2 +-
extensions/photo_importer/gth-import-task.c | 2 +-
extensions/search/gth-search-task.c | 2 +-
gthumb/dlg-bookmarks.c | 4 +-
gthumb/gth-browser-actions-callbacks.c | 2 +-
gthumb/gth-browser-ui.h | 1 +
gthumb/gth-browser.c | 60 ++++++++++++++++++--------
gthumb/gth-browser.h | 3 +-
11 files changed, 85 insertions(+), 26 deletions(-)
---
diff --git a/extensions/catalogs/actions.c b/extensions/catalogs/actions.c
index 0df1da1..eef9dbb 100644
--- a/extensions/catalogs/actions.c
+++ b/extensions/catalogs/actions.c
@@ -352,3 +352,28 @@ gth_browser_activate_action_catalog_rename (GtkAction *action,
g_object_unref (file_data);
}
+
+
+void
+gth_browser_activate_action_go_to_container (GtkAction *action,
+ GthBrowser *browser)
+{
+ GList *items;
+ GList *file_list = NULL;
+
+ items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
+ file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
+
+ if (file_list != NULL) {
+ GthFileData *first_file = file_list->data;
+ GFile *parent;
+
+ parent = g_file_get_parent (first_file->file);
+ gth_browser_go_to (browser, parent, first_file->file);
+
+ g_object_unref (parent);
+ }
+
+ _g_object_list_unref (file_list);
+ _gtk_tree_path_list_free (items);
+}
diff --git a/extensions/catalogs/actions.h b/extensions/catalogs/actions.h
index 22bafdb..82f76a6 100644
--- a/extensions/catalogs/actions.h
+++ b/extensions/catalogs/actions.h
@@ -33,5 +33,6 @@ DEFINE_ACTION(gth_browser_activate_action_catalog_new)
DEFINE_ACTION(gth_browser_activate_action_catalog_new_library)
DEFINE_ACTION(gth_browser_activate_action_catalog_remove)
DEFINE_ACTION(gth_browser_activate_action_catalog_rename)
+DEFINE_ACTION(gth_browser_activate_action_go_to_container)
#endif /* ACTIONS_H */
diff --git a/extensions/catalogs/callbacks.c b/extensions/catalogs/callbacks.c
index a44766c..c8983f9 100644
--- a/extensions/catalogs/callbacks.c
+++ b/extensions/catalogs/callbacks.c
@@ -50,6 +50,9 @@ static const char *fixed_ui_info =
static const char *vfs_ui_info =
"<ui>"
" <popup name='FileListPopup'>"
+" <placeholder name='Open_Actions'>"
+" <menuitem action='Go_FileContainer'/>"
+" </placeholder>"
" <placeholder name='Folder_Actions2'>"
" <menuitem action='Edit_RemoveFromCatalog'/>"
" </placeholder>"
@@ -78,6 +81,12 @@ static const gchar *folder_popup_ui_info =
static GtkActionEntry catalog_action_entries[] = {
+
+ { "Go_FileContainer", GTK_STOCK_JUMP_TO,
+ N_("Open _Folder"), "<alt>End",
+ N_("Go to the folder that contains the selected file"),
+ G_CALLBACK (gth_browser_activate_action_go_to_container) },
+
{ "Edit_AddToCatalog", GTK_STOCK_ADD,
N_("_Add to Catalog..."), NULL,
N_("Add selected images to a catalog"),
diff --git a/extensions/catalogs/dlg-add-to-catalog.c b/extensions/catalogs/dlg-add-to-catalog.c
index dce60ae..c74451b 100644
--- a/extensions/catalogs/dlg-add-to-catalog.c
+++ b/extensions/catalogs/dlg-add-to-catalog.c
@@ -91,7 +91,7 @@ catalog_save_done_cb (void *buffer,
GTH_MONITOR_EVENT_CREATED);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("view_destination_checkbutton"))))
- gth_browser_go_to (data->browser, data->selected_catalog->file);
+ gth_browser_go_to (data->browser, data->selected_catalog->file, NULL);
gtk_widget_destroy (data->dialog);
}
diff --git a/extensions/photo_importer/gth-import-task.c b/extensions/photo_importer/gth-import-task.c
index 0de702c..fa6ffb2 100644
--- a/extensions/photo_importer/gth-import-task.c
+++ b/extensions/photo_importer/gth-import-task.c
@@ -249,7 +249,7 @@ import_current_file (GthImportTask *self)
GList *list;
if (self->priv->current == NULL) {
- gth_browser_go_to (self->priv->browser, self->priv->destination);
+ gth_browser_go_to (self->priv->browser, self->priv->destination, NULL);
gth_task_completed (GTH_TASK (self), NULL);
return;
}
diff --git a/extensions/search/gth-search-task.c b/extensions/search/gth-search-task.c
index a2f14f1..c319050 100644
--- a/extensions/search/gth-search-task.c
+++ b/extensions/search/gth-search-task.c
@@ -323,7 +323,7 @@ clear_search_result_copy_done_cb (void *buffer,
"location-ready",
G_CALLBACK (browser_location_ready_cb),
task);
- gth_browser_go_to (task->priv->browser, task->priv->search_catalog);
+ gth_browser_go_to (task->priv->browser, task->priv->search_catalog, NULL);
}
diff --git a/gthumb/dlg-bookmarks.c b/gthumb/dlg-bookmarks.c
index 8e86084..ae20418 100644
--- a/gthumb/dlg-bookmarks.c
+++ b/gthumb/dlg-bookmarks.c
@@ -85,7 +85,7 @@ go_to_cb (GtkWidget *widget,
GFile *location;
location = g_file_new_for_uri (uri);
- gth_browser_go_to (data->browser, location);
+ gth_browser_go_to (data->browser, location, NULL);
g_object_unref (location);
g_free (uri);
@@ -144,7 +144,7 @@ uri_list_row_activated_cb (GtkTreeView *tree_view,
return;
location = g_file_new_for_uri (uri);
- gth_browser_go_to (data->browser, location);
+ gth_browser_go_to (data->browser, location, NULL);
g_object_unref (location);
g_free (uri);
diff --git a/gthumb/gth-browser-actions-callbacks.c b/gthumb/gth-browser-actions-callbacks.c
index bdf52c3..5da078c 100644
--- a/gthumb/gth-browser-actions-callbacks.c
+++ b/gthumb/gth-browser-actions-callbacks.c
@@ -130,7 +130,7 @@ gth_browser_activate_action_file_new_window (GtkAction *action,
GtkWidget *window;
window = gth_browser_new (NULL);
- gth_browser_go_to (GTH_BROWSER (window), gth_browser_get_location (browser));
+ gth_browser_go_to (GTH_BROWSER (window), gth_browser_get_location (browser), NULL);
gtk_window_present (GTK_WINDOW (window));
}
diff --git a/gthumb/gth-browser-ui.h b/gthumb/gth-browser-ui.h
index 8b99987..625cd55 100644
--- a/gthumb/gth-browser-ui.h
+++ b/gthumb/gth-browser-ui.h
@@ -153,6 +153,7 @@ static const char *fixed_ui_info =
" <menuitem name='Open' action='File_Open'/>"
" <menu name='OpenWith' action='OpenWithMenu'>"
" </menu>"
+" <separator/>"
" <placeholder name='Open_Actions'/>"
" <separator/>"
" <placeholder name='File_Actions'/>"
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index f65ba92..e5691e5 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -291,7 +291,7 @@ activate_go_to_menu_item (GtkMenuItem *menuitem,
GFile *location;
location = g_file_new_for_uri (g_object_get_data (G_OBJECT (menuitem), "uri"));
- gth_browser_go_to (browser, location);
+ gth_browser_go_to (browser, location, NULL);
g_object_unref (location);
}
@@ -873,6 +873,7 @@ typedef struct {
GthBrowser *browser;
GthFileData *requested_folder;
GFile *requested_folder_parent;
+ GFile *scroll_to_file;
GthAction action;
gboolean automatic;
GList *list;
@@ -886,6 +887,7 @@ typedef struct {
static LoadData *
load_data_new (GthBrowser *browser,
GFile *location,
+ GFile *scroll_to_file,
GthAction action,
gboolean automatic,
GFile *entry_point)
@@ -897,6 +899,10 @@ load_data_new (GthBrowser *browser,
load_data->browser = browser;
load_data->requested_folder = gth_file_data_new (location, NULL);
load_data->requested_folder_parent = g_file_get_parent (load_data->requested_folder->file);
+ if (scroll_to_file != NULL)
+ load_data->scroll_to_file = g_file_dup (scroll_to_file);
+ else if (browser->priv->current_file != NULL)
+ load_data->scroll_to_file = g_file_dup (browser->priv->current_file->file);
load_data->action = action;
load_data->automatic = automatic;
load_data->cancellable = g_cancellable_new ();
@@ -934,6 +940,7 @@ load_data_free (LoadData *data)
g_object_unref (data->requested_folder);
_g_object_unref (data->requested_folder_parent);
+ _g_object_unref (data->scroll_to_file);
_g_object_unref (data->file_source);
_g_object_list_unref (data->list);
_g_object_unref (data->entry_point);
@@ -951,7 +958,7 @@ load_data_cancel (LoadData *data)
}
-static void _gth_browser_load (GthBrowser *browser, GFile *location, GthAction action, gboolean automatic);
+static void _gth_browser_load (GthBrowser *browser, GFile *location, GFile *scroll_to_file, GthAction action, gboolean automatic);
static void
@@ -1007,6 +1014,7 @@ load_data_done (LoadData *load_data,
if (parent != NULL) {
_gth_browser_load (load_data->browser,
parent,
+ NULL,
load_data->action,
TRUE);
g_object_unref (parent);
@@ -1402,6 +1410,18 @@ load_data_continue (LoadData *load_data,
break;
}
+ if (load_data->scroll_to_file != NULL) {
+ int pos;
+
+ pos = gth_file_store_get_pos (gth_browser_get_file_store (browser), load_data->scroll_to_file);
+ if (pos >= 0) {
+ GtkWidget *file_view;
+
+ file_view = gth_browser_get_file_list_view (browser);
+ gth_file_view_scroll_to (GTH_FILE_VIEW (file_view), pos, 0.5);
+ gth_file_selection_select (GTH_FILE_SELECTION (file_view), pos);
+ }
+ }
gth_browser_update_sensitivity (browser);
_gth_browser_update_statusbar_list_info (browser);
@@ -1540,6 +1560,7 @@ get_nearest_entry_point (GFile *file)
static void
_gth_browser_load (GthBrowser *browser,
GFile *location,
+ GFile *scroll_to_file,
GthAction action,
gboolean automatic)
{
@@ -1565,7 +1586,7 @@ _gth_browser_load (GthBrowser *browser,
}
entry_point = get_nearest_entry_point (location);
- load_data = load_data_new (browser, location, action, automatic, entry_point);
+ load_data = load_data_new (browser, location, scroll_to_file, action, automatic, entry_point);
if ((load_data->action == GTH_ACTION_GO_TO)
|| (load_data->action == GTH_ACTION_GO_INTO)
@@ -2133,7 +2154,7 @@ folder_tree_open_cb (GthFolderTree *folder_tree,
GFile *file,
GthBrowser *browser)
{
- gth_browser_go_to (browser, file);
+ gth_browser_go_to (browser, file, NULL);
}
@@ -2150,7 +2171,7 @@ folder_tree_list_children_cb (GthFolderTree *folder_tree,
GFile *file,
GthBrowser *browser)
{
- _gth_browser_load (browser, file, GTH_ACTION_LIST_CHILDREN, FALSE);
+ _gth_browser_load (browser, file, NULL, GTH_ACTION_LIST_CHILDREN, FALSE);
}
@@ -2159,7 +2180,7 @@ folder_tree_load_cb (GthFolderTree *folder_tree,
GFile *file,
GthBrowser *browser)
{
- _gth_browser_load (browser, file, GTH_ACTION_VIEW, FALSE);
+ _gth_browser_load (browser, file, NULL, GTH_ACTION_VIEW, FALSE);
}
@@ -2249,7 +2270,7 @@ static void
location_changed_cb (GthLocationChooser *chooser,
GthBrowser *browser)
{
- gth_browser_go_to (browser, gth_location_chooser_get_current (chooser));
+ gth_browser_go_to (browser, gth_location_chooser_get_current (chooser), NULL);
}
@@ -2382,12 +2403,12 @@ folder_changed_cb (GthMonitor *monitor,
return;
if ((event == GTH_MONITOR_EVENT_DELETED) && (_g_file_list_find_file_or_ancestor (list, browser->priv->location->file) != NULL)) {
- _gth_browser_load (browser, parent, GTH_ACTION_GO_TO, TRUE);
+ _gth_browser_load (browser, parent, NULL, GTH_ACTION_GO_TO, TRUE);
return;
}
if ((event == GTH_MONITOR_EVENT_CHANGED) && (_g_file_list_find_file_or_ancestor (list, browser->priv->location->file) != NULL)) {
- _gth_browser_load (browser, browser->priv->location->file, GTH_ACTION_GO_TO, TRUE);
+ _gth_browser_load (browser, browser->priv->location->file, NULL, GTH_ACTION_GO_TO, TRUE);
return;
}
@@ -3454,7 +3475,7 @@ gth_browser_new (const char *uri)
GFile *location;
location = g_file_new_for_uri ((uri != NULL) ? uri : gth_pref_get_startup_location ());
- gth_browser_go_to (browser, location);
+ gth_browser_go_to (browser, location, NULL);
g_object_unref (location);
}
@@ -3495,10 +3516,11 @@ gth_browser_get_file_modified (GthBrowser *browser)
void
gth_browser_go_to (GthBrowser *browser,
- GFile *location)
+ GFile *location,
+ GFile *scroll_to_file)
{
gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_BROWSER);
- _gth_browser_load (browser, location, GTH_ACTION_GO_TO, FALSE);
+ _gth_browser_load (browser, location, scroll_to_file, GTH_ACTION_GO_TO, FALSE);
}
@@ -3516,7 +3538,7 @@ gth_browser_go_back (GthBrowser *browser,
return;
browser->priv->history_current = new_current;
- _gth_browser_load (browser, (GFile*) browser->priv->history_current->data, GTH_ACTION_GO_BACK, FALSE);
+ _gth_browser_load (browser, (GFile*) browser->priv->history_current->data, NULL, GTH_ACTION_GO_BACK, FALSE);
}
@@ -3534,7 +3556,7 @@ gth_browser_go_forward (GthBrowser *browser,
return;
browser->priv->history_current = new_current;
- _gth_browser_load (browser, (GFile *) browser->priv->history_current->data, GTH_ACTION_GO_FORWARD, FALSE);
+ _gth_browser_load (browser, (GFile *) browser->priv->history_current->data, NULL, GTH_ACTION_GO_FORWARD, FALSE);
}
@@ -3557,7 +3579,7 @@ gth_browser_go_up (GthBrowser *browser,
}
if (parent != NULL) {
- gth_browser_go_to (browser, parent);
+ gth_browser_go_to (browser, parent, NULL);
g_object_unref (parent);
}
}
@@ -3570,7 +3592,7 @@ gth_browser_go_home (GthBrowser *browser)
location = g_file_new_for_uri (gth_pref_get_startup_location ());
gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_BROWSER);
- gth_browser_go_to (browser, location);
+ gth_browser_go_to (browser, location, NULL);
g_object_unref (location);
}
@@ -3710,7 +3732,7 @@ gth_browser_stop (GthBrowser *browser)
void
gth_browser_reload (GthBrowser *browser)
{
- gth_browser_go_to (browser, browser->priv->location->file);
+ gth_browser_go_to (browser, browser->priv->location->file, NULL);
}
@@ -4092,7 +4114,7 @@ file_metadata_ready_cb (GList *files,
GFile *parent;
parent = g_file_get_parent (browser->priv->current_file->file);
- _gth_browser_load (browser, parent, GTH_ACTION_GO_TO, FALSE);
+ _gth_browser_load (browser, parent, browser->priv->current_file->file, GTH_ACTION_GO_TO, FALSE);
g_object_unref (parent);
}
}
@@ -4418,7 +4440,7 @@ load_file_attributes_ready_cb (GthFileSource *file_source,
}
else if (g_file_info_get_file_type (file_data->info) == G_FILE_TYPE_DIRECTORY) {
gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_BROWSER);
- gth_browser_go_to (browser, file_data->file);
+ gth_browser_go_to (browser, file_data->file, NULL);
}
else {
GError *error;
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index 4aa8e82..9e98e21 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -72,7 +72,8 @@ GthFileData * gth_browser_get_location_data (GthBrowser *browser);
GthFileData * gth_browser_get_current_file (GthBrowser *browser);
gboolean gth_browser_get_file_modified (GthBrowser *browser);
void gth_browser_go_to (GthBrowser *browser,
- GFile *location);
+ GFile *location,
+ GFile *scroll_to_file);
void gth_browser_go_back (GthBrowser *browser,
int steps);
void gth_browser_go_forward (GthBrowser *browser,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]