[gthumb] queue the make_file_visible call to be sure it's called after setting the model
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] queue the make_file_visible call to be sure it's called after setting the model
- Date: Wed, 7 Dec 2011 19:15:06 +0000 (UTC)
commit f946863688d74b5d1b6f6ddb661be72c2af60b4d
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Dec 7 16:27:53 2011 +0100
queue the make_file_visible call to be sure it's called after setting the model
gthumb/gth-browser.c | 74 ++++--------------------------------------------
gthumb/gth-file-list.c | 36 ++++++++++++++++++++++-
gthumb/gth-file-list.h | 2 +
3 files changed, 42 insertions(+), 70 deletions(-)
---
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 79030d5..31453a7 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -1640,19 +1640,9 @@ load_data_continue (LoadData *load_data,
g_object_unref (filter);
}
- if (load_data->file_to_select != NULL) {
- int pos;
-
- pos = gth_file_store_get_pos (gth_browser_get_file_store (browser), load_data->file_to_select);
- if (pos >= 0) {
- GtkWidget *file_view;
+ if (load_data->file_to_select != NULL)
+ gth_file_list_make_file_visible (GTH_FILE_LIST (browser->priv->file_list), load_data->file_to_select);
- 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_file_view_set_cursor (GTH_FILE_VIEW (file_view), pos);
- }
- }
gth_browser_update_sensitivity (browser);
_gth_browser_update_statusbar_list_info (browser);
@@ -3123,18 +3113,9 @@ folder_changed_cb (GthMonitor *monitor,
if (new_file != NULL) {
if (gth_window_get_current_page (GTH_WINDOW (browser)) == GTH_BROWSER_PAGE_VIEWER)
gth_browser_load_file (browser, new_file, FALSE);
- else if (gth_window_get_current_page (GTH_WINDOW (browser)) == GTH_BROWSER_PAGE_BROWSER) {
- int file_pos;
-
- file_pos = gth_file_store_get_pos (GTH_FILE_STORE (gth_browser_get_file_store (browser)), new_file->file);
- if (file_pos >= 0) {
- GtkWidget *view;
+ else if (gth_window_get_current_page (GTH_WINDOW (browser)) == GTH_BROWSER_PAGE_BROWSER)
+ gth_file_list_make_file_visible (GTH_FILE_LIST (browser->priv->file_list), new_file->file);
- view = gth_browser_get_file_list_view (browser);
- gth_file_selection_select (GTH_FILE_SELECTION (view), file_pos);
- gth_file_view_set_cursor (GTH_FILE_VIEW (view), file_pos);
- }
- }
_g_object_unref (new_file);
}
else {
@@ -3906,9 +3887,8 @@ static gboolean
_gth_browser_make_file_visible (GthBrowser *browser,
GthFileData *file_data)
{
- int file_pos;
- GtkWidget *view;
- GthVisibility visibility;
+ int file_pos;
+ GtkWidget *view;
if (file_data == NULL)
return FALSE;
@@ -3926,27 +3906,6 @@ _gth_browser_make_file_visible (GthBrowser *browser,
gth_file_view_set_cursor (GTH_FILE_VIEW (view), file_pos);
gth_hook_invoke ("gth-browser-selection-changed", browser);
g_signal_handlers_unblock_by_func (view, gth_file_view_selection_changed_cb, browser);
- visibility = gth_file_view_get_visibility (GTH_FILE_VIEW (view), file_pos);
- if (visibility != GTH_VISIBILITY_FULL) {
- double align = 0.0;
-
- switch (visibility) {
- case GTH_VISIBILITY_NONE:
- case GTH_VISIBILITY_FULL:
- case GTH_VISIBILITY_PARTIAL:
- align = 0.5;
- break;
-
- case GTH_VISIBILITY_PARTIAL_TOP:
- align = 0.0;
- break;
-
- case GTH_VISIBILITY_PARTIAL_BOTTOM:
- align = 1.0;
- break;
- }
- gth_file_view_scroll_to (GTH_FILE_VIEW (view), file_pos, align);
- }
/* the thumbnail list in viewer mode */
@@ -3956,27 +3915,6 @@ _gth_browser_make_file_visible (GthBrowser *browser,
gth_file_selection_select (GTH_FILE_SELECTION (view), file_pos);
gth_file_view_set_cursor (GTH_FILE_VIEW (view), file_pos);
g_signal_handlers_unblock_by_func (view, gth_thumbnail_view_selection_changed_cb, browser);
- visibility = gth_file_view_get_visibility (GTH_FILE_VIEW (view), file_pos);
- if (visibility != GTH_VISIBILITY_FULL) {
- double align = 0.0;
-
- switch (visibility) {
- case GTH_VISIBILITY_NONE:
- case GTH_VISIBILITY_FULL:
- case GTH_VISIBILITY_PARTIAL:
- align = 0.5;
- break;
-
- case GTH_VISIBILITY_PARTIAL_TOP:
- align = 0.0;
- break;
-
- case GTH_VISIBILITY_PARTIAL_BOTTOM:
- align = 1.0;
- break;
- }
- gth_file_view_scroll_to (GTH_FILE_VIEW (view), file_pos, align);
- }
return TRUE;
}
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index e37d7c7..3717273 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -53,8 +53,8 @@ typedef enum {
GTH_FILE_LIST_OP_TYPE_SET_FILTER,
GTH_FILE_LIST_OP_TYPE_SET_SORT_FUNC,
GTH_FILE_LIST_OP_TYPE_ENABLE_THUMBS,
- GTH_FILE_LIST_OP_TYPE_RENAME_FILE
- /*GTH_FILE_LIST_OP_TYPE_SET_THUMBS_SIZE,*/
+ GTH_FILE_LIST_OP_TYPE_RENAME_FILE,
+ GTH_FILE_LIST_OP_TYPE_MAKE_FILE_VISIBLE
} GthFileListOpType;
@@ -174,6 +174,9 @@ gth_file_list_op_free (GthFileListOp *op)
g_object_unref (op->file);
g_object_unref (op->file_data);
break;
+ case GTH_FILE_LIST_OP_TYPE_MAKE_FILE_VISIBLE:
+ g_object_unref (op->file);
+ break;
default:
break;
}
@@ -1224,6 +1227,32 @@ gth_file_list_set_caption (GthFileList *file_list,
}
+static void
+gfl_make_file_visible (GthFileList *file_list,
+ GFile *file)
+{
+ int pos;
+
+ pos = gth_file_store_get_pos ((GthFileStore *) gth_file_view_get_model (GTH_FILE_VIEW (file_list->priv->view)), file);
+ if (pos >= 0) {
+ gth_file_selection_select (GTH_FILE_SELECTION (file_list->priv->view), pos);
+ gth_file_view_set_cursor (GTH_FILE_VIEW (file_list->priv->view), pos);
+ }
+}
+
+
+void
+gth_file_list_make_file_visible (GthFileList *file_list,
+ GFile *file)
+{
+ GthFileListOp *op;
+
+ op = gth_file_list_op_new (GTH_FILE_LIST_OP_TYPE_MAKE_FILE_VISIBLE);
+ op->file = g_object_ref (file);
+ _gth_file_list_queue_op (file_list, op);
+}
+
+
GtkWidget *
gth_file_list_get_view (GthFileList *file_list)
{
@@ -1759,6 +1788,9 @@ _gth_file_list_exec_next_op (GthFileList *file_list)
case GTH_FILE_LIST_OP_TYPE_RENAME_FILE:
gfl_rename_file (file_list, op->file, op->file_data);
break;
+ case GTH_FILE_LIST_OP_TYPE_MAKE_FILE_VISIBLE:
+ gfl_make_file_visible (file_list, op->file);
+ break;
default:
exec_next_op = FALSE;
break;
diff --git a/gthumb/gth-file-list.h b/gthumb/gth-file-list.h
index cfa5971..3caea6b 100644
--- a/gthumb/gth-file-list.h
+++ b/gthumb/gth-file-list.h
@@ -100,6 +100,8 @@ void gth_file_list_set_thumb_size (GthFileList *file_li
int size);
void gth_file_list_set_caption (GthFileList *file_list,
const char *attribute);
+void gth_file_list_make_file_visible (GthFileList *file_list,
+ GFile *file);
GtkWidget * gth_file_list_get_view (GthFileList *file_list);
GtkWidget * gth_file_list_get_empty_view (GthFileList *file_list);
GtkAdjustment * gth_file_list_get_vadjustment (GthFileList *file_list);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]