[gthumb] update the current location after changing the catalog date
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] update the current location after changing the catalog date
- Date: Mon, 14 Mar 2016 08:35:37 +0000 (UTC)
commit 929505384bb72981081cd1eebb4f2fe264f4d7e3
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Mar 12 21:33:11 2016 +0100
update the current location after changing the catalog date
gthumb/gth-browser.c | 34 +++++++++++++++++++++----------
gthumb/gth-folder-tree.c | 20 ++++++++++--------
gthumb/gth-location-bar.c | 8 -------
gthumb/gth-location-bar.h | 2 -
gthumb/gth-location-chooser.c | 45 ++++++++++++++++++++++++++++------------
gthumb/gth-location-chooser.h | 3 +-
6 files changed, 66 insertions(+), 46 deletions(-)
---
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 1a59546..f38b792 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -442,9 +442,16 @@ gth_browser_update_sensitivity (GthBrowser *browser)
void
gth_browser_update_extra_widget (GthBrowser *browser)
{
+ GtkWidget *location_chooser;
+
gtk_widget_show (browser->priv->location_bar);
_gtk_container_remove_children (GTK_CONTAINER (gth_location_bar_get_action_area (GTH_LOCATION_BAR
(browser->priv->location_bar))), NULL, NULL);
- gth_location_bar_set_from_file (GTH_LOCATION_BAR (browser->priv->location_bar),
browser->priv->location->file);
+
+ location_chooser = gth_location_bar_get_chooser (GTH_LOCATION_BAR (browser->priv->location_bar));
+ g_signal_handlers_block_by_data (location_chooser, browser);
+ gth_location_chooser_set_current (GTH_LOCATION_CHOOSER (location_chooser),
browser->priv->location->file);
+ g_signal_handlers_unblock_by_data (location_chooser, browser);
+
gth_hook_invoke ("gth-browser-update-extra-widget", browser);
}
@@ -453,23 +460,20 @@ static void
_gth_browser_set_location (GthBrowser *browser,
GthFileData *location)
{
- GtkWidget *location_chooser;
-
if (location == NULL)
return;
- if (browser->priv->location != NULL)
- g_object_unref (browser->priv->location);
- browser->priv->location = gth_file_data_dup (location);
+ if (location != browser->priv->location) {
+ if (browser->priv->location != NULL)
+ g_object_unref (browser->priv->location);
+ browser->priv->location = gth_file_data_dup (location);
+ }
_gth_browser_update_current_file_position (browser);
gth_browser_update_title (browser);
gth_browser_update_sensitivity (browser);
- location_chooser = gth_location_bar_get_chooser (GTH_LOCATION_BAR (browser->priv->location_bar));
- g_signal_handlers_block_by_data (location_chooser, browser);
gth_browser_update_extra_widget (browser);
- g_signal_handlers_unblock_by_data (location_chooser, browser);
}
@@ -3375,6 +3379,7 @@ renamed_file_attributes_ready_cb (GthFileSource *file_source,
new_location = gth_file_data_new (rename_data->new_file, browser->priv->location->info);
new_info = gth_file_source_get_file_info (rename_data->file_source, new_location->file,
GFILE_DISPLAY_ATTRIBUTES);
g_file_info_copy_into (new_info, new_location->info);
+
_gth_browser_set_location (browser, new_location);
g_object_unref (new_info);
@@ -3471,10 +3476,15 @@ metadata_changed_cb (GthMonitor *monitor,
GthBrowser *browser)
{
if ((browser->priv->location != NULL) && g_file_equal (browser->priv->location->file,
file_data->file)) {
+ GtkWidget *location_chooser;
+
if (file_data->info != browser->priv->location->info)
g_file_info_copy_into (file_data->info, browser->priv->location->info);
- gth_browser_update_extra_widget (browser);
- return;
+
+ location_chooser = gth_location_bar_get_chooser (GTH_LOCATION_BAR
(browser->priv->location_bar));
+ gth_location_chooser_reload (GTH_LOCATION_CHOOSER (location_chooser));
+
+ _gth_browser_set_location (browser, browser->priv->location);
}
if ((browser->priv->current_file != NULL) && g_file_equal (browser->priv->current_file->file,
file_data->file)) {
@@ -3487,6 +3497,8 @@ metadata_changed_cb (GthMonitor *monitor,
gth_browser_update_title (browser);
gth_browser_update_sensitivity (browser);
}
+
+ gth_folder_tree_update_child (GTH_FOLDER_TREE (browser->priv->folder_tree), file_data->file,
file_data);
}
diff --git a/gthumb/gth-folder-tree.c b/gthumb/gth-folder-tree.c
index 4bf9574..d34092b 100644
--- a/gthumb/gth-folder-tree.c
+++ b/gthumb/gth-folder-tree.c
@@ -1752,18 +1752,20 @@ gth_folder_tree_update_child (GthFolderTree *folder_tree,
return;
if (gth_folder_tree_get_iter (folder_tree, file_data->file, &new_file_iter, NULL)) {
- GFile *parent;
- GList *files;
+ if (! _g_file_equal (old_file, file_data->file)) {
+ GFile *parent;
+ GList *files;
- /* the new file is already present, remove the old file */
+ /* the new file is already present, remove the old file */
- parent = g_file_get_parent (old_file);
- files = g_list_prepend (NULL, g_object_ref (old_file));
- gth_folder_tree_delete_children (folder_tree, parent, files);
- _g_object_list_unref (files);
- g_object_unref (parent);
+ parent = g_file_get_parent (old_file);
+ files = g_list_prepend (NULL, g_object_ref (old_file));
+ gth_folder_tree_delete_children (folder_tree, parent, files);
+ _g_object_list_unref (files);
+ g_object_unref (parent);
+ }
- /* update the data old of the new file */
+ /* update the data of the new file */
_gth_folder_tree_set_file_data (folder_tree, &new_file_iter, file_data);
}
diff --git a/gthumb/gth-location-bar.c b/gthumb/gth-location-bar.c
index ac3cc09..04fe163 100644
--- a/gthumb/gth-location-bar.c
+++ b/gthumb/gth-location-bar.c
@@ -85,14 +85,6 @@ gth_location_bar_new (void)
}
-void
-gth_location_bar_set_from_file (GthLocationBar *self,
- GFile *file)
-{
- gth_location_chooser_set_current (GTH_LOCATION_CHOOSER (self->priv->location_chooser), file);
-}
-
-
GtkWidget *
gth_location_bar_get_chooser (GthLocationBar *self)
{
diff --git a/gthumb/gth-location-bar.h b/gthumb/gth-location-bar.h
index 6f82e18..c14156e 100644
--- a/gthumb/gth-location-bar.h
+++ b/gthumb/gth-location-bar.h
@@ -50,8 +50,6 @@ struct _GthLocationBarClass
GType gth_location_bar_get_type (void) G_GNUC_CONST;
GtkWidget * gth_location_bar_new (void);
-void gth_location_bar_set_from_file (GthLocationBar *dialog,
- GFile *file);
GtkWidget * gth_location_bar_get_chooser (GthLocationBar *dialog);
GtkWidget * gth_location_bar_get_action_area (GthLocationBar *self);
diff --git a/gthumb/gth-location-chooser.c b/gthumb/gth-location-chooser.c
index 8575815..bde3f08 100644
--- a/gthumb/gth-location-chooser.c
+++ b/gthumb/gth-location-chooser.c
@@ -79,6 +79,7 @@ struct _GthLocationChooserPrivate
guint update_location_list_id;
gboolean show_entry_points;
GtkReliefStyle relief;
+ gboolean reload;
};
@@ -436,7 +437,7 @@ update_location_list (gpointer user_data)
if (self->priv->location == NULL)
return;
- if (get_iter_from_current_file_entries (self, self->priv->location, &iter)) {
+ if (! self->priv->reload && get_iter_from_current_file_entries (self, self->priv->location, &iter)) {
g_signal_handlers_block_by_func (self->priv->combo, combo_changed_cb, self);
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->priv->combo), &iter);
g_signal_handlers_unblock_by_func (self->priv->combo, combo_changed_cb, self);
@@ -469,6 +470,8 @@ update_location_list (gpointer user_data)
_g_object_list_unref (list);
}
+
+ self->priv->reload = FALSE;
}
@@ -476,7 +479,7 @@ static void
current_location_changed (GthLocationChooser *self)
{
if (self->priv->update_location_list_id != 0)
- return;
+ g_source_remove (self->priv->update_location_list_id);
self->priv->update_location_list_id = call_when_idle ((DataFunc) update_location_list, self);
}
@@ -565,6 +568,7 @@ gth_location_chooser_init (GthLocationChooser *self)
self->priv->arrow = NULL;
self->priv->show_entry_points = TRUE;
self->priv->relief = GTK_RELIEF_NORMAL;
+ self->priv->reload = FALSE;
self->priv->model = gtk_tree_store_new (N_COLUMNS,
G_TYPE_ICON,
@@ -739,21 +743,22 @@ void
gth_location_chooser_set_current (GthLocationChooser *self,
GFile *file)
{
+ if (file != self->priv->location) {
+ if (self->priv->file_source != NULL)
+ g_object_unref (self->priv->file_source);
+ self->priv->file_source = gth_main_get_file_source (file);
+ if (self->priv->file_source == NULL)
+ return;
- if (self->priv->file_source != NULL)
- g_object_unref (self->priv->file_source);
- self->priv->file_source = gth_main_get_file_source (file);
-
- if (self->priv->file_source == NULL)
- return;
-
- if ((self->priv->location != NULL) && g_file_equal (file, self->priv->location))
- return;
+ if (self->priv->location != NULL) {
+ g_object_unref (self->priv->location);
+ self->priv->location = NULL;
+ }
- if (self->priv->location != NULL)
- g_object_unref (self->priv->location);
- self->priv->location = g_file_dup (file);
+ if (file != NULL)
+ self->priv->location = g_file_dup (file);
+ }
if (gtk_widget_get_realized (GTK_WIDGET (self)))
current_location_changed (self);
@@ -767,3 +772,15 @@ gth_location_chooser_get_current (GthLocationChooser *self)
{
return self->priv->location;
}
+
+void
+gth_location_chooser_reload (GthLocationChooser *self)
+{
+ if (self->priv->location == NULL)
+ return;
+
+ self->priv->reload = TRUE;
+
+ if (gtk_widget_get_realized (GTK_WIDGET (self)))
+ current_location_changed (self);
+}
diff --git a/gthumb/gth-location-chooser.h b/gthumb/gth-location-chooser.h
index 0059841..577752c 100644
--- a/gthumb/gth-location-chooser.h
+++ b/gthumb/gth-location-chooser.h
@@ -64,8 +64,7 @@ gboolean gth_location_chooser_get_show_entry_points (GthLocationChooser
void gth_location_chooser_set_current (GthLocationChooser *chooser,
GFile *location);
GFile * gth_location_chooser_get_current (GthLocationChooser *chooser);
-GthFileSource * gth_location_chooser_get_file_source (GthLocationChooser *chooser);
-void gth_location_chooser_open_other (GthLocationChooser *chooser);
+void gth_location_chooser_reload (GthLocationChooser *chooser);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]