From e60f2abe9f114f800b22a824402fededf45a5ba7 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 5 Jan 2002 04:05:26 +0000 Subject: [PATCH] add preload of the gconf cache, to hopefully avoid a zillion round trips 2002-01-04 Havoc Pennington * libnautilus-private/nautilus-global-preferences.c (nautilus_global_preferences_init): add preload of the gconf cache, to hopefully avoid a zillion round trips to gconfd on startup. * test/test.c (test_window_new): remove weird gtk_window_set_policy * test/test-nautilus-preferences-display.c: remove user level stuff * test/test-nautilus-preferences-change.c: remove user level stuff * libnautilus-private/nautilus-global-preferences.c: the default click policy was SPEED_TRADEOFF_LOCAL_ONLY, fix * libnautilus-private/nautilus.schemas: add schemas file, incomplete, needs to be finished and installed * libnautilus-private/nautilus-global-preferences.c: strip out user levels * src/nautilus-shell-ui.xml: strip out user level menu * src/nautilus-window-menus.c: strip out user level menu --- ChangeLog | 27 ++ .../nautilus-global-preferences.c | 399 ++++++------------ libnautilus-private/nautilus.schemas | 242 +++++++++++ src/nautilus-navigation-window-menus.c | 183 -------- src/nautilus-shell-ui.xml | 28 +- src/nautilus-window-menus.c | 183 -------- test/test-nautilus-preferences-change.c | 126 +----- test/test-nautilus-preferences-display.c | 52 --- test/test.c | 7 +- 9 files changed, 414 insertions(+), 833 deletions(-) create mode 100644 libnautilus-private/nautilus.schemas diff --git a/ChangeLog b/ChangeLog index ce7c44fae..18e408cbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2002-01-04 Havoc Pennington + + * libnautilus-private/nautilus-global-preferences.c + (nautilus_global_preferences_init): add preload of the gconf + cache, to hopefully avoid a zillion round trips to gconfd on + startup. + + * test/test.c (test_window_new): remove weird gtk_window_set_policy + + * test/test-nautilus-preferences-display.c: remove user level + stuff + + * test/test-nautilus-preferences-change.c: remove user level stuff + + * libnautilus-private/nautilus-global-preferences.c: the default + click policy was SPEED_TRADEOFF_LOCAL_ONLY, fix + + * libnautilus-private/nautilus.schemas: add schemas file, + incomplete, needs to be finished and installed + + * libnautilus-private/nautilus-global-preferences.c: strip out + user levels + + * src/nautilus-shell-ui.xml: strip out user level menu + + * src/nautilus-window-menus.c: strip out user level menu + 2002-01-04 Darin Adler * libnautilus-private/nautilus-icon-container.c: diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c index d50d8a24e..953f06771 100644 --- a/libnautilus-private/nautilus-global-preferences.c +++ b/libnautilus-private/nautilus-global-preferences.c @@ -51,9 +51,9 @@ static const char SYSTEM_GNOME_VFS_PATH[] = "/system/gnome-vfs"; /* Forward declarations */ static void global_preferences_install_defaults (void); static void global_preferences_register_enumerations (void); -static gpointer default_font_callback (int user_level); -static gpointer default_home_location_callback (int user_level); -static gpointer default_default_folder_viewer_callback (int user_level); +static gpointer default_font_callback (void); +static gpointer default_home_location_callback (void); +static gpointer default_default_folder_viewer_callback (void); /* An enumeration used for installing type specific preferences defaults. */ typedef enum @@ -215,31 +215,20 @@ static EelEnumerationInfo enumerations[] = { }; /* - * A callback which can be used to fetch dynamic default values. + * A callback which can be used to fetch dynamic fallback values. * For example, values that are dependent on the environment (such as user name) * cannot be specified as constants. */ -typedef gpointer (*PreferencesDefaultValueCallback) (int user_level); - -/* A structure that pairs a default value with a specific user level. */ -typedef struct -{ - int user_level; - const gpointer value; - PreferencesDefaultValueCallback callback; - GFreeFunc callback_result_free_function; -} PreferenceUserLevelDefault; - -#define USER_LEVEL_NONE -1 +typedef gpointer (*PreferencesDefaultValueCallback) (void); /* A structure that describes a single preference including defaults and visibility. */ typedef struct { const char *name; PreferenceType type; - int visible_user_level; - const PreferenceUserLevelDefault default1; - const PreferenceUserLevelDefault default2; + const gpointer fallback_value; + PreferencesDefaultValueCallback fallback_callback; + GFreeFunc fallback_callback_result_free_function; const char *enumeration_id; } PreferenceDefault; @@ -263,42 +252,14 @@ typedef struct * PREFERENCE_STRING * PREFERENCE_STRING_LIST * - * 3. visible_user_level - * The visible user level is the first user level at which the - * preference is visible. By default all preferences have a visibility of 0. + * 3. fallback_value + * Emergency fallback value if our gconf schemas are hosed somehow. * - * A preference with a visible_user_level greater than 0, will be "visible" - * only at that level or higher. Any getters that ask for that preference at - * lower user levels will always receive the default value. Also, if the - * preference has an entry in the preferences dialog, it will not be shown - * unless the current user level is greater than or equal to the preference's - * visible user level. + * 4. fallback_callback + * callback to get dynamic fallback * - * 4. default1 - * A pair of a user_level and a value (PreferenceUserLevelDefault). For the - * left hand side user_level, the preference will have the right hand side - * default value. - * - * This pair does not need to be given. It can be { USER_LEVEL_NONE }, in - * which case the preference defaults to 0 at all user levels. - * - * 5. default2 - * A pair of a user_level and a value (PreferenceUserLevelDefault). For the - * left hand side user_level, the preference will have the right hand side - * default value. - * - * This pair does not need to be given. It can be { USER_LEVEL_NONE }, in - * which case the preference defaults to 0 at all user levels. - * - * Notes: - * - * Define defaults only for preferences that need something other than 0 (integer) - * FALSE (boolean) or "" (string) as their defaults. - * - * Its possible to have different defaults for different user levels Its not - * required to have defaults for EACH user level. If there is no default - * installed for a high user level, the next lowest user level with a valid - * default is used. + * 5. fallback_callback_result_free_function + * free result of fallback_callback * * 6. enumeration_id * An an enumeration id is a unique string that identifies an enumeration. @@ -306,396 +267,304 @@ typedef struct * The preferences dialog widgetry will use this enumeration id to find out * what choices and descriptions of choices to present to the user. */ + +/* NOTE THAT THE FALLBACKS HERE ARE NOT SUPPOSED TO BE USED - + * YOU SHOULD EDIT THE SCHEMAS FILE TO CHANGE DEFAULTS. + */ static const PreferenceDefault preference_defaults[] = { { NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_CONFIRM_TRASH, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_ADVANCED, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { NAUTILUS_PREFERENCES_ENABLE_DELETE, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_ADVANCED, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS, PREFERENCE_INTEGER, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY), + NULL, NULL, "speed_tradeoff" }, - /* Don't show remote directory item counts for Beginner users because computing them - * can be annoyingly slow, especially for FTP. If we make this fast enough for FTP in - * particular, we should change this default to ALWAYS. + /* Don't show remote directory item counts by default + * because computing them can be annoyingly slow, especially + * for FTP. If we make this fast enough for FTP in particular, + * we should change this default to ALWAYS. */ { NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, PREFERENCE_INTEGER, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, - { EEL_USER_LEVEL_INTERMEDIATE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_ALWAYS) }, + GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY), + NULL, NULL, "speed_tradeoff" }, { NAUTILUS_PREFERENCES_CLICK_POLICY, PREFERENCE_INTEGER, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_CLICK_POLICY_DOUBLE), + NULL, NULL, "click_policy" }, { NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, PREFERENCE_INTEGER, - EEL_USER_LEVEL_ADVANCED, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_EXECUTABLE_TEXT_ASK) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_EXECUTABLE_TEXT_ASK), + NULL, NULL, "executable_text_activation" }, { NAUTILUS_PREFERENCES_THEME, PREFERENCE_STRING, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, "default" }, - { USER_LEVEL_NONE } + "default" }, { NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, PREFERENCE_INTEGER, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY), + NULL, NULL, "speed_tradeoff" }, { NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, PREFERENCE_INTEGER, - EEL_USER_LEVEL_ADVANCED, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (3145728) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (3145728), + NULL, NULL, "file_size" }, { NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA, PREFERENCE_INTEGER, - EEL_USER_LEVEL_ADVANCED, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY), + NULL, NULL, "speed_tradeoff" }, { NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { NAUTILUS_PREFERENCES_PREVIEW_SOUND, PREFERENCE_INTEGER, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY), + NULL, NULL, "speed_tradeoff" }, { NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_ADVANCED, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { EEL_USER_LEVEL_ADVANCED, GINT_TO_POINTER (TRUE) } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_SHOW_DESKTOP, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_ADVANCED, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_CAN_ADD_CONTENT, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { EEL_USER_LEVEL_INTERMEDIATE, GINT_TO_POINTER (TRUE) } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, PREFERENCE_INTEGER, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SIMPLE_SEARCH_BAR) }, - { EEL_USER_LEVEL_INTERMEDIATE, GINT_TO_POINTER (NAUTILUS_COMPLEX_SEARCH_BAR) }, + GINT_TO_POINTER (NAUTILUS_SIMPLE_SEARCH_BAR), + NULL, NULL, "search_bar_type" }, { NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS, PREFERENCE_STRING_LIST, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, "size,date_modified,type", }, - { USER_LEVEL_NONE }, + "size,date_modified,type", + NULL, NULL, "icon_captions" }, { NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_ADVANCED, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, /* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */ { NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (148) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (148) }, { NAUTILUS_PREFERENCES_SEARCH_WEB_URI, PREFERENCE_STRING, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, "http://www.google.com" }, - { USER_LEVEL_NONE } + "http://www.google.com" }, { NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, /* Proxy defaults */ { NAUTILUS_PREFERENCES_HTTP_USE_PROXY, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (8080) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (8080) }, { NAUTILUS_PREFERENCES_HTTP_PROXY_USE_AUTH, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, /* Home URI */ { NAUTILUS_PREFERENCES_HOME_URI, PREFERENCE_STRING, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, NULL, default_home_location_callback, g_free }, - { EEL_USER_LEVEL_INTERMEDIATE, NULL, default_home_location_callback, g_free }, + NULL, default_home_location_callback, g_free }, /* Default fonts */ { NAUTILUS_PREFERENCES_DEFAULT_FONT, PREFERENCE_STRING, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, NULL, default_font_callback, g_free }, - { USER_LEVEL_NONE } + NULL, default_font_callback, g_free }, { NAUTILUS_PREFERENCES_DEFAULT_FONT_SIZE, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (12) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (12), + NULL, NULL, "standard_font_size" }, /* View Preferences */ { NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, NULL, default_default_folder_viewer_callback, NULL }, - { USER_LEVEL_NONE }, + NULL, default_default_folder_viewer_callback, NULL, "default_folder_viewer" }, /* Icon View Default Preferences */ + { NAUTILUS_PREFERENCES_ICON_VIEW_FONT, PREFERENCE_STRING, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, NULL, default_font_callback, g_free }, - { USER_LEVEL_NONE } + NULL, default_font_callback, g_free }, { NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL_FONT_SIZE, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (12) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (12), + NULL, NULL, "standard_font_size" }, { NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_FILE_SORT_BY_DISPLAY_NAME) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_FILE_SORT_BY_DISPLAY_NAME), + NULL, NULL, "default_icon_view_sort_order" }, { NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_FILE_SORT_BY_DISPLAY_NAME) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_FILE_SORT_BY_DISPLAY_NAME), + NULL, NULL, "default_icon_view_sort_order" }, { NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_ZOOM_LEVEL_STANDARD) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_ZOOM_LEVEL_STANDARD), + NULL, NULL, "default_zoom_level" }, /* List View Default Preferences */ { NAUTILUS_PREFERENCES_LIST_VIEW_FONT, PREFERENCE_STRING, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, NULL, default_font_callback, g_free }, - { USER_LEVEL_NONE } + NULL, default_font_callback, g_free }, { NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL_FONT_SIZE, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (12) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (12), + NULL, NULL, "standard_font_size" }, { NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_FILE_SORT_BY_DISPLAY_NAME) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_FILE_SORT_BY_DISPLAY_NAME), + NULL, NULL, "default_list_view_sort_order" }, { NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (FALSE) }, { NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_ZOOM_LEVEL_SMALLER) }, - { USER_LEVEL_NONE }, + GINT_TO_POINTER (NAUTILUS_ZOOM_LEVEL_SMALLER), + NULL, NULL, "default_zoom_level" }, /* Sidebar panel default */ { nautilus_sidebar_news_enabled_preference_name, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { nautilus_sidebar_notes_enabled_preference_name, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { nautilus_sidebar_history_enabled_preference_name, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { nautilus_sidebar_tree_enabled_preference_name, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_INTERMEDIATE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, - { EEL_USER_LEVEL_INTERMEDIATE, GINT_TO_POINTER (TRUE) } + GINT_TO_POINTER (FALSE) }, /* news panel preferences */ { NAUTILUS_PREFERENCES_NEWS_MAX_ITEMS, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (6) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (6) }, { NAUTILUS_PREFERENCES_NEWS_UPDATE_INTERVAL, PREFERENCE_INTEGER, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (5) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (5) }, /* non-visible preferences */ { NAUTILUS_PREFERENCES_ADD_TO_SESSION, PREFERENCE_BOOLEAN, - EEL_USER_LEVEL_NOVICE, - { EEL_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, - { USER_LEVEL_NONE } + GINT_TO_POINTER (TRUE) }, { NULL } @@ -732,53 +601,46 @@ global_preferences_register_enumerations (void) static void global_preferences_install_one_default (const char *preference_name, PreferenceType preference_type, - const PreferenceUserLevelDefault *user_level_default) + const PreferenceDefault *preference_default) { gpointer value = NULL; EelStringList *string_list_value; - + g_return_if_fail (preference_name != NULL); g_return_if_fail (preference_type >= PREFERENCE_BOOLEAN); g_return_if_fail (preference_type <= PREFERENCE_STRING_LIST); - g_return_if_fail (user_level_default != NULL); - - if (user_level_default->user_level == USER_LEVEL_NONE) { - return; - } + g_return_if_fail (preference_default != NULL); /* If a callback is given, use that to fetch the default value */ - if (user_level_default->callback != NULL) { - value = (* user_level_default->callback) (user_level_default->user_level); + if (preference_default->fallback_callback != NULL) { + value = (* preference_default->fallback_callback) (); } else { - value = user_level_default->value; + value = preference_default->fallback_value; } switch (preference_type) { case PREFERENCE_BOOLEAN: - eel_preferences_default_set_boolean (preference_name, - user_level_default->user_level, - GPOINTER_TO_INT (value)); + eel_preferences_set_emergency_fallback_boolean (preference_name, + GPOINTER_TO_INT (value)); break; case PREFERENCE_INTEGER: - eel_preferences_default_set_integer (preference_name, - user_level_default->user_level, - GPOINTER_TO_INT (value)); + eel_preferences_set_emergency_fallback_integer (preference_name, + + GPOINTER_TO_INT (value)); break; case PREFERENCE_STRING: - eel_preferences_default_set_string (preference_name, - user_level_default->user_level, - value); + eel_preferences_set_emergency_fallback_string (preference_name, + value); break; case PREFERENCE_STRING_LIST: string_list_value = eel_string_list_new_from_tokens (value, STRING_LIST_DEFAULT_TOKENS_DELIMETER, TRUE); - eel_preferences_default_set_string_list (preference_name, - user_level_default->user_level, - string_list_value); + eel_preferences_set_emergency_fallback_string_list (preference_name, + string_list_value); eel_string_list_free (string_list_value); break; @@ -787,9 +649,9 @@ global_preferences_install_one_default (const char *preference_name, } /* Free the dynamic default value if needed */ - if (user_level_default->callback != NULL - && user_level_default->callback_result_free_function != NULL) { - (* user_level_default->callback_result_free_function) (value); + if (preference_default->fallback_callback != NULL + && preference_default->fallback_callback_result_free_function != NULL) { + (* preference_default->fallback_callback_result_free_function) (value); } } @@ -811,22 +673,13 @@ global_preferences_install_defaults (void) for (i = 0; preference_defaults[i].name != NULL; i++) { global_preferences_install_one_default (preference_defaults[i].name, preference_defaults[i].type, - &preference_defaults[i].default1); - - global_preferences_install_one_default (preference_defaults[i].name, - preference_defaults[i].type, - &preference_defaults[i].default2); - - eel_preferences_set_visible_user_level (preference_defaults[i].name, - preference_defaults[i].visible_user_level); + &preference_defaults[i]); } } static gpointer -default_font_callback (int user_level) +default_font_callback (void) { - g_return_val_if_fail (eel_preferences_user_level_is_valid (user_level), NULL); - if (eel_dumb_down_for_multi_byte_locale_hack ()) { return g_strdup ("fixed"); } @@ -849,7 +702,7 @@ get_default_folder_viewer_preference_from_iid (const char *iid) } static gpointer -default_default_folder_viewer_callback (int user_level) +default_default_folder_viewer_callback (void) { Bonobo_ServerInfo *bonobo_activation_info; int result; @@ -869,9 +722,8 @@ default_default_folder_viewer_callback (int user_level) } static gpointer -default_home_location_callback (int user_level) +default_home_location_callback (void) { - g_return_val_if_fail (eel_preferences_user_level_is_valid (user_level), NULL); return gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); } @@ -985,8 +837,8 @@ nautilus_global_preferences_init (void) /* Install defaults */ global_preferences_install_defaults (); - global_preferences_register_enumerations (); - + global_preferences_register_enumerations (); + /* Add the gnome-vfs path to the list of monitored directories - for proxy settings */ eel_preferences_monitor_directory (SYSTEM_GNOME_VFS_PATH); @@ -1007,4 +859,9 @@ nautilus_global_preferences_init (void) * widget machinery. */ smooth_graphics_mode_changed_callback (NULL); + + /* Preload everything in a big batch */ + eel_gconf_preload_cache ("/apps/nautilus/preferences", + GCONF_CLIENT_PRELOAD_ONELEVEL); } + diff --git a/libnautilus-private/nautilus.schemas b/libnautilus-private/nautilus.schemas new file mode 100644 index 000000000..4b898286f --- /dev/null +++ b/libnautilus-private/nautilus.schemas @@ -0,0 +1,242 @@ + + + + + + + + + /schemas/apps/nautilus/preferences/show_hidden_files + /apps/nautilus/preferences/show_hidden_files + nautilus + bool + false + + Whether to show dotfiles + + If set to true, then hidden files (dotfiles) are shown in + the file manager. + + + + + + /schemas/apps/nautilus/preferences/show_backup_files + /apps/nautilus/preferences/show_backup_files + nautilus + bool + false + + Whether to show backup files + + If set to true, then backup files such as those created + by Emacs are displayed. Currently, only files ending in + a tilde (~) are considered backup files. + + + + + + /schemas/apps/nautilus/preferences/confirm_trash + /apps/nautilus/preferences/confirm_trash + nautilus + bool + true + + Whether to ask for confirmation when moving files to trash + + If set to true, then Nautilus will ask for confirmation when + you attempt to put files in the trash. + + + + + + /schemas/apps/nautilus/preferences/enable_delete + /apps/nautilus/preferences/enable_delete + nautilus + bool + false + + Whether to enable immediate deletion + + If set to true, then Nautilus will have a feature allowing + you to delete a file immediately and in-place, instead of moving it + to the trash. This feature can be dangerous, so use caution. + + + + + + /schemas/apps/nautilus/preferences/show_icon_text + /apps/nautilus/preferences/show_icon_text + nautilus + string + local_only + + When to show preview text in icons + + Speed tradeoff for when to show a preview of text file contents + in the file's icon. + If set to "always" then always show previews, + even if the directory is on a remote server. + If set to "local_only" then only show previews for local filesystems. + If set to "never" then never bother to read preview data. + + + + + + /schemas/apps/nautilus/preferences/show_directory_item_counts + /apps/nautilus/preferences/show_directory_item_counts + nautilus + string + local_only + + When to show number of items in a directory + + Speed tradeoff for when to show the number of items in a + directory. If set to "always" then always show item counts, + even if the directory is on a remote server. + If set to "local_only" then only show counts for local filesystems. + If set to "never" then never bother to compute item counts. + + + + + + /schemas/apps/nautilus/preferences/click_policy + /apps/nautilus/preferences/click_policy + nautilus + string + double + + Type of click used to launch/open files + + Possible values are "single" to launch files on a single click, + or "double" to launch them on a double click. + + + + + + /schemas/apps/nautilus/preferences/executable_text_activation + /apps/nautilus/preferences/executable_text_activation + nautilus + string + ask + + What to do with executable text files when activated + + What to do with executable text files when they are activated + (single or double clicked). + Possible values are "launch" to launch them as programs, + "ask" to ask what to do via a dialog, and "display" to display + them as text files. + + + + + + /schemas/apps/nautilus/preferences/theme + /apps/nautilus/preferences/theme + nautilus + string + default + + Current Nautilus theme + + Name of the Nautilus theme to use. + + + + + + /schemas/apps/nautilus/preferences/show_image_thumbnails + /apps/nautilus/preferences/show_image_thumbnails + nautilus + string + local_only + + When to show thumbnails of image files + + Speed tradeoff for when to show a image files as a thumbnail. + If set to "always" then always thumbnail, + even if the directory is on a remote server. + If set to "local_only" then only show thumbnails for local filesystems. + If set to "never" then never bother to thumbnail images, + just use a generic icon. + + + + + + /schemas/apps/nautilus/preferences/thumbnail_limit + /apps/nautilus/preferences/thumbnail_limit + nautilus + int + 3145728 + + Maximum image size for thumbnailing + + Images over this size (in bytes) won't be + thumbnailed. The purpose of this setting is to + avoid thumbnailing large images that may + take a long time to load or use lots of memory. + + + + + + + /schemas/apps/nautilus/preferences/use_public_metadata + /apps/nautilus/preferences/use_public_metadata + nautilus + string + local_only + + Whether to store metadata in each directory, or in a single global location + + Nautilus records information about each directory you visit, such + as its background color, emblems, zoom level, and so on. + This information can be stored in one location in your home + directory, or it can be stored in each directory in hidden files. + The advantages of storing per-directory are that it's more robust + (can't be deleted in one go) and that for folders used by + multiple users, the metadata will be shared. So for example + all users can see emblems applied to files. + + If this setting is "local_only", for local filesystems metadata + will be stored per-directory, and for remote connections + it will be stored in the user's home directory. If it's "never" + then all metadata will go in the user's home directory; if it's + "always" then all metadata will go in the directory being described. + (However, for read-only directories, metadata always goes in the + user's home directory.) + + + + + + /schemas/apps/nautilus/preferences/smooth_graphics_mode + /apps/nautilus/preferences/smooth_graphics_mode + nautilus + bool + true + + Whether to use smooth (antialiased) graphics + + If toggled on, smooth out jagged graphics, possibly + using more resources. + + + + + + + + + + + diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c index d2a6b6c14..b5e7fa8f8 100644 --- a/src/nautilus-navigation-window-menus.c +++ b/src/nautilus-navigation-window-menus.c @@ -119,13 +119,6 @@ static void schedule_refresh_bookmarks_menu (Naut static void edit_bookmarks (NautilusWindow *window); static void add_bookmark_for_current_location (NautilusWindow *window); -/* User level things */ -static guint convert_verb_to_user_level (const char *verb); -static const char * convert_user_level_to_path (guint user_level); -static void switch_to_user_level (NautilusWindow *window, - int new_user_level); - - #define NAUTILUS_MENU_PATH_NOVICE_ITEM "/menu/Preferences/User Levels Placeholder/Switch to Beginner Level" #define NAUTILUS_MENU_PATH_INTERMEDIATE_ITEM "/menu/Preferences/User Levels Placeholder/Switch to Intermediate Level" #define NAUTILUS_MENU_PATH_EXPERT_ITEM "/menu/Preferences/User Levels Placeholder/Switch to Advanced Level" @@ -694,89 +687,6 @@ help_menu_nautilus_feedback_callback (BonoboUIComponent *component, CUSTOMER_FEEDBACK_URI); } -/* utility routine to return an image corresponding to the passed-in user level */ - -static char * -get_user_level_icon_name (int user_level, gboolean is_selected) -{ - const char *image_name; - char *full_image_name; - - switch (user_level) { - case EEL_USER_LEVEL_NOVICE: - image_name = "novice"; - break; - case EEL_USER_LEVEL_ADVANCED: - image_name = "expert"; - break; - case EEL_USER_LEVEL_INTERMEDIATE: - default: - image_name = "intermediate"; - break; - } - - if (is_selected) { - full_image_name = g_strdup_printf ("nautilus/%s-selected.png", image_name); - } else { - full_image_name = g_strdup_printf ("nautilus/%s.png", image_name); - } - - return full_image_name; -} - -/* handle user level changes */ -static void -switch_to_user_level (NautilusWindow *window, int new_user_level) -{ - char *old_user_level_icon_name; - int old_user_level; - char *new_user_level_icon_name_selected; - - if (window->details->shell_ui == NULL) { - return; - } - - old_user_level = eel_preferences_get_user_level (); - if (new_user_level == old_user_level) { - return; - } - - eel_preferences_set_user_level (new_user_level); - - nautilus_window_ui_freeze (window); - - bonobo_ui_component_freeze (window->details->shell_ui, NULL); - - /* change the item icons to reflect the new user level */ - old_user_level_icon_name = get_user_level_icon_name (old_user_level, FALSE); - nautilus_bonobo_set_icon (window->details->shell_ui, - convert_user_level_to_path (old_user_level), - old_user_level_icon_name); - g_free (old_user_level_icon_name); - - new_user_level_icon_name_selected = get_user_level_icon_name (new_user_level, TRUE); - nautilus_bonobo_set_icon (window->details->shell_ui, - convert_user_level_to_path (new_user_level), - new_user_level_icon_name_selected); - g_free (new_user_level_icon_name_selected); - - bonobo_ui_component_thaw (window->details->shell_ui, NULL); - - nautilus_window_ui_thaw (window); -} - -static void -user_level_menu_item_callback (BonoboUIComponent *component, - gpointer user_data, - const char *verb) -{ - NautilusWindow *window; - - window = NAUTILUS_WINDOW (user_data); - - switch_to_user_level (window, convert_verb_to_user_level (verb)); -} - static void remove_bookmarks_for_uri_if_yes (GtkDialog *dialog, int response, gpointer callback_data) { @@ -1203,54 +1113,6 @@ nautilus_window_initialize_go_menu (NautilusWindow *window) GTK_OBJECT (window)); } -static void -update_user_level_menu_item (NautilusWindow *window, - const char *menu_path, - guint item_user_level) -{ - - guint current_user_level; - char *icon_name; - - if (window->details->shell_ui == NULL) { - return; - } - - current_user_level = eel_preferences_get_user_level (); - - icon_name = get_user_level_icon_name (item_user_level, current_user_level == item_user_level); - - nautilus_window_ui_freeze (window); - - nautilus_bonobo_set_icon (window->details->shell_ui, - menu_path, - icon_name); - - g_free (icon_name); - - nautilus_window_ui_thaw (window); -} - -static void -user_level_changed_callback (gpointer callback_data) -{ - NautilusWindow *window; - - g_return_if_fail (NAUTILUS_IS_WINDOW (callback_data)); - - window = NAUTILUS_WINDOW (callback_data); - - update_user_level_menu_item (window, - NAUTILUS_MENU_PATH_NOVICE_ITEM, - EEL_USER_LEVEL_NOVICE); - update_user_level_menu_item (window, - NAUTILUS_MENU_PATH_INTERMEDIATE_ITEM, - EEL_USER_LEVEL_INTERMEDIATE); - update_user_level_menu_item (window, - NAUTILUS_MENU_PATH_EXPERT_ITEM, - EEL_USER_LEVEL_ADVANCED); -} - /** * nautilus_window_initialize_menus * @@ -1302,12 +1164,7 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window) BONOBO_UI_VERB ("Nautilus Quick Reference", help_menu_nautilus_quick_reference_callback), BONOBO_UI_VERB ("Nautilus Release Notes", help_menu_nautilus_release_notes_callback), BONOBO_UI_VERB ("Nautilus Feedback", help_menu_nautilus_feedback_callback), - - BONOBO_UI_VERB ("Switch to Beginner Level", user_level_menu_item_callback), - BONOBO_UI_VERB ("Switch to Intermediate Level", user_level_menu_item_callback), - BONOBO_UI_VERB ("Switch to Advanced Level", user_level_menu_item_callback), BONOBO_UI_VERB ("User Level Customization", user_level_customize_callback), - BONOBO_UI_VERB ("Stop", stop_button_callback), BONOBO_UI_VERB_END @@ -1321,14 +1178,6 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window) nautilus_window_update_show_hide_menu_items (window); - /* Keep track of user level changes to update the user level menu item icons */ - eel_preferences_add_callback_while_alive ("user_level", - user_level_changed_callback, - window, - G_OBJECT (window)); - /* Update the user level menu items for the first time */ - user_level_changed_callback (window); - /* Register to catch Bonobo UI events so we can notice View As changes */ g_signal_connect (window->details->shell_ui, "ui_event", G_CALLBACK (nautilus_window_handle_ui_event_callback), window); @@ -1520,35 +1369,3 @@ schedule_refresh_go_menu (NautilusWindow *window) } -static guint -convert_verb_to_user_level (const char *verb) -{ - g_assert (verb != NULL); - - if (strcmp (verb, SWITCH_TO_BEGINNER_VERB) == 0) { - return EEL_USER_LEVEL_NOVICE; - } else if (strcmp (verb, SWITCH_TO_INTERMEDIATE_VERB) == 0) { - return EEL_USER_LEVEL_INTERMEDIATE; - } else if (strcmp (verb, SWITCH_TO_ADVANCED_VERB) == 0) { - return EEL_USER_LEVEL_ADVANCED; - } - - g_assert_not_reached (); - return EEL_USER_LEVEL_NOVICE; -} - -static const char * -convert_user_level_to_path (guint user_level) -{ - switch (user_level) { - case EEL_USER_LEVEL_NOVICE: - return NAUTILUS_MENU_PATH_NOVICE_ITEM; - case EEL_USER_LEVEL_INTERMEDIATE: - return NAUTILUS_MENU_PATH_INTERMEDIATE_ITEM; - case EEL_USER_LEVEL_ADVANCED: - return NAUTILUS_MENU_PATH_EXPERT_ITEM; - } - - g_assert_not_reached (); - return NAUTILUS_MENU_PATH_NOVICE_ITEM; -} diff --git a/src/nautilus-shell-ui.xml b/src/nautilus-shell-ui.xml index fc5074182..f926bf39d 100644 --- a/src/nautilus-shell-ui.xml +++ b/src/nautilus-shell-ui.xml @@ -124,6 +124,11 @@ + + - - - - - - - - - - - details->shell_ui == NULL) { - return; - } - - old_user_level = eel_preferences_get_user_level (); - if (new_user_level == old_user_level) { - return; - } - - eel_preferences_set_user_level (new_user_level); - - nautilus_window_ui_freeze (window); - - bonobo_ui_component_freeze (window->details->shell_ui, NULL); - - /* change the item icons to reflect the new user level */ - old_user_level_icon_name = get_user_level_icon_name (old_user_level, FALSE); - nautilus_bonobo_set_icon (window->details->shell_ui, - convert_user_level_to_path (old_user_level), - old_user_level_icon_name); - g_free (old_user_level_icon_name); - - new_user_level_icon_name_selected = get_user_level_icon_name (new_user_level, TRUE); - nautilus_bonobo_set_icon (window->details->shell_ui, - convert_user_level_to_path (new_user_level), - new_user_level_icon_name_selected); - g_free (new_user_level_icon_name_selected); - - bonobo_ui_component_thaw (window->details->shell_ui, NULL); - - nautilus_window_ui_thaw (window); -} - -static void -user_level_menu_item_callback (BonoboUIComponent *component, - gpointer user_data, - const char *verb) -{ - NautilusWindow *window; - - window = NAUTILUS_WINDOW (user_data); - - switch_to_user_level (window, convert_verb_to_user_level (verb)); -} - static void remove_bookmarks_for_uri_if_yes (GtkDialog *dialog, int response, gpointer callback_data) { @@ -1203,54 +1113,6 @@ nautilus_window_initialize_go_menu (NautilusWindow *window) GTK_OBJECT (window)); } -static void -update_user_level_menu_item (NautilusWindow *window, - const char *menu_path, - guint item_user_level) -{ - - guint current_user_level; - char *icon_name; - - if (window->details->shell_ui == NULL) { - return; - } - - current_user_level = eel_preferences_get_user_level (); - - icon_name = get_user_level_icon_name (item_user_level, current_user_level == item_user_level); - - nautilus_window_ui_freeze (window); - - nautilus_bonobo_set_icon (window->details->shell_ui, - menu_path, - icon_name); - - g_free (icon_name); - - nautilus_window_ui_thaw (window); -} - -static void -user_level_changed_callback (gpointer callback_data) -{ - NautilusWindow *window; - - g_return_if_fail (NAUTILUS_IS_WINDOW (callback_data)); - - window = NAUTILUS_WINDOW (callback_data); - - update_user_level_menu_item (window, - NAUTILUS_MENU_PATH_NOVICE_ITEM, - EEL_USER_LEVEL_NOVICE); - update_user_level_menu_item (window, - NAUTILUS_MENU_PATH_INTERMEDIATE_ITEM, - EEL_USER_LEVEL_INTERMEDIATE); - update_user_level_menu_item (window, - NAUTILUS_MENU_PATH_EXPERT_ITEM, - EEL_USER_LEVEL_ADVANCED); -} - /** * nautilus_window_initialize_menus * @@ -1302,12 +1164,7 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window) BONOBO_UI_VERB ("Nautilus Quick Reference", help_menu_nautilus_quick_reference_callback), BONOBO_UI_VERB ("Nautilus Release Notes", help_menu_nautilus_release_notes_callback), BONOBO_UI_VERB ("Nautilus Feedback", help_menu_nautilus_feedback_callback), - - BONOBO_UI_VERB ("Switch to Beginner Level", user_level_menu_item_callback), - BONOBO_UI_VERB ("Switch to Intermediate Level", user_level_menu_item_callback), - BONOBO_UI_VERB ("Switch to Advanced Level", user_level_menu_item_callback), BONOBO_UI_VERB ("User Level Customization", user_level_customize_callback), - BONOBO_UI_VERB ("Stop", stop_button_callback), BONOBO_UI_VERB_END @@ -1321,14 +1178,6 @@ nautilus_window_initialize_menus_part_1 (NautilusWindow *window) nautilus_window_update_show_hide_menu_items (window); - /* Keep track of user level changes to update the user level menu item icons */ - eel_preferences_add_callback_while_alive ("user_level", - user_level_changed_callback, - window, - G_OBJECT (window)); - /* Update the user level menu items for the first time */ - user_level_changed_callback (window); - /* Register to catch Bonobo UI events so we can notice View As changes */ g_signal_connect (window->details->shell_ui, "ui_event", G_CALLBACK (nautilus_window_handle_ui_event_callback), window); @@ -1520,35 +1369,3 @@ schedule_refresh_go_menu (NautilusWindow *window) } -static guint -convert_verb_to_user_level (const char *verb) -{ - g_assert (verb != NULL); - - if (strcmp (verb, SWITCH_TO_BEGINNER_VERB) == 0) { - return EEL_USER_LEVEL_NOVICE; - } else if (strcmp (verb, SWITCH_TO_INTERMEDIATE_VERB) == 0) { - return EEL_USER_LEVEL_INTERMEDIATE; - } else if (strcmp (verb, SWITCH_TO_ADVANCED_VERB) == 0) { - return EEL_USER_LEVEL_ADVANCED; - } - - g_assert_not_reached (); - return EEL_USER_LEVEL_NOVICE; -} - -static const char * -convert_user_level_to_path (guint user_level) -{ - switch (user_level) { - case EEL_USER_LEVEL_NOVICE: - return NAUTILUS_MENU_PATH_NOVICE_ITEM; - case EEL_USER_LEVEL_INTERMEDIATE: - return NAUTILUS_MENU_PATH_INTERMEDIATE_ITEM; - case EEL_USER_LEVEL_ADVANCED: - return NAUTILUS_MENU_PATH_EXPERT_ITEM; - } - - g_assert_not_reached (); - return NAUTILUS_MENU_PATH_NOVICE_ITEM; -} diff --git a/test/test-nautilus-preferences-change.c b/test/test-nautilus-preferences-change.c index acbf8030b..4d968bd95 100644 --- a/test/test-nautilus-preferences-change.c +++ b/test/test-nautilus-preferences-change.c @@ -6,39 +6,6 @@ #include #include -static void -user_level_changed_callback (gpointer callback_data) -{ - char *name; - int user_level; - int visible_user_level; - - g_return_if_fail (EEL_IS_STRING_PICKER (callback_data)); - - - name = eel_caption_get_title_label (EEL_CAPTION (callback_data)); - - user_level = eel_preferences_get_user_level (); - visible_user_level = eel_preferences_get_visible_user_level (name); - - if (visible_user_level <= user_level) { - gtk_widget_show (GTK_WIDGET (callback_data)); - } else { - gtk_widget_hide (GTK_WIDGET (callback_data)); - } - -#if 0 - g_print ("%s(data=%s) user_level = %d, visible_user_level = %d, action = %s\n", - __FUNCTION__, - name, - user_level, - visible_user_level, - (visible_user_level <= user_level) ? "show" : "hide"); -#endif - - g_free (name); -} - static void fruits_changed_callback (gpointer callback_data) { @@ -64,25 +31,6 @@ int_picker_changed_callback (EelStringPicker *string_picker, g_free (selected_string); } -static void -user_level_picker_changed_callback (EelStringPicker *string_picker, - gpointer callback_data) -{ - char *selected_string; - int new_user_level; - - g_return_if_fail (EEL_IS_STRING_PICKER (string_picker)); - g_return_if_fail (callback_data != NULL); - - selected_string = eel_string_picker_get_selected_string (string_picker); - - new_user_level = eel_string_picker_get_index_for_string (string_picker, selected_string); - - eel_preferences_set_user_level (new_user_level); - - g_free (selected_string); -} - static GtkWidget * picker_new (const char *name, const EelStringList *entries) @@ -100,33 +48,6 @@ picker_new (const char *name, eel_string_picker_set_string_list (EEL_STRING_PICKER (string_picker), entries); eel_string_picker_set_selected_string_index (EEL_STRING_PICKER (string_picker), eel_preferences_get_integer (name)); - - eel_preferences_add_callback ("user_level", user_level_changed_callback, string_picker); - user_level_changed_callback (string_picker); - - return string_picker; -} - -static GtkWidget * -user_level_picker_new (const char *name, - const EelStringList *entries) -{ - GtkWidget *string_picker; - - g_return_val_if_fail (name != NULL, NULL); - g_return_val_if_fail (entries != NULL, NULL); - - string_picker = eel_string_picker_new (); - eel_caption_set_title_label (EEL_CAPTION (string_picker), name); - g_signal_connect (string_picker, "changed", G_CALLBACK (user_level_picker_changed_callback), - (gpointer) name); - - eel_string_picker_set_string_list (EEL_STRING_PICKER (string_picker), entries); - eel_string_picker_set_selected_string_index (EEL_STRING_PICKER (string_picker), - eel_preferences_get_user_level ()); - - eel_preferences_add_callback ("user_level", user_level_changed_callback, string_picker); - user_level_changed_callback (string_picker); return string_picker; } @@ -135,8 +56,6 @@ int main (int argc, char *argv[]) { GtkWidget *window; - - GtkWidget *user_level_picker; GtkWidget *green_picker; GtkWidget *yellow_picker; GtkWidget *red_picker; @@ -157,36 +76,16 @@ main (int argc, char *argv[]) user_level_entries = eel_string_list_new_from_tokens ("Beginner,Intermediate,Advanced", ",", TRUE); color_entries = eel_string_list_new_from_tokens ("0,1,2,3,4,5,6,7,8,9,10", ",", TRUE); fruits_entries = eel_string_list_new_from_tokens ("0,1,2,3", ",", TRUE); - - eel_preferences_default_set_string ("user_level", - EEL_USER_LEVEL_NOVICE, - "advanced"); - eel_preferences_default_set_integer ("green", - EEL_USER_LEVEL_NOVICE, - 3); + eel_preferences_set_emergency_fallback_integer ("green", 3); - eel_preferences_default_set_integer ("yellow", - EEL_USER_LEVEL_NOVICE, - 9); + eel_preferences_set_emergency_fallback_integer ("yellow", 9); - eel_preferences_default_set_integer ("red", - EEL_USER_LEVEL_NOVICE, - 7); + eel_preferences_set_emergency_fallback_integer ("red", 7); - eel_preferences_default_set_integer ("fruits/apple", - EEL_USER_LEVEL_NOVICE, - 1); - eel_preferences_default_set_integer ("fruits/orange", - EEL_USER_LEVEL_NOVICE, - 2); - eel_preferences_default_set_integer ("fruits/pear", - EEL_USER_LEVEL_NOVICE, - 3); - - eel_preferences_set_visible_user_level ("yellow", 1); - eel_preferences_set_visible_user_level ("green", 0); - eel_preferences_set_visible_user_level ("red", 2); + eel_preferences_set_emergency_fallback_integer ("fruits/apple", 1); + eel_preferences_set_emergency_fallback_integer ("fruits/orange", 2); + eel_preferences_set_emergency_fallback_integer ("fruits/pear", 3); //sleep (10); @@ -195,16 +94,14 @@ main (int argc, char *argv[]) vbox = gtk_vbox_new (FALSE, 2); gtk_container_add (GTK_CONTAINER (window), vbox); - - user_level_picker = user_level_picker_new ("user_level", user_level_entries); + green_picker = picker_new ("green", color_entries); yellow_picker = picker_new ("yellow", color_entries); red_picker = picker_new ("red", color_entries); fruits_apple_picker = picker_new ("fruits/apple", fruits_entries); fruits_orange_picker = picker_new ("fruits/orange", fruits_entries); fruits_pear_picker = picker_new ("fruits/pear", fruits_entries); - - gtk_box_pack_start (GTK_BOX (vbox), user_level_picker, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), green_picker, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), yellow_picker, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), red_picker, FALSE, FALSE, 0); @@ -218,12 +115,7 @@ main (int argc, char *argv[]) eel_preferences_add_callback ("fruits", fruits_changed_callback, NULL); - gtk_widget_show (vbox); - gtk_widget_show (window); - -// user_level_changed_callback (green_picker); -// user_level_changed_callback (yellow_picker); -// user_level_changed_callback (red_picker); + gtk_widget_show_all (window); gtk_main (); diff --git a/test/test-nautilus-preferences-display.c b/test/test-nautilus-preferences-display.c index bd3442186..ae4a0f311 100644 --- a/test/test-nautilus-preferences-display.c +++ b/test/test-nautilus-preferences-display.c @@ -20,33 +20,6 @@ text_caption_update (EelTextCaption *text_caption, test_text_caption_set_text_for_int_preferences (text_caption, name); } -static void -user_level_caption_update (EelTextCaption *text_caption) -{ - char *old_text; - char *new_text; - - g_return_if_fail (EEL_IS_TEXT_CAPTION (text_caption)); - - old_text = eel_text_caption_get_text (text_caption); - new_text = eel_preferences_get ("user_level"); - - g_print ("'%s' changed from '%s' to '%s'\n", - "user_level", - old_text, new_text); - - g_free (old_text); - g_free (new_text); - - test_text_caption_set_text_for_string_preferences (text_caption, "user_level"); -} - -static void -user_level_changed_callback (gpointer callback_data) -{ - user_level_caption_update (EEL_TEXT_CAPTION (callback_data)); -} - static void green_changed_callback (gpointer callback_data) { @@ -113,28 +86,6 @@ entry_new (const char *name, return hbox; } -static GtkWidget * -user_level_frame_new (void) -{ - GtkWidget *user_level_caption; - GtkWidget *user_level_default_caption; - GtkWidget *user_level_hbox; - GtkWidget *frame; - - frame = gtk_frame_new ("user_level"); - - user_level_hbox = entry_new ("user_level", &user_level_caption, &user_level_default_caption); - test_text_caption_set_text_for_string_preferences (EEL_TEXT_CAPTION (user_level_caption), "user_level"); - test_text_caption_set_text_for_default_string_preferences (EEL_TEXT_CAPTION (user_level_default_caption), "user_level"); - eel_preferences_add_callback ("user_level", user_level_changed_callback, user_level_caption); - - gtk_container_add (GTK_CONTAINER (frame), user_level_hbox); - - gtk_widget_show_all (frame); - - return frame; -} - static GtkWidget * colors_frame_new (void) { @@ -237,7 +188,6 @@ main (int argc, char *argv[]) GtkWidget *window; GtkWidget *vbox; - GtkWidget *user_level_frame; GtkWidget *colors_frame; GtkWidget *fruits_frame; @@ -251,11 +201,9 @@ main (int argc, char *argv[]) vbox = gtk_vbox_new (FALSE, 2); gtk_container_add (GTK_CONTAINER (window), vbox); - user_level_frame = user_level_frame_new (); colors_frame = colors_frame_new (); fruits_frame = fruits_frame_new (); - gtk_box_pack_start (GTK_BOX (vbox), user_level_frame, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), colors_frame, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), fruits_frame, TRUE, TRUE, 0); diff --git a/test/test.c b/test/test.c index d2e085f17..f7efdf7ec 100644 --- a/test/test.c +++ b/test/test.c @@ -46,11 +46,10 @@ test_window_new (const char *title, guint border_width) } g_signal_connect (window, - "delete_event", - G_CALLBACK (test_delete_event), - NULL); + "delete_event", + G_CALLBACK (test_delete_event), + NULL); - gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE); gtk_container_set_border_width (GTK_CONTAINER (window), border_width); return window;