diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-global-preferences.c | 27 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-preferences-pane.c | 36 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-preferences-pane.h | 2 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.c | 27 | ||||
-rw-r--r-- | libnautilus-private/nautilus-preferences-pane.c | 36 | ||||
-rw-r--r-- | libnautilus-private/nautilus-preferences-pane.h | 2 |
7 files changed, 103 insertions, 48 deletions
@@ -1,5 +1,26 @@ 2001-03-30 Ramiro Estrugo <ramiro@eazel.com> + reviewed by: Mike Fleming <mfleming@eazel.com> + + * libnautilus-extensions/nautilus-global-preferences.c: + (global_preferences_create_dialog), + (global_preferences_populate_pane): + No need to explicitly add pane update callbacks for control + preference. These happen automatically as needed now. + + * libnautilus-extensions/nautilus-preferences-pane.h: + * libnautilus-extensions/nautilus-preferences-pane.c: + (nautilus_preferences_pane_destroy), + (nautilus_preferences_pane_find_group), + (preferences_pane_control_preference_changed_callback), + (nautilus_preferences_pane_add_control_preference): + New function to add control preferences to the pane. For each + unique control preference, a callback will be added to update the + pane so that control actions (such as hiding or showing items) can + take place as needed. + +2001-03-30 Ramiro Estrugo <ramiro@eazel.com> + reviewed by: John Sullivan <sullivan@eazel.com> * components/text/nautilus-text-view.c: (merge_bonobo_menu_items): diff --git a/libnautilus-extensions/nautilus-global-preferences.c b/libnautilus-extensions/nautilus-global-preferences.c index b205a19f9..121cbaa50 100644 --- a/libnautilus-extensions/nautilus-global-preferences.c +++ b/libnautilus-extensions/nautilus-global-preferences.c @@ -75,7 +75,6 @@ static int compare_view_identifiers (gconstp 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 PreferenceDialogItem *preference_dialog_item); @@ -929,12 +928,6 @@ global_preferences_create_dialog (void) _("Appearance"), appearance_items); - nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - global_preferences_pane_update_callback, - appearance_pane, - GTK_OBJECT (prefs_dialog)); - - /* Windows & Desktop */ global_preferences_populate_pane (preference_box, _("Windows & Desktop"), @@ -945,11 +938,6 @@ global_preferences_create_dialog (void) _("Icon & List Views"), directory_views_items); - nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - global_preferences_pane_update_callback, - directory_views_pane, - GTK_OBJECT (prefs_dialog)); - /* Sidebar Panels */ global_preferences_create_sidebar_panels_pane (preference_box); @@ -1111,18 +1099,6 @@ global_preferences_create_sidebar_panels_pane (NautilusPreferencesBox *preferenc sidebar_items); } -/* 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 -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)); -} - /* Make a query to find out what sidebar panels are available. */ static GList * global_preferences_get_sidebar_panel_view_identifiers (void) @@ -1526,6 +1502,9 @@ global_preferences_populate_pane (NautilusPreferencesBox *preference_box, preference_dialog_item[i].control_preference_name); nautilus_preferences_item_set_control_action (NAUTILUS_PREFERENCES_ITEM (item), preference_dialog_item[i].control_action); + + nautilus_preferences_pane_add_control_preference (NAUTILUS_PREFERENCES_PANE (pane), + preference_dialog_item[i].control_preference_name); } } diff --git a/libnautilus-extensions/nautilus-preferences-pane.c b/libnautilus-extensions/nautilus-preferences-pane.c index 8f53aa249..92d90eb54 100644 --- a/libnautilus-extensions/nautilus-preferences-pane.c +++ b/libnautilus-extensions/nautilus-preferences-pane.c @@ -28,6 +28,7 @@ #include "nautilus-gtk-macros.h" #include "nautilus-gtk-extensions.h" #include "nautilus-string.h" +#include "nautilus-string-list.h" #include <gtk/gtkhbox.h> @@ -38,6 +39,7 @@ struct _NautilusPreferencesPaneDetails { GtkWidget *groups_box; GList *groups; + NautilusStringList *control_preference_list; }; /* NautilusPreferencesPaneClass methods */ @@ -82,6 +84,7 @@ nautilus_preferences_pane_destroy (GtkObject* object) preferences_pane = NAUTILUS_PREFERENCES_PANE (object); g_list_free (preferences_pane->details->groups); + nautilus_string_list_free (preferences_pane->details->control_preference_list); g_free (preferences_pane->details); /* Chain destroy */ @@ -239,3 +242,36 @@ nautilus_preferences_pane_find_group (const NautilusPreferencesPane *pane, return NULL; } + +static void +preferences_pane_control_preference_changed_callback (gpointer callback_data) +{ + g_return_if_fail (NAUTILUS_IS_PREFERENCES_PANE (callback_data)); + + nautilus_preferences_pane_update (NAUTILUS_PREFERENCES_PANE (callback_data)); +} + +void +nautilus_preferences_pane_add_control_preference (NautilusPreferencesPane *pane, + const char *control_preference_name) +{ + g_return_if_fail (NAUTILUS_IS_PREFERENCES_PANE (pane)); + g_return_if_fail (control_preference_name != NULL); + + if (nautilus_string_list_contains (pane->details->control_preference_list, + control_preference_name)) { + return; + } + + if (pane->details->control_preference_list == NULL) { + pane->details->control_preference_list = nautilus_string_list_new (TRUE); + } + + nautilus_string_list_insert (pane->details->control_preference_list, + control_preference_name); + + nautilus_preferences_add_callback_while_alive (control_preference_name, + preferences_pane_control_preference_changed_callback, + pane, + GTK_OBJECT (pane)); +} diff --git a/libnautilus-extensions/nautilus-preferences-pane.h b/libnautilus-extensions/nautilus-preferences-pane.h index 1991f375b..c51bd26a4 100644 --- a/libnautilus-extensions/nautilus-preferences-pane.h +++ b/libnautilus-extensions/nautilus-preferences-pane.h @@ -68,6 +68,8 @@ guint nautilus_preferences_pane_get_num_groups (const NautilusPrefe 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); +void nautilus_preferences_pane_add_control_preference (NautilusPreferencesPane *preferences_pane, + const char *control_preference_name); END_GNOME_DECLS diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c index b205a19f9..121cbaa50 100644 --- a/libnautilus-private/nautilus-global-preferences.c +++ b/libnautilus-private/nautilus-global-preferences.c @@ -75,7 +75,6 @@ static int compare_view_identifiers (gconstp 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 PreferenceDialogItem *preference_dialog_item); @@ -929,12 +928,6 @@ global_preferences_create_dialog (void) _("Appearance"), appearance_items); - nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - global_preferences_pane_update_callback, - appearance_pane, - GTK_OBJECT (prefs_dialog)); - - /* Windows & Desktop */ global_preferences_populate_pane (preference_box, _("Windows & Desktop"), @@ -945,11 +938,6 @@ global_preferences_create_dialog (void) _("Icon & List Views"), directory_views_items); - nautilus_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, - global_preferences_pane_update_callback, - directory_views_pane, - GTK_OBJECT (prefs_dialog)); - /* Sidebar Panels */ global_preferences_create_sidebar_panels_pane (preference_box); @@ -1111,18 +1099,6 @@ global_preferences_create_sidebar_panels_pane (NautilusPreferencesBox *preferenc sidebar_items); } -/* 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 -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)); -} - /* Make a query to find out what sidebar panels are available. */ static GList * global_preferences_get_sidebar_panel_view_identifiers (void) @@ -1526,6 +1502,9 @@ global_preferences_populate_pane (NautilusPreferencesBox *preference_box, preference_dialog_item[i].control_preference_name); nautilus_preferences_item_set_control_action (NAUTILUS_PREFERENCES_ITEM (item), preference_dialog_item[i].control_action); + + nautilus_preferences_pane_add_control_preference (NAUTILUS_PREFERENCES_PANE (pane), + preference_dialog_item[i].control_preference_name); } } diff --git a/libnautilus-private/nautilus-preferences-pane.c b/libnautilus-private/nautilus-preferences-pane.c index 8f53aa249..92d90eb54 100644 --- a/libnautilus-private/nautilus-preferences-pane.c +++ b/libnautilus-private/nautilus-preferences-pane.c @@ -28,6 +28,7 @@ #include "nautilus-gtk-macros.h" #include "nautilus-gtk-extensions.h" #include "nautilus-string.h" +#include "nautilus-string-list.h" #include <gtk/gtkhbox.h> @@ -38,6 +39,7 @@ struct _NautilusPreferencesPaneDetails { GtkWidget *groups_box; GList *groups; + NautilusStringList *control_preference_list; }; /* NautilusPreferencesPaneClass methods */ @@ -82,6 +84,7 @@ nautilus_preferences_pane_destroy (GtkObject* object) preferences_pane = NAUTILUS_PREFERENCES_PANE (object); g_list_free (preferences_pane->details->groups); + nautilus_string_list_free (preferences_pane->details->control_preference_list); g_free (preferences_pane->details); /* Chain destroy */ @@ -239,3 +242,36 @@ nautilus_preferences_pane_find_group (const NautilusPreferencesPane *pane, return NULL; } + +static void +preferences_pane_control_preference_changed_callback (gpointer callback_data) +{ + g_return_if_fail (NAUTILUS_IS_PREFERENCES_PANE (callback_data)); + + nautilus_preferences_pane_update (NAUTILUS_PREFERENCES_PANE (callback_data)); +} + +void +nautilus_preferences_pane_add_control_preference (NautilusPreferencesPane *pane, + const char *control_preference_name) +{ + g_return_if_fail (NAUTILUS_IS_PREFERENCES_PANE (pane)); + g_return_if_fail (control_preference_name != NULL); + + if (nautilus_string_list_contains (pane->details->control_preference_list, + control_preference_name)) { + return; + } + + if (pane->details->control_preference_list == NULL) { + pane->details->control_preference_list = nautilus_string_list_new (TRUE); + } + + nautilus_string_list_insert (pane->details->control_preference_list, + control_preference_name); + + nautilus_preferences_add_callback_while_alive (control_preference_name, + preferences_pane_control_preference_changed_callback, + pane, + GTK_OBJECT (pane)); +} diff --git a/libnautilus-private/nautilus-preferences-pane.h b/libnautilus-private/nautilus-preferences-pane.h index 1991f375b..c51bd26a4 100644 --- a/libnautilus-private/nautilus-preferences-pane.h +++ b/libnautilus-private/nautilus-preferences-pane.h @@ -68,6 +68,8 @@ guint nautilus_preferences_pane_get_num_groups (const NautilusPrefe 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); +void nautilus_preferences_pane_add_control_preference (NautilusPreferencesPane *preferences_pane, + const char *control_preference_name); END_GNOME_DECLS |