mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-24 18:25:50 +00:00
reviewed by: Pavel Cisler <pavel@eazel.com>
Lots of bug fixes: 2848 - User level agnostic config settings have nowhere to live. 2654 - Need default values even for non user level preferences. 3414 - Show more preferences at higher user levels. 3415 - Make preference the same for all levels at which it is not visible 3416 - Make preference changes affect all levels at which they are visible 4357 - Web search URL setting should be reset upon Nautilus update 5160 - Tree view doesnt exist when starting nautilus as a beginner 5234 - Sidebar panel preferences are not properly separated among user levels * components/mozilla/mozilla-preferences.cpp: Update for gnome vfs proxy changes. Proxy host and port are now stored in separate gconf settings. * libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-enumeration.h: * libnautilus-extensions/nautilus-enumeration.c: (nautilus_enumeration_new), (nautilus_enumeration_free), (nautilus_enumeration_insert), (nautilus_enumeration_get_nth_entry), (nautilus_enumeration_get_nth_description), (nautilus_enumeration_get_nth_value), (nautilus_enumeration_get_num_entries), (nautilus_self_check_enumeration): New files. An enumeration data structure. * components/tree/nautilus-tree-expansion-state.c: No longer need to give the full path to a gconf setting. * components/tree/nautilus-tree-view.c: (filtering_changed_callback), (nautilus_tree_view_initialize): * libnautilus-extensions/nautilus-directory-async.c: (can_use_public_metafile), (get_filter_options_for_directory_count): * libnautilus-extensions/nautilus-file-operations.c: (confirm_empty_trash): * libnautilus-extensions/nautilus-file.c: (nautilus_file_should_get_top_left_text): * libnautilus-extensions/nautilus-font-factory.c: (nautilus_font_factory_get_font_from_preferences): Update for preferences api changes. * libnautilus-extensions/nautilus-gconf-extensions.h: * libnautilus-extensions/nautilus-gconf-extensions.c: (global_client_free), (nautilus_gconf_client_get_global), (nautilus_gconf_handle_error), (nautilus_gconf_set_boolean), (nautilus_gconf_get_boolean), (nautilus_gconf_set_int), (nautilus_gconf_get_int), (nautilus_gconf_set_string), (nautilus_gconf_get_string), (nautilus_gconf_set_string_list), (nautilus_gconf_get_string_list), (nautilus_gconf_is_default), (nautilus_gconf_monitor_directory): New files. Useful gconf extensions; make peeking and poking settings a little easier. * libnautilus-extensions/nautilus-icon-container.c: (button_press_event): * libnautilus-extensions/nautilus-icon-canvas-item.c: (in_single_click_mode): Update for preferences api changes. * libnautilus-extensions/nautilus-icon-factory.c: (icon_theme_changed_callback), (should_display_image_file_as_itself): Update for preferences api changes. Also no longer need to define a default theme. * libnautilus-extensions/nautilus-lib-self-check-functions.h: Add entries for enumeration and preferences. Remove preference entry. Note plural vs not. * libnautilus-extensions/nautilus-preference.c: * libnautilus-extensions/nautilus-preference.h: Retire these 2. No longer use a GtkObject to store each preference. We simply use the string name instead. * libnautilus-extensions/nautilus-preferences-box.h: * libnautilus-extensions/nautilus-preferences-box.c: (nautilus_preferences_box_add_pane), (nautilus_preferences_box_update): New function. Should be called when user level changes so that the box updates its panes. * libnautilus-extensions/nautilus-preferences-dialog.h: * libnautilus-extensions/nautilus-preferences-dialog.c: (nautilus_preferences_dialog_initialize), (nautilus_preferences_dialog_destroy), (nautilus_preferences_dialog_get_prefs_box), (nautilus_preferences_dialog_update), (user_level_changed_callback): Keep track of user level changes. New function to update the dialog when user level changes. * libnautilus-extensions/nautilus-preferences-group.h: * libnautilus-extensions/nautilus-preferences-group.c: (nautilus_preferences_group_initialize), (nautilus_preferences_group_destroy), (nautilus_preferences_group_add_item): Collect the group's items in a list. Update to user a string to represent a preference instead of a GtkObject. (nautilus_preferences_group_update): New function. Updates the group's items to respect preferences visibility based on the user level. (nautilus_preferences_get_num_visible_items): New function. Return the number of currently visible items. Collect the group's items in a list. Update to user a string to represent a preference instead of a GtkObject. * libnautilus-extensions/nautilus-preferences-item.h: * libnautilus-extensions/nautilus-preferences-item.c: (preferences_item_construct), (preferences_item_create_enum), (preferences_item_create_short_enum), (preferences_item_create_boolean), (preferences_item_create_editable_string), (preferences_item_create_integer), (preferences_item_create_font_family), (preferences_item_create_theme), (enum_radio_group_changed_callback), (editable_string_changed_callback), (integer_changed_callback), (nautilus_preferences_item_get_name): New function to fetch the item's preference name. Add a new kind of preference - INTEGER. Update for string vs. GtkObject preferences representation changes. * libnautilus-extensions/nautilus-preferences-pane.h: * libnautilus-extensions/nautilus-preferences-pane.c: (nautilus_preferences_pane_update): New function. Updates the pane's groups to respect preferences visibility based on the user level. * libnautilus-extensions/nautilus-preferences.h: * libnautilus-extensions/nautilus-preferences.c: (preferences_get_path), (preferences_get_defaults_path), (preferences_get_visibility_path), (preferences_get_user_level_key), (preferences_preference_is_internal), (preferences_preference_is_user_level), (preferences_key_make), (preferences_key_make_for_default), (preferences_key_make_for_default_getter), (preferences_key_make_for_visibility), (preferences_global_client_remove_notification), (preferences_global_client_get), (preferences_preference_is_default), (preferences_make_user_level_filtered_key), (nautilus_preferences_get_visible_user_level), (nautilus_preferences_set_visible_user_level), (nautilus_preferences_set_boolean), (preferences_key_make_for_getter), (nautilus_preferences_get_boolean), (nautilus_preferences_set_int), (nautilus_preferences_get_int), (nautilus_preferences_set), (nautilus_preferences_get), (nautilus_preferences_set_string_list), (nautilus_preferences_get_string_list), (nautilus_preferences_get_user_level), (nautilus_preferences_set_user_level), (nautilus_preferences_default_set_int), (nautilus_preferences_default_get_int), (nautilus_preferences_default_set_boolean), (nautilus_preferences_default_get_boolean), (nautilus_preferences_default_set_string), (nautilus_preferences_default_get_string), (nautilus_preferences_default_set_string_list), (nautilus_preferences_default_get_string_list), (preferences_callback_entry_invoke_function), (preferences_something_changed_notice), (preferences_global_table_check_changes_function), (preferences_user_level_changed_notice), (preferences_entry_add_callback), (preferences_entry_remove_callback), (preferences_callback_entry_free), (preferences_callback_entry_free_func), (preferences_entry_free), (preferences_entry_free_func), (preferences_global_table_free), (preferences_global_table_get_global), (preferences_global_table_lookup), (preferences_global_table_insert), (preferences_global_table_lookup_or_insert), (nautilus_preferences_add_callback), (preferences_while_alive_disconnector), (nautilus_preferences_add_callback_while_alive), (nautilus_preferences_remove_callback), (nautilus_preferences_enumeration_insert), (nautilus_preferences_enumeration_get_nth_entry), (nautilus_preferences_enumeration_get_nth_description), (nautilus_preferences_enumeration_get_nth_value), (nautilus_preferences_enumeration_get_num_entries), (nautilus_preferences_set_description), (nautilus_preferences_get_description), (nautilus_preferences_get_user_level_name_for_display), (nautilus_preferences_get_user_level_name_for_storage), (preferences_user_level_check_range), (nautilus_preferences_monitor_directory), (nautilus_preferences_is_visible), (nautilus_self_check_preferences): Many changes. Redid to support the preferences system described in bugs 3414, 3415 and 3416. * libnautilus-extensions/nautilus-smooth-widget.c: (preferences_get_is_smooth): * libnautilus-extensions/nautilus-sound.c: (kill_sound_if_necessary), (nautilus_sound_initialize), (nautilus_sound_kill_sound), (nautilus_sound_register_sound), (nautilus_sound_can_play_sound): * libnautilus-extensions/nautilus-theme.c: (nautilus_theme_get_theme), (nautilus_theme_get_theme_data), (nautilus_theme_get_image_path): Update for preferences api changes. * libnautilus-extensions/nautilus-user-level-manager.c: * libnautilus-extensions/nautilus-user-level-manager.h: Retire. No longer needed. User level things are handled in nautilus-preferences.[ch] now. The current user level design is much simpler and does no require its own GtkObject. * src/file-manager/fm-desktop-icon-view.c: (update_home_link_and_delete_copies), (real_update_menus): * src/file-manager/fm-directory-view.c: (open_location), (confirm_delete_from_trash), (real_update_menus), (fm_directory_view_activate_files), (filtering_changed_callback): * src/file-manager/fm-icon-text-window.c: (changed_attributes_option_menu_callback), (fm_get_text_attribute_names_preference_or_default): * src/file-manager/fm-icon-view.c: (should_preview_sound), (fm_icon_view_update_click_mode), (fm_icon_view_update_smooth_graphics_mode): * src/file-manager/fm-list-view.c: (fm_list_view_update_click_mode): * src/file-manager/fm-properties-window.c: (create_permissions_page): * src/nautilus-application.c: (desktop_changed_callback): * src/nautilus-complex-search-bar.c: (nautilus_complex_search_bar_get_location): * src/nautilus-first-time-druid.c: (user_level_selection_changed), (make_hbox_user_level_radio_button), (set_up_user_level_page): * src/nautilus-main.c: (main): * src/nautilus-property-browser.c: (nautilus_property_browser_update_contents): * src/nautilus-sidebar.c: (nautilus_sidebar_sidebar_panel_enabled), (toggle_sidebar_panel), (nautilus_sidebar_size_allocate): * src/nautilus-switchable-search-bar.c: (nautilus_switchable_search_bar_new), (nautilus_search_uri_to_search_bar_mode): Update for preferences api changes. * src/nautilus-window-manage-views.c: (position_and_show_window_callback), (nautilus_window_end_location_change_callback): Update for preferences api changes. Also, no longer need to pass in a default location to the preferences getter. * src/nautilus-window-menus.c: (user_level_customize_callback), (switch_to_user_level), (refresh_bookmarks_menu), (user_level_changed_callback), (add_user_level_menu_item), (nautilus_window_initialize_menus), (update_user_level_menu_items), (convert_user_level_to_path): A lot of simplification. The "Edit Settings..." menu item no longer changes it wording based on the user level. We know allow it to edit settings on all user levels, since we have the ability to hide preferences at higher user levels. No longer need to update the preferences dialog or its title. * src/nautilus-window.c: (nautilus_window_constructed), (nautilus_window_close), (nautilus_window_go_web_search), (nautilus_window_go_home), (nautilus_window_show): Update for preferences api changes. * libnautilus-extensions/nautilus-global-preferences.h: Update all the preferences defines to not include a full gconf path. We dont need to do this anymore to get non user level coupled prefernces. * libnautilus-extensions/nautilus-global-preferences.c: (compare_view_identifiers), (global_preferences_create_dialog), (nautilus_global_preferences_get_enabled_sidebar_panel_view_identif iers), (global_preferences_install_sidebar_panel_defaults), (global_preferences_is_sidebar_panel_enabled), (global_preferences_install_speed_tradeoff_descriptions), (register_proxy_preferences), (global_preferences_register), (global_preferences_install_defaults), (nautilus_global_preferences_set_dialog_title): Lots of changes to support new preferences design. Set the WM_CLASS here once instead of everytime the dialog title is changed. This was causing criticals. No longer need to create parallel proxy preferences and map them to the gconf ones. We can use the gconf ones directly now. * test/.cvsignore: * test/Makefile.am: * test/test-nautilus-preferences-change.c: (user_level_changed_callback), (fruits_changed_callback), (int_picker_changed_callback), (user_level_picker_changed_callback), (picker_new), (user_level_picker_new), (main): * test/test-nautilus-preferences-display.c: (text_caption_update), (user_level_caption_update), (user_level_changed_callback), (green_changed_callback), (yellow_changed_callback), (red_changed_callback), (apple_changed_callback), (orange_changed_callback), (pear_changed_callback), (entry_new), (user_level_frame_new), (colors_frame_new), (fruits_frame_new), (main): * test/test.c: (test_pixbuf_draw_rectangle_tiled), (test_text_caption_set_text_for_int_preferences), (test_text_caption_set_text_for_string_preferences), (test_text_caption_set_text_for_default_int_preferences), (test_text_caption_set_text_for_default_string_preferences), (test_text_caption_get_text_as_int), (test_window_set_title_with_pid): * test/test.h: New tests for preferences changes. * test/test-nautilus-preferences.c: Retire old prefs test which didnt really work. * test/test-nautilus-smooth-graphics.c: (smooth_graphics_mode_changed_callback), (main): Update for preferences api changes.
This commit is contained in:
parent
956b4a6072
commit
d927dfd26d
322
ChangeLog
322
ChangeLog
|
@ -1,3 +1,325 @@
|
|||
2001-01-17 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
reviewed by: Pavel Cisler <pavel@eazel.com>
|
||||
|
||||
Lots of bug fixes:
|
||||
|
||||
2848 - User level agnostic config settings have nowhere to live.
|
||||
2654 - Need default values even for non user level preferences.
|
||||
3414 - Show more preferences at higher user levels.
|
||||
3415 - Make preference the same for all levels at which it is not visible
|
||||
3416 - Make preference changes affect all levels at which they are visible
|
||||
4357 - Web search URL setting should be reset upon Nautilus update
|
||||
5160 - Tree view doesnt exist when starting nautilus as a beginner
|
||||
5234 - Sidebar panel preferences are not properly separated among user levels
|
||||
|
||||
* components/mozilla/mozilla-preferences.cpp:
|
||||
Update for gnome vfs proxy changes. Proxy host and port are now
|
||||
stored in separate gconf settings.
|
||||
|
||||
* libnautilus-extensions/Makefile.am:
|
||||
* libnautilus-extensions/nautilus-enumeration.h:
|
||||
* libnautilus-extensions/nautilus-enumeration.c:
|
||||
(nautilus_enumeration_new), (nautilus_enumeration_free),
|
||||
(nautilus_enumeration_insert),
|
||||
(nautilus_enumeration_get_nth_entry),
|
||||
(nautilus_enumeration_get_nth_description),
|
||||
(nautilus_enumeration_get_nth_value),
|
||||
(nautilus_enumeration_get_num_entries),
|
||||
(nautilus_self_check_enumeration):
|
||||
New files. An enumeration data structure.
|
||||
|
||||
* components/tree/nautilus-tree-expansion-state.c:
|
||||
No longer need to give the full path to a gconf setting.
|
||||
|
||||
* components/tree/nautilus-tree-view.c:
|
||||
(filtering_changed_callback), (nautilus_tree_view_initialize):
|
||||
* libnautilus-extensions/nautilus-directory-async.c:
|
||||
(can_use_public_metafile),
|
||||
(get_filter_options_for_directory_count):
|
||||
* libnautilus-extensions/nautilus-file-operations.c:
|
||||
(confirm_empty_trash):
|
||||
* libnautilus-extensions/nautilus-file.c:
|
||||
(nautilus_file_should_get_top_left_text):
|
||||
* libnautilus-extensions/nautilus-font-factory.c:
|
||||
(nautilus_font_factory_get_font_from_preferences):
|
||||
Update for preferences api changes.
|
||||
|
||||
* libnautilus-extensions/nautilus-gconf-extensions.h:
|
||||
* libnautilus-extensions/nautilus-gconf-extensions.c:
|
||||
(global_client_free), (nautilus_gconf_client_get_global),
|
||||
(nautilus_gconf_handle_error), (nautilus_gconf_set_boolean),
|
||||
(nautilus_gconf_get_boolean), (nautilus_gconf_set_int),
|
||||
(nautilus_gconf_get_int), (nautilus_gconf_set_string),
|
||||
(nautilus_gconf_get_string), (nautilus_gconf_set_string_list),
|
||||
(nautilus_gconf_get_string_list), (nautilus_gconf_is_default),
|
||||
(nautilus_gconf_monitor_directory):
|
||||
New files. Useful gconf extensions; make peeking and poking
|
||||
settings a little easier.
|
||||
|
||||
* libnautilus-extensions/nautilus-icon-container.c:
|
||||
(button_press_event):
|
||||
* libnautilus-extensions/nautilus-icon-canvas-item.c:
|
||||
(in_single_click_mode):
|
||||
Update for preferences api changes.
|
||||
|
||||
* libnautilus-extensions/nautilus-icon-factory.c:
|
||||
(icon_theme_changed_callback),
|
||||
(should_display_image_file_as_itself):
|
||||
Update for preferences api changes. Also no longer need to define
|
||||
a default theme.
|
||||
|
||||
* libnautilus-extensions/nautilus-lib-self-check-functions.h:
|
||||
Add entries for enumeration and preferences. Remove preference
|
||||
entry. Note plural vs not.
|
||||
|
||||
* libnautilus-extensions/nautilus-preference.c:
|
||||
* libnautilus-extensions/nautilus-preference.h:
|
||||
Retire these 2. No longer use a GtkObject to store each
|
||||
preference. We simply use the string name instead.
|
||||
|
||||
* libnautilus-extensions/nautilus-preferences-box.h:
|
||||
* libnautilus-extensions/nautilus-preferences-box.c:
|
||||
(nautilus_preferences_box_add_pane),
|
||||
(nautilus_preferences_box_update):
|
||||
New function. Should be called when user level changes so that
|
||||
the box updates its panes.
|
||||
|
||||
* libnautilus-extensions/nautilus-preferences-dialog.h:
|
||||
* libnautilus-extensions/nautilus-preferences-dialog.c:
|
||||
(nautilus_preferences_dialog_initialize),
|
||||
(nautilus_preferences_dialog_destroy),
|
||||
(nautilus_preferences_dialog_get_prefs_box),
|
||||
(nautilus_preferences_dialog_update),
|
||||
(user_level_changed_callback):
|
||||
Keep track of user level changes.
|
||||
New function to update the dialog when user level changes.
|
||||
|
||||
* libnautilus-extensions/nautilus-preferences-group.h:
|
||||
* libnautilus-extensions/nautilus-preferences-group.c:
|
||||
(nautilus_preferences_group_initialize),
|
||||
(nautilus_preferences_group_destroy),
|
||||
(nautilus_preferences_group_add_item): Collect the group's items
|
||||
in a list. Update to user a string to represent a preference
|
||||
instead of a GtkObject.
|
||||
(nautilus_preferences_group_update): New function. Updates the
|
||||
group's items to respect preferences visibility based on the user
|
||||
level.
|
||||
(nautilus_preferences_get_num_visible_items): New function.
|
||||
Return the number of currently visible items.
|
||||
|
||||
Collect the group's items in a list. Update to user a string to
|
||||
represent a preference instead of a GtkObject.
|
||||
|
||||
* libnautilus-extensions/nautilus-preferences-item.h:
|
||||
* libnautilus-extensions/nautilus-preferences-item.c:
|
||||
(preferences_item_construct), (preferences_item_create_enum),
|
||||
(preferences_item_create_short_enum),
|
||||
(preferences_item_create_boolean),
|
||||
(preferences_item_create_editable_string),
|
||||
(preferences_item_create_integer),
|
||||
(preferences_item_create_font_family),
|
||||
(preferences_item_create_theme),
|
||||
(enum_radio_group_changed_callback),
|
||||
(editable_string_changed_callback), (integer_changed_callback),
|
||||
(nautilus_preferences_item_get_name):
|
||||
New function to fetch the item's preference name.
|
||||
Add a new kind of preference - INTEGER. Update for string
|
||||
vs. GtkObject preferences representation changes.
|
||||
|
||||
* libnautilus-extensions/nautilus-preferences-pane.h:
|
||||
* libnautilus-extensions/nautilus-preferences-pane.c:
|
||||
(nautilus_preferences_pane_update):
|
||||
New function. Updates the pane's groups to respect preferences
|
||||
visibility based on the user level.
|
||||
|
||||
* libnautilus-extensions/nautilus-preferences.h:
|
||||
* libnautilus-extensions/nautilus-preferences.c:
|
||||
(preferences_get_path), (preferences_get_defaults_path),
|
||||
(preferences_get_visibility_path),
|
||||
(preferences_get_user_level_key),
|
||||
(preferences_preference_is_internal),
|
||||
(preferences_preference_is_user_level), (preferences_key_make),
|
||||
(preferences_key_make_for_default),
|
||||
(preferences_key_make_for_default_getter),
|
||||
(preferences_key_make_for_visibility),
|
||||
(preferences_global_client_remove_notification),
|
||||
(preferences_global_client_get),
|
||||
(preferences_preference_is_default),
|
||||
(preferences_make_user_level_filtered_key),
|
||||
(nautilus_preferences_get_visible_user_level),
|
||||
(nautilus_preferences_set_visible_user_level),
|
||||
(nautilus_preferences_set_boolean),
|
||||
(preferences_key_make_for_getter),
|
||||
(nautilus_preferences_get_boolean), (nautilus_preferences_set_int),
|
||||
(nautilus_preferences_get_int), (nautilus_preferences_set),
|
||||
(nautilus_preferences_get), (nautilus_preferences_set_string_list),
|
||||
(nautilus_preferences_get_string_list),
|
||||
(nautilus_preferences_get_user_level),
|
||||
(nautilus_preferences_set_user_level),
|
||||
(nautilus_preferences_default_set_int),
|
||||
(nautilus_preferences_default_get_int),
|
||||
(nautilus_preferences_default_set_boolean),
|
||||
(nautilus_preferences_default_get_boolean),
|
||||
(nautilus_preferences_default_set_string),
|
||||
(nautilus_preferences_default_get_string),
|
||||
(nautilus_preferences_default_set_string_list),
|
||||
(nautilus_preferences_default_get_string_list),
|
||||
(preferences_callback_entry_invoke_function),
|
||||
(preferences_something_changed_notice),
|
||||
(preferences_global_table_check_changes_function),
|
||||
(preferences_user_level_changed_notice),
|
||||
(preferences_entry_add_callback),
|
||||
(preferences_entry_remove_callback),
|
||||
(preferences_callback_entry_free),
|
||||
(preferences_callback_entry_free_func), (preferences_entry_free),
|
||||
(preferences_entry_free_func), (preferences_global_table_free),
|
||||
(preferences_global_table_get_global),
|
||||
(preferences_global_table_lookup),
|
||||
(preferences_global_table_insert),
|
||||
(preferences_global_table_lookup_or_insert),
|
||||
(nautilus_preferences_add_callback),
|
||||
(preferences_while_alive_disconnector),
|
||||
(nautilus_preferences_add_callback_while_alive),
|
||||
(nautilus_preferences_remove_callback),
|
||||
(nautilus_preferences_enumeration_insert),
|
||||
(nautilus_preferences_enumeration_get_nth_entry),
|
||||
(nautilus_preferences_enumeration_get_nth_description),
|
||||
(nautilus_preferences_enumeration_get_nth_value),
|
||||
(nautilus_preferences_enumeration_get_num_entries),
|
||||
(nautilus_preferences_set_description),
|
||||
(nautilus_preferences_get_description),
|
||||
(nautilus_preferences_get_user_level_name_for_display),
|
||||
(nautilus_preferences_get_user_level_name_for_storage),
|
||||
(preferences_user_level_check_range),
|
||||
(nautilus_preferences_monitor_directory),
|
||||
(nautilus_preferences_is_visible),
|
||||
(nautilus_self_check_preferences):
|
||||
Many changes. Redid to support the preferences system described
|
||||
in bugs 3414, 3415 and 3416.
|
||||
|
||||
* libnautilus-extensions/nautilus-smooth-widget.c:
|
||||
(preferences_get_is_smooth):
|
||||
* libnautilus-extensions/nautilus-sound.c:
|
||||
(kill_sound_if_necessary), (nautilus_sound_initialize),
|
||||
(nautilus_sound_kill_sound), (nautilus_sound_register_sound),
|
||||
(nautilus_sound_can_play_sound):
|
||||
* libnautilus-extensions/nautilus-theme.c:
|
||||
(nautilus_theme_get_theme), (nautilus_theme_get_theme_data),
|
||||
(nautilus_theme_get_image_path):
|
||||
Update for preferences api changes.
|
||||
|
||||
* libnautilus-extensions/nautilus-user-level-manager.c:
|
||||
* libnautilus-extensions/nautilus-user-level-manager.h:
|
||||
Retire. No longer needed. User level things are handled in
|
||||
nautilus-preferences.[ch] now. The current user level design is
|
||||
much simpler and does no require its own GtkObject.
|
||||
|
||||
* src/file-manager/fm-desktop-icon-view.c:
|
||||
(update_home_link_and_delete_copies), (real_update_menus):
|
||||
* src/file-manager/fm-directory-view.c: (open_location),
|
||||
(confirm_delete_from_trash), (real_update_menus),
|
||||
(fm_directory_view_activate_files), (filtering_changed_callback):
|
||||
* src/file-manager/fm-icon-text-window.c:
|
||||
(changed_attributes_option_menu_callback),
|
||||
(fm_get_text_attribute_names_preference_or_default):
|
||||
* src/file-manager/fm-icon-view.c: (should_preview_sound),
|
||||
(fm_icon_view_update_click_mode),
|
||||
(fm_icon_view_update_smooth_graphics_mode):
|
||||
* src/file-manager/fm-list-view.c:
|
||||
(fm_list_view_update_click_mode):
|
||||
* src/file-manager/fm-properties-window.c:
|
||||
(create_permissions_page):
|
||||
* src/nautilus-application.c: (desktop_changed_callback):
|
||||
* src/nautilus-complex-search-bar.c:
|
||||
(nautilus_complex_search_bar_get_location):
|
||||
* src/nautilus-first-time-druid.c: (user_level_selection_changed),
|
||||
(make_hbox_user_level_radio_button), (set_up_user_level_page):
|
||||
* src/nautilus-main.c: (main):
|
||||
* src/nautilus-property-browser.c:
|
||||
(nautilus_property_browser_update_contents):
|
||||
* src/nautilus-sidebar.c: (nautilus_sidebar_sidebar_panel_enabled),
|
||||
(toggle_sidebar_panel), (nautilus_sidebar_size_allocate):
|
||||
* src/nautilus-switchable-search-bar.c:
|
||||
(nautilus_switchable_search_bar_new),
|
||||
(nautilus_search_uri_to_search_bar_mode):
|
||||
Update for preferences api changes.
|
||||
|
||||
* src/nautilus-window-manage-views.c:
|
||||
(position_and_show_window_callback),
|
||||
(nautilus_window_end_location_change_callback):
|
||||
Update for preferences api changes. Also, no longer need to pass
|
||||
in a default location to the preferences getter.
|
||||
|
||||
* src/nautilus-window-menus.c: (user_level_customize_callback),
|
||||
(switch_to_user_level), (refresh_bookmarks_menu),
|
||||
(user_level_changed_callback), (add_user_level_menu_item),
|
||||
(nautilus_window_initialize_menus), (update_user_level_menu_items),
|
||||
(convert_user_level_to_path):
|
||||
A lot of simplification. The "Edit Settings..." menu item no
|
||||
longer changes it wording based on the user level. We know allow
|
||||
it to edit settings on all user levels, since we have the ability
|
||||
to hide preferences at higher user levels. No longer need to
|
||||
update the preferences dialog or its title.
|
||||
|
||||
* src/nautilus-window.c: (nautilus_window_constructed),
|
||||
(nautilus_window_close), (nautilus_window_go_web_search),
|
||||
(nautilus_window_go_home), (nautilus_window_show):
|
||||
Update for preferences api changes.
|
||||
|
||||
* libnautilus-extensions/nautilus-global-preferences.h:
|
||||
Update all the preferences defines to not include a full gconf
|
||||
path. We dont need to do this anymore to get non user level
|
||||
coupled prefernces.
|
||||
|
||||
* libnautilus-extensions/nautilus-global-preferences.c:
|
||||
(compare_view_identifiers), (global_preferences_create_dialog),
|
||||
(nautilus_global_preferences_get_enabled_sidebar_panel_view_identif
|
||||
iers), (global_preferences_install_sidebar_panel_defaults),
|
||||
(global_preferences_is_sidebar_panel_enabled),
|
||||
(global_preferences_install_speed_tradeoff_descriptions),
|
||||
(register_proxy_preferences), (global_preferences_register),
|
||||
(global_preferences_install_defaults),
|
||||
(nautilus_global_preferences_set_dialog_title):
|
||||
Lots of changes to support new preferences design.
|
||||
|
||||
Set the WM_CLASS here once instead of everytime the dialog title
|
||||
is changed. This was causing criticals.
|
||||
|
||||
No longer need to create parallel proxy preferences and map them
|
||||
to the gconf ones. We can use the gconf ones directly now.
|
||||
|
||||
* test/.cvsignore:
|
||||
* test/Makefile.am:
|
||||
* test/test-nautilus-preferences-change.c:
|
||||
(user_level_changed_callback), (fruits_changed_callback),
|
||||
(int_picker_changed_callback),
|
||||
(user_level_picker_changed_callback), (picker_new),
|
||||
(user_level_picker_new), (main):
|
||||
* test/test-nautilus-preferences-display.c: (text_caption_update),
|
||||
(user_level_caption_update), (user_level_changed_callback),
|
||||
(green_changed_callback), (yellow_changed_callback),
|
||||
(red_changed_callback), (apple_changed_callback),
|
||||
(orange_changed_callback), (pear_changed_callback), (entry_new),
|
||||
(user_level_frame_new), (colors_frame_new), (fruits_frame_new),
|
||||
(main):
|
||||
* test/test.c: (test_pixbuf_draw_rectangle_tiled),
|
||||
(test_text_caption_set_text_for_int_preferences),
|
||||
(test_text_caption_set_text_for_string_preferences),
|
||||
(test_text_caption_set_text_for_default_int_preferences),
|
||||
(test_text_caption_set_text_for_default_string_preferences),
|
||||
(test_text_caption_get_text_as_int),
|
||||
(test_window_set_title_with_pid):
|
||||
* test/test.h:
|
||||
New tests for preferences changes.
|
||||
|
||||
* test/test-nautilus-preferences.c:
|
||||
Retire old prefs test which didnt really work.
|
||||
|
||||
* test/test-nautilus-smooth-graphics.c:
|
||||
(smooth_graphics_mode_changed_callback), (main):
|
||||
Update for preferences api changes.
|
||||
|
||||
2001-01-17 Andy Hertzfeld <andy@eazel.com>
|
||||
|
||||
changed the throbber component to use the new translated oaf file
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
static GConfClient *preferences_get_global_gconf_client (void);
|
||||
static void preferences_proxy_sync_mozilla_with_gconf (void);
|
||||
|
||||
static const char PROXY_KEY[] = "/system/gnome-vfs/http-proxy";
|
||||
static const char PROXY_HOST_KEY[] = "/system/gnome-vfs/http-proxy-host";
|
||||
static const char PROXY_PORT_KEY[] = "/system/gnome-vfs/http-proxy-port";
|
||||
static const char USE_PROXY_KEY[] = "/system/gnome-vfs/use-http-proxy";
|
||||
static const char SYSTEM_GNOME_VFS_PATH[] = "/system/gnome-vfs";
|
||||
|
||||
|
@ -137,11 +138,12 @@ mozilla_gconf_handle_gconf_error (GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static guint gconf_proxy_changed_connection = 0;
|
||||
static guint gconf_proxy_host_changed_connection = 0;
|
||||
static guint gconf_proxy_port_changed_connection = 0;
|
||||
static guint gconf_use_http_proxy_changed_connection = 0;
|
||||
|
||||
static void
|
||||
preferneces_proxy_changed_callback (GConfClient* client,
|
||||
preferences_proxy_changed_callback (GConfClient* client,
|
||||
guint cnxn_id,
|
||||
GConfEntry *entry,
|
||||
gpointer user_data)
|
||||
|
@ -149,15 +151,6 @@ preferneces_proxy_changed_callback (GConfClient* client,
|
|||
preferences_proxy_sync_mozilla_with_gconf ();
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_use_proxy_changed_callback (GConfClient* client,
|
||||
guint cnxn_id,
|
||||
GConfEntry *entry,
|
||||
gpointer user_data)
|
||||
{
|
||||
preferences_proxy_sync_mozilla_with_gconf ();
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_add_gconf_proxy_connections (void)
|
||||
{
|
||||
|
@ -167,17 +160,25 @@ preferences_add_gconf_proxy_connections (void)
|
|||
gconf_client = preferences_get_global_gconf_client ();
|
||||
g_return_if_fail (GCONF_IS_CLIENT (gconf_client));
|
||||
|
||||
gconf_proxy_changed_connection = gconf_client_notify_add (gconf_client,
|
||||
PROXY_KEY,
|
||||
preferneces_proxy_changed_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
&error);
|
||||
gconf_proxy_host_changed_connection = gconf_client_notify_add (gconf_client,
|
||||
PROXY_HOST_KEY,
|
||||
preferences_proxy_changed_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
&error);
|
||||
mozilla_gconf_handle_gconf_error (&error);
|
||||
|
||||
gconf_proxy_port_changed_connection = gconf_client_notify_add (gconf_client,
|
||||
PROXY_PORT_KEY,
|
||||
preferences_proxy_changed_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
&error);
|
||||
mozilla_gconf_handle_gconf_error (&error);
|
||||
|
||||
gconf_use_http_proxy_changed_connection = gconf_client_notify_add (gconf_client,
|
||||
USE_PROXY_KEY,
|
||||
preferences_use_proxy_changed_callback,
|
||||
preferences_proxy_changed_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
&error);
|
||||
|
@ -192,8 +193,11 @@ preferences_remove_gconf_proxy_connections (void)
|
|||
gconf_client = preferences_get_global_gconf_client ();
|
||||
g_return_if_fail (GCONF_IS_CLIENT (gconf_client));
|
||||
|
||||
gconf_client_notify_remove (gconf_client, gconf_proxy_changed_connection);
|
||||
gconf_proxy_changed_connection = 0;
|
||||
gconf_client_notify_remove (gconf_client, gconf_proxy_host_changed_connection);
|
||||
gconf_proxy_host_changed_connection = 0;
|
||||
|
||||
gconf_client_notify_remove (gconf_client, gconf_proxy_port_changed_connection);
|
||||
gconf_proxy_port_changed_connection = 0;
|
||||
|
||||
gconf_client_notify_remove (gconf_client, gconf_use_http_proxy_changed_connection);
|
||||
gconf_use_http_proxy_changed_connection = 0;
|
||||
|
@ -285,31 +289,32 @@ preferences_proxy_sync_mozilla_with_gconf (void)
|
|||
g_return_if_fail (GCONF_IS_CLIENT (gconf_client));
|
||||
|
||||
if (gconf_client_get_bool (gconf_client, USE_PROXY_KEY, &error)) {
|
||||
proxy_string = gconf_client_get_string (gconf_client, PROXY_KEY, &error);
|
||||
if (!mozilla_gconf_handle_gconf_error (&error)) {
|
||||
if (proxy_string != NULL) {
|
||||
char *proxy, *port;
|
||||
port = strchr (proxy_string, ':');
|
||||
if (port != NULL) {
|
||||
proxy = g_strdup (proxy_string);
|
||||
proxy [port - proxy_string] = '\0';
|
||||
port++;
|
||||
|
||||
mozilla_preference_set ("network.proxy.http", proxy);
|
||||
mozilla_preference_set_int ("network.proxy.http_port", atoi (port));
|
||||
|
||||
/* 1, Configure proxy settings manually */
|
||||
mozilla_preference_set_int ("network.proxy.type", 1);
|
||||
|
||||
g_free (proxy_string);
|
||||
g_free (proxy);
|
||||
}
|
||||
}
|
||||
char *proxy_host = NULL;
|
||||
gboolean proxy_host_success;
|
||||
int proxy_port = 8080;
|
||||
gboolean proxy_port_success;
|
||||
|
||||
error = NULL;
|
||||
proxy_host = gconf_client_get_string (gconf_client, PROXY_HOST_KEY, &error);
|
||||
proxy_host_success = !mozilla_gconf_handle_gconf_error (&error);
|
||||
|
||||
error = NULL;
|
||||
proxy_port = gconf_client_get_int (gconf_client, PROXY_PORT_KEY, &error);
|
||||
proxy_port_success = !mozilla_gconf_handle_gconf_error (&error);
|
||||
|
||||
if (proxy_host_success && proxy_port_success) {
|
||||
mozilla_preference_set ("network.proxy.http", proxy_host);
|
||||
mozilla_preference_set_int ("network.proxy.http_port", proxy_port);
|
||||
|
||||
/* 1, Configure proxy settings manually */
|
||||
mozilla_preference_set_int ("network.proxy.type", 1);
|
||||
}
|
||||
|
||||
g_free (proxy_host);
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
/* Default is 3, which conects to internet hosts directly */
|
||||
mozilla_preference_set_int ("network.proxy.type", 3);
|
||||
}
|
||||
|
||||
|
||||
/* Default is 3, which conects to internet hosts directly */
|
||||
mozilla_preference_set_int ("network.proxy.type", 3);
|
||||
}
|
||||
|
|
|
@ -71,9 +71,7 @@ nautilus_tree_expansion_state_initialize_class (gpointer klass)
|
|||
}
|
||||
|
||||
/* Give full gconf path so that this preference won't be coupled to user level. */
|
||||
#define NAUTILUS_PREFERENCES_TREE_VIEW_EXPANSION_STATE "/apps/nautilus/tree-view/expansion_state"
|
||||
|
||||
|
||||
#define NAUTILUS_PREFERENCES_TREE_VIEW_EXPANSION_STATE "sidebar-panels/tree/expansion_state"
|
||||
|
||||
static void
|
||||
nautilus_tree_expansion_state_load_foreach_callback (char *uri,
|
||||
|
|
|
@ -610,13 +610,13 @@ filtering_changed_callback (gpointer callback_data)
|
|||
view = NAUTILUS_TREE_VIEW (callback_data);
|
||||
|
||||
view->details->show_hidden_files =
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, FALSE);
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
|
||||
|
||||
view->details->show_backup_files =
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, FALSE);
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES);
|
||||
|
||||
view->details->show_non_directories =
|
||||
! nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES, FALSE);
|
||||
! nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES);
|
||||
|
||||
|
||||
/* Reload the whole tree so that the filtering changes take place. */
|
||||
|
@ -686,13 +686,13 @@ nautilus_tree_view_initialize (NautilusTreeView *view)
|
|||
|
||||
/* Obtain the filtering preferences */
|
||||
view->details->show_hidden_files =
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, FALSE);
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
|
||||
|
||||
view->details->show_backup_files =
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, FALSE);
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES);
|
||||
|
||||
view->details->show_non_directories =
|
||||
! nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES, FALSE);
|
||||
! nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES);
|
||||
|
||||
/* Keep track of changes in these prefs to filter files accordingly. */
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES,
|
||||
|
|
|
@ -71,6 +71,7 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-druid-page-eazel.c \
|
||||
nautilus-druid.c \
|
||||
nautilus-entry.c \
|
||||
nautilus-enumeration.c \
|
||||
nautilus-file-changes-queue.c \
|
||||
nautilus-file-operations-progress.c \
|
||||
nautilus-file-operations.c \
|
||||
|
@ -78,6 +79,7 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-file.c \
|
||||
nautilus-font-factory.c \
|
||||
nautilus-font-picker.c \
|
||||
nautilus-gconf-extensions.c \
|
||||
nautilus-gdk-extensions.c \
|
||||
nautilus-gdk-font-extensions.c \
|
||||
nautilus-gdk-pixbuf-extensions.c \
|
||||
|
@ -106,7 +108,6 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-merged-directory.c \
|
||||
nautilus-mime-actions.c \
|
||||
nautilus-password-dialog.c \
|
||||
nautilus-preference.c \
|
||||
nautilus-preferences-box.c \
|
||||
nautilus-preferences-dialog.c \
|
||||
nautilus-preferences-group.c \
|
||||
|
@ -136,7 +137,6 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-undo-context.c \
|
||||
nautilus-undo-manager.c \
|
||||
nautilus-undo-signal-handlers.c \
|
||||
nautilus-user-level-manager.c \
|
||||
nautilus-vfs-directory.c \
|
||||
nautilus-vfs-file.c \
|
||||
nautilus-view-identifier.c \
|
||||
|
@ -171,6 +171,7 @@ noinst_HEADERS = \
|
|||
nautilus-druid-page-eazel.h \
|
||||
nautilus-druid.h \
|
||||
nautilus-entry.h \
|
||||
nautilus-enumeration.h \
|
||||
nautilus-file-attributes.h \
|
||||
nautilus-file-changes-queue.h \
|
||||
nautilus-file-operations-progress.h \
|
||||
|
@ -180,6 +181,7 @@ noinst_HEADERS = \
|
|||
nautilus-file.h \
|
||||
nautilus-font-factory.h \
|
||||
nautilus-font-picker.h \
|
||||
nautilus-gconf-extensions.h \
|
||||
nautilus-gdk-extensions.h \
|
||||
nautilus-gdk-font-extensions.h \
|
||||
nautilus-gdk-pixbuf-extensions.h \
|
||||
|
@ -213,7 +215,6 @@ noinst_HEADERS = \
|
|||
nautilus-metadata.h \
|
||||
nautilus-mime-actions.h \
|
||||
nautilus-password-dialog.h \
|
||||
nautilus-preference.h \
|
||||
nautilus-preferences-box.h \
|
||||
nautilus-preferences-dialog.h \
|
||||
nautilus-preferences-group.h \
|
||||
|
@ -224,8 +225,9 @@ noinst_HEADERS = \
|
|||
nautilus-program-chooser.h \
|
||||
nautilus-program-choosing.h \
|
||||
nautilus-radio-button-group.h \
|
||||
nautilus-scalable-font.h \
|
||||
nautilus-scalable-font-private.h \
|
||||
nautilus-scalable-font-private.h \
|
||||
nautilus-scalable-font.h \
|
||||
nautilus-search-uri.h \
|
||||
nautilus-self-checks.h \
|
||||
nautilus-smooth-widget.h \
|
||||
|
@ -245,7 +247,6 @@ noinst_HEADERS = \
|
|||
nautilus-undo-context.h \
|
||||
nautilus-undo-manager.h \
|
||||
nautilus-undo-signal-handlers.h \
|
||||
nautilus-user-level-manager.h \
|
||||
nautilus-vfs-directory.h \
|
||||
nautilus-vfs-file.h \
|
||||
nautilus-view-identifier.h \
|
||||
|
|
|
@ -431,9 +431,7 @@ can_use_public_metafile (NautilusDirectory *directory)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
preference_value = nautilus_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA,
|
||||
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
|
||||
preference_value = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA);
|
||||
|
||||
if (preference_value == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
|
||||
return TRUE;
|
||||
|
@ -1157,10 +1155,10 @@ get_filter_options_for_directory_count (void)
|
|||
filter_options = GNOME_VFS_DIRECTORY_FILTER_NOSELFDIR
|
||||
| GNOME_VFS_DIRECTORY_FILTER_NOPARENTDIR;
|
||||
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, FALSE)) {
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES)) {
|
||||
filter_options |= GNOME_VFS_DIRECTORY_FILTER_NODOTFILES;
|
||||
}
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, FALSE)) {
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES)) {
|
||||
filter_options |= GNOME_VFS_DIRECTORY_FILTER_NOBACKUPFILES;
|
||||
}
|
||||
|
||||
|
|
137
libnautilus-extensions/nautilus-enumeration.c
Normal file
137
libnautilus-extensions/nautilus-enumeration.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-enumeration.c: Enumeration data structure.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "nautilus-enumeration.h"
|
||||
|
||||
#include "nautilus-glib-extensions.h"
|
||||
#include "nautilus-lib-self-check-functions.h"
|
||||
#include "nautilus-string.h"
|
||||
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
|
||||
struct NautilusEnumeration
|
||||
{
|
||||
NautilusStringList *entries;
|
||||
NautilusStringList *descriptions;
|
||||
GList *values;
|
||||
};
|
||||
|
||||
/**
|
||||
* nautilus_enumeration_new:
|
||||
*
|
||||
* Return value: A newly constructed string list.
|
||||
*/
|
||||
NautilusEnumeration *
|
||||
nautilus_enumeration_new (void)
|
||||
{
|
||||
NautilusEnumeration *enumeration;
|
||||
|
||||
enumeration = g_new0 (NautilusEnumeration, 1);
|
||||
|
||||
return enumeration;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_enumeration_free (NautilusEnumeration *enumeration)
|
||||
{
|
||||
if (enumeration == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
nautilus_string_list_free (enumeration->entries);
|
||||
nautilus_string_list_free (enumeration->descriptions);
|
||||
g_list_free (enumeration->values);
|
||||
|
||||
g_free (enumeration);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_enumeration_insert (NautilusEnumeration *enumeration,
|
||||
const char *entry,
|
||||
const char *description,
|
||||
int value)
|
||||
{
|
||||
g_return_if_fail (enumeration != NULL);
|
||||
g_return_if_fail (entry != NULL);
|
||||
|
||||
if (enumeration->entries == NULL) {
|
||||
enumeration->entries =nautilus_string_list_new (TRUE);
|
||||
}
|
||||
|
||||
if (enumeration->descriptions == NULL) {
|
||||
enumeration->descriptions = nautilus_string_list_new (TRUE);
|
||||
}
|
||||
|
||||
nautilus_string_list_insert (enumeration->entries, entry);
|
||||
nautilus_string_list_insert (enumeration->descriptions, description ? description : "");
|
||||
enumeration->values = g_list_append (enumeration->values, GINT_TO_POINTER (value));
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_enumeration_get_nth_entry (const NautilusEnumeration *enumeration,
|
||||
guint n)
|
||||
{
|
||||
g_return_val_if_fail (enumeration != NULL, NULL);
|
||||
g_return_val_if_fail (n < nautilus_string_list_get_length (enumeration->entries), NULL);
|
||||
|
||||
return nautilus_string_list_nth (enumeration->entries, n);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_enumeration_get_nth_description (const NautilusEnumeration *enumeration,
|
||||
guint n)
|
||||
{
|
||||
g_return_val_if_fail (enumeration != NULL, NULL);
|
||||
g_return_val_if_fail (n < nautilus_string_list_get_length (enumeration->descriptions), NULL);
|
||||
|
||||
return nautilus_string_list_nth (enumeration->descriptions, n);
|
||||
}
|
||||
|
||||
int
|
||||
nautilus_enumeration_get_nth_value (const NautilusEnumeration *enumeration,
|
||||
guint n)
|
||||
{
|
||||
g_return_val_if_fail (enumeration != NULL, 0);
|
||||
g_return_val_if_fail (n < g_list_length (enumeration->values), 0);
|
||||
|
||||
return GPOINTER_TO_INT (g_list_nth_data (enumeration->values, n));
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_enumeration_get_num_entries (const NautilusEnumeration *enumeration)
|
||||
{
|
||||
g_return_val_if_fail (enumeration != NULL, 0);
|
||||
|
||||
return nautilus_string_list_get_length (enumeration->entries);
|
||||
}
|
||||
|
||||
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
|
||||
void
|
||||
nautilus_self_check_enumeration (void)
|
||||
{
|
||||
}
|
||||
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
|
48
libnautilus-extensions/nautilus-enumeration.h
Normal file
48
libnautilus-extensions/nautilus-enumeration.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-enumeration.h: Enumeration data structure.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_ENUMERATION_H
|
||||
#define NAUTILUS_ENUMERATION_H
|
||||
|
||||
#include <libnautilus-extensions/nautilus-string-list.h>
|
||||
|
||||
/* Opaque NautilusEnumeration declaration. */
|
||||
typedef struct NautilusEnumeration NautilusEnumeration;
|
||||
|
||||
NautilusEnumeration *nautilus_enumeration_new (void);
|
||||
void nautilus_enumeration_free (NautilusEnumeration *enumeration);
|
||||
void nautilus_enumeration_insert (NautilusEnumeration *enumeration,
|
||||
const char *entry,
|
||||
const char *description,
|
||||
int value);
|
||||
char * nautilus_enumeration_get_nth_entry (const NautilusEnumeration *enumeration,
|
||||
guint n);
|
||||
char * nautilus_enumeration_get_nth_description (const NautilusEnumeration *enumeration,
|
||||
guint n);
|
||||
int nautilus_enumeration_get_nth_value (const NautilusEnumeration *enumeration,
|
||||
guint n);
|
||||
guint nautilus_enumeration_get_num_entries (const NautilusEnumeration *enumeration);
|
||||
|
||||
#endif /* NAUTILUS_ENUMERATION_H */
|
||||
|
|
@ -2197,7 +2197,7 @@ confirm_empty_trash (GtkWidget *parent_view)
|
|||
GtkWindow *parent_window;
|
||||
|
||||
/* Just Say Yes if the preference says not to confirm. */
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH, TRUE)) {
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1058,9 +1058,7 @@ nautilus_file_should_get_top_left_text (NautilusFile *file)
|
|||
|
||||
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
|
||||
|
||||
preference_value = nautilus_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS,
|
||||
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
|
||||
preference_value = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS);
|
||||
|
||||
if (preference_value == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
|
||||
return TRUE;
|
||||
|
|
|
@ -299,7 +299,7 @@ nautilus_font_factory_get_font_from_preferences (guint size_in_pixels)
|
|||
char *family;
|
||||
GdkFont *font;
|
||||
|
||||
family = nautilus_preferences_get (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY, "helvetica");
|
||||
family = nautilus_preferences_get (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY);
|
||||
|
||||
font = nautilus_font_factory_get_font_by_family (family, size_in_pixels);
|
||||
|
||||
|
|
317
libnautilus-extensions/nautilus-gconf-extensions.c
Normal file
317
libnautilus-extensions/nautilus-gconf-extensions.c
Normal file
|
@ -0,0 +1,317 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-gconf-extensions.c - Stuff to make GConf easier to use in Nautilus.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "nautilus-gconf-extensions.h"
|
||||
|
||||
#include <gconf/gconf.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <libgnomeui/gnome-dialog.h>
|
||||
#include <libgnomeui/gnome-dialog-util.h>
|
||||
|
||||
static GConfClient *global_gconf_client = NULL;
|
||||
|
||||
static void
|
||||
global_client_free (void)
|
||||
{
|
||||
if (global_gconf_client == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (global_gconf_client));
|
||||
global_gconf_client = NULL;
|
||||
}
|
||||
|
||||
/* Public */
|
||||
GConfClient *
|
||||
nautilus_gconf_client_get_global (void)
|
||||
{
|
||||
/* Initialize gconf if needed */
|
||||
if (!gconf_is_initialized ()) {
|
||||
char *argv[] = { "nautilus", NULL };
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gconf_init (1, argv, &error)) {
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (global_gconf_client == NULL) {
|
||||
global_gconf_client = gconf_client_get_default ();
|
||||
g_atexit (global_client_free);
|
||||
}
|
||||
|
||||
return global_gconf_client;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_gconf_handle_error (GError **error)
|
||||
{
|
||||
static gboolean shown_dialog = FALSE;
|
||||
|
||||
g_return_val_if_fail (error != NULL, FALSE);
|
||||
|
||||
if (*error != NULL) {
|
||||
g_warning (_("GConf error:\n %s"), (*error)->message);
|
||||
if ( ! shown_dialog) {
|
||||
char *message;
|
||||
GtkWidget *dialog;
|
||||
|
||||
shown_dialog = TRUE;
|
||||
|
||||
message = g_strdup_printf (_("GConf error:\n %s\n"
|
||||
"All further errors shown "
|
||||
"only on terminal"),
|
||||
(*error)->message);
|
||||
|
||||
dialog = gnome_error_dialog (message);
|
||||
}
|
||||
g_error_free (*error);
|
||||
*error = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_gconf_set_boolean (const char *key,
|
||||
gboolean boolean_value)
|
||||
{
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (key != NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_if_fail (client != NULL);
|
||||
|
||||
gconf_client_set_bool (client, key, boolean_value, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
error = NULL;
|
||||
|
||||
gconf_client_suggest_sync (client, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_gconf_get_boolean (const char *key)
|
||||
{
|
||||
gboolean result;
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_val_if_fail (client != NULL, FALSE);
|
||||
|
||||
result = gconf_client_get_bool (client, key, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
result = FALSE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_gconf_set_integer (const char *key,
|
||||
int int_value)
|
||||
{
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (key != NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_if_fail (client != NULL);
|
||||
|
||||
gconf_client_set_int (client, key, int_value, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
error = NULL;
|
||||
|
||||
gconf_client_suggest_sync (client, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
}
|
||||
|
||||
int
|
||||
nautilus_gconf_get_integer (const char *key)
|
||||
{
|
||||
int result;
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, 0);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_val_if_fail (client != NULL, 0);
|
||||
|
||||
result = gconf_client_get_int (client, key, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_gconf_set_string (const char *key,
|
||||
const char *string_value)
|
||||
{
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (key != NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_if_fail (client != NULL);
|
||||
|
||||
gconf_client_set_string (client, key, string_value, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
error = NULL;
|
||||
|
||||
gconf_client_suggest_sync (client, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_gconf_get_string (const char *key)
|
||||
{
|
||||
char *result;
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_val_if_fail (client != NULL, NULL);
|
||||
|
||||
result = gconf_client_get_string (client, key, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
result = g_strdup ("");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_gconf_set_string_list (const char *key,
|
||||
GSList *string_list_value)
|
||||
{
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (key != NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_if_fail (client != NULL);
|
||||
|
||||
gconf_client_set_list (client, key, GCONF_VALUE_STRING, string_list_value, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
error = NULL;
|
||||
|
||||
gconf_client_suggest_sync (client, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
}
|
||||
|
||||
GSList *
|
||||
nautilus_gconf_get_string_list (const char *key)
|
||||
{
|
||||
GSList *result;
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_val_if_fail (client != NULL, NULL);
|
||||
|
||||
result = gconf_client_get_list (client, key, GCONF_VALUE_STRING, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_gconf_is_default (const char *key)
|
||||
{
|
||||
gboolean result;
|
||||
GConfValue *value;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
|
||||
value = gconf_client_get_without_default (nautilus_gconf_client_get_global (), key, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
if (value != NULL) {
|
||||
gconf_value_free (value);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
result = (value == NULL);
|
||||
|
||||
if (value != NULL) {
|
||||
gconf_value_free (value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_gconf_monitor_directory (const char *directory)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GConfClient *client;
|
||||
|
||||
g_return_val_if_fail (directory != NULL, FALSE);
|
||||
|
||||
client = gconf_client_get_default ();
|
||||
|
||||
g_return_val_if_fail (client != NULL, FALSE);
|
||||
|
||||
gconf_client_add_dir (client,
|
||||
directory,
|
||||
GCONF_CLIENT_PRELOAD_NONE,
|
||||
&error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
53
libnautilus-extensions/nautilus-gconf-extensions.h
Normal file
53
libnautilus-extensions/nautilus-gconf-extensions.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-gconf-extensions.h - Stuff to make GConf easier to use in Nautilus.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_GCONF_EXTENSIONS_H
|
||||
#define NAUTILUS_GCONF_EXTENSIONS_H
|
||||
|
||||
#include <gconf/gconf.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
GConfClient *nautilus_gconf_client_get_global (void);
|
||||
gboolean nautilus_gconf_handle_error (GError **error);
|
||||
void nautilus_gconf_set_boolean (const char *key,
|
||||
gboolean boolean_value);
|
||||
gboolean nautilus_gconf_get_boolean (const char *key);
|
||||
int nautilus_gconf_get_integer (const char *key);
|
||||
void nautilus_gconf_set_integer (const char *key,
|
||||
int int_value);
|
||||
char *nautilus_gconf_get_string (const char *key);
|
||||
void nautilus_gconf_set_string (const char *key,
|
||||
const char *string_value);
|
||||
GSList *nautilus_gconf_get_string_list (const char *key);
|
||||
void nautilus_gconf_set_string_list (const char *key,
|
||||
GSList *string_list_value);
|
||||
gboolean nautilus_gconf_is_default (const char *key);
|
||||
gboolean nautilus_gconf_monitor_directory (const char *directory);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
#endif /* NAUTILUS_GCONF_EXTENSIONS_H */
|
File diff suppressed because it is too large
Load diff
|
@ -36,13 +36,13 @@ BEGIN_GNOME_DECLS
|
|||
*/
|
||||
|
||||
/* Which theme is active */
|
||||
#define NAUTILUS_PREFERENCES_THEME "/apps/nautilus/preferences/theme"
|
||||
#define NAUTILUS_PREFERENCES_THEME "preferences/theme"
|
||||
/* Which text attributes appear beneath icon names */
|
||||
#define NAUTILUS_PREFERENCES_ICON_CAPTIONS "/apps/nautilus/icon_view/captions"
|
||||
#define NAUTILUS_PREFERENCES_ICON_CAPTIONS "icon_view/captions"
|
||||
/* How wide the sidebar is (or how wide it will be when expanded) */
|
||||
#define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "/apps/nautilus/preferences/sidebar_width"
|
||||
#define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "preferences/sidebar_width"
|
||||
/* Keep track of the sound playing process */
|
||||
#define NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE "/apps/nautilus/preferences/sound_state"
|
||||
#define NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE "preferences/sound_state"
|
||||
|
||||
/*
|
||||
* The following preferences are coupled to the user level.
|
||||
|
@ -139,7 +139,6 @@ void nautilus_global_preferences_initialize (v
|
|||
void nautilus_global_preferences_show_dialog (void);
|
||||
void nautilus_global_preferences_hide_dialog (void);
|
||||
void nautilus_global_preferences_set_dialog_title (const char *title);
|
||||
void nautilus_global_preferences_dialog_update (void);
|
||||
|
||||
/* Sidebar */
|
||||
GList *nautilus_global_preferences_get_enabled_sidebar_panel_view_identifiers (void);
|
||||
|
|
|
@ -671,10 +671,7 @@ static gboolean
|
|||
in_single_click_mode ()
|
||||
{
|
||||
/* Perhaps this should be computed elsewhere and passed in. */
|
||||
return nautilus_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_CLICK_POLICY, NAUTILUS_CLICK_POLICY_DOUBLE) ==
|
||||
NAUTILUS_CLICK_POLICY_SINGLE;
|
||||
|
||||
return nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_SINGLE;
|
||||
}
|
||||
|
||||
/* Keep these for a bit while we work on performance of draw_or_measure_label_text. */
|
||||
|
|
|
@ -2378,8 +2378,8 @@ button_press_event (GtkWidget *widget,
|
|||
last_click_time = current_time;
|
||||
|
||||
/* Ignore double click if we are in single click mode */
|
||||
click_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
|
||||
NAUTILUS_CLICK_POLICY_DOUBLE);
|
||||
click_mode = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CLICK_POLICY);
|
||||
|
||||
if (click_mode == NAUTILUS_CLICK_POLICY_SINGLE && click_count >= 2) {
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -95,8 +95,6 @@ static const char *icon_file_name_suffixes[] =
|
|||
|
||||
#define EMBLEM_NAME_PREFIX "emblem-"
|
||||
|
||||
#define DEFAULT_ICON_THEME "default"
|
||||
|
||||
/* This used to be called ICON_CACHE_MAX_ENTRIES, but it's misleading
|
||||
* to call it that, since we can have any number of entries in the
|
||||
* cache if the caller keeps the pixbuf around (we only get rid of
|
||||
|
@ -1108,8 +1106,7 @@ icon_theme_changed_callback (gpointer user_data)
|
|||
/* Consult the user preference and the Nautilus theme. In the
|
||||
* long run, we sould just get rid of the user preference.
|
||||
*/
|
||||
theme_preference = nautilus_preferences_get
|
||||
(NAUTILUS_PREFERENCES_THEME, DEFAULT_ICON_THEME);
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME);
|
||||
icon_theme = nautilus_theme_get_theme_data ("icons", "ICON_THEME");
|
||||
|
||||
set_theme (icon_theme == NULL ? theme_preference : icon_theme);
|
||||
|
@ -1296,9 +1293,7 @@ should_display_image_file_as_itself (NautilusFile *file, gboolean anti_aliased)
|
|||
{
|
||||
NautilusSpeedTradeoffValue preference_value;
|
||||
|
||||
preference_value = nautilus_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
|
||||
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
|
||||
preference_value = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS);
|
||||
|
||||
/* see if there's a proxy thumbnail to indicate that thumbnailing
|
||||
* failed, in which case we shouldn't use the thumbnail.
|
||||
|
|
|
@ -41,6 +41,8 @@ void nautilus_run_lib_self_checks (void);
|
|||
#define NAUTILUS_LIB_FOR_EACH_SELF_CHECK_FUNCTION(macro) \
|
||||
macro (nautilus_self_check_string) \
|
||||
macro (nautilus_self_check_string_list) \
|
||||
macro (nautilus_self_check_enumeration) \
|
||||
macro (nautilus_self_check_preferences) \
|
||||
macro (nautilus_self_check_scalable_font) \
|
||||
macro (nautilus_self_check_string_map) \
|
||||
macro (nautilus_self_check_glib_extensions) \
|
||||
|
@ -54,7 +56,6 @@ void nautilus_run_lib_self_checks (void);
|
|||
macro (nautilus_self_check_file) \
|
||||
macro (nautilus_self_check_icon_container) \
|
||||
macro (nautilus_self_check_icon_factory) \
|
||||
macro (nautilus_self_check_preference) \
|
||||
/* Add new self-check functions to the list above this line. */
|
||||
|
||||
/* Generate prototypes for all the functions. */
|
||||
|
|
|
@ -1,865 +0,0 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-preference.c - An object to describe a single Nautilus preference.
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "nautilus-preference.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nautilus-gtk-macros.h"
|
||||
#include "nautilus-string-list.h"
|
||||
#include "nautilus-user-level-manager.h"
|
||||
#include "nautilus-lib-self-check-functions.h"
|
||||
|
||||
/*
|
||||
* PreferenceHashNode:
|
||||
*
|
||||
* A structure to manage preference hash table nodes.
|
||||
* Preferences are hash tables. The hash key is the preference name
|
||||
* (a string). The hash value is a pointer of the following struct:
|
||||
*/
|
||||
typedef struct {
|
||||
NautilusPreference *preference;
|
||||
} PreferenceHashNode;
|
||||
|
||||
static GHashTable *global_preference_table = NULL;
|
||||
|
||||
static const char PREFERENCE_NO_DESCRIPTION[] = "No Description";
|
||||
/*
|
||||
* NautilusPreferenceDetail:
|
||||
*
|
||||
* Private members for NautilusPreference.
|
||||
*/
|
||||
struct NautilusPreferenceDetail {
|
||||
char *name;
|
||||
char *description;
|
||||
NautilusPreferenceType type;
|
||||
gpointer type_info;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
NautilusStringList *names;
|
||||
NautilusStringList *descriptions;
|
||||
GList *values;
|
||||
guint num_entries;
|
||||
} PreferenceEnumInfo;
|
||||
|
||||
/* NautilusPreferenceClass methods */
|
||||
static void nautilus_preference_initialize_class (NautilusPreferenceClass *klass);
|
||||
static void nautilus_preference_initialize (NautilusPreference *preference);
|
||||
|
||||
/* GtkObjectClass methods */
|
||||
static void nautilus_preference_destroy (GtkObject *object);
|
||||
|
||||
/* Private stuff */
|
||||
static void preference_free_type_info (NautilusPreference *preference);
|
||||
static PreferenceHashNode *preference_hash_node_lookup (const char *name);
|
||||
static void destroy_global_preference_table (void);
|
||||
|
||||
static void
|
||||
preference_initialize_if_needed (void)
|
||||
{
|
||||
if (global_preference_table != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
global_preference_table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
g_atexit (destroy_global_preference_table);
|
||||
}
|
||||
|
||||
|
||||
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreference, nautilus_preference, GTK_TYPE_OBJECT)
|
||||
|
||||
/**
|
||||
* nautilus_preference_initialize_class
|
||||
*
|
||||
* NautilusPreferenceClass class initialization method.
|
||||
* @preference_class: The class to initialize.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
nautilus_preference_initialize_class (NautilusPreferenceClass *preference_class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (preference_class);
|
||||
|
||||
parent_class = gtk_type_class (gtk_object_get_type ());
|
||||
|
||||
/* GtkObjectClass */
|
||||
object_class->destroy = nautilus_preference_destroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_initialize
|
||||
*
|
||||
* GtkObject initialization method.
|
||||
* @object: The NautilusPreference object to initialize.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
nautilus_preference_initialize (NautilusPreference *preference)
|
||||
{
|
||||
preference->detail = g_new (NautilusPreferenceDetail, 1);
|
||||
|
||||
preference->detail->name = NULL;
|
||||
|
||||
preference->detail->description = NULL;
|
||||
|
||||
preference->detail->type_info = NULL;
|
||||
|
||||
preference->detail->type = NAUTILUS_PREFERENCE_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_destroy
|
||||
*
|
||||
* GtkObject destruction method. Chains to super class.
|
||||
* @object: The NautilusPreference object to destroy.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
nautilus_preference_destroy (GtkObject *object)
|
||||
{
|
||||
NautilusPreference *preference;
|
||||
|
||||
preference = NAUTILUS_PREFERENCE (object);
|
||||
|
||||
if (preference->detail->name != NULL)
|
||||
g_free (preference->detail->name);
|
||||
|
||||
if (preference->detail->description != NULL)
|
||||
g_free (preference->detail->description);
|
||||
|
||||
preference_free_type_info (preference);
|
||||
|
||||
g_free (preference->detail);
|
||||
|
||||
/* Chain */
|
||||
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
|
||||
}
|
||||
|
||||
/**
|
||||
* preference_free_type_info
|
||||
*
|
||||
* Free the type specific info attatched to this type
|
||||
* @preference: Pointer to self.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
preference_free_type_info (NautilusPreference *preference)
|
||||
{
|
||||
g_assert (preference != NULL);
|
||||
g_assert (NAUTILUS_IS_PREFERENCE (preference));
|
||||
|
||||
switch (preference->detail->type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
if (preference->detail->type_info) {
|
||||
PreferenceEnumInfo * info;
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
if (info->names)
|
||||
nautilus_string_list_free (info->names);
|
||||
|
||||
if (info->descriptions)
|
||||
nautilus_string_list_free (info->descriptions);
|
||||
|
||||
if (info->values)
|
||||
g_list_free (info->values);
|
||||
|
||||
info->num_entries = 0;
|
||||
|
||||
g_free (preference->detail->type_info);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
preference->detail->type_info = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* preference_type_info_allocate
|
||||
*
|
||||
* Allocate the type specific info attatched to this type
|
||||
* @preference: Pointer to self.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
preference_allocate_type_info (NautilusPreference *preference)
|
||||
{
|
||||
g_assert (NAUTILUS_IS_PREFERENCE (preference));
|
||||
|
||||
switch (preference->detail->type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
{
|
||||
PreferenceEnumInfo * info;
|
||||
|
||||
g_assert (preference->detail->type_info == NULL);
|
||||
|
||||
info = g_new (PreferenceEnumInfo, 1);
|
||||
|
||||
info->names = nautilus_string_list_new (TRUE);
|
||||
|
||||
info->descriptions = nautilus_string_list_new (TRUE);
|
||||
|
||||
info->values = NULL;
|
||||
|
||||
info->num_entries = 0;
|
||||
|
||||
preference->detail->type_info = (gpointer) info;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_new
|
||||
*
|
||||
* Allocate a new preference object. By default, preferences created with this
|
||||
* function will have a type of NAUTILUS_PREFERENCE_STRING.
|
||||
* @name: The name of the preference.
|
||||
*
|
||||
* Return value: A newly allocated preference.
|
||||
*
|
||||
**/
|
||||
GtkObject *
|
||||
nautilus_preference_new (const char *name)
|
||||
{
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return nautilus_preference_new_from_type (name, NAUTILUS_PREFERENCE_STRING);
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_new_from_type
|
||||
*
|
||||
* Allocate a new preference object with the given type.
|
||||
* @name: The name of the preference.
|
||||
* @type: The type for the new preference.
|
||||
*
|
||||
* Return value: A newly allocated preference.
|
||||
*
|
||||
**/
|
||||
GtkObject *
|
||||
nautilus_preference_new_from_type (const char *name,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
NautilusPreference *preference;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
preference = NAUTILUS_PREFERENCE (gtk_object_new (nautilus_preference_get_type (), NULL));
|
||||
gtk_object_ref (GTK_OBJECT (preference));
|
||||
gtk_object_sink (GTK_OBJECT (preference));
|
||||
|
||||
preference->detail->name = g_strdup (name);
|
||||
preference->detail->type = type;
|
||||
|
||||
preference_allocate_type_info (preference);
|
||||
|
||||
return GTK_OBJECT (preference);
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_get_preference_type
|
||||
*
|
||||
* Get the type for the given preference.
|
||||
* @preference: The preference object.
|
||||
*
|
||||
* Return value: The type for the preference.
|
||||
*
|
||||
**/
|
||||
NautilusPreferenceType
|
||||
nautilus_preference_get_preference_type (const NautilusPreference *preference)
|
||||
{
|
||||
g_return_val_if_fail (preference != NULL, NAUTILUS_PREFERENCE_STRING);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NAUTILUS_PREFERENCE_STRING);
|
||||
|
||||
return preference->detail->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_set_preference_type
|
||||
*
|
||||
* Set the type for the given preference. Yes it possible to morph the preference type
|
||||
* in midair. This is actually an important feature so that users of preferences can pull
|
||||
* them out of their assess without having to register them first. Changing the preference
|
||||
* type is guranteed not to leak resources regardless of the old/new types. (such as extra
|
||||
* enum type info).
|
||||
*
|
||||
* @preference: The preference object.
|
||||
* @type: The new type of the preference.
|
||||
*
|
||||
**/
|
||||
void
|
||||
nautilus_preference_set_preference_type (NautilusPreference *preference,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
g_return_if_fail (preference != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_PREFERENCE (preference));
|
||||
|
||||
/* cmon */
|
||||
if (preference->detail->type == type)
|
||||
return;
|
||||
|
||||
/* Free the old type info */
|
||||
preference_free_type_info (preference);
|
||||
|
||||
preference->detail->type = type;
|
||||
|
||||
/* allocate the new type info */
|
||||
preference_allocate_type_info (preference);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nautilus_preference_get_name
|
||||
*
|
||||
* Get a copy of the name for the given preference.
|
||||
* @preference: The preference object.
|
||||
*
|
||||
* Return value: A newly allocated string with the prefrence name. This function is always
|
||||
* guranteed to return a valid newly allocated string (the default is "").
|
||||
*
|
||||
**/
|
||||
char *
|
||||
nautilus_preference_get_name (const NautilusPreference *preference)
|
||||
{
|
||||
g_return_val_if_fail (preference != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NULL);
|
||||
|
||||
return g_strdup (preference->detail->name ? preference->detail->name : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_get_description
|
||||
*
|
||||
* Get a copy of the description for the given preference.
|
||||
* @preference: The preference object.
|
||||
*
|
||||
* Return value: A newly allocated string with the prefrence description. This function is always
|
||||
* guranteed to return a valid newly allocated string (the default is "").
|
||||
*
|
||||
**/
|
||||
char *
|
||||
nautilus_preference_get_description (const NautilusPreference *preference)
|
||||
{
|
||||
g_return_val_if_fail (preference != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NULL);
|
||||
|
||||
return g_strdup (preference->detail->description ?
|
||||
preference->detail->description :
|
||||
PREFERENCE_NO_DESCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_set_description
|
||||
*
|
||||
* Set the description for the current preference.
|
||||
* @preference: The preference object.
|
||||
* @description: The new description string.
|
||||
*
|
||||
**/
|
||||
void
|
||||
nautilus_preference_set_description (NautilusPreference *preference,
|
||||
const char * description)
|
||||
{
|
||||
g_return_if_fail (preference != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_PREFERENCE (preference));
|
||||
g_return_if_fail (description != NULL);
|
||||
|
||||
if (preference->detail->description)
|
||||
g_free (preference->detail->description);
|
||||
|
||||
preference->detail->description = g_strdup (description);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preference_enum_add_entry (NautilusPreference *preference,
|
||||
const char *entry_name,
|
||||
const char *entry_description,
|
||||
gint entry_value)
|
||||
{
|
||||
PreferenceEnumInfo *info;
|
||||
|
||||
g_return_if_fail (preference != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_PREFERENCE (preference));
|
||||
g_return_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM);
|
||||
g_return_if_fail (entry_name != NULL);
|
||||
|
||||
g_assert (preference->detail->type_info != NULL);
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
nautilus_string_list_insert (info->names, entry_name);
|
||||
|
||||
nautilus_string_list_insert (info->descriptions,
|
||||
entry_description ? entry_description : PREFERENCE_NO_DESCRIPTION);
|
||||
|
||||
info->values = g_list_append (info->values, GINT_TO_POINTER (entry_value));
|
||||
|
||||
info->num_entries++;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_preference_enum_get_nth_entry_name (const NautilusPreference *preference,
|
||||
guint n)
|
||||
{
|
||||
PreferenceEnumInfo *info;
|
||||
|
||||
g_return_val_if_fail (preference != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NULL);
|
||||
g_return_val_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM, NULL);
|
||||
|
||||
g_assert (preference->detail->type_info != NULL);
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
if (n < nautilus_string_list_get_length (info->names))
|
||||
return nautilus_string_list_nth (info->names, n);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_preference_enum_get_nth_entry_description (const NautilusPreference *preference,
|
||||
guint n)
|
||||
{
|
||||
PreferenceEnumInfo *info;
|
||||
|
||||
g_return_val_if_fail (preference != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NULL);
|
||||
g_return_val_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM, NULL);
|
||||
|
||||
g_assert (preference->detail->type_info != NULL);
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
if (n < nautilus_string_list_get_length (info->descriptions))
|
||||
return nautilus_string_list_nth (info->descriptions, n);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gint
|
||||
nautilus_preference_enum_get_nth_entry_value (const NautilusPreference *preference,
|
||||
guint n)
|
||||
{
|
||||
PreferenceEnumInfo *info;
|
||||
|
||||
g_return_val_if_fail (preference != NULL, 0);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), 0);
|
||||
g_return_val_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM, 0);
|
||||
|
||||
g_assert (preference->detail->type_info != NULL);
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
if (n < g_list_length (info->values))
|
||||
return GPOINTER_TO_INT (g_list_nth_data (info->values, n));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_preference_enum_get_num_entries (const NautilusPreference *preference)
|
||||
{
|
||||
g_return_val_if_fail (preference != NULL, 0);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), 0);
|
||||
g_return_val_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM, 0);
|
||||
|
||||
if (preference->detail->type_info) {
|
||||
PreferenceEnumInfo *info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
return info->num_entries;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* preference_hash_node_alloc
|
||||
*
|
||||
* Allocate a preference hash node.
|
||||
* @info: Pointer to info structure to use for the node memebers.
|
||||
*
|
||||
* Return value: A newly allocated node.
|
||||
**/
|
||||
static PreferenceHashNode *
|
||||
preference_hash_node_alloc (const char *name,
|
||||
const char *description,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
PreferenceHashNode * node;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
||||
node = g_new (PreferenceHashNode, 1);
|
||||
|
||||
node->preference = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type (name, type));
|
||||
|
||||
if (description != NULL) {
|
||||
nautilus_preference_set_description (node->preference, description);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* preference_hash_node_free
|
||||
*
|
||||
* Free a preference hash node members along with the node itself.
|
||||
* @preference_hash_node: The node to free.
|
||||
**/
|
||||
static void
|
||||
preference_hash_node_free (PreferenceHashNode *node)
|
||||
{
|
||||
gtk_object_unref (GTK_OBJECT (node->preference));
|
||||
g_free (node);
|
||||
}
|
||||
|
||||
/**
|
||||
* preference_hash_node_free_func
|
||||
*
|
||||
* A function that frees a pref hash node. It is meant to be fed to
|
||||
* g_hash_table_foreach ()
|
||||
* @key: The hash key privately maintained by the GHashTable.
|
||||
* @value: The hash value privately maintained by the GHashTable.
|
||||
* @callback_data: The callback_data privately maintained by the GHashTable.
|
||||
**/
|
||||
static void
|
||||
preference_hash_node_free_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_free (key);
|
||||
preference_hash_node_free (value);
|
||||
}
|
||||
|
||||
static void
|
||||
preference_register (const char *name,
|
||||
const char *description,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
PreferenceHashNode *node;
|
||||
|
||||
g_return_if_fail (name != NULL);
|
||||
g_return_if_fail (description != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup (name);
|
||||
if (node != NULL) {
|
||||
g_warning ("the '%s' preference is already registered", name);
|
||||
return;
|
||||
}
|
||||
|
||||
node = preference_hash_node_alloc (name, description, type);
|
||||
g_hash_table_insert (global_preference_table, g_strdup (name), node);
|
||||
|
||||
g_assert (node->preference != NULL);
|
||||
}
|
||||
|
||||
static PreferenceHashNode *
|
||||
preference_hash_node_lookup (const char *name)
|
||||
{
|
||||
gpointer hash_value;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
hash_value = g_hash_table_lookup (global_preference_table, name);
|
||||
|
||||
return (PreferenceHashNode *) hash_value;
|
||||
}
|
||||
|
||||
static PreferenceHashNode *
|
||||
preference_hash_node_lookup_with_registration (const char *name,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
PreferenceHashNode * node;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup (name);
|
||||
|
||||
if (!node) {
|
||||
preference_register (name,
|
||||
"Unspecified Description",
|
||||
type);
|
||||
|
||||
node = preference_hash_node_lookup (name);
|
||||
}
|
||||
|
||||
g_assert (node != NULL);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_global_preference_table (void)
|
||||
{
|
||||
g_hash_table_foreach (global_preference_table,
|
||||
preference_hash_node_free_func,
|
||||
NULL);
|
||||
|
||||
g_hash_table_destroy (global_preference_table);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Public functions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* nautilus_preference_find_by_name
|
||||
*
|
||||
* Search for a named preference in the given preference and return it.
|
||||
* @preference: The preference to search
|
||||
*
|
||||
* Return value: A referenced pointer to the preference object that corresponds
|
||||
* to the given preference name. The caller should gtk_object_unref() the return
|
||||
* value of this function.
|
||||
**/
|
||||
NautilusPreference *
|
||||
nautilus_preference_find_by_name (const char *name)
|
||||
{
|
||||
PreferenceHashNode *node;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup (name);
|
||||
|
||||
g_assert (node != NULL);
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (node->preference));
|
||||
|
||||
return node->preference;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preference_set_info_by_name (const char *name,
|
||||
const char *description,
|
||||
NautilusPreferenceType type,
|
||||
gconstpointer *default_values,
|
||||
guint num_default_values)
|
||||
{
|
||||
PreferenceHashNode *node;
|
||||
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup_with_registration (name, type);
|
||||
|
||||
g_assert (node != NULL);
|
||||
g_assert (node->preference != NULL);
|
||||
|
||||
if (description) {
|
||||
nautilus_preference_set_description (node->preference, description);
|
||||
}
|
||||
|
||||
if (default_values && num_default_values) {
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < num_default_values; i++)
|
||||
{
|
||||
nautilus_user_level_manager_set_default_value_if_needed (name,
|
||||
type,
|
||||
i,
|
||||
default_values[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preference_enum_add_entry_by_name (const char *name,
|
||||
const char *entry_name,
|
||||
const char *entry_description,
|
||||
int entry_value)
|
||||
{
|
||||
PreferenceHashNode *node;
|
||||
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup_with_registration (name, NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
g_assert (node != NULL);
|
||||
g_assert (node->preference != NULL);
|
||||
|
||||
g_assert (nautilus_preference_get_preference_type (node->preference) == NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
nautilus_preference_enum_add_entry (node->preference,
|
||||
entry_name,
|
||||
entry_description,
|
||||
entry_value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
|
||||
|
||||
void
|
||||
nautilus_self_check_preference (void)
|
||||
{
|
||||
NautilusPreference *preference;
|
||||
|
||||
preference = NAUTILUS_PREFERENCE (nautilus_preference_new ("foo/bar"));
|
||||
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_get_preference_type (preference), NAUTILUS_PREFERENCE_STRING);
|
||||
|
||||
/* Test boolean things */
|
||||
{
|
||||
NautilusPreference *bp;
|
||||
|
||||
bp = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type ("active", NAUTILUS_PREFERENCE_BOOLEAN));
|
||||
|
||||
nautilus_preference_set_description (bp, "Is it active ?");
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_get_name (bp), "active");
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_get_description (bp), "Is it active ?");
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (bp));
|
||||
}
|
||||
|
||||
/* Test enumeration things */
|
||||
{
|
||||
NautilusPreference *ep;
|
||||
|
||||
ep = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type ("color",NAUTILUS_PREFERENCE_ENUM));
|
||||
|
||||
nautilus_preference_enum_add_entry (ep, "red", "A red something", 100);
|
||||
nautilus_preference_enum_add_entry (ep, "green", "A green something", 200);
|
||||
nautilus_preference_enum_add_entry (ep, "blue", "A blue something", 300);
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_get_name (ep), "color");
|
||||
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_enum_get_num_entries (ep), 3);
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_enum_get_nth_entry_name (ep, 0), "red");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_enum_get_nth_entry_name (ep, 1), "green");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_enum_get_nth_entry_name (ep, 2), "blue");
|
||||
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_enum_get_nth_entry_value (ep, 0), 100);
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_enum_get_nth_entry_value (ep, 1), 200);
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_enum_get_nth_entry_value (ep, 2), 300);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (ep));
|
||||
}
|
||||
|
||||
/* Test string things */
|
||||
{
|
||||
NautilusPreference *sp;
|
||||
|
||||
sp = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type ("font", NAUTILUS_PREFERENCE_STRING));
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_get_name (sp), "font");
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (sp));
|
||||
}
|
||||
|
||||
|
||||
/* Allocate a bunch of preference objects to test that they dont leak */
|
||||
{
|
||||
const guint num_to_allocate = 20; /* larger number is too slow with memprof */
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < num_to_allocate; i++)
|
||||
{
|
||||
NautilusPreference *bp;
|
||||
char *bn;
|
||||
|
||||
bn = g_strdup_printf ("bp_%d", i);
|
||||
|
||||
bp = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type (bn, NAUTILUS_PREFERENCE_BOOLEAN));
|
||||
|
||||
g_free (bn);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (bp));
|
||||
}
|
||||
|
||||
for (i = 0; i < num_to_allocate; i++)
|
||||
{
|
||||
NautilusPreference *ep;
|
||||
char *en;
|
||||
|
||||
en = g_strdup_printf ("ep_%d", i);
|
||||
|
||||
ep = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type (en, NAUTILUS_PREFERENCE_ENUM));
|
||||
|
||||
nautilus_preference_enum_add_entry (ep, "small", "A small foo", 1);
|
||||
nautilus_preference_enum_add_entry (ep, "medium", "A medium foo", 2);
|
||||
nautilus_preference_enum_add_entry (ep, "large", "A large foo", 3);
|
||||
|
||||
g_free (en);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (ep));
|
||||
}
|
||||
|
||||
for (i = 0; i < num_to_allocate; i++)
|
||||
{
|
||||
NautilusPreference *sp;
|
||||
char *sn;
|
||||
|
||||
sn = g_strdup_printf ("sp_%d", i);
|
||||
|
||||
sp = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type (sn, NAUTILUS_PREFERENCE_STRING));
|
||||
|
||||
g_free (sn);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (sp));
|
||||
}
|
||||
}
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (preference));
|
||||
}
|
||||
|
||||
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
|
|
@ -1,112 +0,0 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-preference.h - An object to describe a single Nautilus preference.
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_PREFERENCE_H
|
||||
#define NAUTILUS_PREFERENCE_H
|
||||
|
||||
#include <gtk/gtkobject.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libnautilus-extensions/nautilus-string-list.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
#define NAUTILUS_TYPE_PREFERENCE (nautilus_preference_get_type ())
|
||||
#define NAUTILUS_PREFERENCE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_PREFERENCE, NautilusPreference))
|
||||
#define NAUTILUS_PREFERENCE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PREFERENCE, NautilusPreferenceClass))
|
||||
#define NAUTILUS_IS_PREFERENCE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFERENCE))
|
||||
#define NAUTILUS_IS_PREFERENCE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFERENCE))
|
||||
|
||||
typedef struct NautilusPreference NautilusPreference;
|
||||
typedef struct NautilusPreferenceClass NautilusPreferenceClass;
|
||||
typedef struct NautilusPreferenceDetail NautilusPreferenceDetail;
|
||||
|
||||
struct NautilusPreference
|
||||
{
|
||||
GtkObject object;
|
||||
NautilusPreferenceDetail *detail;
|
||||
};
|
||||
|
||||
/*
|
||||
* NautilusPreferenceType:
|
||||
*
|
||||
* The types of supported preferences. By default, a preference is of type
|
||||
* NAUTILUS_PREFERENCE_STRING, unless otherwise specified in the api.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_PREFERENCE_STRING,
|
||||
NAUTILUS_PREFERENCE_BOOLEAN,
|
||||
NAUTILUS_PREFERENCE_ENUM
|
||||
} NautilusPreferenceType;
|
||||
|
||||
struct NautilusPreferenceClass
|
||||
{
|
||||
GtkObjectClass object_class;
|
||||
};
|
||||
|
||||
GtkType nautilus_preference_get_type (void);
|
||||
GtkObject * nautilus_preference_new (const char *name);
|
||||
GtkObject * nautilus_preference_new_from_type (const char *name,
|
||||
NautilusPreferenceType type);
|
||||
NautilusPreferenceType nautilus_preference_get_preference_type (const NautilusPreference *preference);
|
||||
void nautilus_preference_set_preference_type (NautilusPreference *preference,
|
||||
NautilusPreferenceType type);
|
||||
char * nautilus_preference_get_name (const NautilusPreference *preference);
|
||||
char * nautilus_preference_get_description (const NautilusPreference *preference);
|
||||
void nautilus_preference_set_description (NautilusPreference *preference,
|
||||
const char *description);
|
||||
/* Methods to deal with enum preferences */
|
||||
void nautilus_preference_enum_add_entry (NautilusPreference *preference,
|
||||
const char *entry_name,
|
||||
const char *entry_description,
|
||||
gint entry_value);
|
||||
char * nautilus_preference_enum_get_nth_entry_name (const NautilusPreference *preference,
|
||||
guint n);
|
||||
char * nautilus_preference_enum_get_nth_entry_description (const NautilusPreference *preference,
|
||||
guint n);
|
||||
gint nautilus_preference_enum_get_nth_entry_value (const NautilusPreference *preference,
|
||||
guint n);
|
||||
guint nautilus_preference_enum_get_num_entries (const NautilusPreference *preference);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
NautilusPreference *nautilus_preference_find_by_name (const char *name);
|
||||
void nautilus_preference_set_info_by_name (const char *name,
|
||||
const char *description,
|
||||
NautilusPreferenceType type,
|
||||
gconstpointer *default_values,
|
||||
guint num_default_values);
|
||||
void nautilus_preference_enum_add_entry_by_name (const char *name,
|
||||
const char *entry_name,
|
||||
const char *entry_description,
|
||||
int entry_value);
|
||||
|
||||
void nautilus_preference_shutdown (void);
|
||||
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
#endif /* NAUTILUS_PREFERENCE_H */
|
|
@ -337,8 +337,8 @@ nautilus_preferences_box_add_pane (NautilusPreferencesBox *prefs_box,
|
|||
info = pane_info_alloc (pane_title);
|
||||
|
||||
prefs_box->details->panes = g_list_append (prefs_box->details->panes,
|
||||
(gpointer) info);
|
||||
|
||||
(gpointer) info);
|
||||
|
||||
info->pane_widget = nautilus_preferences_pane_new (pane_title,
|
||||
pane_description);
|
||||
|
||||
|
@ -355,3 +355,17 @@ nautilus_preferences_box_add_pane (NautilusPreferencesBox *prefs_box,
|
|||
|
||||
return info->pane_widget;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_box_update (NautilusPreferencesBox *prefs_box)
|
||||
{
|
||||
GList *iterator;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_PREFS_BOX (prefs_box));
|
||||
|
||||
for (iterator = prefs_box->details->panes; iterator != NULL; iterator = iterator->next) {
|
||||
PaneInfo *info = iterator->data;
|
||||
|
||||
nautilus_preferences_pane_update (NAUTILUS_PREFERENCES_PANE (info->pane_widget));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,10 +58,11 @@ struct _NautilusPreferencesBoxClass
|
|||
};
|
||||
|
||||
GtkType nautilus_preferences_box_get_type (void);
|
||||
GtkWidget* nautilus_preferences_box_new (const gchar *box_title);
|
||||
GtkWidget* nautilus_preferences_box_new (const gchar *box_title);
|
||||
GtkWidget* nautilus_preferences_box_add_pane (NautilusPreferencesBox *prefs_box,
|
||||
const gchar *pane_title,
|
||||
const gchar *pane_description);
|
||||
const gchar *pane_title,
|
||||
const gchar *pane_description);
|
||||
void nautilus_preferences_box_update (NautilusPreferencesBox *prefs_box);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ static void dialog_destroy (GtkWidget *wi
|
|||
/* Misc private stuff */
|
||||
static void nautilus_preferences_dialog_construct (NautilusPreferencesDialog *prefs_dialog,
|
||||
const gchar *dialog_title);
|
||||
static void user_level_changed_callback (gpointer callback_data);
|
||||
|
||||
|
||||
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferencesDialog,
|
||||
|
@ -114,6 +115,8 @@ nautilus_preferences_dialog_initialize (NautilusPreferencesDialog * prefs_dialog
|
|||
prefs_dialog->details = g_new (NautilusPreferencesDialogDetails, 1);
|
||||
|
||||
prefs_dialog->details->prefs_box = NULL;
|
||||
|
||||
nautilus_preferences_add_callback ("user_level", user_level_changed_callback, prefs_dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -238,6 +241,8 @@ nautilus_preferences_dialog_destroy(GtkObject* object)
|
|||
|
||||
prefs_dialog = NAUTILUS_PREFERENCES_DIALOG(object);
|
||||
|
||||
nautilus_preferences_remove_callback ("user_level", user_level_changed_callback, prefs_dialog);
|
||||
|
||||
g_free (prefs_dialog->details);
|
||||
|
||||
/* Chain */
|
||||
|
@ -253,3 +258,19 @@ nautilus_preferences_dialog_get_prefs_box (NautilusPreferencesDialog *prefs_dial
|
|||
|
||||
return prefs_dialog->details->prefs_box;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_dialog_update (NautilusPreferencesDialog *preferences_dialog)
|
||||
{
|
||||
g_return_if_fail (NAUTILUS_IS_PREFS_DIALOG (preferences_dialog));
|
||||
|
||||
nautilus_preferences_box_update (NAUTILUS_PREFERENCES_BOX (preferences_dialog->details->prefs_box));
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_changed_callback (gpointer callback_data)
|
||||
{
|
||||
g_return_if_fail (NAUTILUS_IS_PREFS_DIALOG (callback_data));
|
||||
|
||||
nautilus_preferences_dialog_update (NAUTILUS_PREFERENCES_DIALOG (callback_data));
|
||||
}
|
||||
|
|
|
@ -58,8 +58,9 @@ struct _NautilusPreferencesDialogClass
|
|||
};
|
||||
|
||||
GtkType nautilus_preferences_dialog_get_type (void);
|
||||
GtkWidget* nautilus_preferences_dialog_new (const gchar *dialog_title);
|
||||
GtkWidget* nautilus_preferences_dialog_new (const gchar *dialog_title);
|
||||
GtkWidget* nautilus_preferences_dialog_get_prefs_box (NautilusPreferencesDialog *prefs_dialog);
|
||||
void nautilus_preferences_dialog_update (NautilusPreferencesDialog *prefs_dialog);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ struct _NautilusPreferencesGroupDetails
|
|||
GtkWidget *content_box;
|
||||
GtkWidget *description_label;
|
||||
gboolean show_description;
|
||||
|
||||
GList *items;
|
||||
};
|
||||
|
||||
static const gint PREFERENCES_GROUP_NOT_FOUND = -1;
|
||||
|
@ -96,6 +98,7 @@ nautilus_preferences_group_initialize (NautilusPreferencesGroup *group)
|
|||
group->details->content_box = NULL;
|
||||
group->details->description_label = NULL;
|
||||
group->details->show_description = FALSE;
|
||||
group->details->items = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -111,6 +114,7 @@ nautilus_preferences_group_destroy(GtkObject* object)
|
|||
|
||||
group = NAUTILUS_PREFERENCES_GROUP (object);
|
||||
|
||||
g_list_free (group->details->items);
|
||||
g_free (group->details);
|
||||
|
||||
/* Chain */
|
||||
|
@ -201,23 +205,16 @@ nautilus_preferences_group_add_item (NautilusPreferencesGroup *group,
|
|||
const char *preference_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
{
|
||||
GtkWidget *item;
|
||||
NautilusPreference *preference;
|
||||
GtkWidget *item;
|
||||
|
||||
g_return_val_if_fail (group != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_GROUP (group), NULL);
|
||||
|
||||
g_return_val_if_fail (preference_name != NULL, NULL);
|
||||
|
||||
preference = nautilus_preference_find_by_name (preference_name);
|
||||
|
||||
g_assert (preference != NULL);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (preference));
|
||||
|
||||
preference = NULL;
|
||||
|
||||
item = nautilus_preferences_item_new (preference_name, item_type);
|
||||
|
||||
group->details->items = g_list_append (group->details->items, item);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (group->details->content_box),
|
||||
item,
|
||||
|
@ -229,3 +226,45 @@ nautilus_preferences_group_add_item (NautilusPreferencesGroup *group,
|
|||
|
||||
return item;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_group_update (NautilusPreferencesGroup *group)
|
||||
{
|
||||
GList *iterator;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_PREFERENCES_GROUP (group));
|
||||
|
||||
for (iterator = group->details->items; iterator != NULL; iterator = iterator->next) {
|
||||
char *name;
|
||||
|
||||
name = nautilus_preferences_item_get_name (NAUTILUS_PREFERENCES_ITEM (iterator->data));
|
||||
|
||||
if (nautilus_preferences_is_visible (name)) {
|
||||
gtk_widget_show (GTK_WIDGET (iterator->data));
|
||||
} else {
|
||||
gtk_widget_hide (GTK_WIDGET (iterator->data));
|
||||
}
|
||||
|
||||
g_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_preferences_get_num_visible_items (const NautilusPreferencesGroup *group)
|
||||
{
|
||||
guint n = 0;
|
||||
GList *iterator;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_GROUP (group), 0);
|
||||
|
||||
for (iterator = group->details->items; iterator != NULL; iterator = iterator->next) {
|
||||
char *name;
|
||||
name = nautilus_preferences_item_get_name (NAUTILUS_PREFERENCES_ITEM (iterator->data));
|
||||
if (nautilus_preferences_is_visible (name)) {
|
||||
n++;
|
||||
}
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -56,11 +56,13 @@ struct _NautilusPreferencesGroupClass
|
|||
GtkFrameClass parent_class;
|
||||
};
|
||||
|
||||
GtkType nautilus_preferences_group_get_type (void);
|
||||
GtkWidget* nautilus_preferences_group_new (const gchar *title);
|
||||
GtkWidget* nautilus_preferences_group_add_item (NautilusPreferencesGroup *group,
|
||||
const char *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
GtkType nautilus_preferences_group_get_type (void);
|
||||
GtkWidget* nautilus_preferences_group_new (const gchar *title);
|
||||
GtkWidget* nautilus_preferences_group_add_item (NautilusPreferencesGroup *group,
|
||||
const char *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
void nautilus_preferences_group_update (NautilusPreferencesGroup *group);
|
||||
guint nautilus_preferences_get_num_visible_items (const NautilusPreferencesGroup *group);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nautilus-file-utilities.h"
|
||||
#include "nautilus-glib-extensions.h"
|
||||
#include "nautilus-gtk-macros.h"
|
||||
#include "nautilus-string.h"
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
|
||||
#include <gtk/gtkcheckbutton.h>
|
||||
|
@ -76,17 +77,19 @@ static void preferences_item_construct (NautilusPreferencesItem
|
|||
const gchar *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
static void preferences_item_create_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_short_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_boolean (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_editable_string (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_integer (NautilusPreferencesItem *item,
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_font_family (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void enum_radio_group_changed_callback (GtkWidget *button_group,
|
||||
GtkWidget *button,
|
||||
gpointer user_data);
|
||||
|
@ -96,6 +99,8 @@ static void text_item_changed_callback (GtkWidget
|
|||
gpointer user_data);
|
||||
static void editable_string_changed_callback (GtkWidget *caption,
|
||||
gpointer user_data);
|
||||
static void integer_changed_callback (GtkWidget *caption,
|
||||
gpointer user_data);
|
||||
|
||||
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferencesItem, nautilus_preferences_item, GTK_TYPE_VBOX)
|
||||
|
||||
|
@ -242,8 +247,6 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
const gchar *preference_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
{
|
||||
const NautilusPreference *preference;
|
||||
|
||||
g_assert (item != NULL);
|
||||
|
||||
g_assert (preference_name != NULL);
|
||||
|
@ -255,39 +258,36 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
|
||||
item->details->preference_name = g_strdup (preference_name);
|
||||
|
||||
preference = nautilus_preference_find_by_name (item->details->preference_name);
|
||||
|
||||
g_assert (preference != NULL);
|
||||
|
||||
/* Create the child widget according to the item type */
|
||||
switch (item_type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_ITEM_BOOLEAN:
|
||||
preferences_item_create_boolean (item, preference);
|
||||
preferences_item_create_boolean (item, preference_name);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_ENUM:
|
||||
preferences_item_create_enum (item, preference);
|
||||
preferences_item_create_enum (item, preference_name);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM:
|
||||
preferences_item_create_short_enum (item, preference);
|
||||
preferences_item_create_short_enum (item, preference_name);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY:
|
||||
preferences_item_create_font_family (item, preference);
|
||||
preferences_item_create_font_family (item, preference_name);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_THEME:
|
||||
preferences_item_create_theme (item, preference);
|
||||
preferences_item_create_theme (item, preference_name);
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING:
|
||||
preferences_item_create_editable_string (item, preference);
|
||||
preferences_item_create_editable_string (item, preference_name);
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_ITEM_INTEGER:
|
||||
preferences_item_create_integer (item, preference_name);
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (preference));
|
||||
|
||||
g_assert (item->details->child != NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (item),
|
||||
|
@ -301,33 +301,33 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
|
||||
static void
|
||||
preferences_item_create_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
guint i;
|
||||
gint value;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
|
||||
item->details->child = nautilus_radio_button_group_new (FALSE);
|
||||
|
||||
value = nautilus_preferences_get_enum (item->details->preference_name, 0);
|
||||
value = nautilus_preferences_get_integer (item->details->preference_name);
|
||||
|
||||
for (i = 0; i < nautilus_preference_enum_get_num_entries (preference); i++) {
|
||||
for (i = 0; i < nautilus_preferences_enumeration_get_num_entries (preference_name); i++) {
|
||||
char *description;
|
||||
|
||||
description = nautilus_preference_enum_get_nth_entry_description (preference, i);
|
||||
|
||||
description = nautilus_preferences_enumeration_get_nth_description (preference_name, i);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (item->details->child),
|
||||
description);
|
||||
|
||||
g_free (description);
|
||||
|
||||
if (value == nautilus_preference_enum_get_nth_entry_value (preference, i)) {
|
||||
if (value == nautilus_preferences_enumeration_get_nth_value (preference_name, i)) {
|
||||
|
||||
nautilus_radio_button_group_set_active_index (NAUTILUS_RADIO_BUTTON_GROUP (item->details->child), i);
|
||||
}
|
||||
|
@ -345,24 +345,24 @@ preferences_item_create_enum (NautilusPreferencesItem *item,
|
|||
*/
|
||||
static void
|
||||
preferences_item_create_short_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
guint i;
|
||||
gint value;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
|
||||
item->details->child = nautilus_radio_button_group_new (TRUE);
|
||||
|
||||
value = nautilus_preferences_get_enum (item->details->preference_name, 0);
|
||||
value = nautilus_preferences_get_integer (item->details->preference_name);
|
||||
|
||||
for (i = 0; i < nautilus_preference_enum_get_num_entries (preference); i++) {
|
||||
for (i = 0; i < nautilus_preferences_enumeration_get_num_entries (preference_name); i++) {
|
||||
char *description;
|
||||
|
||||
description = nautilus_preference_enum_get_nth_entry_description (preference, i);
|
||||
description = nautilus_preferences_enumeration_get_nth_description (preference_name, i);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -371,7 +371,7 @@ preferences_item_create_short_enum (NautilusPreferencesItem *item,
|
|||
|
||||
g_free (description);
|
||||
|
||||
if (value == nautilus_preference_enum_get_nth_entry_value (preference, i)) {
|
||||
if (value == nautilus_preferences_enumeration_get_nth_value (preference_name, i)) {
|
||||
|
||||
nautilus_radio_button_group_set_active_index (NAUTILUS_RADIO_BUTTON_GROUP (item->details->child), i);
|
||||
}
|
||||
|
@ -385,16 +385,16 @@ preferences_item_create_short_enum (NautilusPreferencesItem *item,
|
|||
|
||||
static void
|
||||
preferences_item_create_boolean (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
gboolean value;
|
||||
char *description;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preference_get_description (preference);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -402,7 +402,7 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
|
|||
|
||||
g_free (description);
|
||||
|
||||
value = nautilus_preferences_get_boolean (item->details->preference_name, FALSE);
|
||||
value = nautilus_preferences_get_boolean (item->details->preference_name);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item->details->child), value);
|
||||
|
||||
|
@ -414,16 +414,16 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
|
|||
|
||||
static void
|
||||
preferences_item_create_editable_string (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
char *current_value;
|
||||
char *description;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preference_get_description (preference);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -433,7 +433,7 @@ preferences_item_create_editable_string (NautilusPreferencesItem *item,
|
|||
|
||||
g_free (description);
|
||||
|
||||
current_value = nautilus_preferences_get (item->details->preference_name, "file://home/pavel");
|
||||
current_value = nautilus_preferences_get (item->details->preference_name);
|
||||
|
||||
g_assert (current_value != NULL);
|
||||
nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (item->details->child), current_value);
|
||||
|
@ -445,19 +445,52 @@ preferences_item_create_editable_string (NautilusPreferencesItem *item,
|
|||
(gpointer) item);
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_item_create_integer (NautilusPreferencesItem *item,
|
||||
const char *preference_name)
|
||||
{
|
||||
char *current_value;
|
||||
char *description;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
item->details->child = nautilus_text_caption_new ();
|
||||
|
||||
nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), description);
|
||||
|
||||
g_free (description);
|
||||
|
||||
current_value = g_strdup_printf ("%d", nautilus_preferences_get_integer (item->details->preference_name));
|
||||
|
||||
g_assert (current_value != NULL);
|
||||
nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (item->details->child), current_value);
|
||||
g_free (current_value);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (item->details->child),
|
||||
"changed",
|
||||
GTK_SIGNAL_FUNC (integer_changed_callback),
|
||||
(gpointer) item);
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_item_create_font_family (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
char *description;
|
||||
char *current_value;
|
||||
NautilusStringList *font_list;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preference_get_description (preference);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -477,7 +510,7 @@ preferences_item_create_font_family (NautilusPreferencesItem *item,
|
|||
|
||||
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (item->details->child), font_list);
|
||||
|
||||
current_value = nautilus_preferences_get (item->details->preference_name, "helvetica");
|
||||
current_value = nautilus_preferences_get (item->details->preference_name);
|
||||
|
||||
g_assert (current_value != NULL);
|
||||
g_assert (nautilus_string_list_contains (font_list, current_value));
|
||||
|
@ -575,17 +608,17 @@ add_icon_themes(NautilusStringList *theme_list, char *required_file)
|
|||
|
||||
static void
|
||||
preferences_item_create_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
char *description;
|
||||
char *current_value;
|
||||
NautilusStringList *theme_list;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preference_get_description (preference);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -601,7 +634,7 @@ preferences_item_create_theme (NautilusPreferencesItem *item,
|
|||
|
||||
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (item->details->child), theme_list);
|
||||
|
||||
current_value = nautilus_preferences_get (item->details->preference_name, "default");
|
||||
current_value = nautilus_preferences_get (item->details->preference_name);
|
||||
|
||||
g_assert (current_value != NULL);
|
||||
g_assert (nautilus_string_list_contains (theme_list, current_value));
|
||||
|
@ -641,8 +674,7 @@ static void
|
|||
enum_radio_group_changed_callback (GtkWidget *buttons, GtkWidget * button, gpointer user_data)
|
||||
{
|
||||
NautilusPreferencesItem *item;
|
||||
const NautilusPreference *preference;
|
||||
gint i;
|
||||
gint i;
|
||||
|
||||
g_assert (user_data != NULL);
|
||||
g_assert (NAUTILUS_IS_PREFERENCES_ITEM (user_data));
|
||||
|
@ -651,12 +683,10 @@ enum_radio_group_changed_callback (GtkWidget *buttons, GtkWidget * button, gpoin
|
|||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
|
||||
preference = nautilus_preference_find_by_name (item->details->preference_name);
|
||||
|
||||
i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons));
|
||||
|
||||
nautilus_preferences_set_enum (item->details->preference_name,
|
||||
nautilus_preference_enum_get_nth_entry_value (preference, i));
|
||||
|
||||
nautilus_preferences_set_integer (item->details->preference_name,
|
||||
nautilus_preferences_enumeration_get_nth_value (item->details->preference_name, i));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -698,6 +728,7 @@ text_item_changed_callback (GtkWidget *button, gpointer user_data)
|
|||
g_free (text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
editable_string_changed_callback (GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
|
@ -721,3 +752,35 @@ editable_string_changed_callback (GtkWidget *button, gpointer user_data)
|
|||
g_free (text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
integer_changed_callback (GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
NautilusPreferencesItem *item;
|
||||
char *text;
|
||||
int value = 0;
|
||||
|
||||
g_assert (user_data != NULL);
|
||||
g_assert (NAUTILUS_IS_PREFERENCES_ITEM (user_data));
|
||||
|
||||
item = NAUTILUS_PREFERENCES_ITEM (user_data);
|
||||
|
||||
g_assert (item->details->child != NULL);
|
||||
g_assert (NAUTILUS_IS_TEXT_CAPTION (item->details->child));
|
||||
|
||||
text = nautilus_text_caption_get_text (NAUTILUS_TEXT_CAPTION (item->details->child));
|
||||
|
||||
if (text != NULL) {
|
||||
nautilus_eat_str_to_int (text, &value);
|
||||
}
|
||||
|
||||
nautilus_preferences_set_integer (item->details->preference_name, value);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_preferences_item_get_name (const NautilusPreferencesItem *preferences_item)
|
||||
{
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (preferences_item), NULL);
|
||||
|
||||
return g_strdup (preferences_item->details->preference_name);
|
||||
}
|
||||
|
|
|
@ -69,12 +69,13 @@ typedef enum
|
|||
NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY,
|
||||
NAUTILUS_PREFERENCE_ITEM_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING,
|
||||
NAUTILUS_PREFERENCE_ITEM_INTEGER
|
||||
} NautilusPreferencesItemType;
|
||||
|
||||
GtkType nautilus_preferences_item_get_type (void);
|
||||
GtkWidget* nautilus_preferences_item_new (const gchar *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
|
||||
GtkWidget* nautilus_preferences_item_new (const gchar *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
char * nautilus_preferences_item_get_name (const NautilusPreferencesItem *preferences_item);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -323,4 +323,22 @@ nautilus_preferences_pane_add_item_to_nth_group (NautilusPreferencesPane *prefs_
|
|||
return item;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_pane_update (NautilusPreferencesPane *prefs_pane)
|
||||
{
|
||||
GList *iterator;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_PREFS_PANE (prefs_pane));
|
||||
|
||||
for (iterator = prefs_pane->details->groups; iterator != NULL; iterator = iterator->next) {
|
||||
NautilusPreferencesGroup *group = NAUTILUS_PREFERENCES_GROUP (iterator->data);
|
||||
|
||||
nautilus_preferences_group_update (group);
|
||||
|
||||
if (nautilus_preferences_get_num_visible_items (group) == 0) {
|
||||
gtk_widget_hide (GTK_WIDGET (group));
|
||||
} else {
|
||||
gtk_widget_show (GTK_WIDGET (group));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ GtkWidget *nautilus_preferences_pane_add_item_to_nth_group (NautilusPreferencesP
|
|||
guint n,
|
||||
const char *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
void nautilus_preferences_pane_update (NautilusPreferencesPane *prefs_pane);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-preferences.h - Preference peek/poke/notify object interface.
|
||||
/* nautilus-preferences.c - Preference peek/poke/notify interface.
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
|
@ -27,68 +27,100 @@
|
|||
|
||||
#include <gtk/gtkobject.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
|
||||
#include <libnautilus-extensions/nautilus-preference.h>
|
||||
#include <libnautilus-extensions/nautilus-string-list.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
/*
|
||||
* Preference names:
|
||||
*
|
||||
* In the api below, all preference names can be specified in two
|
||||
* different ways.
|
||||
*
|
||||
* 1) Independent of user level:
|
||||
*
|
||||
* Example1: "/apps/nautilus/preferences/something"
|
||||
*
|
||||
* The preference in question will be dealt with just as gconf
|
||||
* would without taking into account the Nautilus user level.
|
||||
*
|
||||
* You can also deal with non Nautilus things, such as:
|
||||
*
|
||||
* Example2: "/system/gnome-vfs/http-proxy"
|
||||
*
|
||||
* 2) By user level:
|
||||
*
|
||||
* Example: "preferences/something"
|
||||
*
|
||||
* The preference in question will depend on the current Nautilus
|
||||
* user level.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* A callback which you can register to to be notified when a particular
|
||||
* preference changes.
|
||||
*/
|
||||
typedef void (*NautilusPreferencesCallback) (gpointer callback_data);
|
||||
|
||||
gboolean nautilus_preferences_add_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data);
|
||||
gboolean nautilus_preferences_remove_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data);
|
||||
void nautilus_preferences_set_boolean (const char *name,
|
||||
gboolean value);
|
||||
gboolean nautilus_preferences_get_boolean (const char *name,
|
||||
gboolean default_value);
|
||||
void nautilus_preferences_set_enum (const char *name,
|
||||
int value);
|
||||
int nautilus_preferences_get_enum (const char *name,
|
||||
int default_value);
|
||||
/* User level */
|
||||
|
||||
void nautilus_preferences_set_string_list (const char *name,
|
||||
GSList *value);
|
||||
/* default value is NULL */
|
||||
GSList * nautilus_preferences_get_string_list (const char *name);
|
||||
/* Note that there's a function to get the number of user levels, but there's
|
||||
* a lot of code elsewhere that assumes three levels. Publicizing the numbers
|
||||
* of these levels lets that other code be coherent and less error-prone.
|
||||
*/
|
||||
#define NAUTILUS_USER_LEVEL_NOVICE 0
|
||||
#define NAUTILUS_USER_LEVEL_INTERMEDIATE 1
|
||||
#define NAUTILUS_USER_LEVEL_HACKER 2
|
||||
|
||||
void nautilus_preferences_set (const char *name,
|
||||
const char *value);
|
||||
char * nautilus_preferences_get (const char *name,
|
||||
const gchar *default_value);
|
||||
char * nautilus_preferences_get_user_level_name_for_display (int user_level);
|
||||
char * nautilus_preferences_get_user_level_name_for_storage (int user_level);
|
||||
int nautilus_preferences_get_user_level (void);
|
||||
void nautilus_preferences_set_user_level (int user_level);
|
||||
|
||||
/* Preferences getters and setters */
|
||||
gboolean nautilus_preferences_get_boolean (const char *name);
|
||||
void nautilus_preferences_set_boolean (const char *name,
|
||||
gboolean boolean_value);
|
||||
int nautilus_preferences_get_integer (const char *name);
|
||||
void nautilus_preferences_set_integer (const char *name,
|
||||
int int_value);
|
||||
char * nautilus_preferences_get (const char *name);
|
||||
void nautilus_preferences_set (const char *name,
|
||||
const char *string_value);
|
||||
GSList * nautilus_preferences_get_string_list (const char *name);
|
||||
void nautilus_preferences_set_string_list (const char *name,
|
||||
GSList *string_list_value);
|
||||
|
||||
/* Default values getters and setters */
|
||||
gboolean nautilus_preferences_default_get_boolean (const char *name,
|
||||
int user_level);
|
||||
void nautilus_preferences_default_set_boolean (const char *name,
|
||||
int user_level,
|
||||
gboolean boolean_value);
|
||||
int nautilus_preferences_default_get_integer (const char *name,
|
||||
int user_level);
|
||||
void nautilus_preferences_default_set_integer (const char *name,
|
||||
int user_level,
|
||||
int int_value);
|
||||
char * nautilus_preferences_default_get_string (const char *name,
|
||||
int user_level);
|
||||
void nautilus_preferences_default_set_string (const char *name,
|
||||
int user_level,
|
||||
const char *string_value);
|
||||
GSList * nautilus_preferences_default_get_string_list (const char *name,
|
||||
int user_level);
|
||||
void nautilus_preferences_default_set_string_list (const char *name,
|
||||
int user_level,
|
||||
GSList *string_list_value);
|
||||
/* Callbacks */
|
||||
void nautilus_preferences_add_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data);
|
||||
void nautilus_preferences_add_callback_while_alive (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data,
|
||||
GtkObject *alive_object);
|
||||
void nautilus_preferences_remove_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data);
|
||||
|
||||
/* Preferences attributes */
|
||||
int nautilus_preferences_get_visible_user_level (const char *name);
|
||||
void nautilus_preferences_set_visible_user_level (const char *name,
|
||||
int visible_user_level);
|
||||
char * nautilus_preferences_get_description (const char *name);
|
||||
void nautilus_preferences_set_description (const char *name,
|
||||
const char *description);
|
||||
|
||||
/* Enumerations */
|
||||
void nautilus_preferences_enumeration_insert (const char *name,
|
||||
const char *entry,
|
||||
const char *description,
|
||||
int value);
|
||||
char * nautilus_preferences_enumeration_get_nth_entry (const char *name,
|
||||
guint n);
|
||||
char * nautilus_preferences_enumeration_get_nth_description (const char *name,
|
||||
guint n);
|
||||
int nautilus_preferences_enumeration_get_nth_value (const char *name,
|
||||
guint n);
|
||||
guint nautilus_preferences_enumeration_get_num_entries (const char *name);
|
||||
gboolean nautilus_preferences_monitor_directory (const char *directory);
|
||||
gboolean nautilus_preferences_is_visible (const char *name);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ smooth_widget_set_is_smooth (GtkWidget *widget, gboolean is_smooth)
|
|||
static gboolean
|
||||
preferences_get_is_smooth (void)
|
||||
{
|
||||
return nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, TRUE);
|
||||
return nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -41,7 +41,7 @@ kill_sound_if_necessary (void)
|
|||
pid_t sound_process;
|
||||
|
||||
/* fetch the sound state */
|
||||
sound_process = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
sound_process = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE);
|
||||
/* if there was a sound playing, kill it */
|
||||
if (sound_process > 0) {
|
||||
kill (-sound_process, SIGTERM);
|
||||
|
@ -54,7 +54,7 @@ kill_sound_if_necessary (void)
|
|||
void
|
||||
nautilus_sound_initialize (void)
|
||||
{
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
}
|
||||
|
||||
/* if there is a sound registered, kill it, and register the empty sound */
|
||||
|
@ -65,7 +65,7 @@ nautilus_sound_kill_sound (void)
|
|||
kill_sound_if_necessary ();
|
||||
|
||||
/* set the process state to quiescent */
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
}
|
||||
|
||||
/* register a new sound process, including kill any old one if necessary */
|
||||
|
@ -76,7 +76,7 @@ nautilus_sound_register_sound (pid_t sound_process)
|
|||
kill_sound_if_necessary ();
|
||||
|
||||
/* record the new sound process ID */
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, sound_process);
|
||||
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, sound_process);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -85,7 +85,7 @@ nautilus_sound_can_play_sound (void)
|
|||
int open_result, sound_process;
|
||||
|
||||
/* first see if there's already one in progress; if so, return true */
|
||||
sound_process = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
sound_process = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE);
|
||||
if (sound_process > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ static xmlDocPtr default_theme_document = NULL;
|
|||
char *
|
||||
nautilus_theme_get_theme (void)
|
||||
{
|
||||
return nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
return nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME);
|
||||
}
|
||||
|
||||
/* set the current theme */
|
||||
|
@ -142,7 +142,7 @@ nautilus_theme_get_theme_data (const char *resource_name, const char *property_n
|
|||
/* fetch the current theme name */
|
||||
theme_data = NULL;
|
||||
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME);
|
||||
if (nautilus_strcmp (theme_name, last_theme_name) == 0) {
|
||||
theme_document = last_theme_document;
|
||||
} else {
|
||||
|
@ -278,7 +278,7 @@ nautilus_theme_get_image_path (const char *image_name)
|
|||
{
|
||||
char *theme_name, *image_path;
|
||||
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME);
|
||||
image_path = nautilus_theme_get_image_path_from_theme (image_name, theme_name);
|
||||
g_free (theme_name);
|
||||
|
||||
|
|
|
@ -1,566 +0,0 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-user-level-manager.c - User level manager class.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "nautilus-user-level-manager.h"
|
||||
#include "nautilus-gtk-macros.h"
|
||||
#include "nautilus-glib-extensions.h"
|
||||
|
||||
#include "nautilus-preferences.h"
|
||||
#include "nautilus-preferences-private.h"
|
||||
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <gtk/gtksignal.h>
|
||||
|
||||
#include <gconf/gconf.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define NAUTILUS_TYPE_USER_LEVEL_MANAGER (nautilus_user_level_manager_get_type ())
|
||||
#define NAUTILUS_USER_LEVEL_MANAGER(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_USER_LEVEL_MANAGER, NautilusUserLevelManager))
|
||||
#define NAUTILUS_USER_LEVEL_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_USER_LEVEL_MANAGER, NautilusUserLevelManagerClass))
|
||||
#define NAUTILUS_IS_USER_LEVEL_MANAGER(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_USER_LEVEL_MANAGER))
|
||||
#define NAUTILUS_IS_USER_LEVEL_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_USER_LEVEL_MANAGER))
|
||||
|
||||
static const char *DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE[] =
|
||||
{
|
||||
"novice",
|
||||
"intermediate",
|
||||
"hacker"
|
||||
};
|
||||
|
||||
static const char *DEFAULT_USER_LEVEL_NAMES_FOR_DISPLAY[] =
|
||||
{
|
||||
N_("Beginner"),
|
||||
N_("Intermediate"),
|
||||
N_("Advanced")
|
||||
};
|
||||
|
||||
static const guint DEFAULT_NUM_USER_LEVELS = NAUTILUS_N_ELEMENTS (DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE);
|
||||
static const guint DEFAULT_USER_LEVEL = NAUTILUS_USER_LEVEL_HACKER;
|
||||
|
||||
static const char USER_LEVEL_KEY[] = "/apps/nautilus/user_level";
|
||||
static const char USER_LEVEL_PATH[] = "/apps/nautilus";
|
||||
|
||||
static NautilusUserLevelManager *global_manager = NULL;
|
||||
|
||||
struct _NautilusUserLevelManager
|
||||
{
|
||||
GtkObject object;
|
||||
|
||||
guint num_user_levels;
|
||||
NautilusStringList *user_level_names_for_storage;
|
||||
NautilusStringList *user_level_names_for_display;
|
||||
|
||||
GConfClient *gconf_client;
|
||||
int user_level_changed_connection;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkObjectClass parent_class;
|
||||
} NautilusUserLevelManagerClass;
|
||||
|
||||
enum
|
||||
{
|
||||
USER_LEVEL_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint user_level_manager_signals[LAST_SIGNAL];
|
||||
|
||||
static GtkType nautilus_user_level_manager_get_type (void);
|
||||
static void nautilus_user_level_manager_initialize_class (NautilusUserLevelManagerClass *user_level_manager_class);
|
||||
static void nautilus_user_level_manager_initialize (NautilusUserLevelManager *user_level_manager);
|
||||
static void user_level_manager_destroy (GtkObject *object);
|
||||
static char *user_level_manager_get_user_level_as_string (void);
|
||||
static NautilusUserLevelManager *user_level_manager_new (void);
|
||||
static void user_level_manager_ensure_global_manager (void);
|
||||
static void user_level_set_default_if_needed (NautilusUserLevelManager *manager);
|
||||
|
||||
|
||||
/* Gconf callbacks */
|
||||
static void gconf_user_level_changed_callback (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
GConfEntry *entry,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusUserLevelManager, nautilus_user_level_manager, GTK_TYPE_OBJECT)
|
||||
|
||||
/* Create the icon factory. */
|
||||
static NautilusUserLevelManager *
|
||||
user_level_manager_new (void)
|
||||
{
|
||||
GError *error = NULL;
|
||||
NautilusUserLevelManager *manager;
|
||||
guint i;
|
||||
|
||||
if (!gconf_is_initialized ()) {
|
||||
char *argv[] = { "nautilus", NULL };
|
||||
|
||||
if (!gconf_init (1, argv, &error)) {
|
||||
g_assert (error != NULL);
|
||||
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
manager = NAUTILUS_USER_LEVEL_MANAGER (gtk_object_new (nautilus_user_level_manager_get_type (), NULL));
|
||||
gtk_object_ref (GTK_OBJECT (manager));
|
||||
gtk_object_sink (GTK_OBJECT (manager));
|
||||
|
||||
manager->gconf_client = gconf_client_get_default ();
|
||||
|
||||
/* Let gconf know about ~/.gconf/apps/nautilus */
|
||||
gconf_client_add_dir (manager->gconf_client,
|
||||
USER_LEVEL_PATH,
|
||||
GCONF_CLIENT_PRELOAD_NONE,
|
||||
&error);
|
||||
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
manager->num_user_levels = DEFAULT_NUM_USER_LEVELS;
|
||||
manager->user_level_names_for_storage = nautilus_string_list_new (TRUE);
|
||||
manager->user_level_names_for_display = nautilus_string_list_new (TRUE);
|
||||
|
||||
for (i = 0; i < DEFAULT_NUM_USER_LEVELS; i++) {
|
||||
nautilus_string_list_insert (manager->user_level_names_for_storage, DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE[i]);
|
||||
nautilus_string_list_insert (manager->user_level_names_for_display, _(DEFAULT_USER_LEVEL_NAMES_FOR_DISPLAY[i]));
|
||||
}
|
||||
|
||||
g_assert (manager->gconf_client != NULL);
|
||||
|
||||
user_level_set_default_if_needed (manager);
|
||||
|
||||
/* Add a gconf notification for user_level changes. */
|
||||
manager->user_level_changed_connection = gconf_client_notify_add (manager->gconf_client,
|
||||
USER_LEVEL_KEY,
|
||||
gconf_user_level_changed_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
&error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_user_level_manager_initialize (NautilusUserLevelManager *manager)
|
||||
{
|
||||
manager->num_user_levels = 0;
|
||||
|
||||
manager->gconf_client = NULL;
|
||||
manager->user_level_changed_connection = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_user_level_manager_initialize_class (NautilusUserLevelManagerClass *user_level_manager_class)
|
||||
{
|
||||
GtkObjectClass *object_class = GTK_OBJECT_CLASS (user_level_manager_class);
|
||||
|
||||
user_level_manager_signals[USER_LEVEL_CHANGED] = gtk_signal_new ("user_level_changed",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
0,
|
||||
gtk_marshal_NONE__NONE,
|
||||
GTK_TYPE_NONE,
|
||||
0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, user_level_manager_signals, LAST_SIGNAL);
|
||||
|
||||
/* GtkObjectClass */
|
||||
object_class->destroy = user_level_manager_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_manager_destroy (GtkObject *object)
|
||||
{
|
||||
NautilusUserLevelManager *manager;
|
||||
|
||||
manager = NAUTILUS_USER_LEVEL_MANAGER (object);
|
||||
|
||||
/* Remove the gconf notification if its still lingering */
|
||||
if (manager->user_level_changed_connection != 0) {
|
||||
gconf_client_notify_remove (manager->gconf_client,
|
||||
manager->user_level_changed_connection);
|
||||
|
||||
manager->user_level_changed_connection = 0;
|
||||
}
|
||||
|
||||
if (manager->gconf_client != NULL) {
|
||||
gtk_object_unref (GTK_OBJECT (manager->gconf_client));
|
||||
}
|
||||
|
||||
nautilus_string_list_free (manager->user_level_names_for_storage);
|
||||
nautilus_string_list_free (manager->user_level_names_for_display);
|
||||
}
|
||||
|
||||
static void
|
||||
unref_user_level_manager (void)
|
||||
{
|
||||
gtk_object_unref (GTK_OBJECT (global_manager));
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_manager_ensure_global_manager (void)
|
||||
{
|
||||
if (global_manager == NULL) {
|
||||
global_manager = user_level_manager_new ();
|
||||
g_atexit (unref_user_level_manager);
|
||||
}
|
||||
|
||||
g_assert (global_manager != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_set_default_if_needed (NautilusUserLevelManager *manager)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GConfValue *value;
|
||||
|
||||
g_assert (manager != NULL);
|
||||
g_assert (manager->gconf_client != NULL);
|
||||
|
||||
value = gconf_client_get_without_default (manager->gconf_client, USER_LEVEL_KEY, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
if (value != NULL) {
|
||||
gconf_value_free (value);
|
||||
value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (value == NULL) {
|
||||
value = gconf_value_new (GCONF_VALUE_STRING);
|
||||
|
||||
gconf_value_set_string (value, DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE[DEFAULT_USER_LEVEL]);
|
||||
|
||||
gconf_client_set (manager->gconf_client, USER_LEVEL_KEY, value, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
gconf_client_suggest_sync (manager->gconf_client, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
}
|
||||
|
||||
g_assert (value != NULL);
|
||||
|
||||
gconf_value_free (value);
|
||||
}
|
||||
|
||||
static void
|
||||
gconf_user_level_changed_callback (GConfClient *client,
|
||||
guint connection_id,
|
||||
GConfEntry *entry,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (manager), user_level_manager_signals[USER_LEVEL_CHANGED]);
|
||||
}
|
||||
|
||||
/* Public NautilusUserLevelManager functions */
|
||||
NautilusUserLevelManager *
|
||||
nautilus_user_level_manager_get (void)
|
||||
{
|
||||
user_level_manager_ensure_global_manager ();
|
||||
|
||||
g_assert (global_manager != NULL);
|
||||
g_assert (NAUTILUS_IS_USER_LEVEL_MANAGER (global_manager));
|
||||
|
||||
return global_manager;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_user_level_manager_set_user_level (guint user_level)
|
||||
{
|
||||
GError *error = NULL;
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
char *user_level_string;
|
||||
guint old_user_level;
|
||||
|
||||
g_return_if_fail (user_level < manager->num_user_levels);
|
||||
g_return_if_fail (user_level < nautilus_string_list_get_length (manager->user_level_names_for_storage));
|
||||
|
||||
old_user_level = nautilus_user_level_manager_get_user_level ();
|
||||
|
||||
if (old_user_level == user_level) {
|
||||
return;
|
||||
}
|
||||
|
||||
user_level_string = nautilus_string_list_nth (manager->user_level_names_for_storage, user_level);
|
||||
|
||||
g_assert (user_level_string != NULL);
|
||||
|
||||
gconf_client_set_string (manager->gconf_client,
|
||||
USER_LEVEL_KEY,
|
||||
user_level_string,
|
||||
&error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
gconf_client_suggest_sync (manager->gconf_client, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_user_level_manager_get_user_level (void)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
char *user_level_string;
|
||||
gint index;
|
||||
|
||||
user_level_string = user_level_manager_get_user_level_as_string ();
|
||||
|
||||
/* The user_level_string is guranteed to be ok now. The above function, will
|
||||
* make sure of that and deal with gconf problems too.
|
||||
*/
|
||||
g_assert (user_level_string != NULL);
|
||||
|
||||
index = nautilus_string_list_get_index_for_string (manager->user_level_names_for_storage,
|
||||
user_level_string);
|
||||
|
||||
g_free (user_level_string);
|
||||
|
||||
g_assert (index != NAUTILUS_STRING_LIST_NOT_FOUND);
|
||||
|
||||
return (guint) index;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_user_level_manager_get_user_level_name_for_display (guint user_level)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
|
||||
return nautilus_string_list_nth (manager->user_level_names_for_display, user_level);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_user_level_manager_make_gconf_key (const char *preference_name,
|
||||
guint user_level)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
|
||||
char *key;
|
||||
char *user_level_string;
|
||||
|
||||
g_return_val_if_fail (preference_name != NULL, NULL);
|
||||
g_return_val_if_fail (user_level < manager->num_user_levels, NULL);
|
||||
g_return_val_if_fail (user_level < nautilus_string_list_get_length (manager->user_level_names_for_storage), NULL);
|
||||
|
||||
user_level_string = nautilus_string_list_nth (manager->user_level_names_for_storage, user_level);
|
||||
g_assert (user_level_string != NULL);
|
||||
|
||||
key = g_strdup_printf ("%s/%s/%s",
|
||||
USER_LEVEL_PATH,
|
||||
user_level_string,
|
||||
preference_name);
|
||||
|
||||
g_free (user_level_string);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_user_level_manager_make_current_gconf_key (const char *preference_name)
|
||||
{
|
||||
return nautilus_user_level_manager_make_gconf_key (preference_name,
|
||||
nautilus_user_level_manager_get_user_level ());
|
||||
}
|
||||
|
||||
static char *
|
||||
user_level_manager_get_user_level_as_string (void)
|
||||
{
|
||||
GError *error = NULL;
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
char *user_level_string = NULL;
|
||||
|
||||
g_assert (manager->gconf_client != NULL);
|
||||
|
||||
user_level_string = gconf_client_get_string (manager->gconf_client, USER_LEVEL_KEY, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
g_free (user_level_string);
|
||||
user_level_string = NULL;
|
||||
}
|
||||
|
||||
if (!user_level_string)
|
||||
user_level_string = g_strdup (DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE[0]);
|
||||
|
||||
return user_level_string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nautilus_user_level_manager_set_default_value_if_needed
|
||||
*
|
||||
* This function will ask gconf for a value. If
|
||||
*
|
||||
* The value is not found in the user's database:
|
||||
* It will be added to the database using the given default value.
|
||||
*
|
||||
* The value is found in the user's database:
|
||||
* Nothing.
|
||||
*
|
||||
* @name: The name of the preference.
|
||||
* @type: The type of preference.
|
||||
* @default_value: The default_value to use.
|
||||
**/
|
||||
void
|
||||
nautilus_user_level_manager_set_default_value_if_needed (const char *preference_name,
|
||||
NautilusPreferenceType type,
|
||||
guint user_level,
|
||||
gconstpointer default_value)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
GError *error = NULL;
|
||||
GConfValue *value = NULL;
|
||||
char *key;
|
||||
|
||||
g_return_if_fail (preference_name != NULL);
|
||||
|
||||
key = nautilus_user_level_manager_make_gconf_key (preference_name, user_level);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* Find out if the preference exists at all */
|
||||
value = gconf_client_get_without_default (manager->gconf_client, key, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
if (value != NULL) {
|
||||
gconf_value_free (value);
|
||||
value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* The value does not exist, so create one */
|
||||
if (!value) {
|
||||
switch (type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_STRING:
|
||||
/* Gconf will not grok NULL strings, so for this case dont do it. */
|
||||
if (default_value) {
|
||||
value = gconf_value_new (GCONF_VALUE_STRING);
|
||||
gconf_value_set_string (value, (const char *) default_value);
|
||||
}
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_BOOLEAN:
|
||||
value = gconf_value_new (GCONF_VALUE_BOOL);
|
||||
gconf_value_set_bool (value, GPOINTER_TO_INT (default_value));
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
value = gconf_value_new (GCONF_VALUE_INT);
|
||||
gconf_value_set_int (value, GPOINTER_TO_INT (default_value));
|
||||
break;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
gconf_client_set (manager->gconf_client, key, value, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
if (value) {
|
||||
gconf_value_free (value);
|
||||
}
|
||||
|
||||
g_free (key);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_user_level_manager_compare_preference_between_user_levels (const char *preference_name,
|
||||
guint user_level_a,
|
||||
guint user_level_b)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
gboolean result = FALSE;
|
||||
char *key_a;
|
||||
char *key_b;
|
||||
GConfValue *value_a;
|
||||
GConfValue *value_b;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (preference_name != NULL, FALSE);
|
||||
|
||||
key_a = nautilus_user_level_manager_make_gconf_key (preference_name, user_level_a);
|
||||
g_assert (key_a != NULL);
|
||||
|
||||
key_b = nautilus_user_level_manager_make_gconf_key (preference_name, user_level_b);
|
||||
g_assert (key_b != NULL);
|
||||
|
||||
value_a = gconf_client_get (manager->gconf_client, key_a, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
if (value_a != NULL) {
|
||||
gconf_value_free (value_a);
|
||||
value_a = NULL;
|
||||
}
|
||||
}
|
||||
value_b = gconf_client_get (manager->gconf_client, key_b, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
if (value_b != NULL) {
|
||||
gconf_value_free (value_b);
|
||||
value_b = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (key_a);
|
||||
g_free (key_b);
|
||||
|
||||
if (value_a && value_b)
|
||||
{
|
||||
g_assert (value_a->type == value_b->type);
|
||||
|
||||
switch (value_a->type)
|
||||
{
|
||||
case GCONF_VALUE_STRING:
|
||||
result = (gconf_value_get_string (value_a)
|
||||
&& gconf_value_get_string (value_b)
|
||||
&& (strcmp (gconf_value_get_string (value_a), gconf_value_get_string (value_b)) == 0));
|
||||
break;
|
||||
|
||||
case GCONF_VALUE_INT:
|
||||
result = (gconf_value_get_int (value_a) == gconf_value_get_int (value_b));
|
||||
break;
|
||||
|
||||
case GCONF_VALUE_BOOL:
|
||||
result = (gconf_value_get_bool (value_a) == gconf_value_get_bool (value_b));
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
if (value_a) {
|
||||
gconf_value_free (value_a);
|
||||
}
|
||||
|
||||
if (value_b) {
|
||||
gconf_value_free (value_b);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-user-level-manager.h - User level manager interface.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_USER_LEVEL_MANAGER_H
|
||||
#define NAUTILUS_USER_LEVEL_MANAGER_H
|
||||
|
||||
#include <gtk/gtkobject.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libnautilus-extensions/nautilus-string-list.h>
|
||||
#include <libnautilus-extensions/nautilus-preference.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
typedef struct _NautilusUserLevelManager NautilusUserLevelManager;
|
||||
|
||||
/* There is a single NautilusUserLevelManager object.
|
||||
* The only thing you need it for is to connect to its signals.
|
||||
*
|
||||
* "user_level_changed", no parameters
|
||||
*
|
||||
*/
|
||||
NautilusUserLevelManager* nautilus_user_level_manager_get (void);
|
||||
void nautilus_user_level_manager_set_user_level (guint user_level);
|
||||
guint nautilus_user_level_manager_get_user_level (void);
|
||||
char *nautilus_user_level_manager_get_user_level_name_for_display (guint user_level);
|
||||
char *nautilus_user_level_manager_make_current_gconf_key (const char *preference_name);
|
||||
char *nautilus_user_level_manager_make_gconf_key (const char *preference_name,
|
||||
guint user_level);
|
||||
void nautilus_user_level_manager_set_default_value_if_needed (const char *preference_name,
|
||||
NautilusPreferenceType type,
|
||||
guint user_level,
|
||||
gconstpointer default_value);
|
||||
gboolean nautilus_user_level_manager_compare_preference_between_user_levels (const char *preference_name,
|
||||
guint user_level_a,
|
||||
guint user_level_b);
|
||||
|
||||
/* Note that there's a function to get the number of user levels, but there's
|
||||
* a lot of code elsewhere that assumes three levels. Publicizing the numbers
|
||||
* of these levels lets that other code be coherent and less error-prone.
|
||||
*/
|
||||
#define NAUTILUS_USER_LEVEL_NOVICE 0
|
||||
#define NAUTILUS_USER_LEVEL_INTERMEDIATE 1
|
||||
#define NAUTILUS_USER_LEVEL_HACKER 2
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
#endif /* NAUTILUS_USER_LEVEL_MANAGER_H */
|
|
@ -71,6 +71,7 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-druid-page-eazel.c \
|
||||
nautilus-druid.c \
|
||||
nautilus-entry.c \
|
||||
nautilus-enumeration.c \
|
||||
nautilus-file-changes-queue.c \
|
||||
nautilus-file-operations-progress.c \
|
||||
nautilus-file-operations.c \
|
||||
|
@ -78,6 +79,7 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-file.c \
|
||||
nautilus-font-factory.c \
|
||||
nautilus-font-picker.c \
|
||||
nautilus-gconf-extensions.c \
|
||||
nautilus-gdk-extensions.c \
|
||||
nautilus-gdk-font-extensions.c \
|
||||
nautilus-gdk-pixbuf-extensions.c \
|
||||
|
@ -106,7 +108,6 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-merged-directory.c \
|
||||
nautilus-mime-actions.c \
|
||||
nautilus-password-dialog.c \
|
||||
nautilus-preference.c \
|
||||
nautilus-preferences-box.c \
|
||||
nautilus-preferences-dialog.c \
|
||||
nautilus-preferences-group.c \
|
||||
|
@ -136,7 +137,6 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-undo-context.c \
|
||||
nautilus-undo-manager.c \
|
||||
nautilus-undo-signal-handlers.c \
|
||||
nautilus-user-level-manager.c \
|
||||
nautilus-vfs-directory.c \
|
||||
nautilus-vfs-file.c \
|
||||
nautilus-view-identifier.c \
|
||||
|
@ -171,6 +171,7 @@ noinst_HEADERS = \
|
|||
nautilus-druid-page-eazel.h \
|
||||
nautilus-druid.h \
|
||||
nautilus-entry.h \
|
||||
nautilus-enumeration.h \
|
||||
nautilus-file-attributes.h \
|
||||
nautilus-file-changes-queue.h \
|
||||
nautilus-file-operations-progress.h \
|
||||
|
@ -180,6 +181,7 @@ noinst_HEADERS = \
|
|||
nautilus-file.h \
|
||||
nautilus-font-factory.h \
|
||||
nautilus-font-picker.h \
|
||||
nautilus-gconf-extensions.h \
|
||||
nautilus-gdk-extensions.h \
|
||||
nautilus-gdk-font-extensions.h \
|
||||
nautilus-gdk-pixbuf-extensions.h \
|
||||
|
@ -213,7 +215,6 @@ noinst_HEADERS = \
|
|||
nautilus-metadata.h \
|
||||
nautilus-mime-actions.h \
|
||||
nautilus-password-dialog.h \
|
||||
nautilus-preference.h \
|
||||
nautilus-preferences-box.h \
|
||||
nautilus-preferences-dialog.h \
|
||||
nautilus-preferences-group.h \
|
||||
|
@ -224,8 +225,9 @@ noinst_HEADERS = \
|
|||
nautilus-program-chooser.h \
|
||||
nautilus-program-choosing.h \
|
||||
nautilus-radio-button-group.h \
|
||||
nautilus-scalable-font.h \
|
||||
nautilus-scalable-font-private.h \
|
||||
nautilus-scalable-font-private.h \
|
||||
nautilus-scalable-font.h \
|
||||
nautilus-search-uri.h \
|
||||
nautilus-self-checks.h \
|
||||
nautilus-smooth-widget.h \
|
||||
|
@ -245,7 +247,6 @@ noinst_HEADERS = \
|
|||
nautilus-undo-context.h \
|
||||
nautilus-undo-manager.h \
|
||||
nautilus-undo-signal-handlers.h \
|
||||
nautilus-user-level-manager.h \
|
||||
nautilus-vfs-directory.h \
|
||||
nautilus-vfs-file.h \
|
||||
nautilus-view-identifier.h \
|
||||
|
|
|
@ -431,9 +431,7 @@ can_use_public_metafile (NautilusDirectory *directory)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
preference_value = nautilus_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA,
|
||||
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
|
||||
preference_value = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA);
|
||||
|
||||
if (preference_value == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
|
||||
return TRUE;
|
||||
|
@ -1157,10 +1155,10 @@ get_filter_options_for_directory_count (void)
|
|||
filter_options = GNOME_VFS_DIRECTORY_FILTER_NOSELFDIR
|
||||
| GNOME_VFS_DIRECTORY_FILTER_NOPARENTDIR;
|
||||
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, FALSE)) {
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES)) {
|
||||
filter_options |= GNOME_VFS_DIRECTORY_FILTER_NODOTFILES;
|
||||
}
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, FALSE)) {
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES)) {
|
||||
filter_options |= GNOME_VFS_DIRECTORY_FILTER_NOBACKUPFILES;
|
||||
}
|
||||
|
||||
|
|
137
libnautilus-private/nautilus-enumeration.c
Normal file
137
libnautilus-private/nautilus-enumeration.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-enumeration.c: Enumeration data structure.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "nautilus-enumeration.h"
|
||||
|
||||
#include "nautilus-glib-extensions.h"
|
||||
#include "nautilus-lib-self-check-functions.h"
|
||||
#include "nautilus-string.h"
|
||||
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
|
||||
struct NautilusEnumeration
|
||||
{
|
||||
NautilusStringList *entries;
|
||||
NautilusStringList *descriptions;
|
||||
GList *values;
|
||||
};
|
||||
|
||||
/**
|
||||
* nautilus_enumeration_new:
|
||||
*
|
||||
* Return value: A newly constructed string list.
|
||||
*/
|
||||
NautilusEnumeration *
|
||||
nautilus_enumeration_new (void)
|
||||
{
|
||||
NautilusEnumeration *enumeration;
|
||||
|
||||
enumeration = g_new0 (NautilusEnumeration, 1);
|
||||
|
||||
return enumeration;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_enumeration_free (NautilusEnumeration *enumeration)
|
||||
{
|
||||
if (enumeration == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
nautilus_string_list_free (enumeration->entries);
|
||||
nautilus_string_list_free (enumeration->descriptions);
|
||||
g_list_free (enumeration->values);
|
||||
|
||||
g_free (enumeration);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_enumeration_insert (NautilusEnumeration *enumeration,
|
||||
const char *entry,
|
||||
const char *description,
|
||||
int value)
|
||||
{
|
||||
g_return_if_fail (enumeration != NULL);
|
||||
g_return_if_fail (entry != NULL);
|
||||
|
||||
if (enumeration->entries == NULL) {
|
||||
enumeration->entries =nautilus_string_list_new (TRUE);
|
||||
}
|
||||
|
||||
if (enumeration->descriptions == NULL) {
|
||||
enumeration->descriptions = nautilus_string_list_new (TRUE);
|
||||
}
|
||||
|
||||
nautilus_string_list_insert (enumeration->entries, entry);
|
||||
nautilus_string_list_insert (enumeration->descriptions, description ? description : "");
|
||||
enumeration->values = g_list_append (enumeration->values, GINT_TO_POINTER (value));
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_enumeration_get_nth_entry (const NautilusEnumeration *enumeration,
|
||||
guint n)
|
||||
{
|
||||
g_return_val_if_fail (enumeration != NULL, NULL);
|
||||
g_return_val_if_fail (n < nautilus_string_list_get_length (enumeration->entries), NULL);
|
||||
|
||||
return nautilus_string_list_nth (enumeration->entries, n);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_enumeration_get_nth_description (const NautilusEnumeration *enumeration,
|
||||
guint n)
|
||||
{
|
||||
g_return_val_if_fail (enumeration != NULL, NULL);
|
||||
g_return_val_if_fail (n < nautilus_string_list_get_length (enumeration->descriptions), NULL);
|
||||
|
||||
return nautilus_string_list_nth (enumeration->descriptions, n);
|
||||
}
|
||||
|
||||
int
|
||||
nautilus_enumeration_get_nth_value (const NautilusEnumeration *enumeration,
|
||||
guint n)
|
||||
{
|
||||
g_return_val_if_fail (enumeration != NULL, 0);
|
||||
g_return_val_if_fail (n < g_list_length (enumeration->values), 0);
|
||||
|
||||
return GPOINTER_TO_INT (g_list_nth_data (enumeration->values, n));
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_enumeration_get_num_entries (const NautilusEnumeration *enumeration)
|
||||
{
|
||||
g_return_val_if_fail (enumeration != NULL, 0);
|
||||
|
||||
return nautilus_string_list_get_length (enumeration->entries);
|
||||
}
|
||||
|
||||
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
|
||||
void
|
||||
nautilus_self_check_enumeration (void)
|
||||
{
|
||||
}
|
||||
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
|
48
libnautilus-private/nautilus-enumeration.h
Normal file
48
libnautilus-private/nautilus-enumeration.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-enumeration.h: Enumeration data structure.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_ENUMERATION_H
|
||||
#define NAUTILUS_ENUMERATION_H
|
||||
|
||||
#include <libnautilus-extensions/nautilus-string-list.h>
|
||||
|
||||
/* Opaque NautilusEnumeration declaration. */
|
||||
typedef struct NautilusEnumeration NautilusEnumeration;
|
||||
|
||||
NautilusEnumeration *nautilus_enumeration_new (void);
|
||||
void nautilus_enumeration_free (NautilusEnumeration *enumeration);
|
||||
void nautilus_enumeration_insert (NautilusEnumeration *enumeration,
|
||||
const char *entry,
|
||||
const char *description,
|
||||
int value);
|
||||
char * nautilus_enumeration_get_nth_entry (const NautilusEnumeration *enumeration,
|
||||
guint n);
|
||||
char * nautilus_enumeration_get_nth_description (const NautilusEnumeration *enumeration,
|
||||
guint n);
|
||||
int nautilus_enumeration_get_nth_value (const NautilusEnumeration *enumeration,
|
||||
guint n);
|
||||
guint nautilus_enumeration_get_num_entries (const NautilusEnumeration *enumeration);
|
||||
|
||||
#endif /* NAUTILUS_ENUMERATION_H */
|
||||
|
|
@ -2197,7 +2197,7 @@ confirm_empty_trash (GtkWidget *parent_view)
|
|||
GtkWindow *parent_window;
|
||||
|
||||
/* Just Say Yes if the preference says not to confirm. */
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH, TRUE)) {
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1058,9 +1058,7 @@ nautilus_file_should_get_top_left_text (NautilusFile *file)
|
|||
|
||||
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
|
||||
|
||||
preference_value = nautilus_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS,
|
||||
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
|
||||
preference_value = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS);
|
||||
|
||||
if (preference_value == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
|
||||
return TRUE;
|
||||
|
|
|
@ -299,7 +299,7 @@ nautilus_font_factory_get_font_from_preferences (guint size_in_pixels)
|
|||
char *family;
|
||||
GdkFont *font;
|
||||
|
||||
family = nautilus_preferences_get (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY, "helvetica");
|
||||
family = nautilus_preferences_get (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY);
|
||||
|
||||
font = nautilus_font_factory_get_font_by_family (family, size_in_pixels);
|
||||
|
||||
|
|
317
libnautilus-private/nautilus-gconf-extensions.c
Normal file
317
libnautilus-private/nautilus-gconf-extensions.c
Normal file
|
@ -0,0 +1,317 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-gconf-extensions.c - Stuff to make GConf easier to use in Nautilus.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "nautilus-gconf-extensions.h"
|
||||
|
||||
#include <gconf/gconf.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <libgnomeui/gnome-dialog.h>
|
||||
#include <libgnomeui/gnome-dialog-util.h>
|
||||
|
||||
static GConfClient *global_gconf_client = NULL;
|
||||
|
||||
static void
|
||||
global_client_free (void)
|
||||
{
|
||||
if (global_gconf_client == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (global_gconf_client));
|
||||
global_gconf_client = NULL;
|
||||
}
|
||||
|
||||
/* Public */
|
||||
GConfClient *
|
||||
nautilus_gconf_client_get_global (void)
|
||||
{
|
||||
/* Initialize gconf if needed */
|
||||
if (!gconf_is_initialized ()) {
|
||||
char *argv[] = { "nautilus", NULL };
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gconf_init (1, argv, &error)) {
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (global_gconf_client == NULL) {
|
||||
global_gconf_client = gconf_client_get_default ();
|
||||
g_atexit (global_client_free);
|
||||
}
|
||||
|
||||
return global_gconf_client;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_gconf_handle_error (GError **error)
|
||||
{
|
||||
static gboolean shown_dialog = FALSE;
|
||||
|
||||
g_return_val_if_fail (error != NULL, FALSE);
|
||||
|
||||
if (*error != NULL) {
|
||||
g_warning (_("GConf error:\n %s"), (*error)->message);
|
||||
if ( ! shown_dialog) {
|
||||
char *message;
|
||||
GtkWidget *dialog;
|
||||
|
||||
shown_dialog = TRUE;
|
||||
|
||||
message = g_strdup_printf (_("GConf error:\n %s\n"
|
||||
"All further errors shown "
|
||||
"only on terminal"),
|
||||
(*error)->message);
|
||||
|
||||
dialog = gnome_error_dialog (message);
|
||||
}
|
||||
g_error_free (*error);
|
||||
*error = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_gconf_set_boolean (const char *key,
|
||||
gboolean boolean_value)
|
||||
{
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (key != NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_if_fail (client != NULL);
|
||||
|
||||
gconf_client_set_bool (client, key, boolean_value, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
error = NULL;
|
||||
|
||||
gconf_client_suggest_sync (client, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_gconf_get_boolean (const char *key)
|
||||
{
|
||||
gboolean result;
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_val_if_fail (client != NULL, FALSE);
|
||||
|
||||
result = gconf_client_get_bool (client, key, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
result = FALSE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_gconf_set_integer (const char *key,
|
||||
int int_value)
|
||||
{
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (key != NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_if_fail (client != NULL);
|
||||
|
||||
gconf_client_set_int (client, key, int_value, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
error = NULL;
|
||||
|
||||
gconf_client_suggest_sync (client, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
}
|
||||
|
||||
int
|
||||
nautilus_gconf_get_integer (const char *key)
|
||||
{
|
||||
int result;
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, 0);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_val_if_fail (client != NULL, 0);
|
||||
|
||||
result = gconf_client_get_int (client, key, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_gconf_set_string (const char *key,
|
||||
const char *string_value)
|
||||
{
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (key != NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_if_fail (client != NULL);
|
||||
|
||||
gconf_client_set_string (client, key, string_value, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
error = NULL;
|
||||
|
||||
gconf_client_suggest_sync (client, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_gconf_get_string (const char *key)
|
||||
{
|
||||
char *result;
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_val_if_fail (client != NULL, NULL);
|
||||
|
||||
result = gconf_client_get_string (client, key, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
result = g_strdup ("");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_gconf_set_string_list (const char *key,
|
||||
GSList *string_list_value)
|
||||
{
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (key != NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_if_fail (client != NULL);
|
||||
|
||||
gconf_client_set_list (client, key, GCONF_VALUE_STRING, string_list_value, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
error = NULL;
|
||||
|
||||
gconf_client_suggest_sync (client, &error);
|
||||
nautilus_gconf_handle_error (&error);
|
||||
}
|
||||
|
||||
GSList *
|
||||
nautilus_gconf_get_string_list (const char *key)
|
||||
{
|
||||
GSList *result;
|
||||
GConfClient *client;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, NULL);
|
||||
|
||||
client = nautilus_gconf_client_get_global ();
|
||||
g_return_val_if_fail (client != NULL, NULL);
|
||||
|
||||
result = gconf_client_get_list (client, key, GCONF_VALUE_STRING, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_gconf_is_default (const char *key)
|
||||
{
|
||||
gboolean result;
|
||||
GConfValue *value;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (key != NULL, FALSE);
|
||||
|
||||
value = gconf_client_get_without_default (nautilus_gconf_client_get_global (), key, &error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
if (value != NULL) {
|
||||
gconf_value_free (value);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
result = (value == NULL);
|
||||
|
||||
if (value != NULL) {
|
||||
gconf_value_free (value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_gconf_monitor_directory (const char *directory)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GConfClient *client;
|
||||
|
||||
g_return_val_if_fail (directory != NULL, FALSE);
|
||||
|
||||
client = gconf_client_get_default ();
|
||||
|
||||
g_return_val_if_fail (client != NULL, FALSE);
|
||||
|
||||
gconf_client_add_dir (client,
|
||||
directory,
|
||||
GCONF_CLIENT_PRELOAD_NONE,
|
||||
&error);
|
||||
|
||||
if (nautilus_gconf_handle_error (&error)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
53
libnautilus-private/nautilus-gconf-extensions.h
Normal file
53
libnautilus-private/nautilus-gconf-extensions.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-gconf-extensions.h - Stuff to make GConf easier to use in Nautilus.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_GCONF_EXTENSIONS_H
|
||||
#define NAUTILUS_GCONF_EXTENSIONS_H
|
||||
|
||||
#include <gconf/gconf.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
GConfClient *nautilus_gconf_client_get_global (void);
|
||||
gboolean nautilus_gconf_handle_error (GError **error);
|
||||
void nautilus_gconf_set_boolean (const char *key,
|
||||
gboolean boolean_value);
|
||||
gboolean nautilus_gconf_get_boolean (const char *key);
|
||||
int nautilus_gconf_get_integer (const char *key);
|
||||
void nautilus_gconf_set_integer (const char *key,
|
||||
int int_value);
|
||||
char *nautilus_gconf_get_string (const char *key);
|
||||
void nautilus_gconf_set_string (const char *key,
|
||||
const char *string_value);
|
||||
GSList *nautilus_gconf_get_string_list (const char *key);
|
||||
void nautilus_gconf_set_string_list (const char *key,
|
||||
GSList *string_list_value);
|
||||
gboolean nautilus_gconf_is_default (const char *key);
|
||||
gboolean nautilus_gconf_monitor_directory (const char *directory);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
#endif /* NAUTILUS_GCONF_EXTENSIONS_H */
|
File diff suppressed because it is too large
Load diff
|
@ -36,13 +36,13 @@ BEGIN_GNOME_DECLS
|
|||
*/
|
||||
|
||||
/* Which theme is active */
|
||||
#define NAUTILUS_PREFERENCES_THEME "/apps/nautilus/preferences/theme"
|
||||
#define NAUTILUS_PREFERENCES_THEME "preferences/theme"
|
||||
/* Which text attributes appear beneath icon names */
|
||||
#define NAUTILUS_PREFERENCES_ICON_CAPTIONS "/apps/nautilus/icon_view/captions"
|
||||
#define NAUTILUS_PREFERENCES_ICON_CAPTIONS "icon_view/captions"
|
||||
/* How wide the sidebar is (or how wide it will be when expanded) */
|
||||
#define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "/apps/nautilus/preferences/sidebar_width"
|
||||
#define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "preferences/sidebar_width"
|
||||
/* Keep track of the sound playing process */
|
||||
#define NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE "/apps/nautilus/preferences/sound_state"
|
||||
#define NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE "preferences/sound_state"
|
||||
|
||||
/*
|
||||
* The following preferences are coupled to the user level.
|
||||
|
@ -139,7 +139,6 @@ void nautilus_global_preferences_initialize (v
|
|||
void nautilus_global_preferences_show_dialog (void);
|
||||
void nautilus_global_preferences_hide_dialog (void);
|
||||
void nautilus_global_preferences_set_dialog_title (const char *title);
|
||||
void nautilus_global_preferences_dialog_update (void);
|
||||
|
||||
/* Sidebar */
|
||||
GList *nautilus_global_preferences_get_enabled_sidebar_panel_view_identifiers (void);
|
||||
|
|
|
@ -671,10 +671,7 @@ static gboolean
|
|||
in_single_click_mode ()
|
||||
{
|
||||
/* Perhaps this should be computed elsewhere and passed in. */
|
||||
return nautilus_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_CLICK_POLICY, NAUTILUS_CLICK_POLICY_DOUBLE) ==
|
||||
NAUTILUS_CLICK_POLICY_SINGLE;
|
||||
|
||||
return nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_SINGLE;
|
||||
}
|
||||
|
||||
/* Keep these for a bit while we work on performance of draw_or_measure_label_text. */
|
||||
|
|
|
@ -2378,8 +2378,8 @@ button_press_event (GtkWidget *widget,
|
|||
last_click_time = current_time;
|
||||
|
||||
/* Ignore double click if we are in single click mode */
|
||||
click_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
|
||||
NAUTILUS_CLICK_POLICY_DOUBLE);
|
||||
click_mode = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CLICK_POLICY);
|
||||
|
||||
if (click_mode == NAUTILUS_CLICK_POLICY_SINGLE && click_count >= 2) {
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -95,8 +95,6 @@ static const char *icon_file_name_suffixes[] =
|
|||
|
||||
#define EMBLEM_NAME_PREFIX "emblem-"
|
||||
|
||||
#define DEFAULT_ICON_THEME "default"
|
||||
|
||||
/* This used to be called ICON_CACHE_MAX_ENTRIES, but it's misleading
|
||||
* to call it that, since we can have any number of entries in the
|
||||
* cache if the caller keeps the pixbuf around (we only get rid of
|
||||
|
@ -1108,8 +1106,7 @@ icon_theme_changed_callback (gpointer user_data)
|
|||
/* Consult the user preference and the Nautilus theme. In the
|
||||
* long run, we sould just get rid of the user preference.
|
||||
*/
|
||||
theme_preference = nautilus_preferences_get
|
||||
(NAUTILUS_PREFERENCES_THEME, DEFAULT_ICON_THEME);
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME);
|
||||
icon_theme = nautilus_theme_get_theme_data ("icons", "ICON_THEME");
|
||||
|
||||
set_theme (icon_theme == NULL ? theme_preference : icon_theme);
|
||||
|
@ -1296,9 +1293,7 @@ should_display_image_file_as_itself (NautilusFile *file, gboolean anti_aliased)
|
|||
{
|
||||
NautilusSpeedTradeoffValue preference_value;
|
||||
|
||||
preference_value = nautilus_preferences_get_enum
|
||||
(NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
|
||||
NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
|
||||
preference_value = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS);
|
||||
|
||||
/* see if there's a proxy thumbnail to indicate that thumbnailing
|
||||
* failed, in which case we shouldn't use the thumbnail.
|
||||
|
|
|
@ -41,6 +41,8 @@ void nautilus_run_lib_self_checks (void);
|
|||
#define NAUTILUS_LIB_FOR_EACH_SELF_CHECK_FUNCTION(macro) \
|
||||
macro (nautilus_self_check_string) \
|
||||
macro (nautilus_self_check_string_list) \
|
||||
macro (nautilus_self_check_enumeration) \
|
||||
macro (nautilus_self_check_preferences) \
|
||||
macro (nautilus_self_check_scalable_font) \
|
||||
macro (nautilus_self_check_string_map) \
|
||||
macro (nautilus_self_check_glib_extensions) \
|
||||
|
@ -54,7 +56,6 @@ void nautilus_run_lib_self_checks (void);
|
|||
macro (nautilus_self_check_file) \
|
||||
macro (nautilus_self_check_icon_container) \
|
||||
macro (nautilus_self_check_icon_factory) \
|
||||
macro (nautilus_self_check_preference) \
|
||||
/* Add new self-check functions to the list above this line. */
|
||||
|
||||
/* Generate prototypes for all the functions. */
|
||||
|
|
|
@ -1,865 +0,0 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-preference.c - An object to describe a single Nautilus preference.
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "nautilus-preference.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nautilus-gtk-macros.h"
|
||||
#include "nautilus-string-list.h"
|
||||
#include "nautilus-user-level-manager.h"
|
||||
#include "nautilus-lib-self-check-functions.h"
|
||||
|
||||
/*
|
||||
* PreferenceHashNode:
|
||||
*
|
||||
* A structure to manage preference hash table nodes.
|
||||
* Preferences are hash tables. The hash key is the preference name
|
||||
* (a string). The hash value is a pointer of the following struct:
|
||||
*/
|
||||
typedef struct {
|
||||
NautilusPreference *preference;
|
||||
} PreferenceHashNode;
|
||||
|
||||
static GHashTable *global_preference_table = NULL;
|
||||
|
||||
static const char PREFERENCE_NO_DESCRIPTION[] = "No Description";
|
||||
/*
|
||||
* NautilusPreferenceDetail:
|
||||
*
|
||||
* Private members for NautilusPreference.
|
||||
*/
|
||||
struct NautilusPreferenceDetail {
|
||||
char *name;
|
||||
char *description;
|
||||
NautilusPreferenceType type;
|
||||
gpointer type_info;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
NautilusStringList *names;
|
||||
NautilusStringList *descriptions;
|
||||
GList *values;
|
||||
guint num_entries;
|
||||
} PreferenceEnumInfo;
|
||||
|
||||
/* NautilusPreferenceClass methods */
|
||||
static void nautilus_preference_initialize_class (NautilusPreferenceClass *klass);
|
||||
static void nautilus_preference_initialize (NautilusPreference *preference);
|
||||
|
||||
/* GtkObjectClass methods */
|
||||
static void nautilus_preference_destroy (GtkObject *object);
|
||||
|
||||
/* Private stuff */
|
||||
static void preference_free_type_info (NautilusPreference *preference);
|
||||
static PreferenceHashNode *preference_hash_node_lookup (const char *name);
|
||||
static void destroy_global_preference_table (void);
|
||||
|
||||
static void
|
||||
preference_initialize_if_needed (void)
|
||||
{
|
||||
if (global_preference_table != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
global_preference_table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
g_atexit (destroy_global_preference_table);
|
||||
}
|
||||
|
||||
|
||||
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreference, nautilus_preference, GTK_TYPE_OBJECT)
|
||||
|
||||
/**
|
||||
* nautilus_preference_initialize_class
|
||||
*
|
||||
* NautilusPreferenceClass class initialization method.
|
||||
* @preference_class: The class to initialize.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
nautilus_preference_initialize_class (NautilusPreferenceClass *preference_class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (preference_class);
|
||||
|
||||
parent_class = gtk_type_class (gtk_object_get_type ());
|
||||
|
||||
/* GtkObjectClass */
|
||||
object_class->destroy = nautilus_preference_destroy;
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_initialize
|
||||
*
|
||||
* GtkObject initialization method.
|
||||
* @object: The NautilusPreference object to initialize.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
nautilus_preference_initialize (NautilusPreference *preference)
|
||||
{
|
||||
preference->detail = g_new (NautilusPreferenceDetail, 1);
|
||||
|
||||
preference->detail->name = NULL;
|
||||
|
||||
preference->detail->description = NULL;
|
||||
|
||||
preference->detail->type_info = NULL;
|
||||
|
||||
preference->detail->type = NAUTILUS_PREFERENCE_STRING;
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_destroy
|
||||
*
|
||||
* GtkObject destruction method. Chains to super class.
|
||||
* @object: The NautilusPreference object to destroy.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
nautilus_preference_destroy (GtkObject *object)
|
||||
{
|
||||
NautilusPreference *preference;
|
||||
|
||||
preference = NAUTILUS_PREFERENCE (object);
|
||||
|
||||
if (preference->detail->name != NULL)
|
||||
g_free (preference->detail->name);
|
||||
|
||||
if (preference->detail->description != NULL)
|
||||
g_free (preference->detail->description);
|
||||
|
||||
preference_free_type_info (preference);
|
||||
|
||||
g_free (preference->detail);
|
||||
|
||||
/* Chain */
|
||||
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
|
||||
}
|
||||
|
||||
/**
|
||||
* preference_free_type_info
|
||||
*
|
||||
* Free the type specific info attatched to this type
|
||||
* @preference: Pointer to self.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
preference_free_type_info (NautilusPreference *preference)
|
||||
{
|
||||
g_assert (preference != NULL);
|
||||
g_assert (NAUTILUS_IS_PREFERENCE (preference));
|
||||
|
||||
switch (preference->detail->type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
if (preference->detail->type_info) {
|
||||
PreferenceEnumInfo * info;
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
if (info->names)
|
||||
nautilus_string_list_free (info->names);
|
||||
|
||||
if (info->descriptions)
|
||||
nautilus_string_list_free (info->descriptions);
|
||||
|
||||
if (info->values)
|
||||
g_list_free (info->values);
|
||||
|
||||
info->num_entries = 0;
|
||||
|
||||
g_free (preference->detail->type_info);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
preference->detail->type_info = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* preference_type_info_allocate
|
||||
*
|
||||
* Allocate the type specific info attatched to this type
|
||||
* @preference: Pointer to self.
|
||||
*
|
||||
**/
|
||||
static void
|
||||
preference_allocate_type_info (NautilusPreference *preference)
|
||||
{
|
||||
g_assert (NAUTILUS_IS_PREFERENCE (preference));
|
||||
|
||||
switch (preference->detail->type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
{
|
||||
PreferenceEnumInfo * info;
|
||||
|
||||
g_assert (preference->detail->type_info == NULL);
|
||||
|
||||
info = g_new (PreferenceEnumInfo, 1);
|
||||
|
||||
info->names = nautilus_string_list_new (TRUE);
|
||||
|
||||
info->descriptions = nautilus_string_list_new (TRUE);
|
||||
|
||||
info->values = NULL;
|
||||
|
||||
info->num_entries = 0;
|
||||
|
||||
preference->detail->type_info = (gpointer) info;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_new
|
||||
*
|
||||
* Allocate a new preference object. By default, preferences created with this
|
||||
* function will have a type of NAUTILUS_PREFERENCE_STRING.
|
||||
* @name: The name of the preference.
|
||||
*
|
||||
* Return value: A newly allocated preference.
|
||||
*
|
||||
**/
|
||||
GtkObject *
|
||||
nautilus_preference_new (const char *name)
|
||||
{
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return nautilus_preference_new_from_type (name, NAUTILUS_PREFERENCE_STRING);
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_new_from_type
|
||||
*
|
||||
* Allocate a new preference object with the given type.
|
||||
* @name: The name of the preference.
|
||||
* @type: The type for the new preference.
|
||||
*
|
||||
* Return value: A newly allocated preference.
|
||||
*
|
||||
**/
|
||||
GtkObject *
|
||||
nautilus_preference_new_from_type (const char *name,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
NautilusPreference *preference;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
preference = NAUTILUS_PREFERENCE (gtk_object_new (nautilus_preference_get_type (), NULL));
|
||||
gtk_object_ref (GTK_OBJECT (preference));
|
||||
gtk_object_sink (GTK_OBJECT (preference));
|
||||
|
||||
preference->detail->name = g_strdup (name);
|
||||
preference->detail->type = type;
|
||||
|
||||
preference_allocate_type_info (preference);
|
||||
|
||||
return GTK_OBJECT (preference);
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_get_preference_type
|
||||
*
|
||||
* Get the type for the given preference.
|
||||
* @preference: The preference object.
|
||||
*
|
||||
* Return value: The type for the preference.
|
||||
*
|
||||
**/
|
||||
NautilusPreferenceType
|
||||
nautilus_preference_get_preference_type (const NautilusPreference *preference)
|
||||
{
|
||||
g_return_val_if_fail (preference != NULL, NAUTILUS_PREFERENCE_STRING);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NAUTILUS_PREFERENCE_STRING);
|
||||
|
||||
return preference->detail->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_set_preference_type
|
||||
*
|
||||
* Set the type for the given preference. Yes it possible to morph the preference type
|
||||
* in midair. This is actually an important feature so that users of preferences can pull
|
||||
* them out of their assess without having to register them first. Changing the preference
|
||||
* type is guranteed not to leak resources regardless of the old/new types. (such as extra
|
||||
* enum type info).
|
||||
*
|
||||
* @preference: The preference object.
|
||||
* @type: The new type of the preference.
|
||||
*
|
||||
**/
|
||||
void
|
||||
nautilus_preference_set_preference_type (NautilusPreference *preference,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
g_return_if_fail (preference != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_PREFERENCE (preference));
|
||||
|
||||
/* cmon */
|
||||
if (preference->detail->type == type)
|
||||
return;
|
||||
|
||||
/* Free the old type info */
|
||||
preference_free_type_info (preference);
|
||||
|
||||
preference->detail->type = type;
|
||||
|
||||
/* allocate the new type info */
|
||||
preference_allocate_type_info (preference);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nautilus_preference_get_name
|
||||
*
|
||||
* Get a copy of the name for the given preference.
|
||||
* @preference: The preference object.
|
||||
*
|
||||
* Return value: A newly allocated string with the prefrence name. This function is always
|
||||
* guranteed to return a valid newly allocated string (the default is "").
|
||||
*
|
||||
**/
|
||||
char *
|
||||
nautilus_preference_get_name (const NautilusPreference *preference)
|
||||
{
|
||||
g_return_val_if_fail (preference != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NULL);
|
||||
|
||||
return g_strdup (preference->detail->name ? preference->detail->name : "");
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_get_description
|
||||
*
|
||||
* Get a copy of the description for the given preference.
|
||||
* @preference: The preference object.
|
||||
*
|
||||
* Return value: A newly allocated string with the prefrence description. This function is always
|
||||
* guranteed to return a valid newly allocated string (the default is "").
|
||||
*
|
||||
**/
|
||||
char *
|
||||
nautilus_preference_get_description (const NautilusPreference *preference)
|
||||
{
|
||||
g_return_val_if_fail (preference != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NULL);
|
||||
|
||||
return g_strdup (preference->detail->description ?
|
||||
preference->detail->description :
|
||||
PREFERENCE_NO_DESCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* nautilus_preference_set_description
|
||||
*
|
||||
* Set the description for the current preference.
|
||||
* @preference: The preference object.
|
||||
* @description: The new description string.
|
||||
*
|
||||
**/
|
||||
void
|
||||
nautilus_preference_set_description (NautilusPreference *preference,
|
||||
const char * description)
|
||||
{
|
||||
g_return_if_fail (preference != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_PREFERENCE (preference));
|
||||
g_return_if_fail (description != NULL);
|
||||
|
||||
if (preference->detail->description)
|
||||
g_free (preference->detail->description);
|
||||
|
||||
preference->detail->description = g_strdup (description);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preference_enum_add_entry (NautilusPreference *preference,
|
||||
const char *entry_name,
|
||||
const char *entry_description,
|
||||
gint entry_value)
|
||||
{
|
||||
PreferenceEnumInfo *info;
|
||||
|
||||
g_return_if_fail (preference != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_PREFERENCE (preference));
|
||||
g_return_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM);
|
||||
g_return_if_fail (entry_name != NULL);
|
||||
|
||||
g_assert (preference->detail->type_info != NULL);
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
nautilus_string_list_insert (info->names, entry_name);
|
||||
|
||||
nautilus_string_list_insert (info->descriptions,
|
||||
entry_description ? entry_description : PREFERENCE_NO_DESCRIPTION);
|
||||
|
||||
info->values = g_list_append (info->values, GINT_TO_POINTER (entry_value));
|
||||
|
||||
info->num_entries++;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_preference_enum_get_nth_entry_name (const NautilusPreference *preference,
|
||||
guint n)
|
||||
{
|
||||
PreferenceEnumInfo *info;
|
||||
|
||||
g_return_val_if_fail (preference != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NULL);
|
||||
g_return_val_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM, NULL);
|
||||
|
||||
g_assert (preference->detail->type_info != NULL);
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
if (n < nautilus_string_list_get_length (info->names))
|
||||
return nautilus_string_list_nth (info->names, n);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_preference_enum_get_nth_entry_description (const NautilusPreference *preference,
|
||||
guint n)
|
||||
{
|
||||
PreferenceEnumInfo *info;
|
||||
|
||||
g_return_val_if_fail (preference != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), NULL);
|
||||
g_return_val_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM, NULL);
|
||||
|
||||
g_assert (preference->detail->type_info != NULL);
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
if (n < nautilus_string_list_get_length (info->descriptions))
|
||||
return nautilus_string_list_nth (info->descriptions, n);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gint
|
||||
nautilus_preference_enum_get_nth_entry_value (const NautilusPreference *preference,
|
||||
guint n)
|
||||
{
|
||||
PreferenceEnumInfo *info;
|
||||
|
||||
g_return_val_if_fail (preference != NULL, 0);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), 0);
|
||||
g_return_val_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM, 0);
|
||||
|
||||
g_assert (preference->detail->type_info != NULL);
|
||||
|
||||
info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
if (n < g_list_length (info->values))
|
||||
return GPOINTER_TO_INT (g_list_nth_data (info->values, n));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_preference_enum_get_num_entries (const NautilusPreference *preference)
|
||||
{
|
||||
g_return_val_if_fail (preference != NULL, 0);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCE (preference), 0);
|
||||
g_return_val_if_fail (preference->detail->type == NAUTILUS_PREFERENCE_ENUM, 0);
|
||||
|
||||
if (preference->detail->type_info) {
|
||||
PreferenceEnumInfo *info = (PreferenceEnumInfo *) preference->detail->type_info;
|
||||
|
||||
return info->num_entries;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* preference_hash_node_alloc
|
||||
*
|
||||
* Allocate a preference hash node.
|
||||
* @info: Pointer to info structure to use for the node memebers.
|
||||
*
|
||||
* Return value: A newly allocated node.
|
||||
**/
|
||||
static PreferenceHashNode *
|
||||
preference_hash_node_alloc (const char *name,
|
||||
const char *description,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
PreferenceHashNode * node;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
||||
node = g_new (PreferenceHashNode, 1);
|
||||
|
||||
node->preference = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type (name, type));
|
||||
|
||||
if (description != NULL) {
|
||||
nautilus_preference_set_description (node->preference, description);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* preference_hash_node_free
|
||||
*
|
||||
* Free a preference hash node members along with the node itself.
|
||||
* @preference_hash_node: The node to free.
|
||||
**/
|
||||
static void
|
||||
preference_hash_node_free (PreferenceHashNode *node)
|
||||
{
|
||||
gtk_object_unref (GTK_OBJECT (node->preference));
|
||||
g_free (node);
|
||||
}
|
||||
|
||||
/**
|
||||
* preference_hash_node_free_func
|
||||
*
|
||||
* A function that frees a pref hash node. It is meant to be fed to
|
||||
* g_hash_table_foreach ()
|
||||
* @key: The hash key privately maintained by the GHashTable.
|
||||
* @value: The hash value privately maintained by the GHashTable.
|
||||
* @callback_data: The callback_data privately maintained by the GHashTable.
|
||||
**/
|
||||
static void
|
||||
preference_hash_node_free_func (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_free (key);
|
||||
preference_hash_node_free (value);
|
||||
}
|
||||
|
||||
static void
|
||||
preference_register (const char *name,
|
||||
const char *description,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
PreferenceHashNode *node;
|
||||
|
||||
g_return_if_fail (name != NULL);
|
||||
g_return_if_fail (description != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup (name);
|
||||
if (node != NULL) {
|
||||
g_warning ("the '%s' preference is already registered", name);
|
||||
return;
|
||||
}
|
||||
|
||||
node = preference_hash_node_alloc (name, description, type);
|
||||
g_hash_table_insert (global_preference_table, g_strdup (name), node);
|
||||
|
||||
g_assert (node->preference != NULL);
|
||||
}
|
||||
|
||||
static PreferenceHashNode *
|
||||
preference_hash_node_lookup (const char *name)
|
||||
{
|
||||
gpointer hash_value;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
hash_value = g_hash_table_lookup (global_preference_table, name);
|
||||
|
||||
return (PreferenceHashNode *) hash_value;
|
||||
}
|
||||
|
||||
static PreferenceHashNode *
|
||||
preference_hash_node_lookup_with_registration (const char *name,
|
||||
NautilusPreferenceType type)
|
||||
{
|
||||
PreferenceHashNode * node;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup (name);
|
||||
|
||||
if (!node) {
|
||||
preference_register (name,
|
||||
"Unspecified Description",
|
||||
type);
|
||||
|
||||
node = preference_hash_node_lookup (name);
|
||||
}
|
||||
|
||||
g_assert (node != NULL);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_global_preference_table (void)
|
||||
{
|
||||
g_hash_table_foreach (global_preference_table,
|
||||
preference_hash_node_free_func,
|
||||
NULL);
|
||||
|
||||
g_hash_table_destroy (global_preference_table);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Public functions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* nautilus_preference_find_by_name
|
||||
*
|
||||
* Search for a named preference in the given preference and return it.
|
||||
* @preference: The preference to search
|
||||
*
|
||||
* Return value: A referenced pointer to the preference object that corresponds
|
||||
* to the given preference name. The caller should gtk_object_unref() the return
|
||||
* value of this function.
|
||||
**/
|
||||
NautilusPreference *
|
||||
nautilus_preference_find_by_name (const char *name)
|
||||
{
|
||||
PreferenceHashNode *node;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup (name);
|
||||
|
||||
g_assert (node != NULL);
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (node->preference));
|
||||
|
||||
return node->preference;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preference_set_info_by_name (const char *name,
|
||||
const char *description,
|
||||
NautilusPreferenceType type,
|
||||
gconstpointer *default_values,
|
||||
guint num_default_values)
|
||||
{
|
||||
PreferenceHashNode *node;
|
||||
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup_with_registration (name, type);
|
||||
|
||||
g_assert (node != NULL);
|
||||
g_assert (node->preference != NULL);
|
||||
|
||||
if (description) {
|
||||
nautilus_preference_set_description (node->preference, description);
|
||||
}
|
||||
|
||||
if (default_values && num_default_values) {
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < num_default_values; i++)
|
||||
{
|
||||
nautilus_user_level_manager_set_default_value_if_needed (name,
|
||||
type,
|
||||
i,
|
||||
default_values[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preference_enum_add_entry_by_name (const char *name,
|
||||
const char *entry_name,
|
||||
const char *entry_description,
|
||||
int entry_value)
|
||||
{
|
||||
PreferenceHashNode *node;
|
||||
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
preference_initialize_if_needed ();
|
||||
|
||||
node = preference_hash_node_lookup_with_registration (name, NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
g_assert (node != NULL);
|
||||
g_assert (node->preference != NULL);
|
||||
|
||||
g_assert (nautilus_preference_get_preference_type (node->preference) == NAUTILUS_PREFERENCE_ENUM);
|
||||
|
||||
nautilus_preference_enum_add_entry (node->preference,
|
||||
entry_name,
|
||||
entry_description,
|
||||
entry_value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
|
||||
|
||||
void
|
||||
nautilus_self_check_preference (void)
|
||||
{
|
||||
NautilusPreference *preference;
|
||||
|
||||
preference = NAUTILUS_PREFERENCE (nautilus_preference_new ("foo/bar"));
|
||||
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_get_preference_type (preference), NAUTILUS_PREFERENCE_STRING);
|
||||
|
||||
/* Test boolean things */
|
||||
{
|
||||
NautilusPreference *bp;
|
||||
|
||||
bp = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type ("active", NAUTILUS_PREFERENCE_BOOLEAN));
|
||||
|
||||
nautilus_preference_set_description (bp, "Is it active ?");
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_get_name (bp), "active");
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_get_description (bp), "Is it active ?");
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (bp));
|
||||
}
|
||||
|
||||
/* Test enumeration things */
|
||||
{
|
||||
NautilusPreference *ep;
|
||||
|
||||
ep = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type ("color",NAUTILUS_PREFERENCE_ENUM));
|
||||
|
||||
nautilus_preference_enum_add_entry (ep, "red", "A red something", 100);
|
||||
nautilus_preference_enum_add_entry (ep, "green", "A green something", 200);
|
||||
nautilus_preference_enum_add_entry (ep, "blue", "A blue something", 300);
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_get_name (ep), "color");
|
||||
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_enum_get_num_entries (ep), 3);
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_enum_get_nth_entry_name (ep, 0), "red");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_enum_get_nth_entry_name (ep, 1), "green");
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_enum_get_nth_entry_name (ep, 2), "blue");
|
||||
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_enum_get_nth_entry_value (ep, 0), 100);
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_enum_get_nth_entry_value (ep, 1), 200);
|
||||
NAUTILUS_CHECK_INTEGER_RESULT (nautilus_preference_enum_get_nth_entry_value (ep, 2), 300);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (ep));
|
||||
}
|
||||
|
||||
/* Test string things */
|
||||
{
|
||||
NautilusPreference *sp;
|
||||
|
||||
sp = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type ("font", NAUTILUS_PREFERENCE_STRING));
|
||||
|
||||
NAUTILUS_CHECK_STRING_RESULT (nautilus_preference_get_name (sp), "font");
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (sp));
|
||||
}
|
||||
|
||||
|
||||
/* Allocate a bunch of preference objects to test that they dont leak */
|
||||
{
|
||||
const guint num_to_allocate = 20; /* larger number is too slow with memprof */
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < num_to_allocate; i++)
|
||||
{
|
||||
NautilusPreference *bp;
|
||||
char *bn;
|
||||
|
||||
bn = g_strdup_printf ("bp_%d", i);
|
||||
|
||||
bp = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type (bn, NAUTILUS_PREFERENCE_BOOLEAN));
|
||||
|
||||
g_free (bn);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (bp));
|
||||
}
|
||||
|
||||
for (i = 0; i < num_to_allocate; i++)
|
||||
{
|
||||
NautilusPreference *ep;
|
||||
char *en;
|
||||
|
||||
en = g_strdup_printf ("ep_%d", i);
|
||||
|
||||
ep = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type (en, NAUTILUS_PREFERENCE_ENUM));
|
||||
|
||||
nautilus_preference_enum_add_entry (ep, "small", "A small foo", 1);
|
||||
nautilus_preference_enum_add_entry (ep, "medium", "A medium foo", 2);
|
||||
nautilus_preference_enum_add_entry (ep, "large", "A large foo", 3);
|
||||
|
||||
g_free (en);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (ep));
|
||||
}
|
||||
|
||||
for (i = 0; i < num_to_allocate; i++)
|
||||
{
|
||||
NautilusPreference *sp;
|
||||
char *sn;
|
||||
|
||||
sn = g_strdup_printf ("sp_%d", i);
|
||||
|
||||
sp = NAUTILUS_PREFERENCE (nautilus_preference_new_from_type (sn, NAUTILUS_PREFERENCE_STRING));
|
||||
|
||||
g_free (sn);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (sp));
|
||||
}
|
||||
}
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (preference));
|
||||
}
|
||||
|
||||
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
|
|
@ -1,112 +0,0 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-preference.h - An object to describe a single Nautilus preference.
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_PREFERENCE_H
|
||||
#define NAUTILUS_PREFERENCE_H
|
||||
|
||||
#include <gtk/gtkobject.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libnautilus-extensions/nautilus-string-list.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
#define NAUTILUS_TYPE_PREFERENCE (nautilus_preference_get_type ())
|
||||
#define NAUTILUS_PREFERENCE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_PREFERENCE, NautilusPreference))
|
||||
#define NAUTILUS_PREFERENCE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PREFERENCE, NautilusPreferenceClass))
|
||||
#define NAUTILUS_IS_PREFERENCE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFERENCE))
|
||||
#define NAUTILUS_IS_PREFERENCE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFERENCE))
|
||||
|
||||
typedef struct NautilusPreference NautilusPreference;
|
||||
typedef struct NautilusPreferenceClass NautilusPreferenceClass;
|
||||
typedef struct NautilusPreferenceDetail NautilusPreferenceDetail;
|
||||
|
||||
struct NautilusPreference
|
||||
{
|
||||
GtkObject object;
|
||||
NautilusPreferenceDetail *detail;
|
||||
};
|
||||
|
||||
/*
|
||||
* NautilusPreferenceType:
|
||||
*
|
||||
* The types of supported preferences. By default, a preference is of type
|
||||
* NAUTILUS_PREFERENCE_STRING, unless otherwise specified in the api.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_PREFERENCE_STRING,
|
||||
NAUTILUS_PREFERENCE_BOOLEAN,
|
||||
NAUTILUS_PREFERENCE_ENUM
|
||||
} NautilusPreferenceType;
|
||||
|
||||
struct NautilusPreferenceClass
|
||||
{
|
||||
GtkObjectClass object_class;
|
||||
};
|
||||
|
||||
GtkType nautilus_preference_get_type (void);
|
||||
GtkObject * nautilus_preference_new (const char *name);
|
||||
GtkObject * nautilus_preference_new_from_type (const char *name,
|
||||
NautilusPreferenceType type);
|
||||
NautilusPreferenceType nautilus_preference_get_preference_type (const NautilusPreference *preference);
|
||||
void nautilus_preference_set_preference_type (NautilusPreference *preference,
|
||||
NautilusPreferenceType type);
|
||||
char * nautilus_preference_get_name (const NautilusPreference *preference);
|
||||
char * nautilus_preference_get_description (const NautilusPreference *preference);
|
||||
void nautilus_preference_set_description (NautilusPreference *preference,
|
||||
const char *description);
|
||||
/* Methods to deal with enum preferences */
|
||||
void nautilus_preference_enum_add_entry (NautilusPreference *preference,
|
||||
const char *entry_name,
|
||||
const char *entry_description,
|
||||
gint entry_value);
|
||||
char * nautilus_preference_enum_get_nth_entry_name (const NautilusPreference *preference,
|
||||
guint n);
|
||||
char * nautilus_preference_enum_get_nth_entry_description (const NautilusPreference *preference,
|
||||
guint n);
|
||||
gint nautilus_preference_enum_get_nth_entry_value (const NautilusPreference *preference,
|
||||
guint n);
|
||||
guint nautilus_preference_enum_get_num_entries (const NautilusPreference *preference);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
NautilusPreference *nautilus_preference_find_by_name (const char *name);
|
||||
void nautilus_preference_set_info_by_name (const char *name,
|
||||
const char *description,
|
||||
NautilusPreferenceType type,
|
||||
gconstpointer *default_values,
|
||||
guint num_default_values);
|
||||
void nautilus_preference_enum_add_entry_by_name (const char *name,
|
||||
const char *entry_name,
|
||||
const char *entry_description,
|
||||
int entry_value);
|
||||
|
||||
void nautilus_preference_shutdown (void);
|
||||
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
#endif /* NAUTILUS_PREFERENCE_H */
|
|
@ -337,8 +337,8 @@ nautilus_preferences_box_add_pane (NautilusPreferencesBox *prefs_box,
|
|||
info = pane_info_alloc (pane_title);
|
||||
|
||||
prefs_box->details->panes = g_list_append (prefs_box->details->panes,
|
||||
(gpointer) info);
|
||||
|
||||
(gpointer) info);
|
||||
|
||||
info->pane_widget = nautilus_preferences_pane_new (pane_title,
|
||||
pane_description);
|
||||
|
||||
|
@ -355,3 +355,17 @@ nautilus_preferences_box_add_pane (NautilusPreferencesBox *prefs_box,
|
|||
|
||||
return info->pane_widget;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_box_update (NautilusPreferencesBox *prefs_box)
|
||||
{
|
||||
GList *iterator;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_PREFS_BOX (prefs_box));
|
||||
|
||||
for (iterator = prefs_box->details->panes; iterator != NULL; iterator = iterator->next) {
|
||||
PaneInfo *info = iterator->data;
|
||||
|
||||
nautilus_preferences_pane_update (NAUTILUS_PREFERENCES_PANE (info->pane_widget));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,10 +58,11 @@ struct _NautilusPreferencesBoxClass
|
|||
};
|
||||
|
||||
GtkType nautilus_preferences_box_get_type (void);
|
||||
GtkWidget* nautilus_preferences_box_new (const gchar *box_title);
|
||||
GtkWidget* nautilus_preferences_box_new (const gchar *box_title);
|
||||
GtkWidget* nautilus_preferences_box_add_pane (NautilusPreferencesBox *prefs_box,
|
||||
const gchar *pane_title,
|
||||
const gchar *pane_description);
|
||||
const gchar *pane_title,
|
||||
const gchar *pane_description);
|
||||
void nautilus_preferences_box_update (NautilusPreferencesBox *prefs_box);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ static void dialog_destroy (GtkWidget *wi
|
|||
/* Misc private stuff */
|
||||
static void nautilus_preferences_dialog_construct (NautilusPreferencesDialog *prefs_dialog,
|
||||
const gchar *dialog_title);
|
||||
static void user_level_changed_callback (gpointer callback_data);
|
||||
|
||||
|
||||
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferencesDialog,
|
||||
|
@ -114,6 +115,8 @@ nautilus_preferences_dialog_initialize (NautilusPreferencesDialog * prefs_dialog
|
|||
prefs_dialog->details = g_new (NautilusPreferencesDialogDetails, 1);
|
||||
|
||||
prefs_dialog->details->prefs_box = NULL;
|
||||
|
||||
nautilus_preferences_add_callback ("user_level", user_level_changed_callback, prefs_dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -238,6 +241,8 @@ nautilus_preferences_dialog_destroy(GtkObject* object)
|
|||
|
||||
prefs_dialog = NAUTILUS_PREFERENCES_DIALOG(object);
|
||||
|
||||
nautilus_preferences_remove_callback ("user_level", user_level_changed_callback, prefs_dialog);
|
||||
|
||||
g_free (prefs_dialog->details);
|
||||
|
||||
/* Chain */
|
||||
|
@ -253,3 +258,19 @@ nautilus_preferences_dialog_get_prefs_box (NautilusPreferencesDialog *prefs_dial
|
|||
|
||||
return prefs_dialog->details->prefs_box;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_dialog_update (NautilusPreferencesDialog *preferences_dialog)
|
||||
{
|
||||
g_return_if_fail (NAUTILUS_IS_PREFS_DIALOG (preferences_dialog));
|
||||
|
||||
nautilus_preferences_box_update (NAUTILUS_PREFERENCES_BOX (preferences_dialog->details->prefs_box));
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_changed_callback (gpointer callback_data)
|
||||
{
|
||||
g_return_if_fail (NAUTILUS_IS_PREFS_DIALOG (callback_data));
|
||||
|
||||
nautilus_preferences_dialog_update (NAUTILUS_PREFERENCES_DIALOG (callback_data));
|
||||
}
|
||||
|
|
|
@ -58,8 +58,9 @@ struct _NautilusPreferencesDialogClass
|
|||
};
|
||||
|
||||
GtkType nautilus_preferences_dialog_get_type (void);
|
||||
GtkWidget* nautilus_preferences_dialog_new (const gchar *dialog_title);
|
||||
GtkWidget* nautilus_preferences_dialog_new (const gchar *dialog_title);
|
||||
GtkWidget* nautilus_preferences_dialog_get_prefs_box (NautilusPreferencesDialog *prefs_dialog);
|
||||
void nautilus_preferences_dialog_update (NautilusPreferencesDialog *prefs_dialog);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ struct _NautilusPreferencesGroupDetails
|
|||
GtkWidget *content_box;
|
||||
GtkWidget *description_label;
|
||||
gboolean show_description;
|
||||
|
||||
GList *items;
|
||||
};
|
||||
|
||||
static const gint PREFERENCES_GROUP_NOT_FOUND = -1;
|
||||
|
@ -96,6 +98,7 @@ nautilus_preferences_group_initialize (NautilusPreferencesGroup *group)
|
|||
group->details->content_box = NULL;
|
||||
group->details->description_label = NULL;
|
||||
group->details->show_description = FALSE;
|
||||
group->details->items = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -111,6 +114,7 @@ nautilus_preferences_group_destroy(GtkObject* object)
|
|||
|
||||
group = NAUTILUS_PREFERENCES_GROUP (object);
|
||||
|
||||
g_list_free (group->details->items);
|
||||
g_free (group->details);
|
||||
|
||||
/* Chain */
|
||||
|
@ -201,23 +205,16 @@ nautilus_preferences_group_add_item (NautilusPreferencesGroup *group,
|
|||
const char *preference_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
{
|
||||
GtkWidget *item;
|
||||
NautilusPreference *preference;
|
||||
GtkWidget *item;
|
||||
|
||||
g_return_val_if_fail (group != NULL, NULL);
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_GROUP (group), NULL);
|
||||
|
||||
g_return_val_if_fail (preference_name != NULL, NULL);
|
||||
|
||||
preference = nautilus_preference_find_by_name (preference_name);
|
||||
|
||||
g_assert (preference != NULL);
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (preference));
|
||||
|
||||
preference = NULL;
|
||||
|
||||
item = nautilus_preferences_item_new (preference_name, item_type);
|
||||
|
||||
group->details->items = g_list_append (group->details->items, item);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (group->details->content_box),
|
||||
item,
|
||||
|
@ -229,3 +226,45 @@ nautilus_preferences_group_add_item (NautilusPreferencesGroup *group,
|
|||
|
||||
return item;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_group_update (NautilusPreferencesGroup *group)
|
||||
{
|
||||
GList *iterator;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_PREFERENCES_GROUP (group));
|
||||
|
||||
for (iterator = group->details->items; iterator != NULL; iterator = iterator->next) {
|
||||
char *name;
|
||||
|
||||
name = nautilus_preferences_item_get_name (NAUTILUS_PREFERENCES_ITEM (iterator->data));
|
||||
|
||||
if (nautilus_preferences_is_visible (name)) {
|
||||
gtk_widget_show (GTK_WIDGET (iterator->data));
|
||||
} else {
|
||||
gtk_widget_hide (GTK_WIDGET (iterator->data));
|
||||
}
|
||||
|
||||
g_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_preferences_get_num_visible_items (const NautilusPreferencesGroup *group)
|
||||
{
|
||||
guint n = 0;
|
||||
GList *iterator;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_GROUP (group), 0);
|
||||
|
||||
for (iterator = group->details->items; iterator != NULL; iterator = iterator->next) {
|
||||
char *name;
|
||||
name = nautilus_preferences_item_get_name (NAUTILUS_PREFERENCES_ITEM (iterator->data));
|
||||
if (nautilus_preferences_is_visible (name)) {
|
||||
n++;
|
||||
}
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -56,11 +56,13 @@ struct _NautilusPreferencesGroupClass
|
|||
GtkFrameClass parent_class;
|
||||
};
|
||||
|
||||
GtkType nautilus_preferences_group_get_type (void);
|
||||
GtkWidget* nautilus_preferences_group_new (const gchar *title);
|
||||
GtkWidget* nautilus_preferences_group_add_item (NautilusPreferencesGroup *group,
|
||||
const char *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
GtkType nautilus_preferences_group_get_type (void);
|
||||
GtkWidget* nautilus_preferences_group_new (const gchar *title);
|
||||
GtkWidget* nautilus_preferences_group_add_item (NautilusPreferencesGroup *group,
|
||||
const char *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
void nautilus_preferences_group_update (NautilusPreferencesGroup *group);
|
||||
guint nautilus_preferences_get_num_visible_items (const NautilusPreferencesGroup *group);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nautilus-file-utilities.h"
|
||||
#include "nautilus-glib-extensions.h"
|
||||
#include "nautilus-gtk-macros.h"
|
||||
#include "nautilus-string.h"
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
|
||||
#include <gtk/gtkcheckbutton.h>
|
||||
|
@ -76,17 +77,19 @@ static void preferences_item_construct (NautilusPreferencesItem
|
|||
const gchar *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
static void preferences_item_create_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_short_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_boolean (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_editable_string (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_integer (NautilusPreferencesItem *item,
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_font_family (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void preferences_item_create_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
const char *preference_name);
|
||||
static void enum_radio_group_changed_callback (GtkWidget *button_group,
|
||||
GtkWidget *button,
|
||||
gpointer user_data);
|
||||
|
@ -96,6 +99,8 @@ static void text_item_changed_callback (GtkWidget
|
|||
gpointer user_data);
|
||||
static void editable_string_changed_callback (GtkWidget *caption,
|
||||
gpointer user_data);
|
||||
static void integer_changed_callback (GtkWidget *caption,
|
||||
gpointer user_data);
|
||||
|
||||
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferencesItem, nautilus_preferences_item, GTK_TYPE_VBOX)
|
||||
|
||||
|
@ -242,8 +247,6 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
const gchar *preference_name,
|
||||
NautilusPreferencesItemType item_type)
|
||||
{
|
||||
const NautilusPreference *preference;
|
||||
|
||||
g_assert (item != NULL);
|
||||
|
||||
g_assert (preference_name != NULL);
|
||||
|
@ -255,39 +258,36 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
|
||||
item->details->preference_name = g_strdup (preference_name);
|
||||
|
||||
preference = nautilus_preference_find_by_name (item->details->preference_name);
|
||||
|
||||
g_assert (preference != NULL);
|
||||
|
||||
/* Create the child widget according to the item type */
|
||||
switch (item_type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_ITEM_BOOLEAN:
|
||||
preferences_item_create_boolean (item, preference);
|
||||
preferences_item_create_boolean (item, preference_name);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_ENUM:
|
||||
preferences_item_create_enum (item, preference);
|
||||
preferences_item_create_enum (item, preference_name);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM:
|
||||
preferences_item_create_short_enum (item, preference);
|
||||
preferences_item_create_short_enum (item, preference_name);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY:
|
||||
preferences_item_create_font_family (item, preference);
|
||||
preferences_item_create_font_family (item, preference_name);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_THEME:
|
||||
preferences_item_create_theme (item, preference);
|
||||
preferences_item_create_theme (item, preference_name);
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING:
|
||||
preferences_item_create_editable_string (item, preference);
|
||||
preferences_item_create_editable_string (item, preference_name);
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_ITEM_INTEGER:
|
||||
preferences_item_create_integer (item, preference_name);
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (preference));
|
||||
|
||||
g_assert (item->details->child != NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (item),
|
||||
|
@ -301,33 +301,33 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
|
||||
static void
|
||||
preferences_item_create_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
guint i;
|
||||
gint value;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
|
||||
item->details->child = nautilus_radio_button_group_new (FALSE);
|
||||
|
||||
value = nautilus_preferences_get_enum (item->details->preference_name, 0);
|
||||
value = nautilus_preferences_get_integer (item->details->preference_name);
|
||||
|
||||
for (i = 0; i < nautilus_preference_enum_get_num_entries (preference); i++) {
|
||||
for (i = 0; i < nautilus_preferences_enumeration_get_num_entries (preference_name); i++) {
|
||||
char *description;
|
||||
|
||||
description = nautilus_preference_enum_get_nth_entry_description (preference, i);
|
||||
|
||||
description = nautilus_preferences_enumeration_get_nth_description (preference_name, i);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
||||
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (item->details->child),
|
||||
description);
|
||||
|
||||
g_free (description);
|
||||
|
||||
if (value == nautilus_preference_enum_get_nth_entry_value (preference, i)) {
|
||||
if (value == nautilus_preferences_enumeration_get_nth_value (preference_name, i)) {
|
||||
|
||||
nautilus_radio_button_group_set_active_index (NAUTILUS_RADIO_BUTTON_GROUP (item->details->child), i);
|
||||
}
|
||||
|
@ -345,24 +345,24 @@ preferences_item_create_enum (NautilusPreferencesItem *item,
|
|||
*/
|
||||
static void
|
||||
preferences_item_create_short_enum (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
guint i;
|
||||
gint value;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
|
||||
item->details->child = nautilus_radio_button_group_new (TRUE);
|
||||
|
||||
value = nautilus_preferences_get_enum (item->details->preference_name, 0);
|
||||
value = nautilus_preferences_get_integer (item->details->preference_name);
|
||||
|
||||
for (i = 0; i < nautilus_preference_enum_get_num_entries (preference); i++) {
|
||||
for (i = 0; i < nautilus_preferences_enumeration_get_num_entries (preference_name); i++) {
|
||||
char *description;
|
||||
|
||||
description = nautilus_preference_enum_get_nth_entry_description (preference, i);
|
||||
description = nautilus_preferences_enumeration_get_nth_description (preference_name, i);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -371,7 +371,7 @@ preferences_item_create_short_enum (NautilusPreferencesItem *item,
|
|||
|
||||
g_free (description);
|
||||
|
||||
if (value == nautilus_preference_enum_get_nth_entry_value (preference, i)) {
|
||||
if (value == nautilus_preferences_enumeration_get_nth_value (preference_name, i)) {
|
||||
|
||||
nautilus_radio_button_group_set_active_index (NAUTILUS_RADIO_BUTTON_GROUP (item->details->child), i);
|
||||
}
|
||||
|
@ -385,16 +385,16 @@ preferences_item_create_short_enum (NautilusPreferencesItem *item,
|
|||
|
||||
static void
|
||||
preferences_item_create_boolean (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
gboolean value;
|
||||
char *description;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preference_get_description (preference);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -402,7 +402,7 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
|
|||
|
||||
g_free (description);
|
||||
|
||||
value = nautilus_preferences_get_boolean (item->details->preference_name, FALSE);
|
||||
value = nautilus_preferences_get_boolean (item->details->preference_name);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item->details->child), value);
|
||||
|
||||
|
@ -414,16 +414,16 @@ preferences_item_create_boolean (NautilusPreferencesItem *item,
|
|||
|
||||
static void
|
||||
preferences_item_create_editable_string (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
char *current_value;
|
||||
char *description;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preference_get_description (preference);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -433,7 +433,7 @@ preferences_item_create_editable_string (NautilusPreferencesItem *item,
|
|||
|
||||
g_free (description);
|
||||
|
||||
current_value = nautilus_preferences_get (item->details->preference_name, "file://home/pavel");
|
||||
current_value = nautilus_preferences_get (item->details->preference_name);
|
||||
|
||||
g_assert (current_value != NULL);
|
||||
nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (item->details->child), current_value);
|
||||
|
@ -445,19 +445,52 @@ preferences_item_create_editable_string (NautilusPreferencesItem *item,
|
|||
(gpointer) item);
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_item_create_integer (NautilusPreferencesItem *item,
|
||||
const char *preference_name)
|
||||
{
|
||||
char *current_value;
|
||||
char *description;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
item->details->child = nautilus_text_caption_new ();
|
||||
|
||||
nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), description);
|
||||
|
||||
g_free (description);
|
||||
|
||||
current_value = g_strdup_printf ("%d", nautilus_preferences_get_integer (item->details->preference_name));
|
||||
|
||||
g_assert (current_value != NULL);
|
||||
nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (item->details->child), current_value);
|
||||
g_free (current_value);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (item->details->child),
|
||||
"changed",
|
||||
GTK_SIGNAL_FUNC (integer_changed_callback),
|
||||
(gpointer) item);
|
||||
}
|
||||
|
||||
static void
|
||||
preferences_item_create_font_family (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
char *description;
|
||||
char *current_value;
|
||||
NautilusStringList *font_list;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preference_get_description (preference);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -477,7 +510,7 @@ preferences_item_create_font_family (NautilusPreferencesItem *item,
|
|||
|
||||
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (item->details->child), font_list);
|
||||
|
||||
current_value = nautilus_preferences_get (item->details->preference_name, "helvetica");
|
||||
current_value = nautilus_preferences_get (item->details->preference_name);
|
||||
|
||||
g_assert (current_value != NULL);
|
||||
g_assert (nautilus_string_list_contains (font_list, current_value));
|
||||
|
@ -575,17 +608,17 @@ add_icon_themes(NautilusStringList *theme_list, char *required_file)
|
|||
|
||||
static void
|
||||
preferences_item_create_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
const char *preference_name)
|
||||
{
|
||||
char *description;
|
||||
char *current_value;
|
||||
NautilusStringList *theme_list;
|
||||
|
||||
g_assert (item != NULL);
|
||||
g_assert (preference != NULL);
|
||||
g_assert (preference_name != NULL);
|
||||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
description = nautilus_preference_get_description (preference);
|
||||
description = nautilus_preferences_get_description (preference_name);
|
||||
|
||||
g_assert (description != NULL);
|
||||
|
||||
|
@ -601,7 +634,7 @@ preferences_item_create_theme (NautilusPreferencesItem *item,
|
|||
|
||||
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (item->details->child), theme_list);
|
||||
|
||||
current_value = nautilus_preferences_get (item->details->preference_name, "default");
|
||||
current_value = nautilus_preferences_get (item->details->preference_name);
|
||||
|
||||
g_assert (current_value != NULL);
|
||||
g_assert (nautilus_string_list_contains (theme_list, current_value));
|
||||
|
@ -641,8 +674,7 @@ static void
|
|||
enum_radio_group_changed_callback (GtkWidget *buttons, GtkWidget * button, gpointer user_data)
|
||||
{
|
||||
NautilusPreferencesItem *item;
|
||||
const NautilusPreference *preference;
|
||||
gint i;
|
||||
gint i;
|
||||
|
||||
g_assert (user_data != NULL);
|
||||
g_assert (NAUTILUS_IS_PREFERENCES_ITEM (user_data));
|
||||
|
@ -651,12 +683,10 @@ enum_radio_group_changed_callback (GtkWidget *buttons, GtkWidget * button, gpoin
|
|||
|
||||
g_assert (item->details->preference_name != NULL);
|
||||
|
||||
preference = nautilus_preference_find_by_name (item->details->preference_name);
|
||||
|
||||
i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons));
|
||||
|
||||
nautilus_preferences_set_enum (item->details->preference_name,
|
||||
nautilus_preference_enum_get_nth_entry_value (preference, i));
|
||||
|
||||
nautilus_preferences_set_integer (item->details->preference_name,
|
||||
nautilus_preferences_enumeration_get_nth_value (item->details->preference_name, i));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -698,6 +728,7 @@ text_item_changed_callback (GtkWidget *button, gpointer user_data)
|
|||
g_free (text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
editable_string_changed_callback (GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
|
@ -721,3 +752,35 @@ editable_string_changed_callback (GtkWidget *button, gpointer user_data)
|
|||
g_free (text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
integer_changed_callback (GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
NautilusPreferencesItem *item;
|
||||
char *text;
|
||||
int value = 0;
|
||||
|
||||
g_assert (user_data != NULL);
|
||||
g_assert (NAUTILUS_IS_PREFERENCES_ITEM (user_data));
|
||||
|
||||
item = NAUTILUS_PREFERENCES_ITEM (user_data);
|
||||
|
||||
g_assert (item->details->child != NULL);
|
||||
g_assert (NAUTILUS_IS_TEXT_CAPTION (item->details->child));
|
||||
|
||||
text = nautilus_text_caption_get_text (NAUTILUS_TEXT_CAPTION (item->details->child));
|
||||
|
||||
if (text != NULL) {
|
||||
nautilus_eat_str_to_int (text, &value);
|
||||
}
|
||||
|
||||
nautilus_preferences_set_integer (item->details->preference_name, value);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_preferences_item_get_name (const NautilusPreferencesItem *preferences_item)
|
||||
{
|
||||
g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (preferences_item), NULL);
|
||||
|
||||
return g_strdup (preferences_item->details->preference_name);
|
||||
}
|
||||
|
|
|
@ -69,12 +69,13 @@ typedef enum
|
|||
NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY,
|
||||
NAUTILUS_PREFERENCE_ITEM_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING,
|
||||
NAUTILUS_PREFERENCE_ITEM_INTEGER
|
||||
} NautilusPreferencesItemType;
|
||||
|
||||
GtkType nautilus_preferences_item_get_type (void);
|
||||
GtkWidget* nautilus_preferences_item_new (const gchar *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
|
||||
GtkWidget* nautilus_preferences_item_new (const gchar *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
char * nautilus_preferences_item_get_name (const NautilusPreferencesItem *preferences_item);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -323,4 +323,22 @@ nautilus_preferences_pane_add_item_to_nth_group (NautilusPreferencesPane *prefs_
|
|||
return item;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_preferences_pane_update (NautilusPreferencesPane *prefs_pane)
|
||||
{
|
||||
GList *iterator;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_PREFS_PANE (prefs_pane));
|
||||
|
||||
for (iterator = prefs_pane->details->groups; iterator != NULL; iterator = iterator->next) {
|
||||
NautilusPreferencesGroup *group = NAUTILUS_PREFERENCES_GROUP (iterator->data);
|
||||
|
||||
nautilus_preferences_group_update (group);
|
||||
|
||||
if (nautilus_preferences_get_num_visible_items (group) == 0) {
|
||||
gtk_widget_hide (GTK_WIDGET (group));
|
||||
} else {
|
||||
gtk_widget_show (GTK_WIDGET (group));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ GtkWidget *nautilus_preferences_pane_add_item_to_nth_group (NautilusPreferencesP
|
|||
guint n,
|
||||
const char *preference_name,
|
||||
NautilusPreferencesItemType item_type);
|
||||
void nautilus_preferences_pane_update (NautilusPreferencesPane *prefs_pane);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-preferences.h - Preference peek/poke/notify object interface.
|
||||
/* nautilus-preferences.c - Preference peek/poke/notify interface.
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
|
@ -27,68 +27,100 @@
|
|||
|
||||
#include <gtk/gtkobject.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
|
||||
#include <libnautilus-extensions/nautilus-preference.h>
|
||||
#include <libnautilus-extensions/nautilus-string-list.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
/*
|
||||
* Preference names:
|
||||
*
|
||||
* In the api below, all preference names can be specified in two
|
||||
* different ways.
|
||||
*
|
||||
* 1) Independent of user level:
|
||||
*
|
||||
* Example1: "/apps/nautilus/preferences/something"
|
||||
*
|
||||
* The preference in question will be dealt with just as gconf
|
||||
* would without taking into account the Nautilus user level.
|
||||
*
|
||||
* You can also deal with non Nautilus things, such as:
|
||||
*
|
||||
* Example2: "/system/gnome-vfs/http-proxy"
|
||||
*
|
||||
* 2) By user level:
|
||||
*
|
||||
* Example: "preferences/something"
|
||||
*
|
||||
* The preference in question will depend on the current Nautilus
|
||||
* user level.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* A callback which you can register to to be notified when a particular
|
||||
* preference changes.
|
||||
*/
|
||||
typedef void (*NautilusPreferencesCallback) (gpointer callback_data);
|
||||
|
||||
gboolean nautilus_preferences_add_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data);
|
||||
gboolean nautilus_preferences_remove_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data);
|
||||
void nautilus_preferences_set_boolean (const char *name,
|
||||
gboolean value);
|
||||
gboolean nautilus_preferences_get_boolean (const char *name,
|
||||
gboolean default_value);
|
||||
void nautilus_preferences_set_enum (const char *name,
|
||||
int value);
|
||||
int nautilus_preferences_get_enum (const char *name,
|
||||
int default_value);
|
||||
/* User level */
|
||||
|
||||
void nautilus_preferences_set_string_list (const char *name,
|
||||
GSList *value);
|
||||
/* default value is NULL */
|
||||
GSList * nautilus_preferences_get_string_list (const char *name);
|
||||
/* Note that there's a function to get the number of user levels, but there's
|
||||
* a lot of code elsewhere that assumes three levels. Publicizing the numbers
|
||||
* of these levels lets that other code be coherent and less error-prone.
|
||||
*/
|
||||
#define NAUTILUS_USER_LEVEL_NOVICE 0
|
||||
#define NAUTILUS_USER_LEVEL_INTERMEDIATE 1
|
||||
#define NAUTILUS_USER_LEVEL_HACKER 2
|
||||
|
||||
void nautilus_preferences_set (const char *name,
|
||||
const char *value);
|
||||
char * nautilus_preferences_get (const char *name,
|
||||
const gchar *default_value);
|
||||
char * nautilus_preferences_get_user_level_name_for_display (int user_level);
|
||||
char * nautilus_preferences_get_user_level_name_for_storage (int user_level);
|
||||
int nautilus_preferences_get_user_level (void);
|
||||
void nautilus_preferences_set_user_level (int user_level);
|
||||
|
||||
/* Preferences getters and setters */
|
||||
gboolean nautilus_preferences_get_boolean (const char *name);
|
||||
void nautilus_preferences_set_boolean (const char *name,
|
||||
gboolean boolean_value);
|
||||
int nautilus_preferences_get_integer (const char *name);
|
||||
void nautilus_preferences_set_integer (const char *name,
|
||||
int int_value);
|
||||
char * nautilus_preferences_get (const char *name);
|
||||
void nautilus_preferences_set (const char *name,
|
||||
const char *string_value);
|
||||
GSList * nautilus_preferences_get_string_list (const char *name);
|
||||
void nautilus_preferences_set_string_list (const char *name,
|
||||
GSList *string_list_value);
|
||||
|
||||
/* Default values getters and setters */
|
||||
gboolean nautilus_preferences_default_get_boolean (const char *name,
|
||||
int user_level);
|
||||
void nautilus_preferences_default_set_boolean (const char *name,
|
||||
int user_level,
|
||||
gboolean boolean_value);
|
||||
int nautilus_preferences_default_get_integer (const char *name,
|
||||
int user_level);
|
||||
void nautilus_preferences_default_set_integer (const char *name,
|
||||
int user_level,
|
||||
int int_value);
|
||||
char * nautilus_preferences_default_get_string (const char *name,
|
||||
int user_level);
|
||||
void nautilus_preferences_default_set_string (const char *name,
|
||||
int user_level,
|
||||
const char *string_value);
|
||||
GSList * nautilus_preferences_default_get_string_list (const char *name,
|
||||
int user_level);
|
||||
void nautilus_preferences_default_set_string_list (const char *name,
|
||||
int user_level,
|
||||
GSList *string_list_value);
|
||||
/* Callbacks */
|
||||
void nautilus_preferences_add_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data);
|
||||
void nautilus_preferences_add_callback_while_alive (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data,
|
||||
GtkObject *alive_object);
|
||||
void nautilus_preferences_remove_callback (const char *name,
|
||||
NautilusPreferencesCallback callback,
|
||||
gpointer callback_data);
|
||||
|
||||
/* Preferences attributes */
|
||||
int nautilus_preferences_get_visible_user_level (const char *name);
|
||||
void nautilus_preferences_set_visible_user_level (const char *name,
|
||||
int visible_user_level);
|
||||
char * nautilus_preferences_get_description (const char *name);
|
||||
void nautilus_preferences_set_description (const char *name,
|
||||
const char *description);
|
||||
|
||||
/* Enumerations */
|
||||
void nautilus_preferences_enumeration_insert (const char *name,
|
||||
const char *entry,
|
||||
const char *description,
|
||||
int value);
|
||||
char * nautilus_preferences_enumeration_get_nth_entry (const char *name,
|
||||
guint n);
|
||||
char * nautilus_preferences_enumeration_get_nth_description (const char *name,
|
||||
guint n);
|
||||
int nautilus_preferences_enumeration_get_nth_value (const char *name,
|
||||
guint n);
|
||||
guint nautilus_preferences_enumeration_get_num_entries (const char *name);
|
||||
gboolean nautilus_preferences_monitor_directory (const char *directory);
|
||||
gboolean nautilus_preferences_is_visible (const char *name);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ smooth_widget_set_is_smooth (GtkWidget *widget, gboolean is_smooth)
|
|||
static gboolean
|
||||
preferences_get_is_smooth (void)
|
||||
{
|
||||
return nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, TRUE);
|
||||
return nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -41,7 +41,7 @@ kill_sound_if_necessary (void)
|
|||
pid_t sound_process;
|
||||
|
||||
/* fetch the sound state */
|
||||
sound_process = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
sound_process = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE);
|
||||
/* if there was a sound playing, kill it */
|
||||
if (sound_process > 0) {
|
||||
kill (-sound_process, SIGTERM);
|
||||
|
@ -54,7 +54,7 @@ kill_sound_if_necessary (void)
|
|||
void
|
||||
nautilus_sound_initialize (void)
|
||||
{
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
}
|
||||
|
||||
/* if there is a sound registered, kill it, and register the empty sound */
|
||||
|
@ -65,7 +65,7 @@ nautilus_sound_kill_sound (void)
|
|||
kill_sound_if_necessary ();
|
||||
|
||||
/* set the process state to quiescent */
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
}
|
||||
|
||||
/* register a new sound process, including kill any old one if necessary */
|
||||
|
@ -76,7 +76,7 @@ nautilus_sound_register_sound (pid_t sound_process)
|
|||
kill_sound_if_necessary ();
|
||||
|
||||
/* record the new sound process ID */
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, sound_process);
|
||||
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, sound_process);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -85,7 +85,7 @@ nautilus_sound_can_play_sound (void)
|
|||
int open_result, sound_process;
|
||||
|
||||
/* first see if there's already one in progress; if so, return true */
|
||||
sound_process = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE, 0);
|
||||
sound_process = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CURRENT_SOUND_STATE);
|
||||
if (sound_process > 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ static xmlDocPtr default_theme_document = NULL;
|
|||
char *
|
||||
nautilus_theme_get_theme (void)
|
||||
{
|
||||
return nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
return nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME);
|
||||
}
|
||||
|
||||
/* set the current theme */
|
||||
|
@ -142,7 +142,7 @@ nautilus_theme_get_theme_data (const char *resource_name, const char *property_n
|
|||
/* fetch the current theme name */
|
||||
theme_data = NULL;
|
||||
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME);
|
||||
if (nautilus_strcmp (theme_name, last_theme_name) == 0) {
|
||||
theme_document = last_theme_document;
|
||||
} else {
|
||||
|
@ -278,7 +278,7 @@ nautilus_theme_get_image_path (const char *image_name)
|
|||
{
|
||||
char *theme_name, *image_path;
|
||||
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME);
|
||||
image_path = nautilus_theme_get_image_path_from_theme (image_name, theme_name);
|
||||
g_free (theme_name);
|
||||
|
||||
|
|
|
@ -1,566 +0,0 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-user-level-manager.c - User level manager class.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the
|
||||
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Author: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "nautilus-user-level-manager.h"
|
||||
#include "nautilus-gtk-macros.h"
|
||||
#include "nautilus-glib-extensions.h"
|
||||
|
||||
#include "nautilus-preferences.h"
|
||||
#include "nautilus-preferences-private.h"
|
||||
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
#include <gtk/gtksignal.h>
|
||||
|
||||
#include <gconf/gconf.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define NAUTILUS_TYPE_USER_LEVEL_MANAGER (nautilus_user_level_manager_get_type ())
|
||||
#define NAUTILUS_USER_LEVEL_MANAGER(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_USER_LEVEL_MANAGER, NautilusUserLevelManager))
|
||||
#define NAUTILUS_USER_LEVEL_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_USER_LEVEL_MANAGER, NautilusUserLevelManagerClass))
|
||||
#define NAUTILUS_IS_USER_LEVEL_MANAGER(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_USER_LEVEL_MANAGER))
|
||||
#define NAUTILUS_IS_USER_LEVEL_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_USER_LEVEL_MANAGER))
|
||||
|
||||
static const char *DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE[] =
|
||||
{
|
||||
"novice",
|
||||
"intermediate",
|
||||
"hacker"
|
||||
};
|
||||
|
||||
static const char *DEFAULT_USER_LEVEL_NAMES_FOR_DISPLAY[] =
|
||||
{
|
||||
N_("Beginner"),
|
||||
N_("Intermediate"),
|
||||
N_("Advanced")
|
||||
};
|
||||
|
||||
static const guint DEFAULT_NUM_USER_LEVELS = NAUTILUS_N_ELEMENTS (DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE);
|
||||
static const guint DEFAULT_USER_LEVEL = NAUTILUS_USER_LEVEL_HACKER;
|
||||
|
||||
static const char USER_LEVEL_KEY[] = "/apps/nautilus/user_level";
|
||||
static const char USER_LEVEL_PATH[] = "/apps/nautilus";
|
||||
|
||||
static NautilusUserLevelManager *global_manager = NULL;
|
||||
|
||||
struct _NautilusUserLevelManager
|
||||
{
|
||||
GtkObject object;
|
||||
|
||||
guint num_user_levels;
|
||||
NautilusStringList *user_level_names_for_storage;
|
||||
NautilusStringList *user_level_names_for_display;
|
||||
|
||||
GConfClient *gconf_client;
|
||||
int user_level_changed_connection;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkObjectClass parent_class;
|
||||
} NautilusUserLevelManagerClass;
|
||||
|
||||
enum
|
||||
{
|
||||
USER_LEVEL_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint user_level_manager_signals[LAST_SIGNAL];
|
||||
|
||||
static GtkType nautilus_user_level_manager_get_type (void);
|
||||
static void nautilus_user_level_manager_initialize_class (NautilusUserLevelManagerClass *user_level_manager_class);
|
||||
static void nautilus_user_level_manager_initialize (NautilusUserLevelManager *user_level_manager);
|
||||
static void user_level_manager_destroy (GtkObject *object);
|
||||
static char *user_level_manager_get_user_level_as_string (void);
|
||||
static NautilusUserLevelManager *user_level_manager_new (void);
|
||||
static void user_level_manager_ensure_global_manager (void);
|
||||
static void user_level_set_default_if_needed (NautilusUserLevelManager *manager);
|
||||
|
||||
|
||||
/* Gconf callbacks */
|
||||
static void gconf_user_level_changed_callback (GConfClient *client,
|
||||
guint cnxn_id,
|
||||
GConfEntry *entry,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusUserLevelManager, nautilus_user_level_manager, GTK_TYPE_OBJECT)
|
||||
|
||||
/* Create the icon factory. */
|
||||
static NautilusUserLevelManager *
|
||||
user_level_manager_new (void)
|
||||
{
|
||||
GError *error = NULL;
|
||||
NautilusUserLevelManager *manager;
|
||||
guint i;
|
||||
|
||||
if (!gconf_is_initialized ()) {
|
||||
char *argv[] = { "nautilus", NULL };
|
||||
|
||||
if (!gconf_init (1, argv, &error)) {
|
||||
g_assert (error != NULL);
|
||||
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
manager = NAUTILUS_USER_LEVEL_MANAGER (gtk_object_new (nautilus_user_level_manager_get_type (), NULL));
|
||||
gtk_object_ref (GTK_OBJECT (manager));
|
||||
gtk_object_sink (GTK_OBJECT (manager));
|
||||
|
||||
manager->gconf_client = gconf_client_get_default ();
|
||||
|
||||
/* Let gconf know about ~/.gconf/apps/nautilus */
|
||||
gconf_client_add_dir (manager->gconf_client,
|
||||
USER_LEVEL_PATH,
|
||||
GCONF_CLIENT_PRELOAD_NONE,
|
||||
&error);
|
||||
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
manager->num_user_levels = DEFAULT_NUM_USER_LEVELS;
|
||||
manager->user_level_names_for_storage = nautilus_string_list_new (TRUE);
|
||||
manager->user_level_names_for_display = nautilus_string_list_new (TRUE);
|
||||
|
||||
for (i = 0; i < DEFAULT_NUM_USER_LEVELS; i++) {
|
||||
nautilus_string_list_insert (manager->user_level_names_for_storage, DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE[i]);
|
||||
nautilus_string_list_insert (manager->user_level_names_for_display, _(DEFAULT_USER_LEVEL_NAMES_FOR_DISPLAY[i]));
|
||||
}
|
||||
|
||||
g_assert (manager->gconf_client != NULL);
|
||||
|
||||
user_level_set_default_if_needed (manager);
|
||||
|
||||
/* Add a gconf notification for user_level changes. */
|
||||
manager->user_level_changed_connection = gconf_client_notify_add (manager->gconf_client,
|
||||
USER_LEVEL_KEY,
|
||||
gconf_user_level_changed_callback,
|
||||
NULL,
|
||||
NULL,
|
||||
&error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_user_level_manager_initialize (NautilusUserLevelManager *manager)
|
||||
{
|
||||
manager->num_user_levels = 0;
|
||||
|
||||
manager->gconf_client = NULL;
|
||||
manager->user_level_changed_connection = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_user_level_manager_initialize_class (NautilusUserLevelManagerClass *user_level_manager_class)
|
||||
{
|
||||
GtkObjectClass *object_class = GTK_OBJECT_CLASS (user_level_manager_class);
|
||||
|
||||
user_level_manager_signals[USER_LEVEL_CHANGED] = gtk_signal_new ("user_level_changed",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
0,
|
||||
gtk_marshal_NONE__NONE,
|
||||
GTK_TYPE_NONE,
|
||||
0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, user_level_manager_signals, LAST_SIGNAL);
|
||||
|
||||
/* GtkObjectClass */
|
||||
object_class->destroy = user_level_manager_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_manager_destroy (GtkObject *object)
|
||||
{
|
||||
NautilusUserLevelManager *manager;
|
||||
|
||||
manager = NAUTILUS_USER_LEVEL_MANAGER (object);
|
||||
|
||||
/* Remove the gconf notification if its still lingering */
|
||||
if (manager->user_level_changed_connection != 0) {
|
||||
gconf_client_notify_remove (manager->gconf_client,
|
||||
manager->user_level_changed_connection);
|
||||
|
||||
manager->user_level_changed_connection = 0;
|
||||
}
|
||||
|
||||
if (manager->gconf_client != NULL) {
|
||||
gtk_object_unref (GTK_OBJECT (manager->gconf_client));
|
||||
}
|
||||
|
||||
nautilus_string_list_free (manager->user_level_names_for_storage);
|
||||
nautilus_string_list_free (manager->user_level_names_for_display);
|
||||
}
|
||||
|
||||
static void
|
||||
unref_user_level_manager (void)
|
||||
{
|
||||
gtk_object_unref (GTK_OBJECT (global_manager));
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_manager_ensure_global_manager (void)
|
||||
{
|
||||
if (global_manager == NULL) {
|
||||
global_manager = user_level_manager_new ();
|
||||
g_atexit (unref_user_level_manager);
|
||||
}
|
||||
|
||||
g_assert (global_manager != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_set_default_if_needed (NautilusUserLevelManager *manager)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GConfValue *value;
|
||||
|
||||
g_assert (manager != NULL);
|
||||
g_assert (manager->gconf_client != NULL);
|
||||
|
||||
value = gconf_client_get_without_default (manager->gconf_client, USER_LEVEL_KEY, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
if (value != NULL) {
|
||||
gconf_value_free (value);
|
||||
value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (value == NULL) {
|
||||
value = gconf_value_new (GCONF_VALUE_STRING);
|
||||
|
||||
gconf_value_set_string (value, DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE[DEFAULT_USER_LEVEL]);
|
||||
|
||||
gconf_client_set (manager->gconf_client, USER_LEVEL_KEY, value, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
gconf_client_suggest_sync (manager->gconf_client, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
}
|
||||
|
||||
g_assert (value != NULL);
|
||||
|
||||
gconf_value_free (value);
|
||||
}
|
||||
|
||||
static void
|
||||
gconf_user_level_changed_callback (GConfClient *client,
|
||||
guint connection_id,
|
||||
GConfEntry *entry,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (manager), user_level_manager_signals[USER_LEVEL_CHANGED]);
|
||||
}
|
||||
|
||||
/* Public NautilusUserLevelManager functions */
|
||||
NautilusUserLevelManager *
|
||||
nautilus_user_level_manager_get (void)
|
||||
{
|
||||
user_level_manager_ensure_global_manager ();
|
||||
|
||||
g_assert (global_manager != NULL);
|
||||
g_assert (NAUTILUS_IS_USER_LEVEL_MANAGER (global_manager));
|
||||
|
||||
return global_manager;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_user_level_manager_set_user_level (guint user_level)
|
||||
{
|
||||
GError *error = NULL;
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
char *user_level_string;
|
||||
guint old_user_level;
|
||||
|
||||
g_return_if_fail (user_level < manager->num_user_levels);
|
||||
g_return_if_fail (user_level < nautilus_string_list_get_length (manager->user_level_names_for_storage));
|
||||
|
||||
old_user_level = nautilus_user_level_manager_get_user_level ();
|
||||
|
||||
if (old_user_level == user_level) {
|
||||
return;
|
||||
}
|
||||
|
||||
user_level_string = nautilus_string_list_nth (manager->user_level_names_for_storage, user_level);
|
||||
|
||||
g_assert (user_level_string != NULL);
|
||||
|
||||
gconf_client_set_string (manager->gconf_client,
|
||||
USER_LEVEL_KEY,
|
||||
user_level_string,
|
||||
&error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
|
||||
gconf_client_suggest_sync (manager->gconf_client, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_user_level_manager_get_user_level (void)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
char *user_level_string;
|
||||
gint index;
|
||||
|
||||
user_level_string = user_level_manager_get_user_level_as_string ();
|
||||
|
||||
/* The user_level_string is guranteed to be ok now. The above function, will
|
||||
* make sure of that and deal with gconf problems too.
|
||||
*/
|
||||
g_assert (user_level_string != NULL);
|
||||
|
||||
index = nautilus_string_list_get_index_for_string (manager->user_level_names_for_storage,
|
||||
user_level_string);
|
||||
|
||||
g_free (user_level_string);
|
||||
|
||||
g_assert (index != NAUTILUS_STRING_LIST_NOT_FOUND);
|
||||
|
||||
return (guint) index;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_user_level_manager_get_user_level_name_for_display (guint user_level)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
|
||||
return nautilus_string_list_nth (manager->user_level_names_for_display, user_level);
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_user_level_manager_make_gconf_key (const char *preference_name,
|
||||
guint user_level)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
|
||||
char *key;
|
||||
char *user_level_string;
|
||||
|
||||
g_return_val_if_fail (preference_name != NULL, NULL);
|
||||
g_return_val_if_fail (user_level < manager->num_user_levels, NULL);
|
||||
g_return_val_if_fail (user_level < nautilus_string_list_get_length (manager->user_level_names_for_storage), NULL);
|
||||
|
||||
user_level_string = nautilus_string_list_nth (manager->user_level_names_for_storage, user_level);
|
||||
g_assert (user_level_string != NULL);
|
||||
|
||||
key = g_strdup_printf ("%s/%s/%s",
|
||||
USER_LEVEL_PATH,
|
||||
user_level_string,
|
||||
preference_name);
|
||||
|
||||
g_free (user_level_string);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
char *
|
||||
nautilus_user_level_manager_make_current_gconf_key (const char *preference_name)
|
||||
{
|
||||
return nautilus_user_level_manager_make_gconf_key (preference_name,
|
||||
nautilus_user_level_manager_get_user_level ());
|
||||
}
|
||||
|
||||
static char *
|
||||
user_level_manager_get_user_level_as_string (void)
|
||||
{
|
||||
GError *error = NULL;
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
char *user_level_string = NULL;
|
||||
|
||||
g_assert (manager->gconf_client != NULL);
|
||||
|
||||
user_level_string = gconf_client_get_string (manager->gconf_client, USER_LEVEL_KEY, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
g_free (user_level_string);
|
||||
user_level_string = NULL;
|
||||
}
|
||||
|
||||
if (!user_level_string)
|
||||
user_level_string = g_strdup (DEFAULT_USER_LEVEL_NAMES_FOR_STORAGE[0]);
|
||||
|
||||
return user_level_string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nautilus_user_level_manager_set_default_value_if_needed
|
||||
*
|
||||
* This function will ask gconf for a value. If
|
||||
*
|
||||
* The value is not found in the user's database:
|
||||
* It will be added to the database using the given default value.
|
||||
*
|
||||
* The value is found in the user's database:
|
||||
* Nothing.
|
||||
*
|
||||
* @name: The name of the preference.
|
||||
* @type: The type of preference.
|
||||
* @default_value: The default_value to use.
|
||||
**/
|
||||
void
|
||||
nautilus_user_level_manager_set_default_value_if_needed (const char *preference_name,
|
||||
NautilusPreferenceType type,
|
||||
guint user_level,
|
||||
gconstpointer default_value)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
GError *error = NULL;
|
||||
GConfValue *value = NULL;
|
||||
char *key;
|
||||
|
||||
g_return_if_fail (preference_name != NULL);
|
||||
|
||||
key = nautilus_user_level_manager_make_gconf_key (preference_name, user_level);
|
||||
g_assert (key != NULL);
|
||||
|
||||
/* Find out if the preference exists at all */
|
||||
value = gconf_client_get_without_default (manager->gconf_client, key, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
if (value != NULL) {
|
||||
gconf_value_free (value);
|
||||
value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* The value does not exist, so create one */
|
||||
if (!value) {
|
||||
switch (type)
|
||||
{
|
||||
case NAUTILUS_PREFERENCE_STRING:
|
||||
/* Gconf will not grok NULL strings, so for this case dont do it. */
|
||||
if (default_value) {
|
||||
value = gconf_value_new (GCONF_VALUE_STRING);
|
||||
gconf_value_set_string (value, (const char *) default_value);
|
||||
}
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_BOOLEAN:
|
||||
value = gconf_value_new (GCONF_VALUE_BOOL);
|
||||
gconf_value_set_bool (value, GPOINTER_TO_INT (default_value));
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_ENUM:
|
||||
value = gconf_value_new (GCONF_VALUE_INT);
|
||||
gconf_value_set_int (value, GPOINTER_TO_INT (default_value));
|
||||
break;
|
||||
}
|
||||
|
||||
if (value) {
|
||||
gconf_client_set (manager->gconf_client, key, value, &error);
|
||||
nautilus_preferences_handle_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
if (value) {
|
||||
gconf_value_free (value);
|
||||
}
|
||||
|
||||
g_free (key);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_user_level_manager_compare_preference_between_user_levels (const char *preference_name,
|
||||
guint user_level_a,
|
||||
guint user_level_b)
|
||||
{
|
||||
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
|
||||
gboolean result = FALSE;
|
||||
char *key_a;
|
||||
char *key_b;
|
||||
GConfValue *value_a;
|
||||
GConfValue *value_b;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (preference_name != NULL, FALSE);
|
||||
|
||||
key_a = nautilus_user_level_manager_make_gconf_key (preference_name, user_level_a);
|
||||
g_assert (key_a != NULL);
|
||||
|
||||
key_b = nautilus_user_level_manager_make_gconf_key (preference_name, user_level_b);
|
||||
g_assert (key_b != NULL);
|
||||
|
||||
value_a = gconf_client_get (manager->gconf_client, key_a, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
if (value_a != NULL) {
|
||||
gconf_value_free (value_a);
|
||||
value_a = NULL;
|
||||
}
|
||||
}
|
||||
value_b = gconf_client_get (manager->gconf_client, key_b, &error);
|
||||
if (nautilus_preferences_handle_error (&error)) {
|
||||
if (value_b != NULL) {
|
||||
gconf_value_free (value_b);
|
||||
value_b = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
g_free (key_a);
|
||||
g_free (key_b);
|
||||
|
||||
if (value_a && value_b)
|
||||
{
|
||||
g_assert (value_a->type == value_b->type);
|
||||
|
||||
switch (value_a->type)
|
||||
{
|
||||
case GCONF_VALUE_STRING:
|
||||
result = (gconf_value_get_string (value_a)
|
||||
&& gconf_value_get_string (value_b)
|
||||
&& (strcmp (gconf_value_get_string (value_a), gconf_value_get_string (value_b)) == 0));
|
||||
break;
|
||||
|
||||
case GCONF_VALUE_INT:
|
||||
result = (gconf_value_get_int (value_a) == gconf_value_get_int (value_b));
|
||||
break;
|
||||
|
||||
case GCONF_VALUE_BOOL:
|
||||
result = (gconf_value_get_bool (value_a) == gconf_value_get_bool (value_b));
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
if (value_a) {
|
||||
gconf_value_free (value_a);
|
||||
}
|
||||
|
||||
if (value_b) {
|
||||
gconf_value_free (value_b);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-user-level-manager.h - User level manager interface.
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_USER_LEVEL_MANAGER_H
|
||||
#define NAUTILUS_USER_LEVEL_MANAGER_H
|
||||
|
||||
#include <gtk/gtkobject.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libnautilus-extensions/nautilus-string-list.h>
|
||||
#include <libnautilus-extensions/nautilus-preference.h>
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
typedef struct _NautilusUserLevelManager NautilusUserLevelManager;
|
||||
|
||||
/* There is a single NautilusUserLevelManager object.
|
||||
* The only thing you need it for is to connect to its signals.
|
||||
*
|
||||
* "user_level_changed", no parameters
|
||||
*
|
||||
*/
|
||||
NautilusUserLevelManager* nautilus_user_level_manager_get (void);
|
||||
void nautilus_user_level_manager_set_user_level (guint user_level);
|
||||
guint nautilus_user_level_manager_get_user_level (void);
|
||||
char *nautilus_user_level_manager_get_user_level_name_for_display (guint user_level);
|
||||
char *nautilus_user_level_manager_make_current_gconf_key (const char *preference_name);
|
||||
char *nautilus_user_level_manager_make_gconf_key (const char *preference_name,
|
||||
guint user_level);
|
||||
void nautilus_user_level_manager_set_default_value_if_needed (const char *preference_name,
|
||||
NautilusPreferenceType type,
|
||||
guint user_level,
|
||||
gconstpointer default_value);
|
||||
gboolean nautilus_user_level_manager_compare_preference_between_user_levels (const char *preference_name,
|
||||
guint user_level_a,
|
||||
guint user_level_b);
|
||||
|
||||
/* Note that there's a function to get the number of user levels, but there's
|
||||
* a lot of code elsewhere that assumes three levels. Publicizing the numbers
|
||||
* of these levels lets that other code be coherent and less error-prone.
|
||||
*/
|
||||
#define NAUTILUS_USER_LEVEL_NOVICE 0
|
||||
#define NAUTILUS_USER_LEVEL_INTERMEDIATE 1
|
||||
#define NAUTILUS_USER_LEVEL_HACKER 2
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
#endif /* NAUTILUS_USER_LEVEL_MANAGER_H */
|
|
@ -1,3 +1,7 @@
|
|||
2001-01-17 Ramiro Estrugo <ramiro@eazel.com>
|
||||
* POTFILES.in:
|
||||
Remove nautilus-user-level-manager.[ch] which was just retired.
|
||||
|
||||
2001-01-17 Christian Rose <menthos@menthos.com>
|
||||
|
||||
* sv.po: Updated Swedish translation.
|
||||
|
|
|
@ -113,7 +113,6 @@ libnautilus-extensions/nautilus-search-uri.c
|
|||
libnautilus-extensions/nautilus-stock-dialogs.c
|
||||
libnautilus-extensions/nautilus-trash-directory.c
|
||||
libnautilus-extensions/nautilus-undo-signal-handlers.c
|
||||
libnautilus-extensions/nautilus-user-level-manager.c
|
||||
libnautilus-extensions/nautilus-volume-monitor.c
|
||||
libnautilus/nautilus-clipboard-ui.xml
|
||||
libnautilus/nautilus-clipboard.c
|
||||
|
|
|
@ -790,7 +790,7 @@ update_link_and_delete_copies (gboolean (*is_link_function) (const char *path),
|
|||
static void
|
||||
update_home_link_and_delete_copies (void)
|
||||
{
|
||||
char *desktop_path, *home_link_name, *home_dir_uri, *home_uri;
|
||||
char *desktop_path, *home_link_name, *home_uri;
|
||||
|
||||
desktop_path = nautilus_get_desktop_directory ();
|
||||
|
||||
|
@ -801,9 +801,7 @@ update_home_link_and_delete_copies (void)
|
|||
*/
|
||||
home_link_name = g_strdup_printf (_("%s's Home"), g_get_user_name ());
|
||||
|
||||
home_dir_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI, home_dir_uri);
|
||||
g_free (home_dir_uri);
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
|
||||
|
||||
if (!update_link_and_delete_copies (nautilus_link_local_is_home_link,
|
||||
home_link_name,
|
||||
|
@ -1086,7 +1084,7 @@ real_update_menus (FMDirectoryView *view)
|
|||
DESKTOP_COMMAND_EMPTY_TRASH_CONDITIONAL,
|
||||
!include_empty_trash);
|
||||
if (include_empty_trash) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH)) {
|
||||
label = g_strdup (_("Empty Trash..."));
|
||||
} else {
|
||||
label = g_strdup (_("Empty Trash"));
|
||||
|
|
|
@ -587,7 +587,7 @@ open_location (FMDirectoryView *directory_view,
|
|||
|
||||
switch (choice) {
|
||||
case RESPECT_PREFERENCE:
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, FALSE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
|
||||
nautilus_view_open_location_prefer_existing_window
|
||||
(directory_view->details->nautilus_view, new_uri);
|
||||
} else {
|
||||
|
@ -2639,7 +2639,7 @@ confirm_delete_from_trash (FMDirectoryView *view, GList *uris)
|
|||
g_assert (FM_IS_DIRECTORY_VIEW (view));
|
||||
|
||||
/* Just Say Yes if the preference says not to confirm. */
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH, TRUE)) {
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -3141,8 +3141,7 @@ real_update_menus (FMDirectoryView *view)
|
|||
selection = fm_directory_view_get_selection (view);
|
||||
selection_count = g_list_length (selection);
|
||||
|
||||
confirm_trash = nautilus_preferences_get_boolean
|
||||
(NAUTILUS_PREFERENCES_CONFIRM_TRASH, TRUE);
|
||||
confirm_trash = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH);
|
||||
selection_contains_special_link = special_link_in_selection (view);
|
||||
can_create_files = fm_directory_view_supports_creating_files (view);
|
||||
|
||||
|
@ -3632,9 +3631,8 @@ fm_directory_view_activate_files (FMDirectoryView *view,
|
|||
*/
|
||||
file_count = g_list_length (files);
|
||||
use_new_window = file_count > 1
|
||||
|| nautilus_preferences_get_boolean
|
||||
(NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, FALSE);
|
||||
|
||||
|| nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW);
|
||||
|
||||
if (!use_new_window || fm_directory_view_confirm_multiple_windows (view, file_count)) {
|
||||
for (node = files; node != NULL; node = node->next) {
|
||||
fm_directory_view_activate_file
|
||||
|
@ -4121,10 +4119,10 @@ filtering_changed_callback (gpointer callback_data)
|
|||
directory_view = FM_DIRECTORY_VIEW (callback_data);
|
||||
|
||||
directory_view->details->show_hidden_files =
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, FALSE);
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
|
||||
|
||||
directory_view->details->show_backup_files =
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, FALSE);
|
||||
nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES);
|
||||
|
||||
/* Reload the current uri so that the filtering changes take place. */
|
||||
if (directory_view->details->model != NULL) {
|
||||
|
|
|
@ -194,7 +194,7 @@ changed_attributes_option_menu_callback (GtkMenuItem *menu_item, gpointer user_d
|
|||
attribute_names_string = g_strjoinv ("|", attribute_names_array);
|
||||
|
||||
nautilus_preferences_set (NAUTILUS_PREFERENCES_ICON_CAPTIONS,
|
||||
attribute_names_string);
|
||||
attribute_names_string);
|
||||
|
||||
g_free (attribute_names_string);
|
||||
g_strfreev (attribute_names_array);
|
||||
|
@ -399,8 +399,7 @@ fm_get_text_attribute_names_preference_or_default (void)
|
|||
{
|
||||
char *preference;
|
||||
|
||||
preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_ICON_CAPTIONS,
|
||||
DEFAULT_ATTRIBUTE_NAMES);
|
||||
preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_ICON_CAPTIONS);
|
||||
if (preference && attribute_names_string_is_good (preference)) {
|
||||
return preference;
|
||||
}
|
||||
|
|
|
@ -1409,8 +1409,7 @@ static gboolean
|
|||
should_preview_sound (NautilusFile *file) {
|
||||
int preview_mode;
|
||||
|
||||
preview_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_PREVIEW_SOUND,
|
||||
NAUTILUS_SPEED_TRADEOFF_ALWAYS);
|
||||
preview_mode = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_PREVIEW_SOUND);
|
||||
|
||||
if (preview_mode == NAUTILUS_SPEED_TRADEOFF_NEVER) {
|
||||
return FALSE;
|
||||
|
@ -1972,8 +1971,7 @@ fm_icon_view_update_click_mode (FMIconView *icon_view)
|
|||
icon_container = get_icon_container (icon_view);
|
||||
g_assert (icon_container != NULL);
|
||||
|
||||
click_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
|
||||
NAUTILUS_CLICK_POLICY_DOUBLE);
|
||||
click_mode = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CLICK_POLICY);
|
||||
|
||||
|
||||
nautilus_icon_container_set_single_click_mode (icon_container,
|
||||
|
@ -1989,9 +1987,8 @@ fm_icon_view_update_smooth_graphics_mode (FMIconView *icon_view)
|
|||
icon_container = get_icon_container (icon_view);
|
||||
g_assert (icon_container != NULL);
|
||||
|
||||
smooth_graphics_mode = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE,
|
||||
TRUE);
|
||||
|
||||
smooth_graphics_mode = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE);
|
||||
|
||||
nautilus_icon_container_set_anti_aliased_mode (icon_container, smooth_graphics_mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -1742,8 +1742,7 @@ fm_list_view_update_click_mode (FMDirectoryView *view)
|
|||
g_assert (FM_IS_LIST_VIEW (view));
|
||||
g_assert (get_list (FM_LIST_VIEW (view)) != NULL);
|
||||
|
||||
click_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
|
||||
NAUTILUS_CLICK_POLICY_DOUBLE);
|
||||
click_mode = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CLICK_POLICY);
|
||||
|
||||
nautilus_list_set_single_click_mode (get_list (FM_LIST_VIEW (view)),
|
||||
click_mode == NAUTILUS_CLICK_POLICY_SINGLE);
|
||||
|
|
|
@ -1660,8 +1660,7 @@ create_permissions_page (FMPropertiesWindow *window)
|
|||
_("You are not the owner, so you can't change these permissions."));
|
||||
}
|
||||
|
||||
show_special_flags = nautilus_preferences_get_boolean
|
||||
(NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS, FALSE);
|
||||
show_special_flags = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS);
|
||||
|
||||
page_table = GTK_TABLE (gtk_table_new (1, COLUMN_COUNT, FALSE));
|
||||
apply_standard_table_padding (page_table);
|
||||
|
|
|
@ -605,7 +605,7 @@ desktop_changed_callback (gpointer user_data)
|
|||
NautilusApplication *application;
|
||||
|
||||
application = NAUTILUS_APPLICATION (user_data);
|
||||
if ( nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP, TRUE)) {
|
||||
if ( nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP)) {
|
||||
nautilus_application_open_desktop (application);
|
||||
} else {
|
||||
nautilus_application_close_desktop ();
|
||||
|
|
|
@ -356,7 +356,7 @@ nautilus_complex_search_bar_get_location (NautilusNavigationBar *navigation_bar)
|
|||
escaped_fragment = gnome_vfs_escape_string (trimmed_fragment);
|
||||
g_free (trimmed_fragment);
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SEARCH_METHOD, FALSE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SEARCH_METHOD)) {
|
||||
search_uri = g_strconcat ("search:index-with-backup", escaped_fragment, NULL);
|
||||
} else {
|
||||
search_uri = g_strconcat ("search:index-if-available", escaped_fragment, NULL);
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include <libnautilus-extensions/nautilus-preferences.h>
|
||||
#include <libnautilus-extensions/nautilus-radio-button-group.h>
|
||||
#include <libnautilus-extensions/nautilus-string.h>
|
||||
#include <libnautilus-extensions/nautilus-user-level-manager.h>
|
||||
#include <libnautilus-extensions/nautilus-global-preferences.h>
|
||||
#include <libnautilus-extensions/nautilus-stock-dialogs.h>
|
||||
#include <nautilus-main.h>
|
||||
#include <netdb.h>
|
||||
|
@ -258,7 +258,7 @@ user_level_selection_changed (GtkWidget *radio_button, gpointer user_data)
|
|||
int user_level = GPOINTER_TO_INT (user_data);
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (radio_button)->active) {
|
||||
nautilus_user_level_manager_set_user_level (user_level);
|
||||
nautilus_preferences_set_user_level (user_level);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ make_hbox_user_level_radio_button (int index, GtkWidget *radio_buttons[],
|
|||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
|
||||
user_level_name = nautilus_user_level_manager_get_user_level_name_for_display (index);
|
||||
user_level_name = nautilus_preferences_get_user_level_name_for_display (index);
|
||||
|
||||
/* Add an "indent" */
|
||||
alignment = gtk_alignment_new (1.0, 1.0, 1.0, 1.0);
|
||||
|
@ -436,7 +436,7 @@ set_up_user_level_page (NautilusDruidPageEazel *page)
|
|||
NULL);
|
||||
gtk_box_pack_start (GTK_BOX (main_box), hbox, FALSE, FALSE, 2);
|
||||
|
||||
user_level = nautilus_user_level_manager_get_user_level ();
|
||||
user_level = nautilus_preferences_get_user_level ();
|
||||
g_assert (user_level >= NAUTILUS_USER_LEVEL_NOVICE && user_level <= NAUTILUS_USER_LEVEL_HACKER);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_buttons[user_level]), TRUE);
|
||||
|
||||
|
|
|
@ -330,7 +330,7 @@ nautilus_sidebar_sidebar_panel_enabled (const char *panel_iid)
|
|||
char *key;
|
||||
|
||||
key = nautilus_sidebar_get_sidebar_panel_key (panel_iid);
|
||||
enabled = nautilus_preferences_get_boolean (key, FALSE);
|
||||
enabled = nautilus_preferences_get_boolean (key);
|
||||
g_free (key);
|
||||
return enabled;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ toggle_sidebar_panel (GtkWidget *widget, char *sidebar_id)
|
|||
nautilus_sidebar_hide_active_panel_if_matches (sidebar, sidebar_id);
|
||||
|
||||
key = nautilus_sidebar_get_sidebar_panel_key (sidebar_id);
|
||||
nautilus_preferences_set_boolean (key, !nautilus_preferences_get_boolean (key, FALSE));
|
||||
nautilus_preferences_set_boolean (key, !nautilus_preferences_get_boolean (key));
|
||||
g_free (key);
|
||||
}
|
||||
|
||||
|
@ -1544,8 +1544,7 @@ nautilus_sidebar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
|
|||
|
||||
if (widget->allocation.width != sidebar->details->old_width) {
|
||||
sidebar->details->old_width = widget->allocation.width;
|
||||
/* FIXME: This is not an "enum". */
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
|
||||
widget->allocation.width);
|
||||
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
|
||||
widget->allocation.width);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ main (int argc, char *argv[])
|
|||
*/
|
||||
nautilus_global_preferences_initialize ();
|
||||
|
||||
start_desktop = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP, TRUE);
|
||||
start_desktop = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP);
|
||||
|
||||
/* Do either the self-check or the real work. */
|
||||
if (perform_self_check) {
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
#include <libnautilus-extensions/nautilus-stock-dialogs.h>
|
||||
#include <libnautilus-extensions/nautilus-string.h>
|
||||
#include <libnautilus-extensions/nautilus-undo-manager.h>
|
||||
#include <libnautilus-extensions/nautilus-user-level-manager.h>
|
||||
#include <libnautilus-extensions/nautilus-xml-extensions.h>
|
||||
#include <libnautilus/nautilus-bonobo-ui.h>
|
||||
|
||||
|
@ -110,12 +109,9 @@ static void add_bookmark_for_current_location (Naut
|
|||
/* 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 char * get_customize_user_level_settings_menu_string (void);
|
||||
static void update_user_level_menu_items (NautilusWindow *window);
|
||||
static char * get_customize_user_level_string (void);
|
||||
static void switch_to_user_level (NautilusWindow *window,
|
||||
int new_user_level);
|
||||
static void update_preferences_dialog_title (void);
|
||||
|
||||
|
||||
#define NAUTILUS_MENU_PATH_USER_LEVEL "/menu/Preferences"
|
||||
|
@ -479,75 +475,13 @@ bookmarks_menu_edit_bookmarks_callback (BonoboUIComponent *component,
|
|||
edit_bookmarks (NAUTILUS_WINDOW (user_data));
|
||||
}
|
||||
|
||||
static void
|
||||
switch_and_show_intermediate_settings_callback (GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
g_assert (NAUTILUS_IS_WINDOW (user_data));
|
||||
|
||||
switch_to_user_level (NAUTILUS_WINDOW (user_data), NAUTILUS_USER_LEVEL_INTERMEDIATE);
|
||||
nautilus_global_preferences_show_dialog ();
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_customize_callback (BonoboUIComponent *component,
|
||||
gpointer user_data,
|
||||
const char *verb)
|
||||
{
|
||||
GnomeDialog *dialog;
|
||||
NautilusWindow *window;
|
||||
char *novice_level_name;
|
||||
char *intermediate_level_name;
|
||||
char *expert_level_name;
|
||||
char *prompt;
|
||||
char *dialog_title;
|
||||
|
||||
window = NAUTILUS_WINDOW (user_data);
|
||||
|
||||
if (nautilus_user_level_manager_get_user_level () == NAUTILUS_USER_LEVEL_NOVICE) {
|
||||
novice_level_name =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(NAUTILUS_USER_LEVEL_NOVICE);
|
||||
intermediate_level_name =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(NAUTILUS_USER_LEVEL_INTERMEDIATE);
|
||||
expert_level_name =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(NAUTILUS_USER_LEVEL_HACKER);
|
||||
/* Localizers: This is the message in the dialog that appears if the user chooses "Edit Beginner Settings".
|
||||
* The first %s is the name of the lowest user level ("Beginner"). The 2nd and 4th %s are the
|
||||
* names of the middle user level ("Intermediate"). The 3rd %s is the name of the highest user
|
||||
* level ("Advanced").
|
||||
*/
|
||||
prompt = g_strdup_printf (_("None of the settings for the %s level can be edited. "
|
||||
"If you want to edit the settings you must choose the %s or %s "
|
||||
"level. Do you want to switch to the %s level now "
|
||||
"and edit its settings?"),
|
||||
novice_level_name,
|
||||
intermediate_level_name,
|
||||
expert_level_name,
|
||||
intermediate_level_name);
|
||||
|
||||
/* Localizers: This is the title of the dialog that appears if the user chooses "Edit Beginner Settings".
|
||||
* The %s is the name of the middle user level ("Intermediate").
|
||||
*/
|
||||
dialog_title = g_strdup_printf (_("Switch to %s Level?"), intermediate_level_name);
|
||||
dialog = nautilus_yes_no_dialog (prompt,
|
||||
dialog_title,
|
||||
_("Switch"),
|
||||
GNOME_STOCK_BUTTON_CANCEL,
|
||||
GTK_WINDOW (window));
|
||||
gnome_dialog_button_connect
|
||||
(dialog, GNOME_OK, switch_and_show_intermediate_settings_callback, window);
|
||||
gnome_dialog_set_default (dialog, GNOME_CANCEL);
|
||||
|
||||
g_free (prompt);
|
||||
g_free (dialog_title);
|
||||
g_free (novice_level_name);
|
||||
g_free (intermediate_level_name);
|
||||
g_free (expert_level_name);
|
||||
} else {
|
||||
nautilus_global_preferences_show_dialog ();
|
||||
}
|
||||
nautilus_global_preferences_set_dialog_title ("Edit Settings");
|
||||
nautilus_global_preferences_show_dialog ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -709,12 +643,12 @@ switch_to_user_level (NautilusWindow *window, int new_user_level)
|
|||
return;
|
||||
}
|
||||
|
||||
old_user_level = nautilus_user_level_manager_get_user_level ();
|
||||
old_user_level = nautilus_preferences_get_user_level ();
|
||||
if (new_user_level == old_user_level) {
|
||||
return;
|
||||
}
|
||||
|
||||
nautilus_user_level_manager_set_user_level (new_user_level);
|
||||
nautilus_preferences_set_user_level (new_user_level);
|
||||
|
||||
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
|
||||
|
||||
|
@ -1058,8 +992,7 @@ refresh_bookmarks_menu (NautilusWindow *window)
|
|||
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
|
||||
nautilus_window_remove_bookmarks_menu_items (window);
|
||||
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
|
||||
FALSE)) {
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS)) {
|
||||
append_static_bookmarks (window, MENU_PATH_BUILT_IN_BOOKMARKS_PLACEHOLDER);
|
||||
}
|
||||
|
||||
|
@ -1126,22 +1059,12 @@ nautilus_window_initialize_go_menu (NautilusWindow *window)
|
|||
/* handler to receive the user_level_changed signal, so we can update the menu and dialog
|
||||
when the user level changes */
|
||||
static void
|
||||
user_level_changed_callback (GtkObject *user_level_manager,
|
||||
gpointer user_data)
|
||||
user_level_changed_callback (gpointer callback_data)
|
||||
{
|
||||
g_return_if_fail (user_data != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_WINDOW (user_data));
|
||||
g_return_if_fail (callback_data != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_WINDOW (callback_data));
|
||||
|
||||
update_user_level_menu_items (NAUTILUS_WINDOW (user_data));
|
||||
|
||||
/* Hide the customize dialog for novice user level */
|
||||
if (nautilus_user_level_manager_get_user_level () == NAUTILUS_USER_LEVEL_NOVICE) {
|
||||
nautilus_global_preferences_hide_dialog ();
|
||||
}
|
||||
/* Otherwise update its title to reflect the user level */
|
||||
else {
|
||||
update_preferences_dialog_title ();
|
||||
}
|
||||
update_user_level_menu_items (NAUTILUS_WINDOW (callback_data));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1157,7 +1080,7 @@ add_user_level_menu_item (NautilusWindow *window,
|
|||
return;
|
||||
}
|
||||
|
||||
current_user_level = nautilus_user_level_manager_get_user_level ();
|
||||
current_user_level = nautilus_preferences_get_user_level ();
|
||||
|
||||
icon_name = get_user_level_icon_name (user_level, current_user_level == user_level);
|
||||
|
||||
|
@ -1252,13 +1175,11 @@ nautilus_window_initialize_menus (NautilusWindow *window)
|
|||
update_user_level_menu_items (window);
|
||||
bonobo_ui_component_thaw (window->details->shell_ui, NULL);
|
||||
|
||||
/* connect to the user level changed signal, so we can update the menu when the
|
||||
user level changes */
|
||||
gtk_signal_connect_while_alive (GTK_OBJECT (nautilus_user_level_manager_get ()),
|
||||
"user_level_changed",
|
||||
user_level_changed_callback,
|
||||
window,
|
||||
GTK_OBJECT (window));
|
||||
/* Monitor user level changes so that we can update the user level menu pane */
|
||||
nautilus_preferences_add_callback_while_alive ("user_level",
|
||||
user_level_changed_callback,
|
||||
window,
|
||||
GTK_OBJECT (window));
|
||||
|
||||
nautilus_window_initialize_bookmarks_menu (window);
|
||||
nautilus_window_initialize_go_menu (window);
|
||||
|
@ -1431,7 +1352,6 @@ schedule_refresh_go_menu (NautilusWindow *window)
|
|||
static void
|
||||
update_user_level_menu_items (NautilusWindow *window)
|
||||
{
|
||||
char *customize_string;
|
||||
int user_level;
|
||||
char *user_level_icon_name;
|
||||
|
||||
|
@ -1439,22 +1359,13 @@ update_user_level_menu_items (NautilusWindow *window)
|
|||
g_assert (NAUTILUS_IS_WINDOW (window));
|
||||
|
||||
/* Update the user radio group to reflect reality */
|
||||
user_level = nautilus_user_level_manager_get_user_level ();
|
||||
user_level = nautilus_preferences_get_user_level ();
|
||||
user_level_icon_name = get_user_level_icon_name (user_level, FALSE);
|
||||
|
||||
nautilus_bonobo_set_icon (window->details->shell_ui,
|
||||
NAUTILUS_MENU_PATH_USER_LEVEL,
|
||||
user_level_icon_name);
|
||||
g_free (user_level_icon_name);
|
||||
|
||||
|
||||
customize_string = get_customize_user_level_settings_menu_string ();
|
||||
g_assert (customize_string != NULL);
|
||||
nautilus_bonobo_set_label (window->details->shell_ui,
|
||||
NAUTILUS_MENU_PATH_USER_LEVEL_CUSTOMIZE,
|
||||
customize_string);
|
||||
|
||||
g_free (customize_string);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1490,60 +1401,3 @@ convert_user_level_to_path (guint user_level)
|
|||
g_assert_not_reached ();
|
||||
return NAUTILUS_MENU_PATH_NOVICE_ITEM;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
get_customize_user_level_string (void)
|
||||
{
|
||||
char *user_level_string_for_display;
|
||||
char *title;
|
||||
|
||||
user_level_string_for_display =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(nautilus_user_level_manager_get_user_level ());
|
||||
|
||||
/* Localizers: This is the title of the user-level settings
|
||||
* dialog. %s will be replaced with the name of a user level
|
||||
* ("Beginner", "Intermediate", or "Advanced").
|
||||
*/
|
||||
title = g_strdup_printf (_("Edit %s Settings"), user_level_string_for_display);
|
||||
|
||||
g_free (user_level_string_for_display);
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_customize_user_level_settings_menu_string (void)
|
||||
{
|
||||
char *user_level_string_for_display;
|
||||
char *title;
|
||||
|
||||
user_level_string_for_display =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(nautilus_user_level_manager_get_user_level ());
|
||||
|
||||
/* Localizers: This is the label for the menu item that brings
|
||||
* up the user-level settings dialog. %s will be replaced with
|
||||
* the name of a user level ("Beginner", "Intermediate", or
|
||||
* "Advanced").
|
||||
*/
|
||||
title = g_strdup_printf (_("Edit %s Settings..."), user_level_string_for_display);
|
||||
|
||||
g_free (user_level_string_for_display);
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
static void
|
||||
update_preferences_dialog_title (void)
|
||||
{
|
||||
char *dialog_title;
|
||||
|
||||
dialog_title = get_customize_user_level_string ();
|
||||
g_assert (dialog_title != NULL);
|
||||
|
||||
nautilus_global_preferences_set_dialog_title (dialog_title);
|
||||
|
||||
g_free (dialog_title);
|
||||
}
|
||||
|
|
|
@ -489,11 +489,9 @@ nautilus_window_constructed (NautilusWindow *window)
|
|||
window->content_hbox = nautilus_horizontal_splitter_new ();
|
||||
panel = E_PANED (window->content_hbox);
|
||||
|
||||
/* FIXME bugzilla.eazel.com 1245: No constant for the default? */
|
||||
/* FIXME bugzilla.eazel.com 1245: Saved in pixels instead of in %? */
|
||||
/* FIXME bugzilla.eazel.com 1245: No reality check on the value? */
|
||||
/* FIXME bugzilla.eazel.com 1245: get_enum? why not get_integer? */
|
||||
sidebar_width = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, 148);
|
||||
sidebar_width = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH);
|
||||
e_paned_set_position (E_PANED (window->content_hbox), sidebar_width);
|
||||
}
|
||||
gtk_widget_show (window->content_hbox);
|
||||
|
@ -737,8 +735,7 @@ nautilus_window_close (NautilusWindow *window)
|
|||
* we're in every-location-in-its-own-window mode. Otherwise it
|
||||
* would be too apparently random when the stored positions change.
|
||||
*/
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
|
||||
FALSE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
|
||||
nautilus_window_save_geometry (window);
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1275,7 @@ nautilus_window_go_web_search (NautilusWindow *window)
|
|||
|
||||
nautilus_window_set_search_mode (window, FALSE);
|
||||
|
||||
search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, "");
|
||||
search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI);
|
||||
g_assert (search_web_uri != NULL);
|
||||
|
||||
nautilus_window_goto_uri (window, search_web_uri);
|
||||
|
@ -1288,13 +1285,11 @@ nautilus_window_go_web_search (NautilusWindow *window)
|
|||
void
|
||||
nautilus_window_go_home (NautilusWindow *window)
|
||||
{
|
||||
char *default_home_uri, *home_uri;
|
||||
char *home_uri;
|
||||
|
||||
nautilus_window_set_search_mode (window, FALSE);
|
||||
|
||||
default_home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI, default_home_uri);
|
||||
g_free (default_home_uri);
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
|
||||
|
||||
g_assert (home_uri != NULL);
|
||||
nautilus_window_goto_uri (window, home_uri);
|
||||
|
@ -1758,25 +1753,25 @@ nautilus_window_show (GtkWidget *widget)
|
|||
/* Initially show or hide views based on preferences; once the window is displayed
|
||||
* these can be controlled on a per-window basis from View menu items.
|
||||
*/
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR)) {
|
||||
nautilus_window_show_tool_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_tool_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
|
||||
nautilus_window_show_location_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_location_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
|
||||
nautilus_window_show_status_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_status_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
|
||||
nautilus_window_show_sidebar (window);
|
||||
} else {
|
||||
nautilus_window_hide_sidebar (window);
|
||||
|
|
|
@ -489,11 +489,9 @@ nautilus_window_constructed (NautilusWindow *window)
|
|||
window->content_hbox = nautilus_horizontal_splitter_new ();
|
||||
panel = E_PANED (window->content_hbox);
|
||||
|
||||
/* FIXME bugzilla.eazel.com 1245: No constant for the default? */
|
||||
/* FIXME bugzilla.eazel.com 1245: Saved in pixels instead of in %? */
|
||||
/* FIXME bugzilla.eazel.com 1245: No reality check on the value? */
|
||||
/* FIXME bugzilla.eazel.com 1245: get_enum? why not get_integer? */
|
||||
sidebar_width = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, 148);
|
||||
sidebar_width = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH);
|
||||
e_paned_set_position (E_PANED (window->content_hbox), sidebar_width);
|
||||
}
|
||||
gtk_widget_show (window->content_hbox);
|
||||
|
@ -737,8 +735,7 @@ nautilus_window_close (NautilusWindow *window)
|
|||
* we're in every-location-in-its-own-window mode. Otherwise it
|
||||
* would be too apparently random when the stored positions change.
|
||||
*/
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
|
||||
FALSE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
|
||||
nautilus_window_save_geometry (window);
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1275,7 @@ nautilus_window_go_web_search (NautilusWindow *window)
|
|||
|
||||
nautilus_window_set_search_mode (window, FALSE);
|
||||
|
||||
search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, "");
|
||||
search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI);
|
||||
g_assert (search_web_uri != NULL);
|
||||
|
||||
nautilus_window_goto_uri (window, search_web_uri);
|
||||
|
@ -1288,13 +1285,11 @@ nautilus_window_go_web_search (NautilusWindow *window)
|
|||
void
|
||||
nautilus_window_go_home (NautilusWindow *window)
|
||||
{
|
||||
char *default_home_uri, *home_uri;
|
||||
char *home_uri;
|
||||
|
||||
nautilus_window_set_search_mode (window, FALSE);
|
||||
|
||||
default_home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI, default_home_uri);
|
||||
g_free (default_home_uri);
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
|
||||
|
||||
g_assert (home_uri != NULL);
|
||||
nautilus_window_goto_uri (window, home_uri);
|
||||
|
@ -1758,25 +1753,25 @@ nautilus_window_show (GtkWidget *widget)
|
|||
/* Initially show or hide views based on preferences; once the window is displayed
|
||||
* these can be controlled on a per-window basis from View menu items.
|
||||
*/
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR)) {
|
||||
nautilus_window_show_tool_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_tool_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
|
||||
nautilus_window_show_location_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_location_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
|
||||
nautilus_window_show_status_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_status_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
|
||||
nautilus_window_show_sidebar (window);
|
||||
} else {
|
||||
nautilus_window_hide_sidebar (window);
|
||||
|
|
|
@ -2163,7 +2163,7 @@ nautilus_property_browser_update_contents (NautilusPropertyBrowser *property_bro
|
|||
|
||||
/* update the title and button */
|
||||
|
||||
show_buttons = nautilus_preferences_get_boolean(NAUTILUS_PREFERENCES_CAN_ADD_CONTENT, FALSE);
|
||||
show_buttons = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CAN_ADD_CONTENT);
|
||||
|
||||
if (property_browser->details->category == NULL) {
|
||||
nautilus_label_set_text(NAUTILUS_LABEL (property_browser->details->title_label), _("Select A Category:"));
|
||||
|
|
|
@ -330,7 +330,7 @@ nautilus_sidebar_sidebar_panel_enabled (const char *panel_iid)
|
|||
char *key;
|
||||
|
||||
key = nautilus_sidebar_get_sidebar_panel_key (panel_iid);
|
||||
enabled = nautilus_preferences_get_boolean (key, FALSE);
|
||||
enabled = nautilus_preferences_get_boolean (key);
|
||||
g_free (key);
|
||||
return enabled;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ toggle_sidebar_panel (GtkWidget *widget, char *sidebar_id)
|
|||
nautilus_sidebar_hide_active_panel_if_matches (sidebar, sidebar_id);
|
||||
|
||||
key = nautilus_sidebar_get_sidebar_panel_key (sidebar_id);
|
||||
nautilus_preferences_set_boolean (key, !nautilus_preferences_get_boolean (key, FALSE));
|
||||
nautilus_preferences_set_boolean (key, !nautilus_preferences_get_boolean (key));
|
||||
g_free (key);
|
||||
}
|
||||
|
||||
|
@ -1544,8 +1544,7 @@ nautilus_sidebar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
|
|||
|
||||
if (widget->allocation.width != sidebar->details->old_width) {
|
||||
sidebar->details->old_width = widget->allocation.width;
|
||||
/* FIXME: This is not an "enum". */
|
||||
nautilus_preferences_set_enum (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
|
||||
widget->allocation.width);
|
||||
nautilus_preferences_set_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
|
||||
widget->allocation.width);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -489,11 +489,9 @@ nautilus_window_constructed (NautilusWindow *window)
|
|||
window->content_hbox = nautilus_horizontal_splitter_new ();
|
||||
panel = E_PANED (window->content_hbox);
|
||||
|
||||
/* FIXME bugzilla.eazel.com 1245: No constant for the default? */
|
||||
/* FIXME bugzilla.eazel.com 1245: Saved in pixels instead of in %? */
|
||||
/* FIXME bugzilla.eazel.com 1245: No reality check on the value? */
|
||||
/* FIXME bugzilla.eazel.com 1245: get_enum? why not get_integer? */
|
||||
sidebar_width = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, 148);
|
||||
sidebar_width = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH);
|
||||
e_paned_set_position (E_PANED (window->content_hbox), sidebar_width);
|
||||
}
|
||||
gtk_widget_show (window->content_hbox);
|
||||
|
@ -737,8 +735,7 @@ nautilus_window_close (NautilusWindow *window)
|
|||
* we're in every-location-in-its-own-window mode. Otherwise it
|
||||
* would be too apparently random when the stored positions change.
|
||||
*/
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
|
||||
FALSE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
|
||||
nautilus_window_save_geometry (window);
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1275,7 @@ nautilus_window_go_web_search (NautilusWindow *window)
|
|||
|
||||
nautilus_window_set_search_mode (window, FALSE);
|
||||
|
||||
search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, "");
|
||||
search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI);
|
||||
g_assert (search_web_uri != NULL);
|
||||
|
||||
nautilus_window_goto_uri (window, search_web_uri);
|
||||
|
@ -1288,13 +1285,11 @@ nautilus_window_go_web_search (NautilusWindow *window)
|
|||
void
|
||||
nautilus_window_go_home (NautilusWindow *window)
|
||||
{
|
||||
char *default_home_uri, *home_uri;
|
||||
char *home_uri;
|
||||
|
||||
nautilus_window_set_search_mode (window, FALSE);
|
||||
|
||||
default_home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI, default_home_uri);
|
||||
g_free (default_home_uri);
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
|
||||
|
||||
g_assert (home_uri != NULL);
|
||||
nautilus_window_goto_uri (window, home_uri);
|
||||
|
@ -1758,25 +1753,25 @@ nautilus_window_show (GtkWidget *widget)
|
|||
/* Initially show or hide views based on preferences; once the window is displayed
|
||||
* these can be controlled on a per-window basis from View menu items.
|
||||
*/
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR)) {
|
||||
nautilus_window_show_tool_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_tool_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
|
||||
nautilus_window_show_location_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_location_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
|
||||
nautilus_window_show_status_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_status_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
|
||||
nautilus_window_show_sidebar (window);
|
||||
} else {
|
||||
nautilus_window_hide_sidebar (window);
|
||||
|
|
|
@ -154,10 +154,9 @@ nautilus_switchable_search_bar_new (NautilusWindow *window)
|
|||
gtk_container_add (GTK_CONTAINER (bar), hbox);
|
||||
|
||||
gtk_widget_show_all (hbox);
|
||||
nautilus_switchable_search_bar_set_mode
|
||||
nautilus_switchable_search_bar_set_mode
|
||||
(bar,
|
||||
nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE,
|
||||
NAUTILUS_SIMPLE_SEARCH_BAR));
|
||||
nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE));
|
||||
|
||||
/* React to future preference changes. */
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE,
|
||||
|
@ -284,8 +283,7 @@ nautilus_search_uri_to_search_bar_mode (const char *uri)
|
|||
{
|
||||
NautilusSearchBarMode preferred_mode;
|
||||
|
||||
preferred_mode = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE,
|
||||
NAUTILUS_SIMPLE_SEARCH_BAR);
|
||||
preferred_mode = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE);
|
||||
if (nautilus_search_uri_is_displayable_by_mode (uri, preferred_mode)) {
|
||||
return preferred_mode;
|
||||
}
|
||||
|
|
|
@ -1202,8 +1202,7 @@ position_and_show_window_callback (NautilusFile *file,
|
|||
|
||||
window = NAUTILUS_WINDOW (callback_data);
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
|
||||
FALSE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
|
||||
geometry_string = nautilus_file_get_metadata
|
||||
(file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL);
|
||||
if (geometry_string != NULL) {
|
||||
|
@ -1408,21 +1407,19 @@ nautilus_window_end_location_change_callback (NautilusNavigationResult result_co
|
|||
|
||||
/* if this is the only window, we don't want to quit, so we redirect it to home */
|
||||
if (just_one_window ()) {
|
||||
char *home_uri, *default_home_uri;
|
||||
char *home_uri;
|
||||
|
||||
/* the user could have typed in a home directory that doesn't exist,
|
||||
in which case going home would cause an infinite loop, so we
|
||||
better test for that */
|
||||
|
||||
default_home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI, default_home_uri);
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
|
||||
if (!nautilus_uris_match (home_uri, location)) {
|
||||
nautilus_window_go_home (NAUTILUS_WINDOW (window));
|
||||
} else {
|
||||
/* the last fallback is to go to a known place that can't be deleted! */
|
||||
nautilus_window_goto_uri (NAUTILUS_WINDOW (window), "file:///");
|
||||
}
|
||||
g_free (default_home_uri);
|
||||
g_free (home_uri);
|
||||
} else {
|
||||
/* Since this is a window, destroying it will also unref it. */
|
||||
|
|
|
@ -56,7 +56,6 @@
|
|||
#include <libnautilus-extensions/nautilus-stock-dialogs.h>
|
||||
#include <libnautilus-extensions/nautilus-string.h>
|
||||
#include <libnautilus-extensions/nautilus-undo-manager.h>
|
||||
#include <libnautilus-extensions/nautilus-user-level-manager.h>
|
||||
#include <libnautilus-extensions/nautilus-xml-extensions.h>
|
||||
#include <libnautilus/nautilus-bonobo-ui.h>
|
||||
|
||||
|
@ -110,12 +109,9 @@ static void add_bookmark_for_current_location (Naut
|
|||
/* 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 char * get_customize_user_level_settings_menu_string (void);
|
||||
static void update_user_level_menu_items (NautilusWindow *window);
|
||||
static char * get_customize_user_level_string (void);
|
||||
static void switch_to_user_level (NautilusWindow *window,
|
||||
int new_user_level);
|
||||
static void update_preferences_dialog_title (void);
|
||||
|
||||
|
||||
#define NAUTILUS_MENU_PATH_USER_LEVEL "/menu/Preferences"
|
||||
|
@ -479,75 +475,13 @@ bookmarks_menu_edit_bookmarks_callback (BonoboUIComponent *component,
|
|||
edit_bookmarks (NAUTILUS_WINDOW (user_data));
|
||||
}
|
||||
|
||||
static void
|
||||
switch_and_show_intermediate_settings_callback (GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
g_assert (NAUTILUS_IS_WINDOW (user_data));
|
||||
|
||||
switch_to_user_level (NAUTILUS_WINDOW (user_data), NAUTILUS_USER_LEVEL_INTERMEDIATE);
|
||||
nautilus_global_preferences_show_dialog ();
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_customize_callback (BonoboUIComponent *component,
|
||||
gpointer user_data,
|
||||
const char *verb)
|
||||
{
|
||||
GnomeDialog *dialog;
|
||||
NautilusWindow *window;
|
||||
char *novice_level_name;
|
||||
char *intermediate_level_name;
|
||||
char *expert_level_name;
|
||||
char *prompt;
|
||||
char *dialog_title;
|
||||
|
||||
window = NAUTILUS_WINDOW (user_data);
|
||||
|
||||
if (nautilus_user_level_manager_get_user_level () == NAUTILUS_USER_LEVEL_NOVICE) {
|
||||
novice_level_name =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(NAUTILUS_USER_LEVEL_NOVICE);
|
||||
intermediate_level_name =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(NAUTILUS_USER_LEVEL_INTERMEDIATE);
|
||||
expert_level_name =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(NAUTILUS_USER_LEVEL_HACKER);
|
||||
/* Localizers: This is the message in the dialog that appears if the user chooses "Edit Beginner Settings".
|
||||
* The first %s is the name of the lowest user level ("Beginner"). The 2nd and 4th %s are the
|
||||
* names of the middle user level ("Intermediate"). The 3rd %s is the name of the highest user
|
||||
* level ("Advanced").
|
||||
*/
|
||||
prompt = g_strdup_printf (_("None of the settings for the %s level can be edited. "
|
||||
"If you want to edit the settings you must choose the %s or %s "
|
||||
"level. Do you want to switch to the %s level now "
|
||||
"and edit its settings?"),
|
||||
novice_level_name,
|
||||
intermediate_level_name,
|
||||
expert_level_name,
|
||||
intermediate_level_name);
|
||||
|
||||
/* Localizers: This is the title of the dialog that appears if the user chooses "Edit Beginner Settings".
|
||||
* The %s is the name of the middle user level ("Intermediate").
|
||||
*/
|
||||
dialog_title = g_strdup_printf (_("Switch to %s Level?"), intermediate_level_name);
|
||||
dialog = nautilus_yes_no_dialog (prompt,
|
||||
dialog_title,
|
||||
_("Switch"),
|
||||
GNOME_STOCK_BUTTON_CANCEL,
|
||||
GTK_WINDOW (window));
|
||||
gnome_dialog_button_connect
|
||||
(dialog, GNOME_OK, switch_and_show_intermediate_settings_callback, window);
|
||||
gnome_dialog_set_default (dialog, GNOME_CANCEL);
|
||||
|
||||
g_free (prompt);
|
||||
g_free (dialog_title);
|
||||
g_free (novice_level_name);
|
||||
g_free (intermediate_level_name);
|
||||
g_free (expert_level_name);
|
||||
} else {
|
||||
nautilus_global_preferences_show_dialog ();
|
||||
}
|
||||
nautilus_global_preferences_set_dialog_title ("Edit Settings");
|
||||
nautilus_global_preferences_show_dialog ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -709,12 +643,12 @@ switch_to_user_level (NautilusWindow *window, int new_user_level)
|
|||
return;
|
||||
}
|
||||
|
||||
old_user_level = nautilus_user_level_manager_get_user_level ();
|
||||
old_user_level = nautilus_preferences_get_user_level ();
|
||||
if (new_user_level == old_user_level) {
|
||||
return;
|
||||
}
|
||||
|
||||
nautilus_user_level_manager_set_user_level (new_user_level);
|
||||
nautilus_preferences_set_user_level (new_user_level);
|
||||
|
||||
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
|
||||
|
||||
|
@ -1058,8 +992,7 @@ refresh_bookmarks_menu (NautilusWindow *window)
|
|||
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
|
||||
nautilus_window_remove_bookmarks_menu_items (window);
|
||||
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS,
|
||||
FALSE)) {
|
||||
if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS)) {
|
||||
append_static_bookmarks (window, MENU_PATH_BUILT_IN_BOOKMARKS_PLACEHOLDER);
|
||||
}
|
||||
|
||||
|
@ -1126,22 +1059,12 @@ nautilus_window_initialize_go_menu (NautilusWindow *window)
|
|||
/* handler to receive the user_level_changed signal, so we can update the menu and dialog
|
||||
when the user level changes */
|
||||
static void
|
||||
user_level_changed_callback (GtkObject *user_level_manager,
|
||||
gpointer user_data)
|
||||
user_level_changed_callback (gpointer callback_data)
|
||||
{
|
||||
g_return_if_fail (user_data != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_WINDOW (user_data));
|
||||
g_return_if_fail (callback_data != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_WINDOW (callback_data));
|
||||
|
||||
update_user_level_menu_items (NAUTILUS_WINDOW (user_data));
|
||||
|
||||
/* Hide the customize dialog for novice user level */
|
||||
if (nautilus_user_level_manager_get_user_level () == NAUTILUS_USER_LEVEL_NOVICE) {
|
||||
nautilus_global_preferences_hide_dialog ();
|
||||
}
|
||||
/* Otherwise update its title to reflect the user level */
|
||||
else {
|
||||
update_preferences_dialog_title ();
|
||||
}
|
||||
update_user_level_menu_items (NAUTILUS_WINDOW (callback_data));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1157,7 +1080,7 @@ add_user_level_menu_item (NautilusWindow *window,
|
|||
return;
|
||||
}
|
||||
|
||||
current_user_level = nautilus_user_level_manager_get_user_level ();
|
||||
current_user_level = nautilus_preferences_get_user_level ();
|
||||
|
||||
icon_name = get_user_level_icon_name (user_level, current_user_level == user_level);
|
||||
|
||||
|
@ -1252,13 +1175,11 @@ nautilus_window_initialize_menus (NautilusWindow *window)
|
|||
update_user_level_menu_items (window);
|
||||
bonobo_ui_component_thaw (window->details->shell_ui, NULL);
|
||||
|
||||
/* connect to the user level changed signal, so we can update the menu when the
|
||||
user level changes */
|
||||
gtk_signal_connect_while_alive (GTK_OBJECT (nautilus_user_level_manager_get ()),
|
||||
"user_level_changed",
|
||||
user_level_changed_callback,
|
||||
window,
|
||||
GTK_OBJECT (window));
|
||||
/* Monitor user level changes so that we can update the user level menu pane */
|
||||
nautilus_preferences_add_callback_while_alive ("user_level",
|
||||
user_level_changed_callback,
|
||||
window,
|
||||
GTK_OBJECT (window));
|
||||
|
||||
nautilus_window_initialize_bookmarks_menu (window);
|
||||
nautilus_window_initialize_go_menu (window);
|
||||
|
@ -1431,7 +1352,6 @@ schedule_refresh_go_menu (NautilusWindow *window)
|
|||
static void
|
||||
update_user_level_menu_items (NautilusWindow *window)
|
||||
{
|
||||
char *customize_string;
|
||||
int user_level;
|
||||
char *user_level_icon_name;
|
||||
|
||||
|
@ -1439,22 +1359,13 @@ update_user_level_menu_items (NautilusWindow *window)
|
|||
g_assert (NAUTILUS_IS_WINDOW (window));
|
||||
|
||||
/* Update the user radio group to reflect reality */
|
||||
user_level = nautilus_user_level_manager_get_user_level ();
|
||||
user_level = nautilus_preferences_get_user_level ();
|
||||
user_level_icon_name = get_user_level_icon_name (user_level, FALSE);
|
||||
|
||||
nautilus_bonobo_set_icon (window->details->shell_ui,
|
||||
NAUTILUS_MENU_PATH_USER_LEVEL,
|
||||
user_level_icon_name);
|
||||
g_free (user_level_icon_name);
|
||||
|
||||
|
||||
customize_string = get_customize_user_level_settings_menu_string ();
|
||||
g_assert (customize_string != NULL);
|
||||
nautilus_bonobo_set_label (window->details->shell_ui,
|
||||
NAUTILUS_MENU_PATH_USER_LEVEL_CUSTOMIZE,
|
||||
customize_string);
|
||||
|
||||
g_free (customize_string);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1490,60 +1401,3 @@ convert_user_level_to_path (guint user_level)
|
|||
g_assert_not_reached ();
|
||||
return NAUTILUS_MENU_PATH_NOVICE_ITEM;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
get_customize_user_level_string (void)
|
||||
{
|
||||
char *user_level_string_for_display;
|
||||
char *title;
|
||||
|
||||
user_level_string_for_display =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(nautilus_user_level_manager_get_user_level ());
|
||||
|
||||
/* Localizers: This is the title of the user-level settings
|
||||
* dialog. %s will be replaced with the name of a user level
|
||||
* ("Beginner", "Intermediate", or "Advanced").
|
||||
*/
|
||||
title = g_strdup_printf (_("Edit %s Settings"), user_level_string_for_display);
|
||||
|
||||
g_free (user_level_string_for_display);
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
static char *
|
||||
get_customize_user_level_settings_menu_string (void)
|
||||
{
|
||||
char *user_level_string_for_display;
|
||||
char *title;
|
||||
|
||||
user_level_string_for_display =
|
||||
nautilus_user_level_manager_get_user_level_name_for_display
|
||||
(nautilus_user_level_manager_get_user_level ());
|
||||
|
||||
/* Localizers: This is the label for the menu item that brings
|
||||
* up the user-level settings dialog. %s will be replaced with
|
||||
* the name of a user level ("Beginner", "Intermediate", or
|
||||
* "Advanced").
|
||||
*/
|
||||
title = g_strdup_printf (_("Edit %s Settings..."), user_level_string_for_display);
|
||||
|
||||
g_free (user_level_string_for_display);
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
static void
|
||||
update_preferences_dialog_title (void)
|
||||
{
|
||||
char *dialog_title;
|
||||
|
||||
dialog_title = get_customize_user_level_string ();
|
||||
g_assert (dialog_title != NULL);
|
||||
|
||||
nautilus_global_preferences_set_dialog_title (dialog_title);
|
||||
|
||||
g_free (dialog_title);
|
||||
}
|
||||
|
|
|
@ -489,11 +489,9 @@ nautilus_window_constructed (NautilusWindow *window)
|
|||
window->content_hbox = nautilus_horizontal_splitter_new ();
|
||||
panel = E_PANED (window->content_hbox);
|
||||
|
||||
/* FIXME bugzilla.eazel.com 1245: No constant for the default? */
|
||||
/* FIXME bugzilla.eazel.com 1245: Saved in pixels instead of in %? */
|
||||
/* FIXME bugzilla.eazel.com 1245: No reality check on the value? */
|
||||
/* FIXME bugzilla.eazel.com 1245: get_enum? why not get_integer? */
|
||||
sidebar_width = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, 148);
|
||||
sidebar_width = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH);
|
||||
e_paned_set_position (E_PANED (window->content_hbox), sidebar_width);
|
||||
}
|
||||
gtk_widget_show (window->content_hbox);
|
||||
|
@ -737,8 +735,7 @@ nautilus_window_close (NautilusWindow *window)
|
|||
* we're in every-location-in-its-own-window mode. Otherwise it
|
||||
* would be too apparently random when the stored positions change.
|
||||
*/
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
|
||||
FALSE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
|
||||
nautilus_window_save_geometry (window);
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1275,7 @@ nautilus_window_go_web_search (NautilusWindow *window)
|
|||
|
||||
nautilus_window_set_search_mode (window, FALSE);
|
||||
|
||||
search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, "");
|
||||
search_web_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_SEARCH_WEB_URI);
|
||||
g_assert (search_web_uri != NULL);
|
||||
|
||||
nautilus_window_goto_uri (window, search_web_uri);
|
||||
|
@ -1288,13 +1285,11 @@ nautilus_window_go_web_search (NautilusWindow *window)
|
|||
void
|
||||
nautilus_window_go_home (NautilusWindow *window)
|
||||
{
|
||||
char *default_home_uri, *home_uri;
|
||||
char *home_uri;
|
||||
|
||||
nautilus_window_set_search_mode (window, FALSE);
|
||||
|
||||
default_home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI, default_home_uri);
|
||||
g_free (default_home_uri);
|
||||
home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI);
|
||||
|
||||
g_assert (home_uri != NULL);
|
||||
nautilus_window_goto_uri (window, home_uri);
|
||||
|
@ -1758,25 +1753,25 @@ nautilus_window_show (GtkWidget *widget)
|
|||
/* Initially show or hide views based on preferences; once the window is displayed
|
||||
* these can be controlled on a per-window basis from View menu items.
|
||||
*/
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOL_BAR)) {
|
||||
nautilus_window_show_tool_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_tool_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR)) {
|
||||
nautilus_window_show_location_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_location_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) {
|
||||
nautilus_window_show_status_bar (window);
|
||||
} else {
|
||||
nautilus_window_hide_status_bar (window);
|
||||
}
|
||||
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, TRUE)) {
|
||||
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
|
||||
nautilus_window_show_sidebar (window);
|
||||
} else {
|
||||
nautilus_window_hide_sidebar (window);
|
||||
|
|
|
@ -28,4 +28,5 @@ test-nautilus-pixbuf-tile
|
|||
test-nautilus-preferences
|
||||
test-nautilus-smooth-graphics
|
||||
test-nautilus-widgets
|
||||
test-nautilus-wrapped-label
|
||||
test-nautilus-preferences-display
|
||||
test-nautilus-preferences-change
|
||||
|
|
|
@ -49,9 +49,10 @@ noinst_PROGRAMS =\
|
|||
test-nautilus-mime-actions-set \
|
||||
test-nautilus-password-dialog \
|
||||
test-nautilus-pixbuf-tile \
|
||||
test-nautilus-preferences \
|
||||
test-nautilus-smooth-graphics \
|
||||
test-nautilus-widgets \
|
||||
test-nautilus-preferences-display \
|
||||
test-nautilus-preferences-change \
|
||||
$(NULL)
|
||||
|
||||
test_nautilus_async_activation_SOURCES = test-nautilus-async-activation.c
|
||||
|
@ -75,7 +76,8 @@ test_nautilus_mime_actions_SOURCES = test-nautilus-mime-actions.c
|
|||
test_nautilus_mime_actions_set_SOURCES = test-nautilus-mime-actions-set.c
|
||||
test_nautilus_password_dialog_SOURCES = test-nautilus-password-dialog.c
|
||||
test_nautilus_pixbuf_tile_SOURCES = test-nautilus-pixbuf-tile.c test.c
|
||||
test_nautilus_preferences_SOURCES = test-nautilus-preferences.c
|
||||
test_nautilus_preferences_change_SOURCES = test-nautilus-preferences-change.c test.c
|
||||
test_nautilus_preferences_display_SOURCES = test-nautilus-preferences-display.c test.c
|
||||
test_nautilus_smooth_graphics_SOURCES = test-nautilus-smooth-graphics.c
|
||||
test_nautilus_widgets_SOURCES = test-nautilus-widgets.c
|
||||
|
||||
|
|
230
test/test-nautilus-preferences-change.c
Normal file
230
test/test-nautilus-preferences-change.c
Normal file
|
@ -0,0 +1,230 @@
|
|||
#include "test.h"
|
||||
|
||||
#include <libnautilus-extensions/nautilus-image.h>
|
||||
#include <libnautilus-extensions/nautilus-image-with-background.h>
|
||||
#include <libnautilus-extensions/nautilus-string-picker.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
static void
|
||||
user_level_changed_callback (gpointer callback_data)
|
||||
{
|
||||
char *name;
|
||||
int user_level;
|
||||
int visible_user_level;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_STRING_PICKER (callback_data));
|
||||
|
||||
|
||||
name = nautilus_caption_get_title_label (NAUTILUS_CAPTION (callback_data));
|
||||
|
||||
user_level = nautilus_preferences_get_user_level ();
|
||||
visible_user_level = nautilus_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)
|
||||
{
|
||||
g_print ("Something underneath 'fruits' changed, dunno what\n");
|
||||
}
|
||||
|
||||
static void
|
||||
int_picker_changed_callback (NautilusStringPicker *string_picker,
|
||||
gpointer callback_data)
|
||||
{
|
||||
char *selected_string;
|
||||
int new_value;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_STRING_PICKER (string_picker));
|
||||
g_return_if_fail (callback_data != NULL);
|
||||
|
||||
selected_string = nautilus_string_picker_get_selected_string (string_picker);
|
||||
|
||||
new_value = nautilus_string_picker_get_index_for_string (string_picker, selected_string);
|
||||
|
||||
nautilus_preferences_set_integer ((const char *) callback_data, new_value);
|
||||
|
||||
g_free (selected_string);
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_picker_changed_callback (NautilusStringPicker *string_picker,
|
||||
gpointer callback_data)
|
||||
{
|
||||
char *selected_string;
|
||||
int new_user_level;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_STRING_PICKER (string_picker));
|
||||
g_return_if_fail (callback_data != NULL);
|
||||
|
||||
selected_string = nautilus_string_picker_get_selected_string (string_picker);
|
||||
|
||||
new_user_level = nautilus_string_picker_get_index_for_string (string_picker, selected_string);
|
||||
|
||||
nautilus_preferences_set_user_level (new_user_level);
|
||||
|
||||
g_free (selected_string);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
picker_new (const char *name,
|
||||
const NautilusStringList *entries)
|
||||
{
|
||||
GtkWidget *string_picker;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (entries != NULL, NULL);
|
||||
|
||||
string_picker = nautilus_string_picker_new ();
|
||||
nautilus_caption_set_title_label (NAUTILUS_CAPTION (string_picker), name);
|
||||
gtk_signal_connect (GTK_OBJECT (string_picker), "changed", GTK_SIGNAL_FUNC (int_picker_changed_callback),
|
||||
(gpointer) name);
|
||||
|
||||
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (string_picker), entries);
|
||||
nautilus_string_picker_set_selected_string_index (NAUTILUS_STRING_PICKER (string_picker),
|
||||
nautilus_preferences_get_integer (name));
|
||||
|
||||
nautilus_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 NautilusStringList *entries)
|
||||
{
|
||||
GtkWidget *string_picker;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (entries != NULL, NULL);
|
||||
|
||||
string_picker = nautilus_string_picker_new ();
|
||||
nautilus_caption_set_title_label (NAUTILUS_CAPTION (string_picker), name);
|
||||
gtk_signal_connect (GTK_OBJECT (string_picker), "changed", GTK_SIGNAL_FUNC (user_level_picker_changed_callback),
|
||||
(gpointer) name);
|
||||
|
||||
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (string_picker), entries);
|
||||
nautilus_string_picker_set_selected_string_index (NAUTILUS_STRING_PICKER (string_picker),
|
||||
nautilus_preferences_get_user_level ());
|
||||
|
||||
nautilus_preferences_add_callback ("user_level", user_level_changed_callback, string_picker);
|
||||
user_level_changed_callback (string_picker);
|
||||
|
||||
return string_picker;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
|
||||
GtkWidget *user_level_picker;
|
||||
GtkWidget *green_picker;
|
||||
GtkWidget *yellow_picker;
|
||||
GtkWidget *red_picker;
|
||||
GtkWidget *fruits_apple_picker;
|
||||
GtkWidget *fruits_orange_picker;
|
||||
GtkWidget *fruits_pear_picker;
|
||||
|
||||
GtkWidget *vbox;
|
||||
|
||||
NautilusStringList *user_level_entries;
|
||||
NautilusStringList *color_entries;
|
||||
NautilusStringList *fruits_entries;
|
||||
|
||||
test_init (&argc, &argv);
|
||||
|
||||
user_level_entries = nautilus_string_list_new_from_tokens ("Beginner,Intermediate,Hacker", ",", TRUE);
|
||||
color_entries = nautilus_string_list_new_from_tokens ("0,1,2,3,4,5,6,7,8,9,10", ",", TRUE);
|
||||
fruits_entries = nautilus_string_list_new_from_tokens ("0,1,2,3", ",", TRUE);
|
||||
|
||||
nautilus_preferences_default_set_string ("user_level",
|
||||
NAUTILUS_USER_LEVEL_NOVICE,
|
||||
"hacker");
|
||||
|
||||
nautilus_preferences_default_set_integer ("green",
|
||||
NAUTILUS_USER_LEVEL_NOVICE,
|
||||
3);
|
||||
|
||||
nautilus_preferences_default_set_integer ("yellow",
|
||||
NAUTILUS_USER_LEVEL_NOVICE,
|
||||
9);
|
||||
|
||||
nautilus_preferences_default_set_integer ("red",
|
||||
NAUTILUS_USER_LEVEL_NOVICE,
|
||||
7);
|
||||
|
||||
nautilus_preferences_default_set_integer ("fruits/apple",
|
||||
NAUTILUS_USER_LEVEL_NOVICE,
|
||||
1);
|
||||
nautilus_preferences_default_set_integer ("fruits/orange",
|
||||
NAUTILUS_USER_LEVEL_NOVICE,
|
||||
2);
|
||||
nautilus_preferences_default_set_integer ("fruits/pear",
|
||||
NAUTILUS_USER_LEVEL_NOVICE,
|
||||
3);
|
||||
|
||||
nautilus_preferences_set_visible_user_level ("yellow", 1);
|
||||
nautilus_preferences_set_visible_user_level ("green", 0);
|
||||
nautilus_preferences_set_visible_user_level ("red", 2);
|
||||
|
||||
//sleep (10);
|
||||
|
||||
window = test_window_new (NULL, 4);
|
||||
test_window_set_title_with_pid (GTK_WINDOW (window), "Preferences Change");
|
||||
|
||||
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);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), fruits_apple_picker, FALSE, FALSE, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), fruits_orange_picker, FALSE, FALSE, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), fruits_pear_picker, FALSE, FALSE, 20);
|
||||
|
||||
nautilus_string_list_free (user_level_entries);
|
||||
nautilus_string_list_free (color_entries);
|
||||
nautilus_string_list_free (fruits_entries);
|
||||
|
||||
nautilus_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_main ();
|
||||
|
||||
return 0;
|
||||
}
|
265
test/test-nautilus-preferences-display.c
Normal file
265
test/test-nautilus-preferences-display.c
Normal file
|
@ -0,0 +1,265 @@
|
|||
#include "test.h"
|
||||
|
||||
#include <libnautilus-extensions/nautilus-image.h>
|
||||
#include <libnautilus-extensions/nautilus-image-with-background.h>
|
||||
#include <libnautilus-extensions/nautilus-text-caption.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences.h>
|
||||
|
||||
static void
|
||||
text_caption_update (NautilusTextCaption *text_caption,
|
||||
const char *name)
|
||||
{
|
||||
g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
g_print ("'%s' changed from '%d' to '%d'\n",
|
||||
name,
|
||||
test_text_caption_get_text_as_int (text_caption),
|
||||
nautilus_preferences_get_integer (name));
|
||||
|
||||
test_text_caption_set_text_for_int_preferences (text_caption, name);
|
||||
}
|
||||
|
||||
static void
|
||||
user_level_caption_update (NautilusTextCaption *text_caption)
|
||||
{
|
||||
char *old_text;
|
||||
char *new_text;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption));
|
||||
|
||||
old_text = nautilus_text_caption_get_text (text_caption);
|
||||
new_text = nautilus_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 (NAUTILUS_TEXT_CAPTION (callback_data));
|
||||
}
|
||||
|
||||
static void
|
||||
green_changed_callback (gpointer callback_data)
|
||||
{
|
||||
text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "green");
|
||||
}
|
||||
|
||||
static void
|
||||
yellow_changed_callback (gpointer callback_data)
|
||||
{
|
||||
text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "yellow");
|
||||
}
|
||||
|
||||
static void
|
||||
red_changed_callback (gpointer callback_data)
|
||||
{
|
||||
text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "red");
|
||||
}
|
||||
|
||||
static void
|
||||
apple_changed_callback (gpointer callback_data)
|
||||
{
|
||||
text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "fruits/apple");
|
||||
}
|
||||
|
||||
static void
|
||||
orange_changed_callback (gpointer callback_data)
|
||||
{
|
||||
text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "fruits/orange");
|
||||
}
|
||||
|
||||
static void
|
||||
pear_changed_callback (gpointer callback_data)
|
||||
{
|
||||
text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "fruits/pear");
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
entry_new (const char *name,
|
||||
GtkWidget **caption_out,
|
||||
GtkWidget **default_caption_out)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (caption_out != NULL, NULL);
|
||||
g_return_val_if_fail (default_caption_out != NULL, NULL);
|
||||
|
||||
hbox = gtk_hbox_new (TRUE, 2);
|
||||
|
||||
*caption_out = nautilus_text_caption_new ();
|
||||
nautilus_text_caption_set_editable (NAUTILUS_TEXT_CAPTION (*caption_out), FALSE);
|
||||
nautilus_caption_set_title_label (NAUTILUS_CAPTION (*caption_out), name);
|
||||
|
||||
*default_caption_out = nautilus_text_caption_new ();
|
||||
nautilus_text_caption_set_editable (NAUTILUS_TEXT_CAPTION (*default_caption_out), FALSE);
|
||||
nautilus_caption_set_title_label (NAUTILUS_CAPTION (*default_caption_out), "default:");
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), *caption_out, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), *default_caption_out, FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show (*caption_out);
|
||||
gtk_widget_show (*default_caption_out);
|
||||
|
||||
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 (NAUTILUS_TEXT_CAPTION (user_level_caption), "user_level");
|
||||
test_text_caption_set_text_for_default_string_preferences (NAUTILUS_TEXT_CAPTION (user_level_default_caption), "user_level");
|
||||
nautilus_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)
|
||||
{
|
||||
GtkWidget *green_caption;
|
||||
GtkWidget *green_default_caption;
|
||||
GtkWidget *green_hbox;
|
||||
|
||||
GtkWidget *yellow_caption;
|
||||
GtkWidget *yellow_default_caption;
|
||||
GtkWidget *yellow_hbox;
|
||||
|
||||
GtkWidget *red_caption;
|
||||
GtkWidget *red_default_caption;
|
||||
GtkWidget *red_hbox;
|
||||
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
|
||||
frame = gtk_frame_new ("colors");
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
green_hbox = entry_new ("green", &green_caption, &green_default_caption);
|
||||
yellow_hbox = entry_new ("yellow", &yellow_caption, &yellow_default_caption);
|
||||
red_hbox = entry_new ("red", &red_caption, &red_default_caption);
|
||||
|
||||
test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (green_caption), "green");
|
||||
test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (yellow_caption), "yellow");
|
||||
test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (red_caption), "red");
|
||||
|
||||
test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (green_default_caption), "green");
|
||||
test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (yellow_default_caption), "yellow");
|
||||
test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (red_default_caption), "red");
|
||||
|
||||
nautilus_preferences_add_callback ("green", green_changed_callback, green_caption);
|
||||
nautilus_preferences_add_callback ("yellow", yellow_changed_callback, yellow_caption);
|
||||
nautilus_preferences_add_callback ("red", red_changed_callback, red_caption);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), green_hbox, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), yellow_hbox, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), red_hbox, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show_all (frame);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
fruits_frame_new (void)
|
||||
{
|
||||
GtkWidget *apple_caption;
|
||||
GtkWidget *apple_default_caption;
|
||||
GtkWidget *apple_hbox;
|
||||
|
||||
GtkWidget *orange_caption;
|
||||
GtkWidget *orange_default_caption;
|
||||
GtkWidget *orange_hbox;
|
||||
|
||||
GtkWidget *pear_caption;
|
||||
GtkWidget *pear_default_caption;
|
||||
GtkWidget *pear_hbox;
|
||||
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
|
||||
frame = gtk_frame_new ("fruits");
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
apple_hbox = entry_new ("fruits/apple", &apple_caption, &apple_default_caption);
|
||||
orange_hbox = entry_new ("fruits/orange", &orange_caption, &orange_default_caption);
|
||||
pear_hbox = entry_new ("fruits/pear", &pear_caption, &pear_default_caption);
|
||||
|
||||
test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (apple_caption), "fruits/apple");
|
||||
test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (orange_caption), "fruits/orange");
|
||||
test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (pear_caption), "fruits/pear");
|
||||
|
||||
test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (apple_default_caption), "fruits/apple");
|
||||
test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (orange_default_caption), "fruits/orange");
|
||||
test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (pear_default_caption), "fruits/pear");
|
||||
|
||||
nautilus_preferences_add_callback ("fruits/apple", apple_changed_callback, apple_caption);
|
||||
nautilus_preferences_add_callback ("fruits/orange", orange_changed_callback, orange_caption);
|
||||
nautilus_preferences_add_callback ("fruits/pear", pear_changed_callback, pear_caption);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), apple_hbox, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), orange_hbox, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), pear_hbox, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show_all (frame);
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *vbox;
|
||||
|
||||
GtkWidget *user_level_frame;
|
||||
GtkWidget *colors_frame;
|
||||
GtkWidget *fruits_frame;
|
||||
|
||||
test_init (&argc, &argv);
|
||||
|
||||
window = test_window_new (NULL, 4);
|
||||
test_window_set_title_with_pid (GTK_WINDOW (window), "Preferences Display");
|
||||
|
||||
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);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
#include <config.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <libgnomeui/gnome-init.h>
|
||||
#include <libnautilus-extensions/nautilus-caption-table.h>
|
||||
#include <libnautilus-extensions/nautilus-password-dialog.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences-group.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences-item.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences.h>
|
||||
#include <libnautilus-extensions/nautilus-radio-button-group.h>
|
||||
|
||||
static void test_preferences_group (void);
|
||||
static void test_preferences_item (void);
|
||||
static void register_global_preferences (void);
|
||||
GtkWidget * create_enum_item (const char *preference_name);
|
||||
GtkWidget * create_bool_item (const char *preference_name);
|
||||
|
||||
enum
|
||||
{
|
||||
FRUIT_APPLE,
|
||||
FRUIT_ORANGE,
|
||||
FRUIT_BANNANA
|
||||
};
|
||||
|
||||
static const char FRUIT_PREFERENCE[] = "/a/very/fruity/path";
|
||||
|
||||
int
|
||||
main (int argc, char * argv[])
|
||||
{
|
||||
gnome_init ("foo", "bar", argc, argv);
|
||||
|
||||
register_global_preferences ();
|
||||
|
||||
test_preferences_group ();
|
||||
test_preferences_item ();
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
test_preferences_item (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * item;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
item = create_enum_item (FRUIT_PREFERENCE);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), item);
|
||||
|
||||
gtk_widget_show (item);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
static void
|
||||
test_preferences_group (void)
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * group;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
group = nautilus_preferences_group_new ("A group");
|
||||
|
||||
nautilus_preferences_group_add_item (NAUTILUS_PREFERENCES_GROUP (group),
|
||||
FRUIT_PREFERENCE,
|
||||
NAUTILUS_PREFERENCE_ITEM_ENUM);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (window), group);
|
||||
|
||||
gtk_widget_show (group);
|
||||
|
||||
gtk_widget_show (window);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
create_enum_item (const char *preference_name)
|
||||
{
|
||||
return nautilus_preferences_item_new (preference_name, NAUTILUS_PREFERENCE_ITEM_ENUM);
|
||||
}
|
||||
|
||||
// GtkWidget *
|
||||
// create_bool_item (const char *preference_name)
|
||||
// {
|
||||
// return nautilus_preferences_item_new (global_preferences,
|
||||
// preference_name,
|
||||
// NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
|
||||
// }
|
||||
|
||||
static void
|
||||
register_global_preferences (void)
|
||||
{
|
||||
gconstpointer default_values[3] = { (gconstpointer)FRUIT_ORANGE, (gconstpointer)FRUIT_ORANGE, (gconstpointer)FRUIT_ORANGE };
|
||||
|
||||
nautilus_preference_set_info_by_name (FRUIT_PREFERENCE,
|
||||
"Fruits",
|
||||
NAUTILUS_PREFERENCE_ENUM,
|
||||
default_values,
|
||||
3);
|
||||
|
||||
nautilus_preference_enum_add_entry_by_name (FRUIT_PREFERENCE,
|
||||
"apple",
|
||||
"Apple",
|
||||
FRUIT_APPLE);
|
||||
|
||||
nautilus_preference_enum_add_entry_by_name (FRUIT_PREFERENCE,
|
||||
"orange",
|
||||
"Orange",
|
||||
FRUIT_ORANGE);
|
||||
|
||||
nautilus_preference_enum_add_entry_by_name (FRUIT_PREFERENCE,
|
||||
"bannana",
|
||||
"Bannana",
|
||||
FRUIT_BANNANA);
|
||||
|
||||
nautilus_preferences_set_enum (FRUIT_PREFERENCE,
|
||||
FRUIT_BANNANA);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue