summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-10-28 05:38:11 -0700
committerBenjamin Otte <otte@redhat.com>2011-12-16 20:09:11 +0100
commitd5e5ca3e2a035005f34551c2c6ed647d2e952e1b (patch)
tree8063fe04522f11b00e35e6c3c91ee7b4cf4fba29 /gtk
parent7b51ca9a4749ce74671f2f903bf65304df786076 (diff)
downloadgtk+-d5e5ca3e2a035005f34551c2c6ed647d2e952e1b.tar.gz
filechooserentry: Reorganize function
Setter functions the way I code it look like this (in order): 1) Figure out if the value changed. If not, exit early. 2) Clear the old value (ie unref stuff, disconnect signals 3) Copy the new value 4) Set up things about the new value This reorganization does that. And by doing that, it even reduces the amount of code and the amount of branches (and with it, nesting) needed.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkfilechooserentry.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 829b529c90..d365d7136f 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -1497,34 +1497,23 @@ reload_current_folder (GtkFileChooserEntry *chooser_entry,
GFile *folder_file,
gboolean force_reload)
{
- gboolean reload = FALSE;
-
g_assert (folder_file != NULL);
- if (chooser_entry->current_folder_file)
- {
- if ((!(g_file_equal (folder_file, chooser_entry->current_folder_file)
- && chooser_entry->load_folder_cancellable))
- || force_reload)
- {
- reload = TRUE;
-
- discard_current_folder (chooser_entry);
- discard_loading_and_current_folder_file (chooser_entry);
+ if (chooser_entry->current_folder_file
+ && g_file_equal (folder_file, chooser_entry->current_folder_file)
+ && chooser_entry->load_folder_cancellable
+ && !force_reload)
+ return REFRESH_OK;
- chooser_entry->current_folder_file = g_object_ref (folder_file);
- }
- }
- else
+ if (chooser_entry->current_folder_file)
{
- chooser_entry->current_folder_file = g_object_ref (folder_file);
- reload = TRUE;
+ discard_current_folder (chooser_entry);
+ discard_loading_and_current_folder_file (chooser_entry);
}
+
+ chooser_entry->current_folder_file = g_object_ref (folder_file);
- if (reload)
- return start_loading_current_folder (chooser_entry);
- else
- return REFRESH_OK;
+ return start_loading_current_folder (chooser_entry);
}
static RefreshStatus