diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-02-07 12:55:09 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-02-07 12:55:09 +0000 |
commit | e46f32bed42a3c00109b27a39ba3df16896f8e85 (patch) | |
tree | 81fc5141978b53e67e8d90a5bfd883a4f306aad4 /libnautilus-private/nautilus-file.c | |
parent | 1d87a73e66e20e2dc41302cd9760374040e4a819 (diff) | |
download | nautilus-e46f32bed42a3c00109b27a39ba3df16896f8e85.tar.gz |
reviewed by: Pavel Cisler <pavel@eazel.com>
* libnautilus-extensions/nautilus-directory-async.c:
(show_hidden_files_changed_callback),
(show_backup_files_changed_callback),
(get_filter_options_for_directory_count):
* libnautilus-extensions/nautilus-file.c:
(show_text_in_icons_changed_callback),
(show_directory_item_count_changed_callback),
(get_speed_tradeoff_preference_for_file),
(nautilus_file_should_show_directory_item_count),
(nautilus_file_should_get_top_left_text):
* libnautilus-extensions/nautilus-theme.c:
(theme_changed_callback), (nautilus_theme_get_theme),
(nautilus_theme_get_theme_data), (nautilus_theme_get_image_path):
* src/file-manager/fm-directory-view.c:
(confirm_trash_changed_callback), (real_update_menus):
* src/file-manager/fm-icon-text-window.c:
(icon_captions_changed_callback),
(fm_get_text_attribute_names_preference_or_default):
Use calllbacks for some preferences values instead of peeking
diectly. The preferences in question here are peeked a lot during
large directory loads, even though they hardly ever change. This
should get preferences stuff mostly out of Pavel's profiles. Now,
im still working on bug 6054 which is about making peeking
preferences in general faster.
Diffstat (limited to 'libnautilus-private/nautilus-file.c')
-rw-r--r-- | libnautilus-private/nautilus-file.c | 107 |
1 files changed, 77 insertions, 30 deletions
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index 6924cf782..c720ed21c 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -1070,34 +1070,6 @@ nautilus_file_is_local (NautilusFile *file) return nautilus_directory_is_local (file->details->directory); } -static gboolean -get_speed_tradeoff_preference_for_file (NautilusFile *file, const char *preference_name) -{ - NautilusSpeedTradeoffValue preference_value; - - g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE); - - preference_value = nautilus_preferences_get_integer (preference_name); - - if (preference_value == NAUTILUS_SPEED_TRADEOFF_ALWAYS) { - return TRUE; - } - - if (preference_value == NAUTILUS_SPEED_TRADEOFF_NEVER) { - return FALSE; - } - - g_assert (preference_value == NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY); - return nautilus_file_is_local (file); -} - -gboolean -nautilus_file_should_get_top_left_text (NautilusFile *file) -{ - return get_speed_tradeoff_preference_for_file - (file, NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS); -} - static void update_link (NautilusFile *link_file, NautilusFile *target_file) { @@ -2292,11 +2264,86 @@ nautilus_file_get_date_as_string (NautilusFile *file, NautilusDateType date_type return nautilus_strdup_strftime (format, file_time); } +static NautilusSpeedTradeoffValue show_directory_item_count; +static NautilusSpeedTradeoffValue show_text_in_icons; + +static void +show_text_in_icons_changed_callback (gpointer callback_data) +{ + show_text_in_icons = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS); +} + +static void +show_directory_item_count_changed_callback (gpointer callback_data) +{ + show_directory_item_count = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS); +} + +static gboolean +get_speed_tradeoff_preference_for_file (NautilusFile *file, NautilusSpeedTradeoffValue value) +{ + g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE); + + if (value == NAUTILUS_SPEED_TRADEOFF_ALWAYS) { + return TRUE; + } + + if (value == NAUTILUS_SPEED_TRADEOFF_NEVER) { + return FALSE; + } + + g_assert (value == NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY); + return nautilus_file_is_local (file); +} + gboolean nautilus_file_should_show_directory_item_count (NautilusFile *file) { - return get_speed_tradeoff_preference_for_file - (file, NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS); + static gboolean show_directory_item_count_callback_added = FALSE; + + g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE); + + /* Add the callback once for the life of our process */ + if (!show_directory_item_count_callback_added) { + nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, + show_directory_item_count_changed_callback, + NULL); + show_directory_item_count_callback_added = TRUE; + + /* Peek for the first time */ + show_directory_item_count_changed_callback (NULL); + } + + return get_speed_tradeoff_preference_for_file (file, show_directory_item_count); +} + +gboolean +nautilus_file_should_get_top_left_text (NautilusFile *file) +{ + static gboolean show_text_in_icons_callback_added = FALSE; + + g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE); + + /* Add the callback once for the life of our process */ + if (!show_text_in_icons_callback_added) { + nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS, + show_text_in_icons_changed_callback, + NULL); + show_text_in_icons_callback_added = TRUE; + + /* Peek for the first time */ + show_text_in_icons_changed_callback (NULL); + } + + if (show_text_in_icons == NAUTILUS_SPEED_TRADEOFF_ALWAYS) { + return TRUE; + } + + if (show_text_in_icons == NAUTILUS_SPEED_TRADEOFF_NEVER) { + return FALSE; + } + + return get_speed_tradeoff_preference_for_file (file, show_text_in_icons); } /** |