diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-03-28 10:10:29 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2001-03-28 10:10:29 +0000 |
commit | f7170ace275607f2e1630ef06e9a50288ffb7530 (patch) | |
tree | 635bb99ee844af31883e161e450b7d32e63beec5 /libnautilus-private | |
parent | a09a439c679622c77d5a26895b5f3541c956f435 (diff) | |
download | nautilus-f7170ace275607f2e1630ef06e9a50288ffb7530.tar.gz |
Fix bugs:
7343 - Fonts checks should work even when nautilus has not
undergone 'make install'
7703 - index status dialog is mixing gnome dialog font and
nautilus custom font
7204 - Need a better way to pick a fallback font
1102 - Embedded text should use preferences to determine the font
it uses
7357 - Preferences dialog spews critical in the ja_JP locale
7344 - NautilusScalable should not be doing any preferences
peeking
7345 - Default font "helvetica" hard coded and marked for
translatation in many places
7834 - Should mark selected style in font picker menu
5239 - Please make the text viewer use a fixed-width font
7401 - Non smooth font family picker should have a "GTK System
Font" entry
Work in progress for related bugs:
5101 - font sizes hard-coded in icon view
5456 - Sidebar tabs use hard coded font families
7670 - Font size is small in list view.
reviewed by: Glynn Foster <glynn.foster@ireland.sun.com>
* components/notes/nautilus-notes.c: (make_notes_view):
Dont translate the font name.
* components/text/nautilus-text-view-ui.xml:
Add default and fixed entries.
* components/text/nautilus-text-view.c:
(nautilus_text_view_initialize_class),
(nautilus_text_view_initialize), (nautilus_text_view_destroy),
(nautilus_text_view_update_font), (handle_ui_event),
(merge_bonobo_menu_items), (nautilus_text_view_zoom_to_level),
(zoomable_zoom_to_fit_callback), (font_changed_callback):
Dont store the font name and size. Compute these as needed. Use
deltas instead of hard coded font sizes to compute the font size
for a given zoom level. Store the font changes in preferences.
* libnautilus-extensions/nautilus-caption.c:
(nautilus_caption_initialize), (nautilus_caption_set_title_label),
(nautilus_caption_get_title_label),
(nautilus_caption_get_title_label_width),
(nautilus_caption_set_child), (nautilus_caption_set_spacing):
* libnautilus-extensions/nautilus-caption.h:
Add support for nice caption alignments.
* libnautilus-extensions/nautilus-directory.c:
(add_preferences_callbacks), (remove_preferences_callbacks):
A bit of a hack. Keep track of changes in the default smooth font
so that embedded icon text previews can be updated as needed.
* libnautilus-extensions/nautilus-font-factory.c:
(nautilus_font_factory_get_font_by_family),
A temporary hack for default system font usage. In a future
checkin this will not be needed anymore.
(nautilus_font_factory_get_font_from_preferences):
Dont translate font names anymore.
* libnautilus-extensions/nautilus-font-manager.c:
(font_description_new), (font_description_free),
(font_description_get_char_set), (font_description_table_for_each),
(font_list_find_bold_callback), (get_test_font_dir),
(nautilus_self_check_font_manager):
* libnautilus-extensions/nautilus-font-manager.h:
Merge char_set_registry and char_set_encoding into one string
'char_set.' Make the font checks work even if nautilus has not
undergone 'make install'
* libnautilus-extensions/nautilus-font-picker.c:
(nautilus_font_picker_initialize), (nautilus_font_picker_destroy),
(font_picker_populate), (font_make_style_name),
(font_style_entry_new), (compare_style),
(global_font_list_populate_callback):
* libnautilus-extensions/nautilus-font-picker.h:
Sublcass the font picker from NautilusCaption so that it will
nicely align in the preferences dialog.
Mark selected style in font picker menus by using radio buttons.
Fix a storage leak on destruction.
* libnautilus-extensions/nautilus-glib-extensions.c:
(nautilus_compare_integer), (nautilus_self_check_glib_extensions):
* libnautilus-extensions/nautilus-glib-extensions.h:
New GCompare function for integers.
* libnautilus-extensions/nautilus-global-preferences.c:
(global_preferences_install_defaults),
(global_preferences_create_dialog),
(global_preferences_create_search_pane),
(global_preferences_create_sidebar_panels_pane),
(global_preferences_pane_update_callback),
(global_preferences_get_dialog),
(global_preferences_install_sidebar_panel_defaults),
(global_preferences_make_sidebar_panel_key),
(global_preferences_is_sidebar_panel_enabled),
(global_preferences_install_home_location_defaults),
(global_preferences_install_font_defaults),
(global_preferences_install_medusa_defaults),
(global_preferences_populate_pane),
(global_preferences_get_smooth_font),
(global_preferences_get_smooth_bold_font),
(nautilus_global_preferences_get_icon_view_smooth_font),
(nautilus_global_preferences_get_default_smooth_font),
(nautilus_global_preferences_get_default_smooth_bold_font),
(nautilus_global_preferences_initialize):
* libnautilus-extensions/nautilus-global-preferences.h:
Simplify the creation of preferences by using structures to
describe both preferences and preference fialog entries.
* libnautilus-extensions/nautilus-gtk-extensions.c:
(nautilus_gtk_get_system_font):
* libnautilus-extensions/nautilus-gtk-extensions.h:
New function to obtain the "Gtk System Font."
* libnautilus-extensions/nautilus-icon-canvas-item.c:
(nautilus_icon_canvas_item_initialize_class),
(nautilus_icon_canvas_item_set_arg),
(nautilus_icon_canvas_item_get_arg),
(nautilus_icon_canvas_item_set_smooth_font_size):
* libnautilus-extensions/nautilus-icon-canvas-item.h:
Use signed integers for the font dimensions.
* libnautilus-extensions/nautilus-icon-container.c:
(nautilus_icon_container_initialize),
(nautilus_icon_container_update_icon),
(nautilus_icon_container_theme_changed),
(nautilus_icon_container_set_font_size_table):
* libnautilus-extensions/nautilus-icon-container.h:
* libnautilus-extensions/nautilus-icon-private.h:
Dont translate the font names. Rename the font size table to
better reflect its purpose. Use signed integers for font sizes.
* libnautilus-extensions/nautilus-icon-factory.c:
(embedded_text_font_changed_callback), (embedded_text_font_free),
(embed_text):
Keep track of changes in the smooth font used for embedded text so
that the icon text previews will update as needed.
* libnautilus-extensions/nautilus-preferences-box.c:
(nautilus_preferences_box_find_pane):
* libnautilus-extensions/nautilus-preferences-box.h:
New function to find a named pane.
* libnautilus-extensions/nautilus-preferences-group.c:
(preferences_group_align_captions),
(nautilus_preferences_group_update),
(nautilus_preferences_group_get_title_label):
* libnautilus-extensions/nautilus-preferences-group.h:
Add support for aligning captions.
* libnautilus-extensions/nautilus-preferences-item.c:
(nautilus_preferences_item_initialize),
(preferences_item_construct), (preferences_item_update_enum),
(preferences_item_create_enum),
(preferences_item_update_short_enum),
(preferences_item_create_short_enum),
(preferences_item_update_boolean),
(preferences_item_create_boolean),
(preferences_item_update_editable_string),
(preferences_item_create_editable_string),
(preferences_item_update_editable_integer),
(preferences_item_create_editable_integer),
(preferences_item_update_constrained_integer),
(preferences_item_create_constrained_integer),
(preferences_item_update_font), (preferences_item_create_font),
(preferences_item_update_smooth_font),
(preferences_item_create_smooth_font),
(nautilus_preferences_item_new),
(enum_radio_group_changed_callback),
(boolean_button_toggled_callback), (font_item_changed_callback),
(editable_string_changed_callback),
(editable_integer_changed_callback),
(constrained_integer_changed_callback),
(nautilus_preferences_item_update_displayed_value),
(preferences_item_update_editable_integer_settings_at_idle),
(nautilus_preferences_item_get_control_showing),
(nautilus_preferences_item_set_constrained_integer_paramaters),
(nautilus_preferences_item_child_is_caption),
(nautilus_preferences_item_get_caption_title_label_width),
(nautilus_preferences_item_set_caption_spacing):
* libnautilus-extensions/nautilus-preferences-item.h:
Add a new CONSTRAINED INTEGER item type. Add support for aligning
captions.
Dont translate font names.
* libnautilus-extensions/nautilus-preferences-pane.c:
(nautilus_preferences_pane_add_group),
(nautilus_preferences_pane_add_item_to_nth_group),
(nautilus_preferences_pane_get_num_visible_groups),
(nautilus_preferences_pane_get_num_groups),
(nautilus_preferences_pane_find_group):
* libnautilus-extensions/nautilus-preferences-pane.h:
Add a function for finding a named group.
* libnautilus-extensions/nautilus-scalable-font.c:
(nautilus_scalable_font_get_default_font),
(nautilus_scalable_font_get_default_bold_font):
Dont peek preferences for the default fonts. These are now
handled in nautilus-global-preferences.
* libnautilus-extensions/nautilus-smooth-text-layout.c:
(smooth_text_layout_line_list_new),
(smooth_text_layout_line_list_new_wrapped),
(nautilus_smooth_text_layout_new),
(nautilus_smooth_text_layout_set_font_size):
Use signed integers for font sizes.
* libnautilus-extensions/nautilus-string-picker.c:
(nautilus_string_picker_initialize),
(nautilus_string_picker_set_string_list):
Update for Caption superclass changes. Dont make singleton
choices insensitive.
* libnautilus-extensions/nautilus-text-caption.c:
(nautilus_text_caption_initialize):
* libnautilus-extensions/nautilus-text-caption.h:
Update for Caption superclass changes. Fix errors in header comments.
* src/file-manager/fm-directory-view.c:
(fm_directory_view_initialize), (fm_directory_view_destroy):
* src/file-manager/fm-directory-view.h:
Remove knowledge of font stuff. The fonts for icon and list view
are now handled separately so each subclass will have to do its
own preferences listening.
* src/file-manager/fm-icon-view.c: (set_sort_criterion_by_id),
(font_changed_callback), (smooth_font_changed_callback),
(standard_font_size_changed_callback),
(fm_icon_view_initialize_class), (fm_icon_view_initialize),
(fm_icon_view_update_icon_container_font_size_table),
(fm_icon_view_update_icon_container_smooth_font),
(create_icon_container):
Keep track of icon view font changes. Use deltas to compute the
font sizes instead of hard coded point sizes.
* src/file-manager/fm-list-view.c: (fm_list_view_initialize_class),
(fm_list_view_initialize), (fm_list_view_update_font),
(font_or_font_size_changed_callback),
(fm_list_view_image_display_policy_changed):
Keep track of list view font changes. Use deltas to compute the
font sizes instead of hard coded point sizes.
* src/file-manager/nautilus-indexing-info.c:
(last_index_time_and_reindex_button_dialog_new),
(index_progress_dialog_new):
Dont use smooth labels mixed in with regular gtk labels.
* src/nautilus-sidebar-tabs.c:
(nautilus_sidebar_tabs_load_theme_data),
(smooth_font_changed_callback), (nautilus_sidebar_tabs_initialize),
(nautilus_sidebar_tabs_destroy):
Add macros and FIXME for hard coded font size. NULL out the tab_font
when its unreffed, otherwise all hell breaks lose when user level
changes. Update for default font changes.
* src/nautilus-sidebar-title.c: (smooth_font_changed_callback),
(nautilus_sidebar_title_initialize),
(nautilus_sidebar_title_destroy), (update_font):
Keep track of smooth font changes. Update for default font changes.
* test/test-nautilus-font-manager.c: (font_iterator_callback):
* test/test-nautilus-font-picker.c: (update_font),
(print_selected_font_callback), (main):
* test/test-nautilus-label-simple.c: (use_system_font_callback),
(use_system_font_bold_callback), (main):
Update for font picker and font manager changes.
Diffstat (limited to 'libnautilus-private')
33 files changed, 1924 insertions, 1339 deletions
diff --git a/libnautilus-private/nautilus-caption.c b/libnautilus-private/nautilus-caption.c index 54f0f7051..1a2a6b307 100644 --- a/libnautilus-private/nautilus-caption.c +++ b/libnautilus-private/nautilus-caption.c @@ -28,6 +28,7 @@ #include "nautilus-gtk-macros.h" #include "nautilus-glib-extensions.h" +#include "nautilus-art-gtk-extensions.h" #include <gtk/gtklabel.h> #include <gtk/gtkentry.h> @@ -37,9 +38,10 @@ static const gint CAPTION_SPACING = 10; struct _NautilusCaptionDetail { - GtkWidget *title_label; - GtkWidget *child; - gboolean show_title; + GtkWidget *title_label; + GtkWidget *child; + gboolean show_title; + int spacing; }; /* NautilusCaptionClass methods */ @@ -47,11 +49,9 @@ static void nautilus_caption_initialize_class (NautilusCaptionClass *klass) static void nautilus_caption_initialize (NautilusCaption *caption); /* GtkObjectClass methods */ -static void nautilus_caption_destroy (GtkObject *object); - -static void nautilus_font_picker_show_all (GtkWidget *widget); - -static void update_title (NautilusCaption *caption); +static void nautilus_caption_destroy (GtkObject *object); +static void nautilus_font_picker_show_all (GtkWidget *widget); +static void update_title (NautilusCaption *caption); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusCaption, nautilus_caption, GTK_TYPE_HBOX) @@ -77,7 +77,7 @@ nautilus_caption_initialize_class (NautilusCaptionClass *caption_class) static void nautilus_caption_initialize (NautilusCaption *caption) { - caption->detail = g_new (NautilusCaptionDetail, 1); + caption->detail = g_new0 (NautilusCaptionDetail, 1); gtk_box_set_homogeneous (GTK_BOX (caption), FALSE); gtk_box_set_spacing (GTK_BOX (caption), CAPTION_SPACING); @@ -156,7 +156,6 @@ void nautilus_caption_set_title_label (NautilusCaption *caption, const char *title_label) { - g_return_if_fail (caption != NULL); g_return_if_fail (NAUTILUS_IS_CAPTION (caption)); g_return_if_fail (title_label != NULL); @@ -195,7 +194,6 @@ nautilus_caption_get_title_label (const NautilusCaption *caption) { gchar *str; - g_return_val_if_fail (caption != NULL, NULL); g_return_val_if_fail (NAUTILUS_IS_CAPTION (caption), NULL); /* DANGER! DANGER! @@ -208,29 +206,90 @@ nautilus_caption_get_title_label (const NautilusCaption *caption) } /** - * nautilus_caption_get_title_label: + * nautilus_caption_get_title_label_width: * @caption: A NautilusCaption * - * Returns: A newly allocated copy of the title label. + * Returns: A width of the title label. + */ +int +nautilus_caption_get_title_label_width (const NautilusCaption *caption) +{ + NautilusDimensions title_dimensions; + + g_return_val_if_fail (NAUTILUS_IS_CAPTION (caption), 0); + + title_dimensions = nautilus_gtk_widget_get_preferred_dimensions (caption->detail->title_label); + + return title_dimensions.width; +} + +/** + * nautilus_caption_set_child + * @caption: A NautilusCaption + * @child: A GtkWidget to become the caption's one and only child. + * @expand: Same as GtkBox. + * @fill: Same as GtkBox. + * + * Install a widget as the one and only child of the caption. */ void nautilus_caption_set_child (NautilusCaption *caption, - GtkWidget *child) + GtkWidget *child, + gboolean expand, + gboolean fill) { - g_return_if_fail (caption != NULL); g_return_if_fail (NAUTILUS_IS_CAPTION (caption)); - g_return_if_fail (child != NULL); g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (caption->detail->child == NULL); caption->detail->child = child; + + gtk_box_pack_start (GTK_BOX (caption), + caption->detail->child, + expand, /* expand */ + fill, /* fill */ + caption->detail->spacing); /* padding */ + + gtk_widget_show (caption->detail->child); +} + +/** + * nautilus_caption_set_spacing + * @caption: A NautilusCaption + * @spacing: Spacing in pixels between the title and the child. + * + * Set the spacing between the title label and the caption's one + * and only child. + */ +void +nautilus_caption_set_spacing (NautilusCaption *caption, + int spacing) +{ + gboolean expand; + gboolean fill; + guint padding; + GtkPackType pack_type; - gtk_box_pack_end (GTK_BOX (caption), - caption->detail->child, - TRUE, /* expand */ - TRUE, /* fill */ - 0); /* padding */ + g_return_if_fail (NAUTILUS_IS_CAPTION (caption)); + g_return_if_fail (spacing >= 0); - gtk_widget_show (caption->detail->child); + caption->detail->spacing = spacing; + + if (caption->detail->child == NULL) { + return; + } + gtk_box_query_child_packing (GTK_BOX (caption), + caption->detail->child, + &expand, + &fill, + &padding, + &pack_type); + + gtk_box_set_child_packing (GTK_BOX (caption), + caption->detail->child, + expand, + fill, + caption->detail->spacing, + pack_type); } diff --git a/libnautilus-private/nautilus-caption.h b/libnautilus-private/nautilus-caption.h index 0ae4d5a10..56d0e5e46 100644 --- a/libnautilus-private/nautilus-caption.h +++ b/libnautilus-private/nautilus-caption.h @@ -60,24 +60,29 @@ struct _NautilusCaptionClass GtkHBoxClass parent_class; }; -GtkType nautilus_caption_get_type (void); -GtkWidget* nautilus_caption_new (void); +GtkType nautilus_caption_get_type (void); +GtkWidget* nautilus_caption_new (void); /* Title label mutator. */ -void nautilus_caption_set_title_label (NautilusCaption *caption, - const char *title_label); -void nautilus_caption_set_show_title (NautilusCaption *caption, - gboolean show_title); +void nautilus_caption_set_title_label (NautilusCaption *caption, + const char *title_label); +void nautilus_caption_set_show_title (NautilusCaption *caption, + gboolean show_title); /* Title label accessor. */ -char * nautilus_caption_get_title_label (const NautilusCaption *caption); +char * nautilus_caption_get_title_label (const NautilusCaption *caption); /* Set the child. */ -void nautilus_caption_set_child (NautilusCaption *caption, - GtkWidget *child); +void nautilus_caption_set_child (NautilusCaption *caption, + GtkWidget *child, + gboolean expand, + gboolean fill); +void nautilus_caption_set_spacing (NautilusCaption *caption, + int spacing); +int nautilus_caption_get_title_label_width (const NautilusCaption *caption); END_GNOME_DECLS diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c index 15185b8b2..1d53acf8a 100644 --- a/libnautilus-private/nautilus-directory.c +++ b/libnautilus-private/nautilus-directory.c @@ -283,6 +283,9 @@ add_preferences_callbacks (void) nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, async_data_preference_changed_callback, NULL); + nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT, + async_data_preference_changed_callback, + NULL); } static void @@ -300,6 +303,9 @@ remove_preferences_callbacks (void) nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, async_data_preference_changed_callback, NULL); + nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT, + async_data_preference_changed_callback, + NULL); } char * diff --git a/libnautilus-private/nautilus-font-factory.c b/libnautilus-private/nautilus-font-factory.c index ca7e7583d..58be96a39 100644 --- a/libnautilus-private/nautilus-font-factory.c +++ b/libnautilus-private/nautilus-font-factory.c @@ -29,6 +29,7 @@ #include "nautilus-gtk-macros.h" #include "nautilus-string.h" #include "nautilus-gdk-font-extensions.h" +#include "nautilus-gtk-extensions.h" #include <pthread.h> #include <unistd.h> @@ -218,6 +219,10 @@ nautilus_font_factory_get_font_by_family (const char *family, g_return_val_if_fail (family != NULL, NULL); g_return_val_if_fail (size_in_pixels > 0, NULL); + if (nautilus_str_is_equal (family, "default")) { + return nautilus_gtk_get_system_font (); + } + fontset = g_strsplit (family, ",", 5); iter = fontset; @@ -268,10 +273,8 @@ 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); - - font = nautilus_font_factory_get_font_by_family (_(family), size_in_pixels); - + family = nautilus_preferences_get (NAUTILUS_PREFERENCES_ICON_VIEW_FONT); + font = nautilus_font_factory_get_font_by_family (family, size_in_pixels); g_free (family); return font; diff --git a/libnautilus-private/nautilus-font-manager.c b/libnautilus-private/nautilus-font-manager.c index 5e980241c..b9b0f71c8 100644 --- a/libnautilus-private/nautilus-font-manager.c +++ b/libnautilus-private/nautilus-font-manager.c @@ -120,8 +120,7 @@ typedef struct { char *weight; char *slant; char *set_width; - char *char_set_registry; - char *char_set_encoding; + char *char_set; gboolean is_ignored; } FontDescription; @@ -156,8 +155,7 @@ static char *font_description_get_family (const F static char *font_description_get_weight (const FontDescription *description); static char *font_description_get_slant (const FontDescription *description); static char *font_description_get_set_width (const FontDescription *description); -static char *font_description_get_char_set_registry (const FontDescription *description); -static char *font_description_get_char_set_encoding (const FontDescription *description); +static char *font_description_get_char_set (const FontDescription *description); static FontDescriptionTable * font_description_table_new (const char *font_directory, const GList *postscript_font_list, const GList *true_type_font_list); @@ -254,6 +252,8 @@ font_description_new (const char *font_file_name, { FontDescription *description = NULL; NautilusStringList *tokenized_xlfd; + char *char_set_registry; + char *char_set_encoding; g_return_val_if_fail (string_is_valid (font_file_name), NULL); g_return_val_if_fail (string_is_valid (xlfd_string), NULL); @@ -271,8 +271,13 @@ font_description_new (const char *font_file_name, description->weight = nautilus_string_list_nth (tokenized_xlfd, XLFD_INDEX_WEIGHT); description->slant = nautilus_string_list_nth (tokenized_xlfd, XLFD_INDEX_SLANT); description->set_width = nautilus_string_list_nth (tokenized_xlfd, XLFD_INDEX_SET_WIDTH); - description->char_set_registry = nautilus_string_list_nth (tokenized_xlfd, XLFD_INDEX_CHAR_SET_REGISTRY); - description->char_set_encoding = nautilus_string_list_nth (tokenized_xlfd, XLFD_INDEX_CHAR_SET_ENCODING); + + char_set_registry = nautilus_string_list_nth (tokenized_xlfd, XLFD_INDEX_CHAR_SET_REGISTRY); + char_set_encoding = nautilus_string_list_nth (tokenized_xlfd, XLFD_INDEX_CHAR_SET_ENCODING); + description->char_set = g_strdup_printf ("%s-%s", char_set_registry, char_set_encoding); + g_free (char_set_registry); + g_free (char_set_encoding); + description->is_ignored = font_foundry_is_ignored (description->foundry) || font_family_is_ignored (description->family); } else { @@ -295,8 +300,7 @@ font_description_free (FontDescription *description) g_free (description->weight); g_free (description->slant); g_free (description->set_width); - g_free (description->char_set_registry); - g_free (description->char_set_encoding); + g_free (description->char_set); g_free (description); } @@ -349,19 +353,11 @@ font_description_get_set_width (const FontDescription *description) } static char * -font_description_get_char_set_registry (const FontDescription *description) +font_description_get_char_set (const FontDescription *description) { g_return_val_if_fail (description != NULL, NULL); - return g_strdup (description->char_set_registry); -} - -static char * -font_description_get_char_set_encoding (const FontDescription *description) -{ - g_return_val_if_fail (description != NULL, NULL); - - return g_strdup (description->char_set_encoding); + return g_strdup (description->char_set); } static guint @@ -565,8 +561,7 @@ font_description_table_for_each (const FontDescriptionTable *table, description->weight, description->slant, description->set_width, - description->char_set_registry, - description->char_set_encoding, + description->char_set, callback_data); } @@ -1250,8 +1245,7 @@ font_list_find_bold_callback (const char *font_file_name, const char *weight, const char *slant, const char *set_width, - const char *char_set_registry, - const char *char_set_encoding, + const char *char_set, gpointer callback_data) { FindData *data; @@ -1262,8 +1256,7 @@ font_list_find_bold_callback (const char *font_file_name, g_return_val_if_fail (weight != NULL, FALSE); g_return_val_if_fail (slant != NULL, FALSE); g_return_val_if_fail (set_width != NULL, FALSE); - g_return_val_if_fail (char_set_registry != NULL, FALSE); - g_return_val_if_fail (char_set_encoding != NULL, FALSE); + g_return_val_if_fail (char_set != NULL, FALSE); g_return_val_if_fail (callback_data != NULL, FALSE); data = callback_data; @@ -1275,8 +1268,7 @@ font_list_find_bold_callback (const char *font_file_name, && nautilus_istr_is_equal (data->description->family, family) && nautilus_istr_is_equal (data->description->slant, slant) && nautilus_istr_is_equal (data->description->set_width, set_width) - && nautilus_istr_is_equal (data->description->char_set_registry, char_set_registry) - && nautilus_istr_is_equal (data->description->char_set_encoding, char_set_encoding) + && nautilus_istr_is_equal (data->description->char_set, char_set) && nautilus_font_manager_weight_is_bold (weight)) { data->found_file_name = g_strdup (font_file_name); } @@ -1331,7 +1323,31 @@ call_chop_off_comments (const char *input) return test_copy; } -#define TEST_FONT_DIR "/usr/share/fonts/default/Type1" +static char * +get_test_font_dir (void) +{ + char *test_font_dir; + char *uri; + char *base_uri; + char *relative_part; + char *current_dir; + + current_dir = g_get_current_dir (); + + base_uri = g_strdup_printf ("file://%s/", current_dir); + relative_part = g_strdup_printf ("%s/%s", SOURCE_DATADIR, "/fonts/urw"); + + uri = nautilus_uri_make_full_from_relative (base_uri, relative_part); + + test_font_dir = g_strdup (uri + strlen ("file://")); + + g_free (base_uri); + g_free (relative_part); + g_free (uri); + g_free (current_dir); + + return test_font_dir; +} void nautilus_self_check_font_manager (void) @@ -1339,6 +1355,8 @@ nautilus_self_check_font_manager (void) FontDescriptionTable *table; const FontDescription *description; GList *font_table_list = NULL; + char *test_font_dir; + char *font_name_table[4]; /* chop_off_comments() */ NAUTILUS_CHECK_STRING_RESULT (call_chop_off_comments ("foo bar"), "foo bar"); @@ -1349,67 +1367,73 @@ nautilus_self_check_font_manager (void) NAUTILUS_CHECK_STRING_RESULT (call_chop_off_comments ("\\#foo bar"), "\\#foo bar"); NAUTILUS_CHECK_STRING_RESULT (call_chop_off_comments ("\\##foo bar"), "\\#"); - /* Its too hard to get these font manager checks to work in tinderbox - * without bug 7343 being fixed. So im going to fix 7343 instead of - * messing around with tinderbox. - */ - return; + test_font_dir = get_test_font_dir (); - if (!g_file_exists (TEST_FONT_DIR)) { - return; - } + g_return_if_fail (g_file_exists (test_font_dir)); - font_manager_collect_font_tables (TEST_FONT_DIR, &font_table_list); + font_name_table[0] = g_strdup_printf ("%s/%s", test_font_dir, "n019003l.pfb"); + font_name_table[1] = g_strdup_printf ("%s/%s", test_font_dir, "n019004l.pfb"); + font_name_table[2] = g_strdup_printf ("%s/%s", test_font_dir, "n019023l.pfb"); + font_name_table[3] = g_strdup_printf ("%s/%s", test_font_dir, "n019024l.pfb"); + + g_return_if_fail (g_file_exists (font_name_table[0])); + g_return_if_fail (g_file_exists (font_name_table[1])); + g_return_if_fail (g_file_exists (font_name_table[2])); + g_return_if_fail (g_file_exists (font_name_table[3])); + + font_manager_collect_font_tables (test_font_dir, &font_table_list); g_return_if_fail (font_table_list != NULL); g_return_if_fail (g_list_nth_data (font_table_list, 0) != NULL); table = g_list_nth_data (font_table_list, 0); - NAUTILUS_CHECK_INTEGER_RESULT (font_description_table_get_length (table), 35); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 0), TEST_FONT_DIR "/a010013l.pfb"); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 1), TEST_FONT_DIR "/a010015l.pfb"); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 2), TEST_FONT_DIR "/a010033l.pfb"); - NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 3), TEST_FONT_DIR "/a010035l.pfb"); + NAUTILUS_CHECK_INTEGER_RESULT (font_description_table_get_length (table), 4); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 0), font_name_table[0]); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 1), font_name_table[1]); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 2), font_name_table[2]); + NAUTILUS_CHECK_STRING_RESULT (font_description_table_get_nth_file_name (table, 3), font_name_table[3]); description = font_description_table_peek_nth (table, 0); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT_DIR "/a010013l.pfb"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[0]); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Avantgarde"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "book"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "medium"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_slant (description), "r"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_set_width (description), "normal"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set_encoding (description), "1"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set_registry (description), "iso8859"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); description = font_description_table_peek_nth (table, 1); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT_DIR "/a010015l.pfb"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[1]); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Avantgarde"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "demibold"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "bold"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_slant (description), "r"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_set_width (description), "normal"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set_encoding (description), "1"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set_registry (description), "iso8859"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); description = font_description_table_peek_nth (table, 2); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT_DIR "/a010033l.pfb"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[2]); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Avantgarde"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "book"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "medium"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_slant (description), "o"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_set_width (description), "normal"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set_encoding (description), "1"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set_registry (description), "iso8859"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); description = font_description_table_peek_nth (table, 3); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), TEST_FONT_DIR "/a010035l.pfb"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_file_name (description), font_name_table[3]); NAUTILUS_CHECK_STRING_RESULT (font_description_get_foundry (description), "URW"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Avantgarde"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "demibold"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_family (description), "Helvetica Default"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_weight (description), "bold"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_slant (description), "o"); NAUTILUS_CHECK_STRING_RESULT (font_description_get_set_width (description), "normal"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set_encoding (description), "1"); - NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set_registry (description), "iso8859"); + NAUTILUS_CHECK_STRING_RESULT (font_description_get_char_set (description), "iso8859-1"); + + g_free (font_name_table[0]); + g_free (font_name_table[1]); + g_free (font_name_table[2]); + g_free (font_name_table[3]); + g_free (test_font_dir); font_table_list_free (font_table_list); } diff --git a/libnautilus-private/nautilus-font-manager.h b/libnautilus-private/nautilus-font-manager.h index ce8213bc5..6a9c41041 100644 --- a/libnautilus-private/nautilus-font-manager.h +++ b/libnautilus-private/nautilus-font-manager.h @@ -46,8 +46,7 @@ typedef gboolean (*NautilusFontManagerCallback) (const char *font_file_name, const char *weight, const char *slant, const char *set_width, - const char *char_set_registry, - const char *char_set_encoding, + const char *char_set, gpointer callback_data); void nautilus_font_manager_for_each_font (NautilusFontManagerCallback callback, diff --git a/libnautilus-private/nautilus-font-picker.c b/libnautilus-private/nautilus-font-picker.c index ce5ee8304..12bb6032b 100644 --- a/libnautilus-private/nautilus-font-picker.c +++ b/libnautilus-private/nautilus-font-picker.c @@ -35,11 +35,11 @@ #include <libgnome/gnome-i18n.h> #include <gtk/gtkentry.h> -#include <gtk/gtkhbox.h> #include <gtk/gtklabel.h> #include <gtk/gtkmenu.h> #include <gtk/gtkmenuitem.h> #include <gtk/gtkoptionmenu.h> +#include <gtk/gtkradiomenuitem.h> #include <gtk/gtksignal.h> #include <libgnome/gnome-i18n.h> @@ -127,7 +127,6 @@ typedef enum struct NautilusFontPickerDetails { - GtkWidget *title_label; GtkWidget *option_menu; GtkWidget *menu; GtkWidget *current_menu; @@ -153,8 +152,7 @@ static gboolean global_font_list_populate_callback (const char const char *weight, const char *slant, const char *set_width, - const char *char_set_registry, - const char *char_set_encoding, + const char *char_set, gpointer callback_data); static guint nautilus_gtk_menu_shell_get_num_items (const GtkMenuShell *menu_shell); static const FontStyleEntry *font_picker_get_selected_style_entry (const NautilusFontPicker *font_picker); @@ -164,7 +162,7 @@ static gboolean font_picker_find_entries_for_font (const char static int font_picker_get_index_for_entry (const NautilusFontPicker *font_picker, const FontEntry *entry); -NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusFontPicker, nautilus_font_picker, GTK_TYPE_HBOX) +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusFontPicker, nautilus_font_picker, NAUTILUS_TYPE_CAPTION) static guint font_picker_signals[LAST_SIGNAL] = { 0 }; @@ -241,14 +239,6 @@ nautilus_font_picker_initialize (NautilusFontPicker *font_picker) gtk_box_set_homogeneous (GTK_BOX (font_picker), FALSE); gtk_box_set_spacing (GTK_BOX (font_picker), FONT_PICKER_SPACING); - /* The title label */ - font_picker->details->title_label = gtk_label_new (_("Pick A Font")); - gtk_label_set_justify (GTK_LABEL (font_picker->details->title_label), - GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (font_picker->details->title_label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (font_picker), font_picker->details->title_label, FALSE, FALSE, 0); - gtk_widget_show (font_picker->details->title_label); - /* The font option menu */ font_picker->details->option_menu = gtk_option_menu_new (); font_picker->details->menu = gtk_menu_new (); @@ -264,9 +254,12 @@ nautilus_font_picker_initialize (NautilusFontPicker *font_picker) font_picker); font_picker->details->current_menu = font_picker->details->menu; - gtk_box_pack_start (GTK_BOX (font_picker), font_picker->details->option_menu, TRUE, TRUE, 0); - gtk_widget_show (font_picker->details->option_menu); - + + nautilus_caption_set_child (NAUTILUS_CAPTION (font_picker), + font_picker->details->option_menu, + FALSE, + FALSE); + font_picker_populate (font_picker); gtk_option_menu_set_menu (GTK_OPTION_MENU (font_picker->details->option_menu), @@ -291,6 +284,7 @@ nautilus_font_picker_destroy (GtkObject* object) font_picker = NAUTILUS_FONT_PICKER (object); + g_free (font_picker->details->selected_font); g_free (font_picker->details); /* Chain */ @@ -486,10 +480,11 @@ font_picker_populate (NautilusFontPicker *font_picker) const FontStyleEntry *style_entry; const GList *style_node; GtkWidget *font_menu_item; - GtkWidget *style_menu_item; + GtkWidget *style_menu_item = NULL; GtkWidget *style_menu; guint font_item_count; guint style_item_count; + GSList *radio_item_group = NULL; g_return_if_fail (NAUTILUS_IS_FONT_PICKER (font_picker)); @@ -518,7 +513,12 @@ font_picker_populate (NautilusFontPicker *font_picker) g_assert (style_node->data != NULL); style_entry = style_node->data; - style_menu_item = gtk_menu_item_new_with_label (style_entry->name); + radio_item_group = style_menu_item != NULL ? + gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (style_menu_item)) : + NULL; + + style_menu_item = gtk_radio_menu_item_new_with_label (radio_item_group, style_entry->name); + gtk_menu_append (GTK_MENU (style_menu), style_menu_item); gtk_widget_show (style_menu_item); gtk_signal_connect (GTK_OBJECT (style_menu_item), @@ -573,8 +573,7 @@ static char * font_make_style_name (const char *weight, const char *slant, const char *set_width, - const char *char_set_registry, - const char *char_set_encoding) + const char *char_set) { const char *mapped_weight; const char *mapped_slant; @@ -583,8 +582,7 @@ font_make_style_name (const char *weight, g_return_val_if_fail (weight != NULL, NULL); g_return_val_if_fail (slant != NULL, NULL); g_return_val_if_fail (set_width != NULL, NULL); - g_return_val_if_fail (char_set_registry != NULL, NULL); - g_return_val_if_fail (char_set_encoding != NULL, NULL); + g_return_val_if_fail (char_set != NULL, NULL); mapped_weight = font_find_style (font_weight_map, NAUTILUS_N_ELEMENTS (font_weight_map), @@ -662,8 +660,7 @@ font_style_entry_new (const char *font_file_name, const char *weight, const char *slant, const char *set_width, - const char *char_set_registry, - const char *char_set_encoding) + const char *char_set) { FontStyleEntry *style_entry; @@ -671,11 +668,10 @@ font_style_entry_new (const char *font_file_name, g_return_val_if_fail (weight != NULL, NULL); g_return_val_if_fail (slant != NULL, NULL); g_return_val_if_fail (set_width != NULL, NULL); - g_return_val_if_fail (char_set_registry != NULL, NULL); - g_return_val_if_fail (char_set_encoding != NULL, NULL); + g_return_val_if_fail (char_set != NULL, NULL); style_entry = g_new0 (FontStyleEntry, 1); - style_entry->name = font_make_style_name (weight, slant, set_width, char_set_registry, char_set_encoding); + style_entry->name = font_make_style_name (weight, slant, set_width, char_set); style_entry->is_bold = nautilus_font_manager_weight_is_bold (weight); style_entry->slant = font_slant_string_to_enum (slant); style_entry->stretch = font_set_width_string_to_enum (set_width); @@ -825,17 +821,6 @@ list_contains_style (GList *styles, FontStyleEntry *style) #define GREATER_THAN 1 static int -compare_int (int a, - int b) -{ - if (a == b) { - return EQUAL; - } - - return a < b ? LESS_THAN : GREATER_THAN; -} - -static int compare_style (gconstpointer a, gconstpointer b) { @@ -852,10 +837,12 @@ compare_style (gconstpointer a, if (style_a->is_bold == style_b->is_bold) { /* Same slant */ if (style_a->slant == style_b->slant) { - return compare_int (style_a->stretch, style_b->stretch); + return nautilus_compare_integer (GINT_TO_POINTER (style_a->stretch), + GINT_TO_POINTER (style_b->stretch)); } - return compare_int (style_a->slant, style_b->slant); + return nautilus_compare_integer (GINT_TO_POINTER (style_a->slant), + GINT_TO_POINTER (style_b->slant)); } /* Different weight */ @@ -870,8 +857,7 @@ global_font_list_populate_callback (const char *font_file_name, const char *weight, const char *slant, const char *set_width, - const char *char_set_registry, - const char *char_set_encoding, + const char *char_set, gpointer callback_data) { GList **font_list; @@ -885,8 +871,7 @@ global_font_list_populate_callback (const char *font_file_name, g_return_val_if_fail (weight != NULL, FALSE); g_return_val_if_fail (slant != NULL, FALSE); g_return_val_if_fail (set_width != NULL, FALSE); - g_return_val_if_fail (char_set_registry != NULL, FALSE); - g_return_val_if_fail (char_set_encoding != NULL, FALSE); + g_return_val_if_fail (char_set != NULL, FALSE); g_return_val_if_fail (callback_data != NULL, FALSE); font_list = callback_data; @@ -908,8 +893,7 @@ global_font_list_populate_callback (const char *font_file_name, weight, slant, set_width, - char_set_registry, - char_set_encoding); + char_set); if (list_contains_style (entry->style_list, style_entry)) { font_style_entry_free (style_entry); @@ -1066,12 +1050,3 @@ nautilus_font_picker_set_selected_font (NautilusFontPicker *font_picker, gtk_option_menu_set_history (GTK_OPTION_MENU (font_picker->details->option_menu), font_item_index); } - -void -nautilus_font_picker_set_title_label (NautilusFontPicker *font_picker, - const char *title_label) -{ - g_return_if_fail (NAUTILUS_IS_FONT_PICKER (font_picker)); - - gtk_label_set_text (GTK_LABEL (font_picker->details->title_label), title_label); -} diff --git a/libnautilus-private/nautilus-font-picker.h b/libnautilus-private/nautilus-font-picker.h index cf4fe0d54..a396ca184 100644 --- a/libnautilus-private/nautilus-font-picker.h +++ b/libnautilus-private/nautilus-font-picker.h @@ -25,8 +25,8 @@ #ifndef NAUTILUS_FONT_PICKER_H #define NAUTILUS_FONT_PICKER_H -#include <gtk/gtkhbox.h> #include <libnautilus-extensions/nautilus-scalable-font.h> +#include <libnautilus-extensions/nautilus-caption.h> BEGIN_GNOME_DECLS @@ -42,7 +42,7 @@ typedef struct NautilusFontPickerDetails NautilusFontPickerDetails; struct NautilusFontPicker { /* Super Class */ - GtkHBox hbox; + NautilusCaption caption; /* Private stuff */ NautilusFontPickerDetails *details; @@ -50,7 +50,7 @@ struct NautilusFontPicker struct NautilusFontPickerClass { - GtkHBoxClass parent_class; + NautilusCaptionClass parent_class; }; GtkType nautilus_font_picker_get_type (void); @@ -58,8 +58,6 @@ GtkWidget* nautilus_font_picker_new (void); char * nautilus_font_picker_get_selected_font (const NautilusFontPicker *font_picker); void nautilus_font_picker_set_selected_font (NautilusFontPicker *font_picker, const char *font); -void nautilus_font_picker_set_title_label (NautilusFontPicker *font_picker, - const char *title_label); END_GNOME_DECLS #endif /* NAUTILUS_FONT_PICKER_H */ diff --git a/libnautilus-private/nautilus-glib-extensions.c b/libnautilus-private/nautilus-glib-extensions.c index 9fba9536f..c096668ac 100644 --- a/libnautilus-private/nautilus-glib-extensions.c +++ b/libnautilus-private/nautilus-glib-extensions.c @@ -1247,6 +1247,23 @@ nautilus_dumb_down_for_multi_byte_locale_hack (void) return is_multi_byte_locale; } +int +nautilus_compare_integer (gconstpointer a, + gconstpointer b) +{ + int int_a; + int int_b; + + int_a = GPOINTER_TO_INT (a); + int_b = GPOINTER_TO_INT (b); + + if (int_a == int_b) { + return 0; + } + + return int_a < int_b ? -1 : 1; +} + #if !defined (NAUTILUS_OMIT_SELF_CHECK) static void @@ -1437,6 +1454,14 @@ nautilus_self_check_glib_extensions (void) NAUTILUS_CHECK_STRING_RESULT (nautilus_shell_quote ("'a"), "''\\''a'"); NAUTILUS_CHECK_STRING_RESULT (nautilus_shell_quote ("a'"), "'a'\\'''"); NAUTILUS_CHECK_STRING_RESULT (nautilus_shell_quote ("a'a"), "'a'\\''a'"); + + /* nautilus_compare_integer */ + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_compare_integer (GINT_TO_POINTER (0), GINT_TO_POINTER (0)), 0); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_compare_integer (GINT_TO_POINTER (0), GINT_TO_POINTER (1)), -1); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_compare_integer (GINT_TO_POINTER (1), GINT_TO_POINTER (0)), 1); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_compare_integer (GINT_TO_POINTER (-1), GINT_TO_POINTER (0)), -1); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_compare_integer (GINT_TO_POINTER (0), GINT_TO_POINTER (-1)), 1); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_compare_integer (GINT_TO_POINTER (-1), GINT_TO_POINTER (-1)), 0); } #endif /* !NAUTILUS_OMIT_SELF_CHECK */ diff --git a/libnautilus-private/nautilus-glib-extensions.h b/libnautilus-private/nautilus-glib-extensions.h index 86707a6b4..d0752ba4d 100644 --- a/libnautilus-private/nautilus-glib-extensions.h +++ b/libnautilus-private/nautilus-glib-extensions.h @@ -52,108 +52,112 @@ typedef gboolean (* NautilusPredicateFunction) (gpointer data, gpointer callback_data); /* Date & time functions. */ -GDate * nautilus_g_date_new_tm (struct tm *time_pieces); -char * nautilus_strdup_strftime (const char *format, - struct tm *time_pieces); +GDate * nautilus_g_date_new_tm (struct tm *time_pieces); +char * nautilus_strdup_strftime (const char *format, + struct tm *time_pieces); /* environment manipulation functions */ -int nautilus_setenv (const char *name, - const char *value, - gboolean overwrite); -void nautilus_unsetenv (const char *name); +int nautilus_setenv (const char *name, + const char *value, + gboolean overwrite); +void nautilus_unsetenv (const char *name); /* GList functions. */ -gboolean nautilus_g_list_exactly_one_item (GList *list); -gboolean nautilus_g_list_more_than_one_item (GList *list); -gboolean nautilus_g_list_equal (GList *list_a, - GList *list_b); -GList * nautilus_g_list_copy (GList *list); -void nautilus_g_list_safe_for_each (GList *list, - GFunc function, - gpointer user_data); -GList * nautilus_g_list_sort_custom (GList *list, - NautilusCompareFunction compare, - gpointer user_data); -gboolean nautilus_g_lists_sort_and_check_for_intersection (GList **list_a, - GList **list_b); -GList * nautilus_g_list_partition (GList *list, - NautilusPredicateFunction predicate, - gpointer user_data, - GList **removed); +gboolean nautilus_g_list_exactly_one_item (GList *list); +gboolean nautilus_g_list_more_than_one_item (GList *list); +gboolean nautilus_g_list_equal (GList *list_a, + GList *list_b); +GList * nautilus_g_list_copy (GList *list); +void nautilus_g_list_safe_for_each (GList *list, + GFunc function, + gpointer user_data); +GList * nautilus_g_list_sort_custom (GList *list, + NautilusCompareFunction compare, + gpointer user_data); +gboolean nautilus_g_lists_sort_and_check_for_intersection (GList **list_a, + GList **list_b); +GList * nautilus_g_list_partition (GList *list, + NautilusPredicateFunction predicate, + gpointer user_data, + GList **removed); /* List functions for lists of g_free'able objects. */ -void nautilus_g_list_free_deep (GList *list); -void nautilus_g_list_free_deep_custom (GList *list, - GFunc element_free_func, - gpointer user_data); +void nautilus_g_list_free_deep (GList *list); +void nautilus_g_list_free_deep_custom (GList *list, + GFunc element_free_func, + gpointer user_data); /* GSList functions. */ -GList * nautilus_g_list_from_g_slist (GSList *list); -GSList * nautilus_g_slist_from_g_list (GList *list); +GList * nautilus_g_list_from_g_slist (GSList *list); +GSList * nautilus_g_slist_from_g_list (GList *list); /* List functions for slists of g_free'able objects. */ -void nautilus_g_slist_free_deep (GSList *list); -void nautilus_g_slist_free_deep_custom (GSList *list, - GFunc element_free_func, - gpointer user_data); +void nautilus_g_slist_free_deep (GSList *list); +void nautilus_g_slist_free_deep_custom (GSList *list, + GFunc element_free_func, + gpointer user_data); /* List functions for lists of C strings. */ -gboolean nautilus_g_str_list_equal (GList *str_list_a, - GList *str_list_b); -GList * nautilus_g_str_list_copy (GList *str_list); -GList * nautilus_g_str_list_alphabetize (GList *str_list); +gboolean nautilus_g_str_list_equal (GList *str_list_a, + GList *str_list_b); +GList * nautilus_g_str_list_copy (GList *str_list); +GList * nautilus_g_str_list_alphabetize (GList *str_list); /* GString functions */ -void nautilus_g_string_append_len (GString *string, - const char *characters, - int length); +void nautilus_g_string_append_len (GString *string, + const char *characters, + int length); /* GHashTable functions */ -GHashTable *nautilus_g_hash_table_new_free_at_exit (GHashFunc hash_function, - GCompareFunc key_compare_function, - const char *display_name); -void nautilus_g_hash_table_safe_for_each (GHashTable *hash_table, - GHFunc callback, - gpointer callback_data); -gboolean nautilus_g_hash_table_remove_deep_custom (GHashTable *hash_table, - gconstpointer key, - GFunc key_free_func, - gpointer key_free_data, - GFunc value_free_func, - gpointer value_free_data); -gboolean nautilus_g_hash_table_remove_deep (GHashTable *hash_table, - gconstpointer key); -void nautilus_g_hash_table_destroy_deep_custom (GHashTable *hash_table, - GFunc key_free_func, - gpointer key_free_data, - GFunc value_free_func, - gpointer value_free_data); -void nautilus_g_hash_table_destroy_deep (GHashTable *hash_table); +GHashTable *nautilus_g_hash_table_new_free_at_exit (GHashFunc hash_function, + GCompareFunc key_compare_function, + const char *display_name); +void nautilus_g_hash_table_safe_for_each (GHashTable *hash_table, + GHFunc callback, + gpointer callback_data); +gboolean nautilus_g_hash_table_remove_deep_custom (GHashTable *hash_table, + gconstpointer key, + GFunc key_free_func, + gpointer key_free_data, + GFunc value_free_func, + gpointer value_free_data); +gboolean nautilus_g_hash_table_remove_deep (GHashTable *hash_table, + gconstpointer key); +void nautilus_g_hash_table_destroy_deep_custom (GHashTable *hash_table, + GFunc key_free_func, + gpointer key_free_data, + GFunc value_free_func, + gpointer value_free_data); +void nautilus_g_hash_table_destroy_deep (GHashTable *hash_table); /* GPtrArray functions */ -GPtrArray * nautilus_g_ptr_array_new_from_list (GList *list); -void nautilus_g_ptr_array_sort (GPtrArray *array, - NautilusCompareFunction compare_callback, - gpointer callback_data); -int nautilus_g_ptr_array_search (GPtrArray *array, - NautilusSearchFunction search_callback, - gpointer callback_data, - gboolean match_only); +GPtrArray * nautilus_g_ptr_array_new_from_list (GList *list); +void nautilus_g_ptr_array_sort (GPtrArray *array, + NautilusCompareFunction compare_callback, + gpointer callback_data); +int nautilus_g_ptr_array_search (GPtrArray *array, + NautilusSearchFunction search_callback, + gpointer callback_data, + gboolean match_only); /* NULL terminated string arrays (strv). */ -int nautilus_g_strv_find (char **strv, - const char *find_me); +int nautilus_g_strv_find (char **strv, + const char *find_me); /* return the time in microseconds since the machine was started */ -gint64 nautilus_get_system_time (void); +gint64 nautilus_get_system_time (void); /* shell */ -char * nautilus_shell_quote (const char *string); +char * nautilus_shell_quote (const char *string); /* math */ -int nautilus_round (double d); +int nautilus_round (double d); /* Locale */ -gboolean nautilus_dumb_down_for_multi_byte_locale_hack (void); +gboolean nautilus_dumb_down_for_multi_byte_locale_hack (void); + +/* A GCompareFunc for integers */ +int nautilus_compare_integer (gconstpointer a, + gconstpointer b); #endif /* NAUTILUS_GLIB_EXTENSIONS_H */ diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c index 918fadd4f..55aa8d614 100644 --- a/libnautilus-private/nautilus-global-preferences.c +++ b/libnautilus-private/nautilus-global-preferences.c @@ -55,186 +55,273 @@ 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"; -/* Forward declarations */ -static char * global_preferences_get_sidebar_panel_key (const char *panel_iid); -static gboolean global_preferences_is_sidebar_panel_enabled_cover (gpointer data, - gpointer callback_data); -static GList * global_preferences_get_sidebar_panel_view_identifiers (void); -static gboolean global_preferences_close_dialog_callback (GtkWidget *dialog, - gpointer user_data); -static void global_preferences_install_sidebar_panel_defaults (void); -static void global_preferences_install_sidebar_panel_descriptions (void); -static void global_preferences_install_defaults (void); -static void global_preferences_install_visibility (void); -static void global_preferences_install_speed_tradeoff_descriptions (const char *name, - const char *description); -static void global_preferences_install_home_location_defaults (void); -static void global_preferences_install_medusa_defaults (void); -static void global_preferences_install_font_defaults (void); -static void global_preferences_install_descriptions (void); -static int compare_view_identifiers (gconstpointer a, - gconstpointer b); -static GtkWidget *global_preferences_create_dialog (void); -static GtkWidget *global_preferences_create_search_pane (NautilusPreferencesBox *preference_box); -static GtkWidget *global_preferences_create_font_group (NautilusPreferencesPane *appearance_pane); - -static GtkWidget *global_prefs_dialog = NULL; - -/** - * global_preferences_install_descriptions - * - * Install descriptions for some preferences. A preference needs a description - * only if it appears in the preferences dialog. - */ -static void -global_preferences_install_descriptions (void) +typedef struct { - static gboolean preferences_registered = FALSE; - g_return_if_fail (preferences_registered == FALSE); - preferences_registered = TRUE; - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_THEME, - _("current theme")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, - _("Open each file or folder in a separate window")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_CONFIRM_TRASH, - _("Ask before emptying the Trash or deleting files")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_ENABLE_DELETE, - _("Include a Delete command that bypasses Trash")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_CLICK_POLICY, - _("Click Behavior")); - - nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_CLICK_POLICY, - _("single"), - _("Activate items with a single click"), - NAUTILUS_CLICK_POLICY_SINGLE); - - nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_CLICK_POLICY, - _("double"), - _("Activate items with a double click"), - NAUTILUS_CLICK_POLICY_DOUBLE); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, - _("Executable Text Files")); - - nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, - _("launch"), - _("Execute files when they are clicked"), - NAUTILUS_EXECUTABLE_TEXT_LAUNCH); - - nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, - _("display"), - _("Display files when they are clicked"), - NAUTILUS_EXECUTABLE_TEXT_DISPLAY); - - nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, - _("ask"), - _("Ask each time"), - NAUTILUS_EXECUTABLE_TEXT_ASK); - - /* Note that I've changed all these descriptions to match the displayed text. - * The original intention was to use them differently, but currently they aren't - * used at all. By matching the displayed text, at least localizers won't have to - * localize two different strings. If we ever make them appear separately, we will - * have to reword them (as we would have had to anyway). - */ - global_preferences_install_speed_tradeoff_descriptions (NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS, - _("Show Text in Icons")); - - global_preferences_install_speed_tradeoff_descriptions (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, - _("Show Count of Items in Folders")); - - global_preferences_install_speed_tradeoff_descriptions (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, - _("Show Thumbnails for Image Files")); - - global_preferences_install_speed_tradeoff_descriptions (NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA, - _("Make Folder Appearance Details Public")); - - global_preferences_install_speed_tradeoff_descriptions (NAUTILUS_PREFERENCES_PREVIEW_SOUND, - _("Preview Sound Files")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - _("Use smoother (but slower) graphics")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY, - _("Use this font to display non-smooth text:")); + const char *stored_value; + const char *display_value; + int value; +} EnumerationEntry; - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT, - _("Use this font to display smooth text:")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, - _("Display toolbar in new windows")); +typedef struct +{ + const char *group_name; + const char *preference_name; + const char *preference_description; + NautilusPreferencesItemType item_type; + const char *control_preference_name; + NautilusPreferencesItemControlAction control_action; + const EnumerationEntry *enumeration_values; + int constrained_integer_lower; + int constrained_integer_upper; + int constrained_integer_increment; +} ItemDescription; + +typedef enum +{ + PREFERENCE_BOOLEAN = 1, + PREFERENCE_INTEGER, + PREFERENCE_STRING +} PreferenceType; - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, - _("Display location bar in new windows")); +typedef struct +{ + int user_level; + const gpointer value; +} PreferenceUserLevelDefault; - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, - _("Display status bar in new windows")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, - _("Display sidebar in new windows")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_SHOW_DESKTOP, - _("Use Nautilus to draw the desktop")); - - /* search tradeoffs */ - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_USE_FAST_SEARCH, - _("Enable fast search (indexes your hard drive)")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - _("search type to do by default")); - - nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - _("search by text"), - _("Search for files by file name only"), - NAUTILUS_SIMPLE_SEARCH_BAR); - - nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - _("search by text and properties"), - _("Search for files by file name and file properties"), - NAUTILUS_COMPLEX_SEARCH_BAR); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, - _("Search Engine Location")); +#define USER_LEVEL_NONE -1 - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, - _("Show hidden files (file names start with \".\")")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, - _("Show backup files (file names end with \"~\")")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS, - _("Show special flags in Properties window")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, - _("Always list folders before files")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES, - _("Show only folders (no files) in the tree")); +typedef struct +{ + const char *name; + PreferenceType type; + int visible_user_level; + PreferenceUserLevelDefault default1; + PreferenceUserLevelDefault default2; +} PreferenceDefault; - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_CAN_ADD_CONTENT, - _("Can add Content")); +/* Forward declarations */ +static char * global_preferences_make_sidebar_panel_key (const char *panel_iid); +static gboolean global_preferences_is_sidebar_panel_enabled_cover (gpointer data, + gpointer callback_data); +static GList * global_preferences_get_sidebar_panel_view_identifiers (void); +static gboolean global_preferences_close_dialog_callback (GtkWidget *dialog, + gpointer user_data); +static void global_preferences_install_sidebar_panel_defaults (void); +static void global_preferences_install_defaults (void); +static void global_preferences_install_home_location_defaults (void); +static void global_preferences_install_medusa_defaults (void); +static void global_preferences_install_font_defaults (void); +static int compare_view_identifiers (gconstpointer a, + gconstpointer b); +static GtkWidget *global_preferences_create_dialog (void); +static void global_preferences_create_search_pane (NautilusPreferencesBox *preference_box); +static void global_preferences_create_sidebar_panels_pane (NautilusPreferencesBox *preference_box); +static void global_preferences_pane_update_callback (gpointer callback_data); +static GtkWidget *global_preferences_populate_pane (NautilusPreferencesBox *preference_box, + const char *pane_name, + const ItemDescription *item_descriptions); - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS, - _("Don't include the built-in bookmarks in the Bookmarks menu")); - - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS, - _("Use Emacs-style keyboard shortcuts in text fields")); +static GtkWidget *global_prefs_dialog = NULL; - nautilus_preferences_set_description (NAUTILUS_PREFERENCES_HOME_URI, - _("Location:")); +static const PreferenceDefault preference_defaults[] = { + { NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_CONFIRM_TRASH, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_ADVANCED, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_ENABLE_DELETE, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_ADVANCED, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, + { USER_LEVEL_NONE } + }, + /* Don't show remote directory item counts for Beginner users because computing them + * can be annoyingly slow, especially for FTP. If we make this fast enough for FTP in + * particular, we should change this default to ALWAYS. + */ + { NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, + { NAUTILUS_USER_LEVEL_INTERMEDIATE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_ALWAYS) } + }, + { NAUTILUS_PREFERENCES_CLICK_POLICY, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_ADVANCED, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_EXECUTABLE_TEXT_ASK) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_THEME, + PREFERENCE_STRING, + NAUTILUS_USER_LEVEL_NOVICE, + { NAUTILUS_USER_LEVEL_NOVICE, "default" }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_ADVANCED, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, + /* { NAUTILUS_USER_LEVEL_NOVICE, !nautilus_dumb_down_for_multi_byte_locale_hack () }, */ + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_PREVIEW_SOUND, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_ADVANCED, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { NAUTILUS_USER_LEVEL_ADVANCED, GINT_TO_POINTER (TRUE) }, + }, + { NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_SHOW_DESKTOP, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_CAN_ADD_CONTENT, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_NOVICE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { NAUTILUS_USER_LEVEL_INTERMEDIATE, GINT_TO_POINTER (TRUE) }, + }, + { NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (NAUTILUS_SIMPLE_SEARCH_BAR) }, + { NAUTILUS_USER_LEVEL_INTERMEDIATE, GINT_TO_POINTER (NAUTILUS_COMPLEX_SEARCH_BAR) }, + }, + { NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_NOVICE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_ICON_CAPTIONS, + PREFERENCE_STRING, + NAUTILUS_USER_LEVEL_NOVICE, + { NAUTILUS_USER_LEVEL_NOVICE, "size|date_modified|type" }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_ADVANCED, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { USER_LEVEL_NONE } + }, + /* FIXME bugzilla.eazel.com 1245: Saved in pixels instead of in %? */ + { NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_NOVICE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (148) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_SEARCH_WEB_URI, + PREFERENCE_STRING, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, "http://www.eazel.com/websearch" }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (TRUE) }, + { USER_LEVEL_NONE } + }, + { NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { USER_LEVEL_NONE } + }, - global_preferences_install_sidebar_panel_descriptions (); - - nautilus_preferences_set_description (USE_PROXY_KEY, _("Use HTTP Proxy")); - nautilus_preferences_set_description (PROXY_HOST_KEY, _("Location:")); - nautilus_preferences_set_description (PROXY_PORT_KEY, _("Port:")); -} + /* Proxy defaults */ + { USE_PROXY_KEY, + PREFERENCE_BOOLEAN, + NAUTILUS_USER_LEVEL_NOVICE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (FALSE) }, + { USER_LEVEL_NONE } + }, + { PROXY_PORT_KEY, + PREFERENCE_INTEGER, + NAUTILUS_USER_LEVEL_NOVICE, + { NAUTILUS_USER_LEVEL_NOVICE, GINT_TO_POINTER (8080) }, + { USER_LEVEL_NONE } + }, + + { NULL } +}; /** * global_preferences_install_defaults @@ -251,148 +338,66 @@ global_preferences_install_descriptions (void) static void global_preferences_install_defaults (void) { - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH, - NAUTILUS_USER_LEVEL_NOVICE, - TRUE); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_ENABLE_DELETE, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS, - NAUTILUS_USER_LEVEL_NOVICE, - NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY); - - /* Don't show remote directory item counts for Beginner users because computing them - * can be annoyingly slow, especially for FTP. If we make this fast enough for FTP in - * particular, we should change this default to ALWAYS. - */ - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, - NAUTILUS_USER_LEVEL_NOVICE, - NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY); - - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, - NAUTILUS_USER_LEVEL_INTERMEDIATE, - NAUTILUS_SPEED_TRADEOFF_ALWAYS); - - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_CLICK_POLICY, - NAUTILUS_USER_LEVEL_NOVICE, - NAUTILUS_CLICK_POLICY_DOUBLE); - - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, - NAUTILUS_USER_LEVEL_NOVICE, - NAUTILUS_EXECUTABLE_TEXT_ASK); - - nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_THEME, - NAUTILUS_USER_LEVEL_NOVICE, - "default"); - - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, - NAUTILUS_USER_LEVEL_NOVICE, - NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY); - - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA, - NAUTILUS_USER_LEVEL_NOVICE, - NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - NAUTILUS_USER_LEVEL_NOVICE, - !nautilus_dumb_down_for_multi_byte_locale_hack ()); - - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_PREVIEW_SOUND, - NAUTILUS_USER_LEVEL_NOVICE, - NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS, - NAUTILUS_USER_LEVEL_ADVANCED, - TRUE); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_SHOW_DESKTOP, - NAUTILUS_USER_LEVEL_NOVICE, - TRUE); - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_CAN_ADD_CONTENT, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_CAN_ADD_CONTENT, - NAUTILUS_USER_LEVEL_INTERMEDIATE, - TRUE); - - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - NAUTILUS_USER_LEVEL_NOVICE, - NAUTILUS_SIMPLE_SEARCH_BAR); - - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - NAUTILUS_USER_LEVEL_INTERMEDIATE, - NAUTILUS_COMPLEX_SEARCH_BAR); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - - nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_ICON_CAPTIONS, - NAUTILUS_USER_LEVEL_NOVICE, - "size|date_modified|type"); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - - /* FIXME bugzilla.eazel.com 1245: Saved in pixels instead of in %? */ - nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, - NAUTILUS_USER_LEVEL_NOVICE, - 148); - - nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, - NAUTILUS_USER_LEVEL_NOVICE, - "http://www.eazel.com/websearch"); + guint i; - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, - NAUTILUS_USER_LEVEL_NOVICE, - TRUE); - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, - NAUTILUS_USER_LEVEL_NOVICE, - TRUE); - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, - NAUTILUS_USER_LEVEL_NOVICE, - TRUE); - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, - NAUTILUS_USER_LEVEL_NOVICE, - TRUE); + for (i = 0; preference_defaults[i].name != NULL; i++) { + switch (preference_defaults[i].type) { + case PREFERENCE_BOOLEAN: + if (preference_defaults[i].default1.user_level != USER_LEVEL_NONE) { + nautilus_preferences_default_set_boolean ( + preference_defaults[i].name, + preference_defaults[i].default1.user_level, + GPOINTER_TO_INT (preference_defaults[i].default1.value)); + } + if (preference_defaults[i].default2.user_level != USER_LEVEL_NONE) { + nautilus_preferences_default_set_boolean ( + preference_defaults[i].name, + preference_defaults[i].default2.user_level, + GPOINTER_TO_INT (preference_defaults[i].default2.value)); + } + break; + + case PREFERENCE_INTEGER: + if (preference_defaults[i].default1.user_level != USER_LEVEL_NONE) { + nautilus_preferences_default_set_integer ( + preference_defaults[i].name, + preference_defaults[i].default1.user_level, + GPOINTER_TO_INT (preference_defaults[i].default1.value)); + } + if (preference_defaults[i].default2.user_level != USER_LEVEL_NONE) { + nautilus_preferences_default_set_integer ( + preference_defaults[i].name, + preference_defaults[i].default2.user_level, + GPOINTER_TO_INT (preference_defaults[i].default2.value)); + } + break; + + case PREFERENCE_STRING: + if (preference_defaults[i].default1.user_level != USER_LEVEL_NONE) { + nautilus_preferences_default_set_string ( + preference_defaults[i].name, + preference_defaults[i].default1.user_level, + preference_defaults[i].default1.value); + } + if (preference_defaults[i].default2.user_level != USER_LEVEL_NONE) { + nautilus_preferences_default_set_string ( + preference_defaults[i].name, + preference_defaults[i].default2.user_level, + preference_defaults[i].default2.value); + } + break; + + default: + g_assert_not_reached (); + } - nautilus_preferences_default_set_boolean (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); + nautilus_preferences_set_visible_user_level (preference_defaults[i].name, + preference_defaults[i].visible_user_level); + } /* Add the gnome-vfs path to the list of monitored directories - for proxy settings */ nautilus_preferences_monitor_directory (SYSTEM_GNOME_VFS_PATH); - /* Proxy defaults */ - nautilus_preferences_default_set_boolean (USE_PROXY_KEY, - NAUTILUS_USER_LEVEL_NOVICE, - FALSE); - nautilus_preferences_default_set_integer (PROXY_PORT_KEY, - NAUTILUS_USER_LEVEL_NOVICE, - 8080); - /* Sidebar panel defaults */ global_preferences_install_sidebar_panel_defaults (); @@ -421,90 +426,10 @@ global_preferences_install_defaults (void) * user level. * */ -static void -global_preferences_install_visibility (void) -{ - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_HOME_URI, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_CLICK_POLICY, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_CONFIRM_TRASH, - NAUTILUS_USER_LEVEL_ADVANCED); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_ENABLE_DELETE, - NAUTILUS_USER_LEVEL_ADVANCED); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS, - NAUTILUS_USER_LEVEL_ADVANCED); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, - NAUTILUS_USER_LEVEL_ADVANCED); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SHOW_DESKTOP, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_PREVIEW_SOUND, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA, - NAUTILUS_USER_LEVEL_ADVANCED); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_USE_FAST_SEARCH, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SEARCH_WEB_URI, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_HOME_URI, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS, - NAUTILUS_USER_LEVEL_INTERMEDIATE); - - nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS, - NAUTILUS_USER_LEVEL_ADVANCED); -} +// static void +// global_preferences_install_visibility (void) +// { +// } /* * Private stuff @@ -524,17 +449,336 @@ compare_view_identifiers (gconstpointer a, gconstpointer b) return nautilus_strcmp (idenfifier_a->name, idenfifier_b->name); } +static EnumerationEntry speed_tradeoff_enumeration[] = { + { N_("always"), + N_("Always"), + NAUTILUS_SPEED_TRADEOFF_ALWAYS, + }, + { N_("local only"), + N_("Local Files Only"), + NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY, + }, + { N_("never"), + N_("Never"), + NAUTILUS_SPEED_TRADEOFF_NEVER, + }, + { NULL, NULL, 0 } +}; + +static ItemDescription appearance_items[] = { + { N_("Smoother Graphics"), + NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + N_("Use smoother (but slower) graphics"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Fonts"), + NAUTILUS_PREFERENCES_DEFAULT_FONT, + N_("Use this font to display non-smooth text:"), + NAUTILUS_PREFERENCE_ITEM_FONT, + NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + NAUTILUS_PREFERENCE_ITEM_HIDE + }, + { N_("Fonts"), + NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT, + N_("Use this font to display smooth text:"), + NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT, + NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + NAUTILUS_PREFERENCE_ITEM_SHOW + }, +#if 0 + { N_("Fonts"), + NAUTILUS_PREFERENCES_DEFAULT_FONT_SIZE, + N_("Use this font size for default text:"), + NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER, + NULL, + 0, + NULL, + 8, 24, 2 + }, +#endif + { NULL, NULL, NULL, 0, NULL, 0 } +}; + +static ItemDescription windows_and_desktop_items[] = { + { N_("Desktop"), + NAUTILUS_PREFERENCES_SHOW_DESKTOP, + N_("Use Nautilus to draw the desktop"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Opening New Windows"), + NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, + N_("Open each file or folder in a separate window"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Opening New Windows"), + NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, + N_("Display toolbar in new windows"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Opening New Windows"), + NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, + N_("Display location bar in new windows"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Opening New Windows"), + NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, + N_("Display status bar in new windows"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Opening New Windows"), + NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, + N_("Display sidebar in new windows"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Trash Behavior"), + NAUTILUS_PREFERENCES_CONFIRM_TRASH, + N_("Ask before emptying the Trash or deleting files"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Trash Behavior"), + NAUTILUS_PREFERENCES_ENABLE_DELETE, + N_("Include a Delete command that bypasses Trash"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + /* FIXME: This group clearly doesn't belong in Windows & + * Desktop, but there's no obviously-better place for it and + * it probably doesn't deserve a pane of its own. + */ + { N_("Keyboard Shortcuts"), + NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS, + N_("Use Emacs-style keyboard shortcuts in text fields"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { NULL, NULL, NULL, 0, NULL, 0 } +}; + +static EnumerationEntry click_policy_enumeration[] = { + { N_("single"), + N_("Activate items with a single click"), + NAUTILUS_CLICK_POLICY_SINGLE, + }, + { N_("double"), + N_("Activate items with a double click"), + NAUTILUS_CLICK_POLICY_DOUBLE, + }, + { NULL, NULL, 0 } +}; + +static EnumerationEntry executable_text_activation_enumeration[] = { + { N_("launch"), + N_("Execute files when they are clicked"), + NAUTILUS_EXECUTABLE_TEXT_LAUNCH, + }, + { N_("display"), + N_("Display files when they are clicked"), + NAUTILUS_EXECUTABLE_TEXT_DISPLAY, + }, + { N_("ask"), + N_("Ask each time"), + NAUTILUS_EXECUTABLE_TEXT_ASK, + }, + { NULL, NULL, 0 } +}; + +static ItemDescription directory_views_items[] = { + { N_("Fonts"), + NAUTILUS_PREFERENCES_ICON_VIEW_FONT, + N_("Use this font to display non-smooth icon file names"), + NAUTILUS_PREFERENCE_ITEM_FONT, + NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + NAUTILUS_PREFERENCE_ITEM_HIDE + }, + { N_("Fonts"), + NAUTILUS_PREFERENCES_ICON_VIEW_SMOOTH_FONT, + N_("Use this font to display smooth icon file names"), + NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT, + NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + NAUTILUS_PREFERENCE_ITEM_SHOW + }, + { N_("Fonts"), + NAUTILUS_PREFERENCES_ICON_VIEW_STANDARD_FONT_SIZE, + N_("Use this font size for 100% icon zoom"), + NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER, + NULL, + 0, + NULL, + 8, 24, 2 + }, + { N_("Fonts"), + NAUTILUS_PREFERENCES_LIST_VIEW_FONT, + N_("Use this font to display list file names"), + NAUTILUS_PREFERENCE_ITEM_FONT, + NULL, + 0 + }, + { N_("Fonts"), + NAUTILUS_PREFERENCES_LIST_VIEW_STANDARD_FONT_SIZE, + N_("Use this font size for 100% list zoom"), + NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER, + NULL, + 0, + NULL, + 8, 24, 2 + }, + { N_("Click Behavior"), + NAUTILUS_PREFERENCES_CLICK_POLICY, + N_("Click Behavior"), + NAUTILUS_PREFERENCE_ITEM_ENUM, + NULL, + 0, + click_policy_enumeration + }, + { N_("Executable Text Files"), + NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, + N_("Executable Text Files"), + NAUTILUS_PREFERENCE_ITEM_ENUM, + NULL, + 0, + executable_text_activation_enumeration + }, + { N_("Show/Hide Options"), + NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, + N_("Show hidden files (file names start with \".\")"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Show/Hide Options"), + NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, + N_("Show backup files (file names end with \"~\")"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Show/Hide Options"), + NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS, + N_("Show special flags in Properties window"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Sorting Order"), + NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, + N_("Always list folders before files"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { NULL, NULL, NULL, 0, NULL, 0 } +}; + +static ItemDescription navigation_items[] = { + { N_("Home"), + NAUTILUS_PREFERENCES_HOME_URI, + N_("Location:"), + NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING, + NULL, + 0 + }, + { N_("HTTP Proxy Settings"), + USE_PROXY_KEY, + N_("Use HTTP Proxy"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("HTTP Proxy Settings"), + PROXY_HOST_KEY, + N_("Location:"), + NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING, + NULL, + 0 + }, + { N_("HTTP Proxy Settings"), + PROXY_PORT_KEY, + N_("Port:"), + NAUTILUS_PREFERENCE_ITEM_EDITABLE_INTEGER, + NULL, + 0 + }, + { N_("Built-in Bookmarks"), + NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS, + N_("Don't include the built-in bookmarks in the Bookmarks menu"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { NULL, NULL, NULL, 0, NULL, 0 } +}; + +static ItemDescription tradeoffs_items[] = { + { N_("Show Text in Icons"), + NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS, + N_(""), + NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM, + NULL, + 0, + speed_tradeoff_enumeration + }, + { N_("Show Count of Items in Folders"), + NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, + N_(""), + NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM, + NULL, + 0, + speed_tradeoff_enumeration + }, + { N_("Show Thumbnails for Image Files"), + NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, + N_(""), + NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM, + NULL, + 0, + speed_tradeoff_enumeration + }, + { N_("Preview Sound Files"), + NAUTILUS_PREFERENCES_PREVIEW_SOUND, + N_(""), + NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM, + NULL, + 0, + speed_tradeoff_enumeration + }, + + /* FIXME bugzilla.eazel.com 2560: This title phrase needs improvement. */ + { N_("Make Folder Appearance Details Public"), + NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA, + N_(""), + NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM, + NULL, + 0, + speed_tradeoff_enumeration + }, + { NULL, NULL, NULL, 0, NULL, 0 } +}; + static GtkWidget * global_preferences_create_dialog (void) { - GtkWidget *prefs_dialog; - NautilusPreferencesBox *preference_box; - GtkWidget *directory_views_pane; - GtkWidget *windows_and_desktop_pane; - GtkWidget *sidebar_panels_pane; - GtkWidget *appearance_pane; - GtkWidget *tradeoffs_pane; - GtkWidget *navigation_pane; + GtkWidget *prefs_dialog; + NautilusPreferencesBox *preference_box; + GtkWidget *directory_views_pane; + GtkWidget *appearance_pane; /* * In the soon to come star trek future, the following widgetry @@ -555,277 +799,47 @@ global_preferences_create_dialog (void) (NAUTILUS_PREFERENCES_DIALOG (prefs_dialog))); - /* - * Appearance - */ - appearance_pane = nautilus_preferences_box_add_pane (preference_box, - _("Appearance")); + /* Appearance */ + appearance_pane = global_preferences_populate_pane (preference_box, + _("Appearance"), + appearance_items); - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), - _("Smoother Graphics")); + nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + global_preferences_pane_update_callback, + appearance_pane, + GTK_OBJECT (prefs_dialog)); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), - 0, - NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - /* - * Fonts - */ - global_preferences_create_font_group (NAUTILUS_PREFERENCES_PANE (appearance_pane)); - - - /* - * Windows & Desktop pane - */ - windows_and_desktop_pane = nautilus_preferences_box_add_pane (preference_box, - _("Windows & Desktop")); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - _("Desktop")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - 0, - NAUTILUS_PREFERENCES_SHOW_DESKTOP, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - _("Opening New Windows")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - 1, - NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - 1, - NAUTILUS_PREFERENCES_START_WITH_TOOLBAR, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - 1, - NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - 1, - NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - 1, - NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - _("Trash Behavior")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - 2, - NAUTILUS_PREFERENCES_CONFIRM_TRASH, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - 2, - NAUTILUS_PREFERENCES_ENABLE_DELETE, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - /* FIXME: This group clearly doesn't belong in Windows & - * Desktop, but there's no obviously-better place for it and - * it probably doesn't deserve a pane of its own. - */ - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - _("Keyboard Shortcuts")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (windows_and_desktop_pane), - 3, - NAUTILUS_PREFERENCES_USE_EMACS_SHORTCUTS, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - /* - * Folder Views pane - */ - directory_views_pane = nautilus_preferences_box_add_pane (preference_box, - _("Icon & List Views")); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - _("Click Behavior")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - 0, - NAUTILUS_PREFERENCES_CLICK_POLICY, - NAUTILUS_PREFERENCE_ITEM_ENUM); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - _("Executable Text Files")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - 1, - NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, - NAUTILUS_PREFERENCE_ITEM_ENUM); + /* Windows & Desktop */ + global_preferences_populate_pane (preference_box, + _("Windows & Desktop"), + windows_and_desktop_items); - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - _("Show/Hide Options")); + /* Folder Views */ + directory_views_pane = global_preferences_populate_pane (preference_box, + _("Icon & List Views"), + directory_views_items); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - 2, - NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - 2, - NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - 2, - NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - _("Sorting Order")); + nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, + global_preferences_pane_update_callback, + directory_views_pane, + GTK_OBJECT (prefs_dialog)); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), - 3, - NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); + /* Sidebar Panels */ + global_preferences_create_sidebar_panels_pane (preference_box); - /* - * Sidebar panels pane - */ - sidebar_panels_pane = nautilus_preferences_box_add_pane (preference_box, - _("Sidebar Panels")); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (sidebar_panels_pane), - _("Tabs")); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (sidebar_panels_pane), - _("Tree")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (sidebar_panels_pane), - 1, - NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - { - char *preference_key; - GList *view_identifiers; - GList *p; - NautilusViewIdentifier *identifier; - - view_identifiers = global_preferences_get_sidebar_panel_view_identifiers (); - - view_identifiers = g_list_sort (view_identifiers, compare_view_identifiers); - - for (p = view_identifiers; p != NULL; p = p->next) { - identifier = (NautilusViewIdentifier *) (p->data); - - preference_key = global_preferences_get_sidebar_panel_key (identifier->iid); - - g_assert (preference_key != NULL); - - nautilus_preferences_pane_add_item_to_nth_group - (NAUTILUS_PREFERENCES_PANE (sidebar_panels_pane), - 0, - preference_key, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - g_free (preference_key); - - } - - nautilus_view_identifier_list_free (view_identifiers); - } - - /* - * Search Settings - */ + /* Search */ global_preferences_create_search_pane (preference_box); - /* - * Navigation - */ - navigation_pane = nautilus_preferences_box_add_pane (preference_box, - _("Navigation")); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), - _("Home")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), - 0, - NAUTILUS_PREFERENCES_HOME_URI, - NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), - _("HTTP Proxy Settings")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), - 1, - USE_PROXY_KEY, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), - 1, - PROXY_HOST_KEY, - NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), - 1, - PROXY_PORT_KEY, - NAUTILUS_PREFERENCE_ITEM_INTEGER); - - /* built-in bookmarks */ - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), - _("Built-in Bookmarks")); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (navigation_pane), - 2, - NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - - /* - * Tradeoffs - */ - tradeoffs_pane = nautilus_preferences_box_add_pane (preference_box, - _("Speed Tradeoffs")); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - _("Show Text in Icons")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - 0, - NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS, - NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - _("Show Count of Items in Folders")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - 1, - NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, - NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - _("Show Thumbnails for Image Files")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - 2, - NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, - NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM); - - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - _("Preview Sound Files")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - 3, - NAUTILUS_PREFERENCES_PREVIEW_SOUND, - NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM); - - /* FIXME bugzilla.eazel.com 2560: This title phrase needs improvement. */ - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - _("Make Folder Appearance Details Public")); - - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (tradeoffs_pane), - 4, - NAUTILUS_PREFERENCES_USE_PUBLIC_METADATA, - NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM); + /* Navigation */ + global_preferences_populate_pane (preference_box, + _("Navigation"), + navigation_items); + /* Tradeoffs */ + global_preferences_populate_pane (preference_box, + _("Speed Tradeoffs"), + tradeoffs_items); /* Update the dialog so that the right items show up based on the current user level */ nautilus_preferences_dialog_update (NAUTILUS_PREFERENCES_DIALOG (prefs_dialog)); @@ -846,101 +860,144 @@ global_preferences_medusa_blocked_changed_callback (gpointer callback_data) gtk_widget_set_sensitive (GTK_WIDGET (callback_data), !medusa_blocked); } -static GtkWidget * +static EnumerationEntry search_bar_type_enumeration[] = { + { N_("search by text"), + N_("Search for files by file name only"), + NAUTILUS_SIMPLE_SEARCH_BAR, + }, + { N_("search by text and properties"), + N_("Search for files by file name and file properties"), + NAUTILUS_COMPLEX_SEARCH_BAR, + }, + { NULL, NULL, 0 } +}; + +static ItemDescription search_items[] = { + { N_("Search Complexity Options"), + NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, + N_("search type to do by default"), + NAUTILUS_PREFERENCE_ITEM_ENUM, + NULL, + 0, + search_bar_type_enumeration + }, + { N_("Fast Search"), + NAUTILUS_PREFERENCES_USE_FAST_SEARCH, + N_("Enable fast search (indexes your hard drive)"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { N_("Search Engines"), + NAUTILUS_PREFERENCES_SEARCH_WEB_URI, + N_("Search Engine Location"), + NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING, + NULL, + 0 + }, + { NULL, NULL, NULL, 0, NULL, 0 } +}; + +static void global_preferences_create_search_pane (NautilusPreferencesBox *preference_box) { - GtkWidget *search_pane; GtkWidget *fast_search_group; - - g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_BOX (preference_box), NULL); + GtkWidget *search_pane; - /* - * Search Settings - */ - search_pane = nautilus_preferences_box_add_pane (preference_box, - _("Search")); - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (search_pane), - _("Search Complexity Options")); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (search_pane), - 0, - NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE, - NAUTILUS_PREFERENCE_ITEM_ENUM); - fast_search_group = nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (search_pane), - _("Fast Search")); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (search_pane), - 1, - NAUTILUS_PREFERENCES_USE_FAST_SEARCH, - NAUTILUS_PREFERENCE_ITEM_BOOLEAN); - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (search_pane), - _("Search Engines")); - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (search_pane), - 2, - NAUTILUS_PREFERENCES_SEARCH_WEB_URI, - NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING); + g_return_if_fail (NAUTILUS_IS_PREFERENCES_BOX (preference_box)); + + search_pane = global_preferences_populate_pane (preference_box, + _("Search"), + search_items); /* Setup callbacks so that we can update the sensitivity of * the search pane when the medusa blocked state changes */ + fast_search_group = nautilus_preferences_pane_find_group (NAUTILUS_PREFERENCES_PANE (search_pane), + _("Fast Search")); + + g_assert (NAUTILUS_IS_PREFERENCES_GROUP (fast_search_group)); + nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_MEDUSA_BLOCKED, global_preferences_medusa_blocked_changed_callback, fast_search_group, GTK_OBJECT (fast_search_group)); global_preferences_medusa_blocked_changed_callback (fast_search_group); +} + +static ItemDescription sidebar_items[] = { + { N_("Tree"), + NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES, + N_("Show only folders (no files) in the tree"), + NAUTILUS_PREFERENCE_ITEM_BOOLEAN, + NULL, + 0 + }, + { NULL, NULL, NULL, 0, NULL, 0 } +}; + +static void +global_preferences_create_sidebar_panels_pane (NautilusPreferencesBox *preference_box) +{ + char *preference_key; + GList *view_identifiers; + GList *p; + NautilusViewIdentifier *identifier; + char *description; + + GtkWidget *sidebar_pane; + + g_return_if_fail (NAUTILUS_IS_PREFERENCES_BOX (preference_box)); + + /* Sidebar Panels - dynamic part */ + sidebar_pane = nautilus_preferences_box_add_pane (preference_box, _("Sidebar Panels")); + + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (sidebar_pane), _("Tabs")); + + view_identifiers = global_preferences_get_sidebar_panel_view_identifiers (); + + view_identifiers = g_list_sort (view_identifiers, compare_view_identifiers); + + for (p = view_identifiers; p != NULL; p = p->next) { + identifier = (NautilusViewIdentifier *) (p->data); + + preference_key = global_preferences_make_sidebar_panel_key (identifier->iid); + + g_assert (preference_key != NULL); + + description = g_strdup_printf (_("Display %s tab in sidebar"), identifier->name); + nautilus_preferences_set_description (preference_key, description); + g_free (description); + + nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (sidebar_pane), + 0, + preference_key, + NAUTILUS_PREFERENCE_ITEM_BOOLEAN); + + g_free (preference_key); + + } + nautilus_view_identifier_list_free (view_identifiers); + - return search_pane; + /* Sidebar Panels - non dynamic parts */ + global_preferences_populate_pane (preference_box, + _("Sidebar Panels"), + sidebar_items); } -/* - * We have 2 font picker items, but we only show one depending on - * the value of the SMOOTH_GRAPHICS preference. +/* Update a pane as a result of a preference change. + * For example, we have 2 font picker items, but we only show + * one depending on the value of the SMOOTH_GRAPHICS preference. */ static void -appearance_pane_update (gpointer callback_data) +global_preferences_pane_update_callback (gpointer callback_data) { g_return_if_fail (NAUTILUS_IS_PREFERENCES_PANE (callback_data)); nautilus_preferences_pane_update (NAUTILUS_PREFERENCES_PANE (callback_data)); } -static GtkWidget * -global_preferences_create_font_group (NautilusPreferencesPane *appearance_pane) -{ - GtkWidget *font_group; - GtkWidget *font_picker_smooth_item; - GtkWidget *font_picker_gdk_item; - - font_group = - nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), _("Fonts")); - - font_picker_gdk_item = - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), - 1, - NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY, - NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY); - - nautilus_preferences_item_set_control_preference (NAUTILUS_PREFERENCES_ITEM (font_picker_gdk_item), - NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE); - nautilus_preferences_item_set_control_action (NAUTILUS_PREFERENCES_ITEM (font_picker_gdk_item), - NAUTILUS_PREFERENCE_ITEM_HIDE); - - font_picker_smooth_item = - nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), - 1, - NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT, - NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT); - - nautilus_preferences_item_set_control_preference (NAUTILUS_PREFERENCES_ITEM (font_picker_smooth_item), - NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE); - nautilus_preferences_item_set_control_action (NAUTILUS_PREFERENCES_ITEM (font_picker_smooth_item), - NAUTILUS_PREFERENCE_ITEM_SHOW); - - nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - appearance_pane_update, - appearance_pane); - - return font_group; -} - /* Make a query to find out what sidebar panels are available. */ static GList * global_preferences_get_sidebar_panel_view_identifiers (void) @@ -1014,11 +1071,6 @@ global_preferences_get_dialog (void) nautilus_global_preferences_initialize (); if (global_prefs_dialog == NULL) { - /* Install descriptions right before creating the dialog. - * The descriptions are only used within the preferences - * dialog. - */ - global_preferences_install_descriptions (); global_prefs_dialog = global_preferences_create_dialog (); } @@ -1052,7 +1104,7 @@ global_preferences_install_sidebar_panel_defaults (void) /* Install the user level on/off defaults for known sidebar panels */ for (i = 0; i < NAUTILUS_N_ELEMENTS (known_sidebar_panels); i++) { - char *key = global_preferences_get_sidebar_panel_key (known_sidebar_panels[i].name); + char *key = global_preferences_make_sidebar_panel_key (known_sidebar_panels[i].name); nautilus_preferences_default_set_boolean (key, NAUTILUS_USER_LEVEL_NOVICE, @@ -1071,36 +1123,8 @@ global_preferences_install_sidebar_panel_defaults (void) } } -static void -global_preferences_install_sidebar_panel_descriptions (void) -{ - GList *view_identifiers; - GList *iterator; - NautilusViewIdentifier *identifier; - char *key, *label; - - /* Install the descriptions for the available sidebar panels */ - view_identifiers = global_preferences_get_sidebar_panel_view_identifiers (); - - for (iterator = view_identifiers; iterator != NULL; iterator = iterator->next) { - - identifier = iterator->data; - g_return_if_fail (identifier != NULL); - - key = global_preferences_get_sidebar_panel_key (identifier->iid); - g_return_if_fail (key != NULL); - - label = g_strdup_printf (_("Display %s tab in sidebar"), identifier->name); - nautilus_preferences_set_description (key, label); - g_free (key); - g_free (label); - } - - nautilus_view_identifier_list_free (view_identifiers); -} - static char * -global_preferences_get_sidebar_panel_key (const char *panel_iid) +global_preferences_make_sidebar_panel_key (const char *panel_iid) { g_return_val_if_fail (panel_iid != NULL, NULL); @@ -1116,7 +1140,7 @@ global_preferences_is_sidebar_panel_enabled (NautilusViewIdentifier *panel_ident g_return_val_if_fail (panel_identifier != NULL, FALSE); g_return_val_if_fail (panel_identifier->iid != NULL, FALSE); - key = global_preferences_get_sidebar_panel_key (panel_identifier->iid); + key = global_preferences_make_sidebar_panel_key (panel_identifier->iid); g_return_val_if_fail (key != NULL, FALSE); enabled = nautilus_preferences_get_boolean (key); g_free (key); @@ -1131,26 +1155,6 @@ global_preferences_is_sidebar_panel_enabled_cover (gpointer data, gpointer callb } static void -global_preferences_install_speed_tradeoff_descriptions (const char *name, - const char *description) -{ - nautilus_preferences_set_description (name, description); - - nautilus_preferences_enumeration_insert (name, - _("always"), - _("Always"), - NAUTILUS_SPEED_TRADEOFF_ALWAYS); - nautilus_preferences_enumeration_insert (name, - _("local only"), - _("Local Files Only"), - NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY); - nautilus_preferences_enumeration_insert (name, - _("never"), - _("Never"), - NAUTILUS_SPEED_TRADEOFF_NEVER); -} - -static void global_preferences_install_home_location_defaults (void) { char *default_novice_home_uri; @@ -1170,6 +1174,8 @@ global_preferences_install_home_location_defaults (void) NAUTILUS_USER_LEVEL_INTERMEDIATE, default_intermediate_home_uri); + nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_HOME_URI, + NAUTILUS_USER_LEVEL_INTERMEDIATE); g_free (user_main_directory); g_free (default_novice_home_uri); g_free (default_intermediate_home_uri); @@ -1179,17 +1185,43 @@ static void global_preferences_install_font_defaults (void) { char *default_smooth_font; + const char *default_font; + + default_font = nautilus_dumb_down_for_multi_byte_locale_hack () ? "fixed" : "helvetica"; + default_smooth_font = nautilus_font_manager_get_default_font (); - nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY, + /* Icon view fonts */ + nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_ICON_VIEW_FONT, + NAUTILUS_USER_LEVEL_NOVICE, + default_font); + nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_ICON_VIEW_SMOOTH_FONT, NAUTILUS_USER_LEVEL_NOVICE, - _("helvetica")); + default_smooth_font); + nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_ICON_VIEW_STANDARD_FONT_SIZE, + NAUTILUS_USER_LEVEL_NOVICE, + 12); - /* The default smooth font */ - default_smooth_font = nautilus_font_manager_get_default_font (); - - nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT, + /* List view fonts */ + nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_LIST_VIEW_FONT, + NAUTILUS_USER_LEVEL_NOVICE, + default_font); + nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_LIST_VIEW_STANDARD_FONT_SIZE, + NAUTILUS_USER_LEVEL_NOVICE, + 12); + + /* Default fonts */ + nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_DEFAULT_FONT, + NAUTILUS_USER_LEVEL_NOVICE, + default_font); + + nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT, NAUTILUS_USER_LEVEL_NOVICE, default_smooth_font); + + nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_DEFAULT_FONT_SIZE, + NAUTILUS_USER_LEVEL_NOVICE, + 12); + g_free (default_smooth_font); } @@ -1279,6 +1311,8 @@ global_preferences_install_medusa_defaults (void) NAUTILUS_USER_LEVEL_NOVICE, use_fast_search); + nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_USE_FAST_SEARCH, + NAUTILUS_USER_LEVEL_INTERMEDIATE); nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_USE_FAST_SEARCH, global_preferences_use_fast_search_changed_callback, @@ -1297,6 +1331,82 @@ global_preferences_close_dialog_callback (GtkWidget *dialog, return TRUE; } +static GtkWidget * +global_preferences_populate_pane (NautilusPreferencesBox *preference_box, + const char *pane_name, + const ItemDescription *item_descriptions) +{ + GtkWidget *pane; + GtkWidget *item; + NautilusStringList *group_names; + guint i; + int group_index; + guint start_group_index; + const EnumerationEntry *enumeration_values; + + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_BOX (preference_box), NULL); + g_return_val_if_fail (pane_name != NULL, NULL); + g_return_val_if_fail (item_descriptions != NULL, NULL); + + /* Create the pane if needed */ + pane = nautilus_preferences_box_find_pane (preference_box, pane_name); + if (pane == NULL) { + pane = nautilus_preferences_box_add_pane (preference_box, pane_name); + } + + group_names = nautilus_string_list_new (TRUE); + + start_group_index = nautilus_preferences_pane_get_num_groups (NAUTILUS_PREFERENCES_PANE (pane)); + + for (i = 0; item_descriptions[i].group_name != NULL; i++) { + if (!nautilus_string_list_contains (group_names, item_descriptions[i].group_name)) { + nautilus_string_list_insert (group_names, item_descriptions[i].group_name); + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (pane), + item_descriptions[i].group_name); + } + } + + for (i = 0; item_descriptions[i].group_name != NULL; i++) { + group_index = start_group_index + + nautilus_string_list_get_index_for_string (group_names, item_descriptions[i].group_name); + + nautilus_preferences_set_description (item_descriptions[i].preference_name, + item_descriptions[i].preference_description); + + enumeration_values = item_descriptions[i].enumeration_values; + while (enumeration_values != NULL && enumeration_values->stored_value != NULL) { + nautilus_preferences_enumeration_insert (item_descriptions[i].preference_name, + enumeration_values->stored_value, + enumeration_values->display_value, + enumeration_values->value); + enumeration_values++; + } + + item = nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (pane), + group_index, + item_descriptions[i].preference_name, + item_descriptions[i].item_type); + + if (item_descriptions[i].item_type == NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER) { + nautilus_preferences_item_set_constrained_integer_paramaters ( + NAUTILUS_PREFERENCES_ITEM (item), + item_descriptions[i].constrained_integer_lower, + item_descriptions[i].constrained_integer_upper, + item_descriptions[i].constrained_integer_increment); + } + + if (item_descriptions[i].control_preference_name != NULL) { + nautilus_preferences_item_set_control_preference (NAUTILUS_PREFERENCES_ITEM (item), + item_descriptions[i].control_preference_name); + nautilus_preferences_item_set_control_action (NAUTILUS_PREFERENCES_ITEM (item), + item_descriptions[i].control_action); + } + } + + nautilus_string_list_free (group_names); + + return pane; +} /* * Public functions @@ -1328,46 +1438,34 @@ nautilus_global_preferences_set_dialog_title (const char *title) gtk_window_set_title (GTK_WINDOW (dialog), title); } -/** - * nautilus_global_preferences_get_smooth_font - * - * Return value: The user's preferred smooth font. Need to - * unref the returned GtkObject when done with it. - */ -NautilusScalableFont * -nautilus_global_preferences_get_smooth_font (void) +static NautilusScalableFont * +global_preferences_get_smooth_font (const char *preference_name) { - NautilusScalableFont *scalable_font; - char *font_file_name; + NautilusScalableFont *smooth_font; + char *smooth_font_file_name; - font_file_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT); + g_return_val_if_fail (preference_name != NULL, NULL); + + smooth_font_file_name = nautilus_preferences_get (preference_name); - scalable_font = - (font_file_name && g_file_exists (font_file_name)) ? - nautilus_scalable_font_new (font_file_name) : + smooth_font = (smooth_font_file_name && g_file_exists (smooth_font_file_name)) ? + nautilus_scalable_font_new (smooth_font_file_name) : nautilus_scalable_font_get_default_font (); - g_free (font_file_name); + g_free (smooth_font_file_name); - g_assert (NAUTILUS_IS_SCALABLE_FONT (scalable_font)); - - return scalable_font; + g_assert (NAUTILUS_IS_SCALABLE_FONT (smooth_font)); + return smooth_font; } -/** - * nautilus_global_preferences_get_smooth_bold_font - * - * Return value: A bold flavor on the user's preferred smooth font. If - * no bold font is found, then the plain preffered font is - * used. Need to unref the returned GtkObject when done - * with it. - */ -NautilusScalableFont * -nautilus_global_preferences_get_smooth_bold_font (void) +static NautilusScalableFont * +global_preferences_get_smooth_bold_font (const char *preference_name) { NautilusScalableFont *plain_font; NautilusScalableFont *bold_font; - plain_font = nautilus_global_preferences_get_smooth_font (); + g_return_val_if_fail (preference_name != NULL, NULL); + + plain_font = global_preferences_get_smooth_font (preference_name); g_assert (NAUTILUS_IS_SCALABLE_FONT (plain_font)); bold_font = nautilus_scalable_font_make_bold (plain_font); @@ -1382,6 +1480,44 @@ nautilus_global_preferences_get_smooth_bold_font (void) return bold_font; } +/** + * nautilus_global_preferences_get_icon_view_smooth_font + * + * Return value: The user's smooth font for icon file names. Need to + * unref the returned GtkObject when done with it. + */ +NautilusScalableFont * +nautilus_global_preferences_get_icon_view_smooth_font (void) +{ + return global_preferences_get_smooth_font (NAUTILUS_PREFERENCES_ICON_VIEW_SMOOTH_FONT); +} + +/** + * nautilus_global_preferences_get_default_smooth_font + * + * Return value: The user's smooth font for default text. + * Need to unref the returned GtkObject when done with it. + */ +NautilusScalableFont * +nautilus_global_preferences_get_default_smooth_font (void) +{ + return global_preferences_get_smooth_font (NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT); +} + +/** + * nautilus_global_preferences_get_default_smooth_bold_font + * + * Return value: A bold flavor on the user's default text font. If + * no bold font is found, then the plain preffered font is + * used. Need to unref the returned GtkObject when done + * with it. + */ +NautilusScalableFont * +nautilus_global_preferences_get_default_smooth_bold_font (void) +{ + return global_preferences_get_smooth_bold_font (NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT); +} + void nautilus_global_preferences_initialize (void) { @@ -1395,7 +1531,4 @@ nautilus_global_preferences_initialize (void) /* Install defaults */ global_preferences_install_defaults (); - - /* Install visiblities */ - global_preferences_install_visibility (); } diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h index 26678f255..1dd731f14 100644 --- a/libnautilus-private/nautilus-global-preferences.h +++ b/libnautilus-private/nautilus-global-preferences.h @@ -33,6 +33,7 @@ BEGIN_GNOME_DECLS #define NAUTILUS_PREFERENCES_THEME "preferences/theme" /* Which text attributes appear beneath icon names */ #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 "preferences/sidebar_width" @@ -58,6 +59,8 @@ BEGIN_GNOME_DECLS #define NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES "preferences/show_hidden_files" #define NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES "preferences/show_backup_files" #define NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS "preferences/show_special_flags" + +/* Sidebar panels */ #define NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES "sidebar-panels/tree/show_only_directories" /* Navigation */ @@ -72,6 +75,11 @@ BEGIN_GNOME_DECLS /* adding/removing from property browser */ #define NAUTILUS_PREFERENCES_CAN_ADD_CONTENT "preferences/can_add_content" +/* Content fonts */ +#define NAUTILUS_PREFERENCES_DEFAULT_FONT "preferences/default_font" +#define NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT "preferences/default_smooth_font" +#define NAUTILUS_PREFERENCES_DEFAULT_FONT_SIZE "preferences/default_font_size" + /* Single/Double click preference */ #define NAUTILUS_PREFERENCES_CLICK_POLICY "preferences/click_policy" @@ -96,9 +104,14 @@ BEGIN_GNOME_DECLS /* Sorting order */ #define NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST "preferences/sort_directories_first" -/* Directory view */ -#define NAUTILUS_PREFERENCES_DIRECTORY_VIEW_FONT_FAMILY "directory-view/font_family" -#define NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT "directory-view/smooth_font" +/* Icon View */ +#define NAUTILUS_PREFERENCES_ICON_VIEW_FONT "icon-view/font" +#define NAUTILUS_PREFERENCES_ICON_VIEW_SMOOTH_FONT "icon-view/smooth_font" +#define NAUTILUS_PREFERENCES_ICON_VIEW_STANDARD_FONT_SIZE "icon-view/standard_font_size" + +/* List View */ +#define NAUTILUS_PREFERENCES_LIST_VIEW_FONT "list-view/font" +#define NAUTILUS_PREFERENCES_LIST_VIEW_STANDARD_FONT_SIZE "list-view/standard_font_size" /* File Indexing */ #define NAUTILUS_PREFERENCES_SEARCH_BAR_TYPE "preferences/search_bar_type" @@ -150,8 +163,9 @@ void nautilus_global_preferences_set_dialog_title /* Sidebar */ GList * nautilus_global_preferences_get_enabled_sidebar_panel_view_identifiers (void); -struct NautilusScalableFont *nautilus_global_preferences_get_smooth_font (void); -struct NautilusScalableFont *nautilus_global_preferences_get_smooth_bold_font (void); +struct NautilusScalableFont *nautilus_global_preferences_get_icon_view_smooth_font (void); +struct NautilusScalableFont *nautilus_global_preferences_get_default_smooth_font (void); +struct NautilusScalableFont *nautilus_global_preferences_get_default_smooth_bold_font (void); END_GNOME_DECLS diff --git a/libnautilus-private/nautilus-gtk-extensions.c b/libnautilus-private/nautilus-gtk-extensions.c index cabc2fba9..82018c7a8 100644 --- a/libnautilus-private/nautilus-gtk-extensions.c +++ b/libnautilus-private/nautilus-gtk-extensions.c @@ -2068,6 +2068,32 @@ nautilus_get_window_list_ordered_front_to_back (void) return windows; } +/* nautilus_gtk_get_system_font: + * + * Return the system font as selected in the control center. Need to + * gdk_font_unref() the result when done with it. + * + * Perhaps there is a better way to figure out what that font is, but + * the following is simple enough and it works. + */ +GdkFont * +nautilus_gtk_get_system_font (void) +{ + GtkWidget *label; + GdkFont *font; + + label = gtk_label_new (""); + + gtk_widget_ensure_style (label); + + font = label->style->font; + gdk_font_ref (font); + + gtk_widget_destroy (label); + + return font; +} + static guint event_get_time (GdkEvent *event) { diff --git a/libnautilus-private/nautilus-gtk-extensions.h b/libnautilus-private/nautilus-gtk-extensions.h index 4e48ee289..4f28f34d4 100644 --- a/libnautilus-private/nautilus-gtk-extensions.h +++ b/libnautilus-private/nautilus-gtk-extensions.h @@ -105,6 +105,8 @@ void nautilus_gtk_widget_set_foreground_color (GtkWidge GtkWidget *nautilus_gtk_widget_find_windowed_ancestor (GtkWidget *widget); guint nautilus_get_current_event_time (void); +GdkFont *nautilus_gtk_get_system_font (void); + /* GtkContainer */ GtkWidget *nautilus_gtk_container_get_first_child (GtkContainer *container); void nautilus_gtk_container_foreach_deep (GtkContainer *container, diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-icon-canvas-item.c index 399cade1d..4d3606f15 100644 --- a/libnautilus-private/nautilus-icon-canvas-item.c +++ b/libnautilus-private/nautilus-icon-canvas-item.c @@ -97,7 +97,7 @@ struct NautilusIconCanvasItemDetails { gboolean is_renaming; /* Font stuff whilst in smooth mode */ - guint smooth_font_size; + int smooth_font_size; NautilusScalableFont *smooth_font; /* Cached rectangle in canvas coordinates */ @@ -259,7 +259,7 @@ nautilus_icon_canvas_item_initialize_class (NautilusIconCanvasItemClass *class) gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_for_drop", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_FOR_DROP); gtk_object_add_arg_type ("NautilusIconCanvasItem::smooth_font_size", - GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_SMOOTH_FONT_SIZE); + GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_SMOOTH_FONT_SIZE); gtk_object_add_arg_type ("NautilusIconCanvasItem::smooth_font", GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_SMOOTH_FONT); @@ -446,7 +446,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) case ARG_SMOOTH_FONT_SIZE: nautilus_icon_canvas_item_set_smooth_font_size (NAUTILUS_ICON_CANVAS_ITEM (object), - GTK_VALUE_UINT (*arg)); + GTK_VALUE_INT (*arg)); break; default: @@ -497,7 +497,7 @@ nautilus_icon_canvas_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_SMOOTH_FONT_SIZE: - GTK_VALUE_UINT (*arg) = details->smooth_font_size; + GTK_VALUE_INT (*arg) = details->smooth_font_size; break; default: @@ -2168,8 +2168,8 @@ nautilus_icon_canvas_item_set_smooth_font (NautilusIconCanvasItem *icon_item, } void -nautilus_icon_canvas_item_set_smooth_font_size (NautilusIconCanvasItem *icon_item, - guint font_size) +nautilus_icon_canvas_item_set_smooth_font_size (NautilusIconCanvasItem *icon_item, + int font_size) { g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (icon_item)); g_return_if_fail (font_size > 0); diff --git a/libnautilus-private/nautilus-icon-canvas-item.h b/libnautilus-private/nautilus-icon-canvas-item.h index 312efd69d..e9f52d227 100644 --- a/libnautilus-private/nautilus-icon-canvas-item.h +++ b/libnautilus-private/nautilus-icon-canvas-item.h @@ -93,7 +93,7 @@ void nautilus_icon_canvas_item_update_bounds (NautilusIconCanv void nautilus_icon_canvas_item_set_smooth_font (NautilusIconCanvasItem *item, NautilusScalableFont *font); void nautilus_icon_canvas_item_set_smooth_font_size (NautilusIconCanvasItem *item, - guint font_size); + int font_size); END_GNOME_DECLS diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c index b485124f5..82b5a884b 100644 --- a/libnautilus-private/nautilus-icon-container.c +++ b/libnautilus-private/nautilus-icon-container.c @@ -3337,28 +3337,26 @@ nautilus_icon_container_initialize (NautilusIconContainer *container) /* FIXME bugzilla.eazel.com 5093: Font name is hard-coded here. */ /* FIXME bugzilla.eazel.com 5101: Font size is hard-coded here. */ - /* FIXME bugzilla.eazel.com 7345: - * Default font "helvetica" hard coded and marked for translatation in many - * placesFonts hard marked for localization in disparate places. - */ - details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLEST] = nautilus_font_factory_get_font_by_family (_("helvetica"), 8); - details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLER] = nautilus_font_factory_get_font_by_family (_("helvetica"), 8); - details->label_font[NAUTILUS_ZOOM_LEVEL_SMALL] = nautilus_font_factory_get_font_by_family (_("helvetica"), 10); - details->label_font[NAUTILUS_ZOOM_LEVEL_STANDARD] = nautilus_font_factory_get_font_by_family (_("helvetica"), 12); - details->label_font[NAUTILUS_ZOOM_LEVEL_LARGE] = nautilus_font_factory_get_font_by_family (_("helvetica"), 14); - details->label_font[NAUTILUS_ZOOM_LEVEL_LARGER] = nautilus_font_factory_get_font_by_family (_("helvetica"), 18); - details->label_font[NAUTILUS_ZOOM_LEVEL_LARGEST] = nautilus_font_factory_get_font_by_family (_("helvetica"), 18); + details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLEST] = nautilus_font_factory_get_font_by_family ("helvetica", 8); + details->label_font[NAUTILUS_ZOOM_LEVEL_SMALLER] = nautilus_font_factory_get_font_by_family ("helvetica", 8); + details->label_font[NAUTILUS_ZOOM_LEVEL_SMALL] = nautilus_font_factory_get_font_by_family ("helvetica", 10); + details->label_font[NAUTILUS_ZOOM_LEVEL_STANDARD] = nautilus_font_factory_get_font_by_family ("helvetica", 12); + details->label_font[NAUTILUS_ZOOM_LEVEL_LARGE] = nautilus_font_factory_get_font_by_family ("helvetica", 14); + details->label_font[NAUTILUS_ZOOM_LEVEL_LARGER] = nautilus_font_factory_get_font_by_family ("helvetica", 18); + details->label_font[NAUTILUS_ZOOM_LEVEL_LARGEST] = nautilus_font_factory_get_font_by_family ("helvetica", 18); details->smooth_label_font = nautilus_scalable_font_get_default_font (); - - /* FIXME bugzilla.eazel.com 5101: Font size is hard-coded here. */ - details->smooth_font_size[NAUTILUS_ZOOM_LEVEL_SMALLEST] = 8; - details->smooth_font_size[NAUTILUS_ZOOM_LEVEL_SMALLER] = 8; - details->smooth_font_size[NAUTILUS_ZOOM_LEVEL_SMALL] = 10; - details->smooth_font_size[NAUTILUS_ZOOM_LEVEL_STANDARD] = 12; - details->smooth_font_size[NAUTILUS_ZOOM_LEVEL_LARGE] = 14; - details->smooth_font_size[NAUTILUS_ZOOM_LEVEL_LARGER] = 18; - details->smooth_font_size[NAUTILUS_ZOOM_LEVEL_LARGEST] = 18; + + /* These are the default font sizes. The font sizes are configurable via + * nautilus_icon_container_set_font_size_table() + */ + details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = 8; + details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER] = 8; + details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL] = 10; + details->font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] = 12; + details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE] = 14; + details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER] = 18; + details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST] = 18; container->details = details; @@ -3721,7 +3719,7 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container, GList *emblem_scalable_icons, *emblem_pixbufs, *p; char *editable_text, *additional_text; GdkFont *font; - guint smooth_font_size; + int smooth_font_size; if (icon == NULL) { return; @@ -3814,7 +3812,7 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container, font = details->label_font[details->zoom_level]; - smooth_font_size = details->smooth_font_size[details->zoom_level]; + smooth_font_size = details->font_size_table[details->zoom_level]; gnome_canvas_item_set (GNOME_CANVAS_ITEM (icon->item), "editable_text", editable_text, @@ -5144,6 +5142,20 @@ nautilus_icon_container_theme_changed (gpointer user_data) } } +void +nautilus_icon_container_set_font_size_table (NautilusIconContainer *container, + const int font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST + 1]) +{ + int i; + + g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container)); + g_return_if_fail (font_size_table != NULL); + + for (i = 0; i <= NAUTILUS_ZOOM_LEVEL_LARGEST; i++) { + container->details->font_size_table[i] = font_size_table[i]; + } +} + #if ! defined (NAUTILUS_OMIT_SELF_CHECK) static char * diff --git a/libnautilus-private/nautilus-icon-container.h b/libnautilus-private/nautilus-icon-container.h index a82a8f6d0..c1744c9e1 100644 --- a/libnautilus-private/nautilus-icon-container.h +++ b/libnautilus-private/nautilus-icon-container.h @@ -152,81 +152,81 @@ typedef struct { } NautilusIconContainerClass; /* GtkObject */ -guint nautilus_icon_container_get_type (void); -GtkWidget *nautilus_icon_container_new (void); +guint nautilus_icon_container_get_type (void); +GtkWidget * nautilus_icon_container_new (void); /* adding, removing, and managing icons */ -void nautilus_icon_container_clear (NautilusIconContainer *view); -gboolean nautilus_icon_container_add (NautilusIconContainer *view, - NautilusIconData *data); -gboolean nautilus_icon_container_remove (NautilusIconContainer *view, - NautilusIconData *data); -void nautilus_icon_container_for_each (NautilusIconContainer *view, - NautilusIconCallback callback, - gpointer callback_data); -void nautilus_icon_container_request_update (NautilusIconContainer *view, - NautilusIconData *data); -void nautilus_icon_container_request_update_all (NautilusIconContainer *container); -void nautilus_icon_container_reveal (NautilusIconContainer *container, - NautilusIconData *data); -gboolean nautilus_icon_container_is_empty (NautilusIconContainer *container); +void nautilus_icon_container_clear (NautilusIconContainer *view); +gboolean nautilus_icon_container_add (NautilusIconContainer *view, + NautilusIconData *data); +gboolean nautilus_icon_container_remove (NautilusIconContainer *view, + NautilusIconData *data); +void nautilus_icon_container_for_each (NautilusIconContainer *view, + NautilusIconCallback callback, + gpointer callback_data); +void nautilus_icon_container_request_update (NautilusIconContainer *view, + NautilusIconData *data); +void nautilus_icon_container_request_update_all (NautilusIconContainer *container); +void nautilus_icon_container_reveal (NautilusIconContainer *container, + NautilusIconData *data); +gboolean nautilus_icon_container_is_empty (NautilusIconContainer *container); /* control the layout */ -gboolean nautilus_icon_container_is_auto_layout (NautilusIconContainer *container); -void nautilus_icon_container_set_auto_layout (NautilusIconContainer *container, - gboolean auto_layout); -gboolean nautilus_icon_container_is_tighter_layout (NautilusIconContainer *container); -void nautilus_icon_container_set_tighter_layout (NautilusIconContainer *container, - gboolean tighter_layout); -void nautilus_icon_container_set_layout_mode (NautilusIconContainer *container, - NautilusIconLayoutMode mode); -void nautilus_icon_container_sort (NautilusIconContainer *container); -void nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container); +gboolean nautilus_icon_container_is_auto_layout (NautilusIconContainer *container); +void nautilus_icon_container_set_auto_layout (NautilusIconContainer *container, + gboolean auto_layout); +gboolean nautilus_icon_container_is_tighter_layout (NautilusIconContainer *container); +void nautilus_icon_container_set_tighter_layout (NautilusIconContainer *container, + gboolean tighter_layout); +void nautilus_icon_container_set_layout_mode (NautilusIconContainer *container, + NautilusIconLayoutMode mode); +void nautilus_icon_container_sort (NautilusIconContainer *container); +void nautilus_icon_container_freeze_icon_positions (NautilusIconContainer *container); /* operations on all icons */ -void nautilus_icon_container_unselect_all (NautilusIconContainer *view); -void nautilus_icon_container_select_all (NautilusIconContainer *view); +void nautilus_icon_container_unselect_all (NautilusIconContainer *view); +void nautilus_icon_container_select_all (NautilusIconContainer *view); /* operations on the selection */ -GList *nautilus_icon_container_get_selection (NautilusIconContainer *view); -void nautilus_icon_container_set_selection (NautilusIconContainer *view, - GList *selection); -GArray *nautilus_icon_container_get_selected_icon_locations (NautilusIconContainer *view); -gboolean nautilus_icon_container_has_stretch_handles (NautilusIconContainer *container); -gboolean nautilus_icon_container_is_stretched (NautilusIconContainer *container); -void nautilus_icon_container_show_stretch_handles (NautilusIconContainer *container); -void nautilus_icon_container_unstretch (NautilusIconContainer *container); -void nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container); +GList * nautilus_icon_container_get_selection (NautilusIconContainer *view); +void nautilus_icon_container_set_selection (NautilusIconContainer *view, + GList *selection); +GArray * nautilus_icon_container_get_selected_icon_locations (NautilusIconContainer *view); +gboolean nautilus_icon_container_has_stretch_handles (NautilusIconContainer *container); +gboolean nautilus_icon_container_is_stretched (NautilusIconContainer *container); +void nautilus_icon_container_show_stretch_handles (NautilusIconContainer *container); +void nautilus_icon_container_unstretch (NautilusIconContainer *container); +void nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *container); /* options */ -NautilusZoomLevel nautilus_icon_container_get_zoom_level (NautilusIconContainer *view); -void nautilus_icon_container_set_zoom_level (NautilusIconContainer *view, - int new_zoom_level); -void nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container, - gboolean single_click_mode); -void nautilus_icon_container_enable_linger_selection (NautilusIconContainer *view, - gboolean enable); -gboolean nautilus_icon_container_get_anti_aliased_mode (NautilusIconContainer *view); -void nautilus_icon_container_set_anti_aliased_mode (NautilusIconContainer *view, - gboolean anti_aliased_mode); -void nautilus_icon_container_set_label_font_for_zoom_level (NautilusIconContainer *container, - int zoom_level, - GdkFont *font); -void nautilus_icon_container_set_smooth_label_font (NautilusIconContainer *container, - NautilusScalableFont *font); -gboolean nautilus_icon_container_get_is_fixed_size (NautilusIconContainer *container); -void nautilus_icon_container_set_is_fixed_size (NautilusIconContainer *container, - gboolean is_fixed_size); - -void nautilus_icon_container_reset_scroll_region (NautilusIconContainer *container); - -void nautilus_icon_container_set_margins (NautilusIconContainer *container, - int left_margin, - int right_margin, - int top_margin, - int bottom_margin); +NautilusZoomLevel nautilus_icon_container_get_zoom_level (NautilusIconContainer *view); +void nautilus_icon_container_set_zoom_level (NautilusIconContainer *view, + int new_zoom_level); +void nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container, + gboolean single_click_mode); +void nautilus_icon_container_enable_linger_selection (NautilusIconContainer *view, + gboolean enable); +gboolean nautilus_icon_container_get_anti_aliased_mode (NautilusIconContainer *view); +void nautilus_icon_container_set_anti_aliased_mode (NautilusIconContainer *view, + gboolean anti_aliased_mode); +void nautilus_icon_container_set_label_font_for_zoom_level (NautilusIconContainer *container, + int zoom_level, + GdkFont *font); +void nautilus_icon_container_set_smooth_label_font (NautilusIconContainer *container, + NautilusScalableFont *font); +gboolean nautilus_icon_container_get_is_fixed_size (NautilusIconContainer *container); +void nautilus_icon_container_set_is_fixed_size (NautilusIconContainer *container, + gboolean is_fixed_size); +void nautilus_icon_container_reset_scroll_region (NautilusIconContainer *container); +void nautilus_icon_container_set_font_size_table (NautilusIconContainer *container, + const int font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST + 1]); +void nautilus_icon_container_set_margins (NautilusIconContainer *container, + int left_margin, + int right_margin, + int top_margin, + int bottom_margin); #endif /* NAUTILUS_ICON_CONTAINER_H */ diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c index e86766d4d..beabac0be 100644 --- a/libnautilus-private/nautilus-icon-factory.c +++ b/libnautilus-private/nautilus-icon-factory.c @@ -129,7 +129,9 @@ static const char *icon_file_name_suffixes[] = #define MAXIMUM_ICON_SIZE 96 /* Embedded text font size and text line settings */ -#define EMBEDDED_TEXT_FONT_SIZE 9 + +/* FIXME; Hard coded font size */ +#define EMBEDDED_TEXT_FONT_SIZE 9 #define EMBEDDED_TEXT_LINE_SPACING 1 #define EMBEDDED_TEXT_EMPTY_LINE_HEIGHT 4 @@ -2368,12 +2370,37 @@ embedded_text_rect_usable (const ArtIRect *embedded_text_rect) return TRUE; } +static gboolean embedded_text_preferences_callbacks_added = FALSE; +static NautilusScalableFont *embedded_text_font = NULL; + +static void +embedded_text_font_changed_callback (gpointer callback_data) +{ + gboolean clear_cache = GPOINTER_TO_INT (callback_data); + + embedded_text_font = nautilus_global_preferences_get_default_smooth_font (); + + if (clear_cache) { + nautilus_icon_factory_clear (); + } +} + +static void +embedded_text_font_free (void) +{ + if (embedded_text_font == NULL) { + return; + } + + gtk_object_unref (GTK_OBJECT (embedded_text_font)); + embedded_text_font = NULL; +} + static GdkPixbuf * embed_text (GdkPixbuf *pixbuf_without_text, const ArtIRect *embedded_text_rect, const char *text) { - NautilusScalableFont *smooth_font; NautilusSmoothTextLayout *smooth_text_layout; GdkPixbuf *pixbuf_with_text; @@ -2387,21 +2414,23 @@ embed_text (GdkPixbuf *pixbuf_without_text, return NULL; } - /* FIXME bugzilla.eazel.com 1102: Embedded text should use preferences to determine - * the font it uses - */ + /* Listen for changes in embedded text (icon text preview) font preferences */ + if (embedded_text_preferences_callbacks_added == FALSE) { + embedded_text_preferences_callbacks_added = TRUE; - /* FIXME bugzilla.eazel.com 2783: It would be nice if embedded didnt always draw - * anti aliased based on the user's smooth graphics preference. It is however - * a questionable improvement since at that tiny font size, anti aliased fonts - * probably give a better preview of the content than non anti-aliased fonts. - */ - smooth_font = nautilus_scalable_font_get_default_font (); - g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (smooth_font), NULL); + nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_DEFAULT_SMOOTH_FONT, + embedded_text_font_changed_callback, + GINT_TO_POINTER (TRUE)); + embedded_text_font_changed_callback (GINT_TO_POINTER (FALSE)); + + g_atexit (embedded_text_font_free); + } + + g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (embedded_text_font), NULL); smooth_text_layout = nautilus_smooth_text_layout_new (text, nautilus_strlen (text), - smooth_font, + embedded_text_font, EMBEDDED_TEXT_FONT_SIZE, FALSE); g_return_val_if_fail (NAUTILUS_IS_SMOOTH_TEXT_LAYOUT (smooth_text_layout), NULL); @@ -2421,7 +2450,6 @@ embed_text (GdkPixbuf *pixbuf_without_text, NAUTILUS_OPACITY_FULLY_OPAQUE); gtk_object_unref (GTK_OBJECT (smooth_text_layout)); - gtk_object_unref (GTK_OBJECT (smooth_font)); return pixbuf_with_text; } diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-icon-private.h index e858540c9..9c426eeca 100644 --- a/libnautilus-private/nautilus-icon-private.h +++ b/libnautilus-private/nautilus-icon-private.h @@ -177,7 +177,7 @@ struct NautilusIconContainerDetails { /* font used to draw labels in smooth mode */ NautilusScalableFont *smooth_label_font; - guint smooth_font_size[NAUTILUS_ZOOM_LEVEL_LARGEST + 1]; + int font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST + 1]; /* pixbuf and color for label highlighting */ GdkPixbuf *highlight_frame; diff --git a/libnautilus-private/nautilus-preferences-box.c b/libnautilus-private/nautilus-preferences-box.c index 40c0825fe..0a80758c4 100644 --- a/libnautilus-private/nautilus-preferences-box.c +++ b/libnautilus-private/nautilus-preferences-box.c @@ -373,3 +373,24 @@ nautilus_preferences_box_update (NautilusPreferencesBox *preferences_box) preferences_box_category_list_recreate (preferences_box); } + +GtkWidget * +nautilus_preferences_box_find_pane (const NautilusPreferencesBox *preferences_box, + const char *pane_name) +{ + GList *node; + PaneInfo *info; + + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_BOX (preferences_box), FALSE); + + for (node = preferences_box->details->panes; node != NULL; node = node->next) { + g_assert (node->data != NULL); + info = node->data; + if (nautilus_str_is_equal (info->pane_name, pane_name)) { + return info->pane_widget; + } + } + + return NULL; +} + diff --git a/libnautilus-private/nautilus-preferences-box.h b/libnautilus-private/nautilus-preferences-box.h index 225274a57..3b3a8e08a 100644 --- a/libnautilus-private/nautilus-preferences-box.h +++ b/libnautilus-private/nautilus-preferences-box.h @@ -57,11 +57,13 @@ struct _NautilusPreferencesBoxClass void (*activate) (GtkWidget *preferences_box, gint entry_number); }; -GtkType nautilus_preferences_box_get_type (void); -GtkWidget* nautilus_preferences_box_new (const char *box_title); -GtkWidget* nautilus_preferences_box_add_pane (NautilusPreferencesBox *prefs_box, - const char *pane_title); -void nautilus_preferences_box_update (NautilusPreferencesBox *prefs_box); +GtkType nautilus_preferences_box_get_type (void); +GtkWidget* nautilus_preferences_box_new (const char *box_title); +GtkWidget* nautilus_preferences_box_add_pane (NautilusPreferencesBox *prefs_box, + const char *pane_title); +void nautilus_preferences_box_update (NautilusPreferencesBox *prefs_box); +GtkWidget* nautilus_preferences_box_find_pane (const NautilusPreferencesBox *prefs_box, + const char *pane_name); END_GNOME_DECLS diff --git a/libnautilus-private/nautilus-preferences-group.c b/libnautilus-private/nautilus-preferences-group.c index bdf83865c..89cbd2954 100644 --- a/libnautilus-private/nautilus-preferences-group.c +++ b/libnautilus-private/nautilus-preferences-group.c @@ -56,17 +56,18 @@ struct _NautilusPreferencesGroupDetails static const gint PREFERENCES_GROUP_NOT_FOUND = -1; /* NautilusPreferencesGroupClass methods */ -static void nautilus_preferences_group_initialize_class (NautilusPreferencesGroupClass *klass); -static void nautilus_preferences_group_initialize (NautilusPreferencesGroup *preferences_group); +static void nautilus_preferences_group_initialize_class (NautilusPreferencesGroupClass *klass); +static void nautilus_preferences_group_initialize (NautilusPreferencesGroup *preferences_group); /* GtkObjectClass methods */ -static void nautilus_preferences_group_destroy (GtkObject *object); +static void nautilus_preferences_group_destroy (GtkObject *object); /* Private stuff */ -static void preferences_group_construct (NautilusPreferencesGroup *prefs_group, - const gchar * title); +static void preferences_group_construct (NautilusPreferencesGroup *prefs_group, + const gchar *title); +static void preferences_group_align_captions (NautilusPreferencesGroup *group); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferencesGroup, nautilus_preferences_group, @@ -183,6 +184,42 @@ preferences_group_construct (NautilusPreferencesGroup *group, gtk_widget_show (group->details->main_box); } +static void +preferences_group_align_captions (NautilusPreferencesGroup *group) +{ + GList *node; + NautilusPreferencesItem *item; + int max_title_width = 0; + int width; + + g_return_if_fail (NAUTILUS_IS_PREFERENCES_GROUP (group)); + + /* Compute the max caption title label width */ + for (node = group->details->items; node != NULL; node = node->next) { + g_assert (NAUTILUS_IS_PREFERENCES_ITEM (node->data)); + item = NAUTILUS_PREFERENCES_ITEM (node->data); + + if (GTK_WIDGET_VISIBLE (item) && nautilus_preferences_item_child_is_caption (item)) { + max_title_width = MAX (max_title_width, + nautilus_preferences_item_get_caption_title_label_width (item)); + } + } + + /* Set the spacing on all the captions accordingly */ + for (node = group->details->items; node != NULL; node = node->next) { + g_assert (NAUTILUS_IS_PREFERENCES_ITEM (node->data)); + item = NAUTILUS_PREFERENCES_ITEM (node->data); + + if (GTK_WIDGET_VISIBLE (item) && nautilus_preferences_item_child_is_caption (item)) { + width = nautilus_preferences_item_get_caption_title_label_width (item); + + g_assert (width <= max_title_width); + + nautilus_preferences_item_set_caption_spacing (item, max_title_width - width); + } + } +} + /* * NautilusPreferencesGroup public methods */ @@ -255,6 +292,8 @@ nautilus_preferences_group_update (NautilusPreferencesGroup *group) g_free (name); } + + preferences_group_align_captions (group); } guint @@ -276,3 +315,12 @@ nautilus_preferences_group_get_num_visible_items (const NautilusPreferencesGroup return n; } + +char * +nautilus_preferences_group_get_title_label (const NautilusPreferencesGroup *group) +{ + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_GROUP (group), NULL); + + return g_strdup (GTK_FRAME (group)->label); +} + diff --git a/libnautilus-private/nautilus-preferences-group.h b/libnautilus-private/nautilus-preferences-group.h index 1e0a3fc2a..e80bc002c 100644 --- a/libnautilus-private/nautilus-preferences-group.h +++ b/libnautilus-private/nautilus-preferences-group.h @@ -63,6 +63,7 @@ GtkWidget* nautilus_preferences_group_add_item (NautilusPreferences NautilusPreferencesItemType item_type); void nautilus_preferences_group_update (NautilusPreferencesGroup *group); guint nautilus_preferences_group_get_num_visible_items (const NautilusPreferencesGroup *group); +char * nautilus_preferences_group_get_title_label (const NautilusPreferencesGroup *group); END_GNOME_DECLS diff --git a/libnautilus-private/nautilus-preferences-item.c b/libnautilus-private/nautilus-preferences-item.c index 3253bac04..acb4cf457 100644 --- a/libnautilus-private/nautilus-preferences-item.c +++ b/libnautilus-private/nautilus-preferences-item.c @@ -58,44 +58,51 @@ struct _NautilusPreferencesItemDetails guint change_signal_ID; char *control_preference_name; NautilusPreferencesItemControlAction control_action; + int constrained_integer_lower; + int constrained_integer_upper; + int constrained_integer_increment; }; /* GtkObjectClass methods */ -static void nautilus_preferences_item_initialize_class (NautilusPreferencesItemClass *preferences_item_class); -static void nautilus_preferences_item_initialize (NautilusPreferencesItem *preferences_item); -static void preferences_item_destroy (GtkObject *object); +static void nautilus_preferences_item_initialize_class (NautilusPreferencesItemClass *preferences_item_class); +static void nautilus_preferences_item_initialize (NautilusPreferencesItem *preferences_item); +static void preferences_item_destroy (GtkObject *object); /* Private stuff */ -static void preferences_item_construct (NautilusPreferencesItem *item, - const char *preference_name, - NautilusPreferencesItemType item_type); -static void preferences_item_create_enum (NautilusPreferencesItem *item, - const char *preference_name); -static void preferences_item_create_short_enum (NautilusPreferencesItem *item, - const char *preference_name); -static void preferences_item_create_boolean (NautilusPreferencesItem *item, - const char *preference_name); -static void preferences_item_create_editable_string (NautilusPreferencesItem *item, - 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 char *preference_name); -static void preferences_item_create_smooth_font (NautilusPreferencesItem *item, - const char *preference_name); -static void preferences_item_update_text_settings_at_idle (NautilusPreferencesItem *preferences_item); -static void preferences_item_update_integer_settings_at_idle (NautilusPreferencesItem *preferences_item); -static void enum_radio_group_changed_callback (GtkWidget *button_group, - GtkWidget *button, - gpointer user_data); -static void boolean_button_toggled_callback (GtkWidget *button_group, - gpointer user_data); -static void editable_string_changed_callback (GtkWidget *caption, - gpointer user_data); -static void integer_changed_callback (GtkWidget *caption, - gpointer user_data); -static void font_family_item_changed_callback (GtkWidget *caption, - gpointer user_data); +static void preferences_item_construct (NautilusPreferencesItem *item, + const char *preference_name, + NautilusPreferencesItemType item_type); +static void preferences_item_create_enum (NautilusPreferencesItem *item, + const char *preference_name); +static void preferences_item_create_short_enum (NautilusPreferencesItem *item, + const char *preference_name); +static void preferences_item_create_boolean (NautilusPreferencesItem *item, + const char *preference_name); +static void preferences_item_create_editable_string (NautilusPreferencesItem *item, + const char *preference_name); +static void preferences_item_create_editable_integer (NautilusPreferencesItem *item, + const char *preference_name); +static void preferences_item_create_constrained_integer (NautilusPreferencesItem *item, + const char *preference_name); +static void preferences_item_create_font (NautilusPreferencesItem *item, + const char *preference_name); +static void preferences_item_create_smooth_font (NautilusPreferencesItem *item, + const char *preference_name); +static void preferences_item_update_text_settings_at_idle (NautilusPreferencesItem *preferences_item); +static void preferences_item_update_editable_integer_settings_at_idle (NautilusPreferencesItem *preferences_item); +static void enum_radio_group_changed_callback (GtkWidget *button_group, + GtkWidget *button, + gpointer user_data); +static void boolean_button_toggled_callback (GtkWidget *button_group, + gpointer user_data); +static void editable_string_changed_callback (GtkWidget *caption, + gpointer user_data); +static void editable_integer_changed_callback (GtkWidget *caption, + gpointer user_data); +static void constrained_integer_changed_callback (NautilusStringPicker *string_picker, + NautilusPreferencesItem *item); +static void font_item_changed_callback (GtkWidget *caption, + gpointer user_data); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferencesItem, nautilus_preferences_item, GTK_TYPE_VBOX) @@ -120,6 +127,10 @@ nautilus_preferences_item_initialize (NautilusPreferencesItem *item) { item->details = g_new0 (NautilusPreferencesItemDetails, 1); item->details->item_type = PREFERENCES_ITEM_UNDEFINED_ITEM; + + item->details->constrained_integer_lower = 0; + item->details->constrained_integer_upper = 10; + item->details->constrained_integer_increment = 1; } /* GtkObjectClass methods */ @@ -144,7 +155,7 @@ preferences_item_destroy (GtkObject *object) * Private stuff */ static void -preferences_item_construct (NautilusPreferencesItem *item, +preferences_item_construct (NautilusPreferencesItem *item, const char *preference_name, NautilusPreferencesItemType item_type) { @@ -175,8 +186,8 @@ preferences_item_construct (NautilusPreferencesItem *item, preferences_item_create_short_enum (item, preference_name); break; - case NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY: - preferences_item_create_font_family (item, preference_name); + case NAUTILUS_PREFERENCE_ITEM_FONT: + preferences_item_create_font (item, preference_name); break; case NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT: @@ -187,8 +198,12 @@ preferences_item_construct (NautilusPreferencesItem *item, preferences_item_create_editable_string (item, preference_name); break; - case NAUTILUS_PREFERENCE_ITEM_INTEGER: - preferences_item_create_integer (item, preference_name); + case NAUTILUS_PREFERENCE_ITEM_EDITABLE_INTEGER: + preferences_item_create_editable_integer (item, preference_name); + break; + + case NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER: + preferences_item_create_constrained_integer (item, preference_name); break; } @@ -207,7 +222,7 @@ preferences_item_construct (NautilusPreferencesItem *item, } static void -preferences_item_update_enum (const NautilusPreferencesItem *item) +preferences_item_update_enum (NautilusPreferencesItem *item) { int value; char *preference_name; @@ -227,8 +242,8 @@ preferences_item_update_enum (const NautilusPreferencesItem *item) } static void -preferences_item_create_enum (NautilusPreferencesItem *item, - const char *preference_name) +preferences_item_create_enum (NautilusPreferencesItem *item, + const char *preference_name) { guint i; @@ -256,11 +271,11 @@ preferences_item_create_enum (NautilusPreferencesItem *item, gtk_signal_connect (GTK_OBJECT (item->details->child), "changed", GTK_SIGNAL_FUNC (enum_radio_group_changed_callback), - (gpointer) item); + item); } static void -preferences_item_update_short_enum (const NautilusPreferencesItem *item) +preferences_item_update_short_enum (NautilusPreferencesItem *item) { int value; char *preference_name; @@ -284,8 +299,8 @@ preferences_item_update_short_enum (const NautilusPreferencesItem *item) * only with short text for the choices). */ static void -preferences_item_create_short_enum (NautilusPreferencesItem *item, - const char *preference_name) +preferences_item_create_short_enum (NautilusPreferencesItem *item, + const char *preference_name) { guint i; @@ -313,11 +328,11 @@ preferences_item_create_short_enum (NautilusPreferencesItem *item, gtk_signal_connect (GTK_OBJECT (item->details->child), "changed", GTK_SIGNAL_FUNC (enum_radio_group_changed_callback), - (gpointer) item); + item); } static void -preferences_item_update_boolean (const NautilusPreferencesItem *item) +preferences_item_update_boolean (NautilusPreferencesItem *item) { gboolean value; @@ -329,8 +344,8 @@ preferences_item_update_boolean (const NautilusPreferencesItem *item) } static void -preferences_item_create_boolean (NautilusPreferencesItem *item, - const char *preference_name) +preferences_item_create_boolean (NautilusPreferencesItem *item, + const char *preference_name) { char *description; @@ -351,11 +366,11 @@ preferences_item_create_boolean (NautilusPreferencesItem *item, gtk_signal_connect (GTK_OBJECT (item->details->child), "toggled", GTK_SIGNAL_FUNC (boolean_button_toggled_callback), - (gpointer) item); + item); } static void -preferences_item_update_editable_string (const NautilusPreferencesItem *item) +preferences_item_update_editable_string (NautilusPreferencesItem *item) { char *current_value; @@ -370,8 +385,8 @@ preferences_item_update_editable_string (const NautilusPreferencesItem *item) } static void -preferences_item_create_editable_string (NautilusPreferencesItem *item, - const char *preference_name) +preferences_item_create_editable_string (NautilusPreferencesItem *item, + const char *preference_name) { char *description; @@ -398,16 +413,16 @@ preferences_item_create_editable_string (NautilusPreferencesItem *item, gtk_signal_connect (GTK_OBJECT (item->details->child), "changed", GTK_SIGNAL_FUNC (editable_string_changed_callback), - (gpointer) item); + item); } static void -preferences_item_update_integer (const NautilusPreferencesItem *item) +preferences_item_update_editable_integer (NautilusPreferencesItem *item) { char *current_value; g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); - g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_INTEGER); + g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_EDITABLE_INTEGER); current_value = g_strdup_printf ("%d", nautilus_preferences_get_integer (item->details->preference_name)); @@ -417,10 +432,10 @@ preferences_item_update_integer (const NautilusPreferencesItem *item) } static void -preferences_item_create_integer (NautilusPreferencesItem *item, - const char *preference_name) +preferences_item_create_editable_integer (NautilusPreferencesItem *item, + const char *preference_name) { - char *description; + char *description; g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); g_return_if_fail (nautilus_strlen (preference_name) > 0); @@ -438,29 +453,95 @@ preferences_item_create_integer (NautilusPreferencesItem *item, item->details->change_signal_ID = gtk_signal_connect (GTK_OBJECT (item->details->child), "changed", - GTK_SIGNAL_FUNC (integer_changed_callback), - (gpointer) item); + GTK_SIGNAL_FUNC (editable_integer_changed_callback), + item); } static void -preferences_item_update_font_family (const NautilusPreferencesItem *item) +preferences_item_update_constrained_integer (NautilusPreferencesItem *item) +{ + char *current_value_string; + int current_value; + + g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); + g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER); + + current_value = nautilus_preferences_get_integer (item->details->preference_name); + current_value_string = g_strdup_printf ("%d", current_value); + + if (nautilus_string_picker_contains (NAUTILUS_STRING_PICKER (item->details->child), current_value_string)) { + nautilus_string_picker_set_selected_string (NAUTILUS_STRING_PICKER (item->details->child), + current_value_string); + } + + g_free (current_value_string); +} + +static void +preferences_item_create_constrained_integer (NautilusPreferencesItem *item, + const char *preference_name) +{ + char *description; + NautilusStringList *size_list; + int i; + char *number; + + g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); + g_return_if_fail (nautilus_strlen (preference_name) > 0); + + description = nautilus_preferences_get_description (preference_name); + g_return_if_fail (description != NULL); + + item->details->child = nautilus_string_picker_new (); + nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), description); + g_free (description); + + size_list = nautilus_string_list_new (TRUE); + + for (i = item->details->constrained_integer_lower; + i <= item->details->constrained_integer_upper; + i += item->details->constrained_integer_increment) { + number = g_strdup_printf ("%d", i); + nautilus_string_list_insert (size_list, number); + g_free (number); + } + + nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (item->details->child), size_list); + nautilus_string_list_free (size_list); + + item->details->change_signal_ID = gtk_signal_connect (GTK_OBJECT (item->details->child), + "changed", + GTK_SIGNAL_FUNC (constrained_integer_changed_callback), + item); +} + +static void +preferences_item_update_font (NautilusPreferencesItem *item) { char *current_value; g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); - g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY); + g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_FONT); current_value = nautilus_preferences_get (item->details->preference_name); g_assert (current_value != NULL); - nautilus_string_picker_set_selected_string (NAUTILUS_STRING_PICKER (item->details->child), current_value); + /* The value of the gconf preference can be anything. In theory garbage could + * be used for the preference using a third party tool. So we make sure that + * it is one of the choice before trying to select it, otherwise we would get + * assertions. + */ + if (nautilus_string_picker_contains (NAUTILUS_STRING_PICKER (item->details->child), current_value)) { + nautilus_string_picker_set_selected_string (NAUTILUS_STRING_PICKER (item->details->child), + current_value); + } g_free (current_value); } static void -preferences_item_create_font_family (NautilusPreferencesItem *item, - const char *preference_name) +preferences_item_create_font (NautilusPreferencesItem *item, + const char *preference_name) { char *description; NautilusStringList *font_list; @@ -479,23 +560,34 @@ preferences_item_create_font_family (NautilusPreferencesItem *item, /* FIXME bugzilla.eazel.com 1274: Need to query system for available fonts */ font_list = nautilus_string_list_new (TRUE); - nautilus_string_list_insert (font_list, _("helvetica")); - nautilus_string_list_insert (font_list, _("times")); - nautilus_string_list_insert (font_list, _("courier")); - nautilus_string_list_insert (font_list, _("lucida")); + /* Once upon a time we had a bug in Nautilus that caused crashes with the "fixed" + * font. That bug (2256) was fixed by removing the "fixed" choice from this menu + * below. Subsequently we fixed many font bugs in nautilus (such hard coded font sizes) + * that would cause both crashes and ugliness. Bug 2256 seems to have been fixed by + * these changes as well. + * + * Anyhow, the "fixed" font choice is not very interesting because the other fonts + * look much better. However, in multi byte locales, the fixed font is usually the + * only one that is available at the right encoding. + */ + nautilus_string_list_insert (font_list, "default"); + nautilus_string_list_insert (font_list, "fixed"); + nautilus_string_list_insert (font_list, "helvetica"); + nautilus_string_list_insert (font_list, "times"); + nautilus_string_list_insert (font_list, "courier"); + nautilus_string_list_insert (font_list, "lucida"); nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (item->details->child), font_list); nautilus_string_list_free (font_list); item->details->change_signal_ID = gtk_signal_connect (GTK_OBJECT (item->details->child), "changed", - GTK_SIGNAL_FUNC (font_family_item_changed_callback), + GTK_SIGNAL_FUNC (font_item_changed_callback), item); } - static void -preferences_item_update_smooth_font (const NautilusPreferencesItem *item) +preferences_item_update_smooth_font (NautilusPreferencesItem *item) { char *current_value; @@ -540,8 +632,8 @@ preferences_item_create_smooth_font (NautilusPreferencesItem *item, g_return_if_fail (description != NULL); item->details->child = nautilus_font_picker_new (); - nautilus_font_picker_set_title_label (NAUTILUS_FONT_PICKER (item->details->child), - description); + nautilus_caption_set_title_label (NAUTILUS_CAPTION (item->details->child), + description); g_free (description); @@ -553,8 +645,8 @@ preferences_item_create_smooth_font (NautilusPreferencesItem *item, /* NautilusPreferencesItem public methods */ GtkWidget * -nautilus_preferences_item_new (const char *preference_name, - NautilusPreferencesItemType item_type) +nautilus_preferences_item_new (const char *preference_name, + NautilusPreferencesItemType item_type) { NautilusPreferencesItem * item; @@ -573,7 +665,7 @@ nautilus_preferences_item_new (const char *preference_name, static void enum_radio_group_changed_callback (GtkWidget *buttons, GtkWidget * button, gpointer user_data) { - NautilusPreferencesItem *item; + NautilusPreferencesItem *item; int i; g_assert (user_data != NULL); @@ -592,7 +684,7 @@ enum_radio_group_changed_callback (GtkWidget *buttons, GtkWidget * button, gpoin static void boolean_button_toggled_callback (GtkWidget *button, gpointer user_data) { - NautilusPreferencesItem *item; + NautilusPreferencesItem *item; gboolean active_state; g_assert (user_data != NULL); @@ -606,9 +698,9 @@ boolean_button_toggled_callback (GtkWidget *button, gpointer user_data) } static void -font_family_item_changed_callback (GtkWidget *string_picker, gpointer user_data) +font_item_changed_callback (GtkWidget *string_picker, gpointer user_data) { - NautilusPreferencesItem *item; + NautilusPreferencesItem *item; char *selected_string; g_return_if_fail (NAUTILUS_IS_STRING_PICKER (string_picker)); @@ -629,7 +721,7 @@ font_family_item_changed_callback (GtkWidget *string_picker, gpointer user_data) static void editable_string_changed_callback (GtkWidget *button, gpointer user_data) { - NautilusPreferencesItem *item; + NautilusPreferencesItem *item; g_assert (user_data != NULL); g_assert (NAUTILUS_IS_PREFERENCES_ITEM (user_data)); @@ -643,9 +735,9 @@ editable_string_changed_callback (GtkWidget *button, gpointer user_data) } static void -integer_changed_callback (GtkWidget *button, gpointer user_data) +editable_integer_changed_callback (GtkWidget *button, gpointer user_data) { - NautilusPreferencesItem *item; + NautilusPreferencesItem *item; g_assert (user_data != NULL); g_assert (NAUTILUS_IS_PREFERENCES_ITEM (user_data)); @@ -655,7 +747,25 @@ integer_changed_callback (GtkWidget *button, gpointer user_data) g_assert (item->details->child != NULL); g_assert (NAUTILUS_IS_TEXT_CAPTION (item->details->child)); - preferences_item_update_integer_settings_at_idle (item); + preferences_item_update_editable_integer_settings_at_idle (item); +} + +static void +constrained_integer_changed_callback (NautilusStringPicker *string_picker, + NautilusPreferencesItem *item) +{ + char *new_value_string; + int new_value; + + g_return_if_fail (NAUTILUS_IS_STRING_PICKER (string_picker)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); + + new_value_string = nautilus_string_picker_get_selected_string (string_picker); + g_assert (new_value_string != NULL); + + if (nautilus_eat_str_to_int (new_value_string, &new_value)) { + nautilus_preferences_set_integer (item->details->preference_name, new_value); + } } char * @@ -667,7 +777,7 @@ nautilus_preferences_item_get_name (const NautilusPreferencesItem *preferences_i } void -nautilus_preferences_item_update_displayed_value (const NautilusPreferencesItem *item) +nautilus_preferences_item_update_displayed_value (NautilusPreferencesItem *item) { NautilusPreferencesItemType item_type; @@ -698,8 +808,8 @@ nautilus_preferences_item_update_displayed_value (const NautilusPreferencesItem preferences_item_update_short_enum (item); break; - case NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY: - preferences_item_update_font_family (item); + case NAUTILUS_PREFERENCE_ITEM_FONT: + preferences_item_update_font (item); break; case NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT: @@ -710,8 +820,12 @@ nautilus_preferences_item_update_displayed_value (const NautilusPreferencesItem preferences_item_update_editable_string (item); break; - case NAUTILUS_PREFERENCE_ITEM_INTEGER: - preferences_item_update_integer (item); + case NAUTILUS_PREFERENCE_ITEM_EDITABLE_INTEGER: + preferences_item_update_editable_integer (item); + break; + + case NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER: + preferences_item_update_constrained_integer (item); break; default: g_assert_not_reached (); @@ -769,7 +883,7 @@ update_integer_settings_at_idle (NautilusPreferencesItem *preferences_item) } static void -preferences_item_update_integer_settings_at_idle (NautilusPreferencesItem *preferences_item) +preferences_item_update_editable_integer_settings_at_idle (NautilusPreferencesItem *preferences_item) { g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (preferences_item)); @@ -832,3 +946,70 @@ nautilus_preferences_item_get_control_showing (const NautilusPreferencesItem *pr return !value; } + +void +nautilus_preferences_item_set_constrained_integer_paramaters (NautilusPreferencesItem *item, + int lower, + int upper, + int increment) +{ + NautilusStringList *size_list; + int i; + char *number; + + g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); + g_return_if_fail (item->details->item_type == NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER); + g_return_if_fail (upper >= lower); + g_return_if_fail (increment > 0); + + item->details->constrained_integer_lower = lower; + item->details->constrained_integer_upper = upper; + item->details->constrained_integer_increment = increment; + + size_list = nautilus_string_list_new (TRUE); + + for (i = item->details->constrained_integer_lower; + i <= item->details->constrained_integer_upper; + i += item->details->constrained_integer_increment) { + number = g_strdup_printf ("%d", i); + nautilus_string_list_insert (size_list, number); + g_free (number); + } + + nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (item->details->child), size_list); + nautilus_string_list_free (size_list); +} + +gboolean +nautilus_preferences_item_child_is_caption (const NautilusPreferencesItem *item) +{ + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item), FALSE); + + return NAUTILUS_IS_CAPTION (item->details->child); +} + +int +nautilus_preferences_item_get_caption_title_label_width (const NautilusPreferencesItem *item) +{ + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item), 0); + + if (!nautilus_preferences_item_child_is_caption (item)) { + return 0; + } + + return nautilus_caption_get_title_label_width (NAUTILUS_CAPTION (item->details->child)); +} + +void +nautilus_preferences_item_set_caption_spacing (NautilusPreferencesItem *item, + int spacing) +{ + g_return_if_fail (NAUTILUS_IS_PREFERENCES_ITEM (item)); + g_return_if_fail (spacing >= 0); + + if (!nautilus_preferences_item_child_is_caption (item)) { + return; + } + + return nautilus_caption_set_spacing (NAUTILUS_CAPTION (item->details->child), spacing); +} diff --git a/libnautilus-private/nautilus-preferences-item.h b/libnautilus-private/nautilus-preferences-item.h index 56348b2ef..dfb6b410f 100644 --- a/libnautilus-private/nautilus-preferences-item.h +++ b/libnautilus-private/nautilus-preferences-item.h @@ -66,10 +66,11 @@ typedef enum NAUTILUS_PREFERENCE_ITEM_BOOLEAN, NAUTILUS_PREFERENCE_ITEM_ENUM, NAUTILUS_PREFERENCE_ITEM_SHORT_ENUM, - NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY, + NAUTILUS_PREFERENCE_ITEM_FONT, NAUTILUS_PREFERENCE_ITEM_SMOOTH_FONT, NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING, - NAUTILUS_PREFERENCE_ITEM_INTEGER + NAUTILUS_PREFERENCE_ITEM_EDITABLE_INTEGER, + NAUTILUS_PREFERENCE_ITEM_CONSTRAINED_INTEGER } NautilusPreferencesItemType; typedef enum @@ -78,16 +79,24 @@ typedef enum NAUTILUS_PREFERENCE_ITEM_HIDE } NautilusPreferencesItemControlAction; -GtkType nautilus_preferences_item_get_type (void); -GtkWidget* nautilus_preferences_item_new (const char *preference_name, - NautilusPreferencesItemType item_type); -char * nautilus_preferences_item_get_name (const NautilusPreferencesItem *preferences_item); -void nautilus_preferences_item_update_displayed_value (const NautilusPreferencesItem *preferences_item); -void nautilus_preferences_item_set_control_preference (NautilusPreferencesItem *preferences_item, - const char *control_preference_name); -void nautilus_preferences_item_set_control_action (NautilusPreferencesItem *preferences_item, - NautilusPreferencesItemControlAction control_action); -gboolean nautilus_preferences_item_get_control_showing (const NautilusPreferencesItem *preferences_item); +GtkType nautilus_preferences_item_get_type (void); +GtkWidget* nautilus_preferences_item_new (const char *preference_name, + NautilusPreferencesItemType item_type); +char * nautilus_preferences_item_get_name (const NautilusPreferencesItem *preferences_item); +void nautilus_preferences_item_update_displayed_value (NautilusPreferencesItem *preferences_item); +void nautilus_preferences_item_set_control_preference (NautilusPreferencesItem *preferences_item, + const char *control_preference_name); +void nautilus_preferences_item_set_control_action (NautilusPreferencesItem *preferences_item, + NautilusPreferencesItemControlAction control_action); +gboolean nautilus_preferences_item_get_control_showing (const NautilusPreferencesItem *preferences_item); +void nautilus_preferences_item_set_constrained_integer_paramaters (NautilusPreferencesItem *preferences_item, + int lower, + int upper, + int increment); +gboolean nautilus_preferences_item_child_is_caption (const NautilusPreferencesItem *preferences_item); +int nautilus_preferences_item_get_caption_title_label_width (const NautilusPreferencesItem *item); +void nautilus_preferences_item_set_caption_spacing (NautilusPreferencesItem *item, + int spacing); END_GNOME_DECLS diff --git a/libnautilus-private/nautilus-preferences-pane.c b/libnautilus-private/nautilus-preferences-pane.c index 3466661de..8f53aa249 100644 --- a/libnautilus-private/nautilus-preferences-pane.c +++ b/libnautilus-private/nautilus-preferences-pane.c @@ -27,6 +27,7 @@ #include "nautilus-preferences-pane.h" #include "nautilus-gtk-macros.h" #include "nautilus-gtk-extensions.h" +#include "nautilus-string.h" #include <gtk/gtkhbox.h> @@ -115,19 +116,18 @@ nautilus_preferences_pane_new (void) } GtkWidget * -nautilus_preferences_pane_add_group (NautilusPreferencesPane *preferences_pane, - const char *group_title) +nautilus_preferences_pane_add_group (NautilusPreferencesPane *preferences_pane, + const char *group_title) { GtkWidget *group; - - g_return_val_if_fail (preferences_pane != NULL, NULL); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_PANE (preferences_pane), NULL); g_return_val_if_fail (group_title != NULL, NULL); group = nautilus_preferences_group_new (group_title); preferences_pane->details->groups = g_list_append (preferences_pane->details->groups, - (gpointer) group); + group); gtk_box_pack_start (GTK_BOX (preferences_pane->details->groups_box), group, @@ -149,9 +149,7 @@ nautilus_preferences_pane_add_item_to_nth_group (NautilusPreferencesPane *prefer GtkWidget *item; GtkWidget *group; - g_return_val_if_fail (preferences_pane != NULL, NULL); g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_PANE (preferences_pane), NULL); - g_return_val_if_fail (preference_name != NULL, NULL); if (!preferences_pane->details->groups) { @@ -209,3 +207,35 @@ nautilus_preferences_pane_get_num_visible_groups (const NautilusPreferencesPane return n; } + +guint +nautilus_preferences_pane_get_num_groups (const NautilusPreferencesPane *pane) +{ + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_PANE (pane), 0); + + return g_list_length (pane->details->groups); +} + +GtkWidget * +nautilus_preferences_pane_find_group (const NautilusPreferencesPane *pane, + const char *group_title) +{ + GList *node; + char *title; + + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES_PANE (pane), 0); + + for (node = pane->details->groups; node != NULL; node = node->next) { + g_assert (NAUTILUS_IS_PREFERENCES_GROUP (node->data)); + + title = nautilus_preferences_group_get_title_label (NAUTILUS_PREFERENCES_GROUP (node->data)); + if (nautilus_str_is_equal (title, group_title)) { + g_free (title); + return node->data; + } + + g_free (title); + } + + return NULL; +} diff --git a/libnautilus-private/nautilus-preferences-pane.h b/libnautilus-private/nautilus-preferences-pane.h index 0b0fc3702..1991f375b 100644 --- a/libnautilus-private/nautilus-preferences-pane.h +++ b/libnautilus-private/nautilus-preferences-pane.h @@ -64,7 +64,10 @@ GtkWidget *nautilus_preferences_pane_add_item_to_nth_group (NautilusPreferences const char *preference_name, NautilusPreferencesItemType item_type); void nautilus_preferences_pane_update (NautilusPreferencesPane *preferences_pane); +guint nautilus_preferences_pane_get_num_groups (const NautilusPreferencesPane *pane); guint nautilus_preferences_pane_get_num_visible_groups (const NautilusPreferencesPane *pane); +GtkWidget* nautilus_preferences_pane_find_group (const NautilusPreferencesPane *preferences_pane, + const char *group_title); END_GNOME_DECLS diff --git a/libnautilus-private/nautilus-scalable-font.c b/libnautilus-private/nautilus-scalable-font.c index 875d5843d..7b4739fd3 100644 --- a/libnautilus-private/nautilus-scalable-font.c +++ b/libnautilus-private/nautilus-scalable-font.c @@ -300,16 +300,7 @@ nautilus_scalable_font_get_default_font (void) char *default_font_file_name; NautilusScalableFont *default_font; - /* FIXME bugzilla.eazel.com 7344: - * Its evil that we have to peek preferences here to - * find the default smooth font, but so it goes. - */ - default_font_file_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_DIRECTORY_VIEW_SMOOTH_FONT); - if (!g_file_exists (default_font_file_name)) { - g_free (default_font_file_name); - default_font_file_name = nautilus_font_manager_get_default_font (); - } - + default_font_file_name = nautilus_font_manager_get_default_font (); g_assert (default_font_file_name != NULL); default_font = nautilus_scalable_font_new (default_font_file_name); g_free (default_font_file_name); @@ -323,16 +314,7 @@ nautilus_scalable_font_get_default_bold_font (void) char *default_bold_font_file_name; NautilusScalableFont *default_bold_font; - /* FIXME bugzilla.eazel.com 7344: - * Its evil that we have to peek preferences here to - * find the default smooth font, but so it goes. - */ - default_bold_font_file_name = nautilus_preferences_get ("directory-view/smooth_font"); - if (!g_file_exists (default_bold_font_file_name)) { - g_free (default_bold_font_file_name); - default_bold_font_file_name = nautilus_font_manager_get_default_bold_font (); - } - + default_bold_font_file_name = nautilus_font_manager_get_default_bold_font (); g_assert (default_bold_font_file_name != NULL); default_bold_font = nautilus_scalable_font_new (default_bold_font_file_name); g_free (default_bold_font_file_name); diff --git a/libnautilus-private/nautilus-smooth-text-layout.c b/libnautilus-private/nautilus-smooth-text-layout.c index 9905c7c31..52fcb3dd2 100644 --- a/libnautilus-private/nautilus-smooth-text-layout.c +++ b/libnautilus-private/nautilus-smooth-text-layout.c @@ -249,7 +249,7 @@ smooth_text_layout_line_list_new (const char *text, g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), NULL); g_return_val_if_fail (text_length >= 0, NULL); - g_return_val_if_fail (font_size > MIN_FONT_SIZE, NULL); + g_return_val_if_fail (font_size >= MIN_FONT_SIZE, NULL); end = text + text_length; @@ -402,7 +402,7 @@ smooth_text_layout_line_list_new_wrapped (const char *text, g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), NULL); g_return_val_if_fail (text_length >= 0, NULL); - g_return_val_if_fail (font_size > MIN_FONT_SIZE, NULL); + g_return_val_if_fail (font_size >= MIN_FONT_SIZE, NULL); g_return_val_if_fail (max_width > 0, NULL); g_return_val_if_fail (line_break_characters != NULL, NULL); g_return_val_if_fail (line_break_characters[0] != '\0', NULL); @@ -605,7 +605,7 @@ nautilus_smooth_text_layout_new (const char *text, NautilusSmoothTextLayout *smooth_text_layout; g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), NULL); - g_return_val_if_fail (font_size > MIN_FONT_SIZE, NULL); + g_return_val_if_fail (font_size >= MIN_FONT_SIZE, NULL); smooth_text_layout = NAUTILUS_SMOOTH_TEXT_LAYOUT (gtk_object_new (nautilus_smooth_text_layout_get_type (), NULL)); gtk_object_ref (GTK_OBJECT (smooth_text_layout)); @@ -896,7 +896,7 @@ nautilus_smooth_text_layout_set_font_size (NautilusSmoothTextLayout *smooth_text int font_size) { g_return_if_fail (NAUTILUS_IS_SMOOTH_TEXT_LAYOUT (smooth_text_layout)); - g_return_if_fail (font_size > MIN_FONT_SIZE); + g_return_if_fail (font_size >= MIN_FONT_SIZE); if (smooth_text_layout->details->font_size == font_size) { return; diff --git a/libnautilus-private/nautilus-string-picker.c b/libnautilus-private/nautilus-string-picker.c index 370266393..8b1043e43 100644 --- a/libnautilus-private/nautilus-string-picker.c +++ b/libnautilus-private/nautilus-string-picker.c @@ -109,7 +109,9 @@ nautilus_string_picker_initialize (NautilusStringPicker *string_picker) string_picker->detail->option_menu = gtk_option_menu_new (); nautilus_caption_set_child (NAUTILUS_CAPTION (string_picker), - string_picker->detail->option_menu); + string_picker->detail->option_menu, + FALSE, + FALSE); gtk_widget_show (string_picker->detail->option_menu); } @@ -214,14 +216,6 @@ nautilus_string_picker_set_string_list (NautilusStringPicker *string_picker, } - /* Allow the string picker to be sensitive only if there is a choice */ - if (nautilus_string_list_get_length (string_picker->detail->string_list) > 1) { - gtk_widget_set_sensitive (GTK_WIDGET (string_picker), TRUE); - } - else { - gtk_widget_set_sensitive (GTK_WIDGET (string_picker), FALSE); - } - /* Attatch the menu to the option button */ gtk_option_menu_set_menu (GTK_OPTION_MENU (string_picker->detail->option_menu), string_picker->detail->menu); } diff --git a/libnautilus-private/nautilus-text-caption.c b/libnautilus-private/nautilus-text-caption.c index 0c1856257..6fcc3558f 100644 --- a/libnautilus-private/nautilus-text-caption.c +++ b/libnautilus-private/nautilus-text-caption.c @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* nautilus-string-picker.c - A widget to pick a string from a list. +/* nautilus-text-caption.c - A text caption widget. Copyright (C) 1999, 2000 Eazel, Inc. @@ -111,11 +111,13 @@ nautilus_text_caption_initialize (NautilusTextCaption *text_caption) gtk_box_set_spacing (GTK_BOX (text_caption), TEXT_CAPTION_SPACING); text_caption->detail->text = gtk_entry_new (); - + gtk_entry_set_editable (GTK_ENTRY (text_caption->detail->text), TRUE); - + nautilus_caption_set_child (NAUTILUS_CAPTION (text_caption), - text_caption->detail->text); + text_caption->detail->text, + TRUE, + TRUE); gtk_signal_connect (GTK_OBJECT (text_caption->detail->text), "changed", diff --git a/libnautilus-private/nautilus-text-caption.h b/libnautilus-private/nautilus-text-caption.h index d157e041e..eda774889 100644 --- a/libnautilus-private/nautilus-text-caption.h +++ b/libnautilus-private/nautilus-text-caption.h @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* nautilus-string-picker.h - A widget to pick a string from a list. +/* nautilus-text-caption.c - A text caption widget. Copyright (C) 1999, 2000 Eazel, Inc. @@ -48,31 +48,30 @@ typedef struct _NautilusTextCaptionDetail NautilusTextCaptionDetail; struct _NautilusTextCaption { /* Super Class */ - NautilusCaption caption; + NautilusCaption caption; /* Private stuff */ - NautilusTextCaptionDetail *detail; + NautilusTextCaptionDetail *detail; }; struct _NautilusTextCaptionClass { - NautilusCaptionClass parent_class; + NautilusCaptionClass parent_class; }; GtkType nautilus_text_caption_get_type (void); GtkWidget* nautilus_text_caption_new (void); /* Entry text accesor. */ -char *nautilus_text_caption_get_text (const NautilusTextCaption *text_caption); +char *nautilus_text_caption_get_text (const NautilusTextCaption *text_caption); /* Entry text mutator. */ -void nautilus_text_caption_set_text (NautilusTextCaption *text_caption, - const char *text); -void nautilus_text_caption_set_editable (NautilusTextCaption *text_caption, - gboolean editable); - -void nautilus_text_caption_set_expand_tilde (NautilusTextCaption *text_caption, - gboolean expand_tilde); +void nautilus_text_caption_set_text (NautilusTextCaption *text_caption, + const char *text); +void nautilus_text_caption_set_editable (NautilusTextCaption *text_caption, + gboolean editable); +void nautilus_text_caption_set_expand_tilde (NautilusTextCaption *text_caption, + gboolean expand_tilde); END_GNOME_DECLS |