[nautilus] Convert last eel_preference users to raw gconf
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Convert last eel_preference users to raw gconf
- Date: Fri, 23 Jul 2010 10:34:59 +0000 (UTC)
commit e85f7b768edd103a48dc18993edd431fd880f5d4
Author: Alexander Larsson <alexl redhat com>
Date: Fri Jul 23 11:47:34 2010 +0200
Convert last eel_preference users to raw gconf
This is moslty the lockdown stuff, but we also access the background
setting. This should be converted to use the new gsettings when they
land.
libnautilus-private/nautilus-global-preferences.c | 202 +-------------------
libnautilus-private/nautilus-global-preferences.h | 5 +-
src/file-manager/fm-desktop-icon-view.c | 34 ++--
src/file-manager/fm-directory-view.c | 28 ++-
src/nautilus-connect-server-dialog-main.c | 1 +
5 files changed, 56 insertions(+), 214 deletions(-)
---
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 2a2da50..a6b9c17 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -40,16 +40,10 @@
#define PREFERENCES_SORT_ORDER_MANUALLY 100
/* Path for gnome-vfs preferences */
-static const char *EXTRA_MONITOR_PATHS[] = { "/desktop/gnome/file_views",
- "/desktop/gnome/background",
+static const char *EXTRA_MONITOR_PATHS[] = { "/desktop/gnome/background",
"/desktop/gnome/lockdown",
NULL };
-/* Forward declarations */
-static void global_preferences_install_defaults (void);
-static void global_preferences_register_enumerations (void);
-
-
/* An enumeration used for installing type specific preferences defaults. */
typedef enum
{
@@ -59,48 +53,6 @@ typedef enum
PREFERENCE_STRING_ARRAY
} PreferenceType;
-static EelEnumerationEntry default_zoom_level_enum_entries[] = {
- /* xgettext:no-c-format */
- { "smallest", N_("25%"), NAUTILUS_ZOOM_LEVEL_SMALLEST },
- /* xgettext:no-c-format */
- { "smaller", N_("50%"), NAUTILUS_ZOOM_LEVEL_SMALLER },
- /* xgettext:no-c-format */
- { "small", N_("75%"), NAUTILUS_ZOOM_LEVEL_SMALL },
- /* xgettext:no-c-format */
- { "standard", N_("100%"), NAUTILUS_ZOOM_LEVEL_STANDARD },
- /* xgettext:no-c-format */
- { "large", N_("150%"), NAUTILUS_ZOOM_LEVEL_LARGE },
- /* xgettext:no-c-format */
- { "larger", N_("200%"), NAUTILUS_ZOOM_LEVEL_LARGER },
- /* xgettext:no-c-format */
- { "largest", N_("400%"), NAUTILUS_ZOOM_LEVEL_LARGEST }
-};
-
-static EelEnumerationEntry file_size_enum_entries[] = {
- { "102400", N_("100 K"), 102400 },
- { "512000", N_("500 K"), 512000 },
- { "1048576", N_("1 MB"), 1048576 },
- { "3145728", N_("3 MB"), 3145728 },
- { "5242880", N_("5 MB"), 5242880 },
- { "10485760", N_("10 MB"), 10485760 },
- { "104857600", N_("100 MB"), 104857600 },
- { "1073741824", N_("1 GB"), 1073741824 },
- { "2147483648", N_("2 GB"), 2147483648U },
- { "4294967295", N_("4 GB"), 4294967295U }
-};
-
-static EelEnumerationEntry standard_font_size_entries[] = {
- { "8", N_("8"), 8 },
- { "10", N_("10"), 10 },
- { "12", N_("12"), 12 },
- { "14", N_("14"), 14 },
- { "16", N_("16"), 16 },
- { "18", N_("18"), 18 },
- { "20", N_("20"), 20 },
- { "22", N_("22"), 22 },
- { "24", N_("24"), 24 }
-};
-
/*
* A callback which can be used to fetch dynamic fallback values.
* For example, values that are dependent on the environment (such as user name)
@@ -155,138 +107,6 @@ typedef struct
* what choices and descriptions of choices to present to the user.
*/
-/* NOTE THAT THE FALLBACKS HERE ARE NOT SUPPOSED TO BE USED -
- * YOU SHOULD EDIT THE SCHEMAS FILE TO CHANGE DEFAULTS.
- */
-static const PreferenceDefault preference_defaults[] = {
-
- { NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- PREFERENCE_BOOLEAN,
- GINT_TO_POINTER (FALSE)
- },
- { NULL }
-};
-
-/**
- * global_preferences_register_enumerations
- *
- * Register enumerations for INTEGER preferences that need them.
- *
- * This function needs to be called before the preferences dialog
- * panes are populated, as they use the registered information to
- * create enumeration item widgets.
- */
-static void
-global_preferences_register_enumerations (void)
-{
- guint i;
-
- /* Register the enumerations.
- * These enumerations are used in the preferences dialog to
- * populate widgets and route preferences changes between the
- * storage (GConf) and the displayed values.
- */
- eel_enumeration_register ("default_zoom_level",
- default_zoom_level_enum_entries,
- G_N_ELEMENTS (default_zoom_level_enum_entries));
- eel_enumeration_register ("file_size",
- file_size_enum_entries,
- G_N_ELEMENTS (file_size_enum_entries));
- eel_enumeration_register ("standard_font_size",
- standard_font_size_entries,
- G_N_ELEMENTS (standard_font_size_entries));
-
- /* Set the enumeration ids for preferences that need them */
- for (i = 0; preference_defaults[i].name != NULL; i++) {
- if (eel_strlen (preference_defaults[i].enumeration_id) > 0) {
- g_assert (preference_defaults[i].type == PREFERENCE_STRING
- || preference_defaults[i].type == PREFERENCE_STRING_ARRAY
- || preference_defaults[i].type == PREFERENCE_INTEGER);
- eel_preferences_set_enumeration_id (preference_defaults[i].name,
- preference_defaults[i].enumeration_id);
- }
- }
-}
-
-static void
-global_preferences_install_one_default (const char *preference_name,
- PreferenceType preference_type,
- const PreferenceDefault *preference_default)
-{
- gpointer value = NULL;
- char **string_array_value;
-
- g_return_if_fail (preference_name != NULL);
- g_return_if_fail (preference_type >= PREFERENCE_BOOLEAN);
- g_return_if_fail (preference_type <= PREFERENCE_STRING_ARRAY);
- g_return_if_fail (preference_default != NULL);
-
- /* If a callback is given, use that to fetch the default value */
- if (preference_default->fallback_callback != NULL) {
- value = (* preference_default->fallback_callback) ();
- } else {
- value = preference_default->fallback_value;
- }
-
- switch (preference_type) {
- case PREFERENCE_BOOLEAN:
- eel_preferences_set_emergency_fallback_boolean (preference_name,
- GPOINTER_TO_INT (value));
- break;
-
- case PREFERENCE_INTEGER:
- eel_preferences_set_emergency_fallback_integer (preference_name,
-
- GPOINTER_TO_INT (value));
- break;
-
- case PREFERENCE_STRING:
- eel_preferences_set_emergency_fallback_string (preference_name,
- value);
- break;
-
- case PREFERENCE_STRING_ARRAY:
- string_array_value = g_strsplit (value,
- STRING_ARRAY_DEFAULT_TOKENS_DELIMETER,
- -1);
- eel_preferences_set_emergency_fallback_string_array (preference_name,
- string_array_value);
- g_strfreev (string_array_value);
- break;
-
- default:
- g_assert_not_reached ();
- }
-
- /* Free the dynamic default value if needed */
- if (preference_default->fallback_callback != NULL
- && preference_default->fallback_callback_result_free_function != NULL) {
- (* preference_default->fallback_callback_result_free_function) (value);
- }
-}
-
-/**
- * global_preferences_install_defaults
- *
- * Install defaults and visibilities.
- *
- * Most of the defaults come from the preference_defaults table above.
- *
- * Many preferences require their defaults to be computed, and so there
- * are special functions to install those.
- */
-static void
-global_preferences_install_defaults (void)
-{
- guint i;
-
- for (i = 0; preference_defaults[i].name != NULL; i++) {
- global_preferences_install_one_default (preference_defaults[i].name,
- preference_defaults[i].type,
- &preference_defaults[i]);
- }
-}
-
/*
* Public functions
*/
@@ -324,16 +144,6 @@ nautilus_global_preferences_init (void)
eel_preferences_init ("/apps/nautilus");
- /* Install defaults */
- global_preferences_install_defaults ();
-
- global_preferences_register_enumerations ();
-
- /* Add monitors for any other GConf paths we have keys in */
- for (i=0; EXTRA_MONITOR_PATHS[i] != NULL; i++) {
- eel_preferences_monitor_directory (EXTRA_MONITOR_PATHS[i]);
- }
-
nautilus_preferences = g_settings_new("org.gnome.nautilus.preferences");
nautilus_media_preferences = g_settings_new("org.gnome.media-handling");
nautilus_window_state = g_settings_new("org.gnome.nautilus.window-state");
@@ -343,6 +153,16 @@ nautilus_global_preferences_init (void)
nautilus_desktop_preferences = g_settings_new("org.gnome.nautilus.desktop");
nautilus_tree_sidebar_preferences = g_settings_new("org.gnome.nautilus.sidebar-panels.tree");
+ nautilus_gconf_client = gconf_client_get_default ();
+
+ /* Add monitors for any other GConf paths we have keys in */
+ for (i=0; EXTRA_MONITOR_PATHS[i] != NULL; i++) {
+ gconf_client_add_dir (nautilus_gconf_client,
+ EXTRA_MONITOR_PATHS[i],
+ GCONF_CLIENT_PRELOAD_ONELEVEL,
+ NULL);
+ }
+
/* Preload everything in a big batch */
eel_gconf_preload_cache ("/apps/nautilus/preferences",
GCONF_CLIENT_PRELOAD_ONELEVEL);
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index bccb59a..d25fcbf 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -27,6 +27,7 @@
#define NAUTILUS_GLOBAL_PREFERENCES_H
#include <eel/eel-preferences.h>
+#include <libnautilus-private/nautilus-global-preferences.h>
#include <gio/gio.h>
G_BEGIN_DECLS
@@ -204,7 +205,7 @@ typedef enum
#define NAUTILUS_PREFERENCES_DESKTOP_NETWORK_NAME "network-icon-name"
/* Lockdown */
-#define NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE "/desktop/gnome/lockdown/disable_command_line"
+#define NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE "/desktop/gnome/lockdown/disable_command_line"
void nautilus_global_preferences_init (void);
char *nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void);
@@ -218,6 +219,8 @@ GSettings *nautilus_tree_sidebar_preferences;
GSettings *nautilus_media_preferences;
GSettings *nautilus_window_state;
+GConfClient *nautilus_gconf_client;
+
G_END_DECLS
#endif /* NAUTILUS_GLOBAL_PREFERENCES_H */
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index 5dde0d9..abd124a 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -72,12 +72,14 @@ struct FMDesktopIconViewDetails
GdkWindow *root_window;
GtkActionGroup *desktop_action_group;
guint desktop_merge_id;
-
+
/* For the desktop rescanning
*/
gulong delayed_init_signal;
guint reload_desktop_timeout;
gboolean pending_rescan;
+
+ guint lockdown_notification_id;
};
static void fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view);
@@ -108,7 +110,10 @@ desktop_directory_changed_callback (gpointer callback_data)
}
static void
-lockdown_disable_command_line_changed_callback (gpointer callback_data)
+lockdown_disable_command_line_changed_callback (GConfClient* client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer callback_data)
{
fm_directory_view_update_menus (FM_DIRECTORY_VIEW (callback_data));
}
@@ -299,13 +304,13 @@ fm_desktop_icon_view_finalize (GObject *object)
font_changed_callback,
icon_view);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- lockdown_disable_command_line_changed_callback,
- icon_view);
-
g_signal_handlers_disconnect_by_func (nautilus_preferences,
desktop_directory_changed_callback,
NULL);
+
+ gconf_client_notify_remove (nautilus_gconf_client,
+ icon_view->details->lockdown_notification_id);
+
g_free (icon_view->details);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -615,10 +620,13 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
default_zoom_level_changed (desktop_icon_view);
fm_desktop_icon_view_update_icon_container_fonts (desktop_icon_view);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- lockdown_disable_command_line_changed_callback,
- desktop_icon_view);
-
+ desktop_icon_view->details->lockdown_notification_id =
+ gconf_client_notify_add (nautilus_gconf_client,
+ NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE,
+ lockdown_disable_command_line_changed_callback,
+ desktop_icon_view,
+ NULL,
+ NULL);
}
static void
@@ -698,7 +706,7 @@ real_update_menus (FMDirectoryView *view)
gboolean disable_command_line;
gboolean include_empty_trash;
GtkAction *action;
-
+
g_assert (FM_IS_DESKTOP_ICON_VIEW (view));
EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, update_menus, (view));
@@ -706,7 +714,7 @@ real_update_menus (FMDirectoryView *view)
desktop_view = FM_DESKTOP_ICON_VIEW (view);
/* New Launcher */
- disable_command_line = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE);
+ disable_command_line = gconf_client_get_bool (nautilus_gconf_client, NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE, NULL);
action = gtk_action_group_get_action (desktop_view->details->desktop_action_group,
FM_ACTION_NEW_LAUNCHER_DESKTOP);
gtk_action_set_visible (action,
@@ -716,7 +724,7 @@ real_update_menus (FMDirectoryView *view)
include_empty_trash = trash_link_is_selection (view);
action = gtk_action_group_get_action (desktop_view->details->desktop_action_group,
FM_ACTION_EMPTY_TRASH_CONDITIONAL);
- gtk_action_set_visible (action,
+ gtk_action_set_visible (action,
include_empty_trash);
if (include_empty_trash) {
label = g_strdup (_("E_mpty Trash"));
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index c9af161..3f2e4cb 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -252,6 +252,7 @@ struct FMDirectoryViewDetails
gboolean allow_moves;
GdkPoint context_menu_position;
+ guint lockdown_notification_id;
};
typedef struct {
@@ -1623,7 +1624,10 @@ sort_directories_first_changed_callback (gpointer callback_data)
}
static void
-lockdown_disable_command_line_changed_callback (gpointer callback_data)
+lockdown_disable_command_line_changed_callback (GConfClient* client,
+ guint cnxn_id,
+ GConfEntry *entry,
+ gpointer callback_data)
{
FMDirectoryView *view;
@@ -2001,8 +2005,13 @@ fm_directory_view_init (FMDirectoryView *view)
g_signal_connect_swapped (nautilus_preferences,
"changed::" NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST,
G_CALLBACK(sort_directories_first_changed_callback), view);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- lockdown_disable_command_line_changed_callback, view);
+ view->details->lockdown_notification_id =
+ gconf_client_notify_add (nautilus_gconf_client,
+ NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE,
+ lockdown_disable_command_line_changed_callback,
+ view,
+ NULL,
+ NULL);
}
static void
@@ -2116,8 +2125,9 @@ fm_directory_view_finalize (GObject *object)
click_policy_changed_callback, view);
g_signal_handlers_disconnect_by_func (nautilus_preferences,
sort_directories_first_changed_callback, view);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE,
- lockdown_disable_command_line_changed_callback, view);
+
+ gconf_client_notify_remove (nautilus_gconf_client,
+ view->details->lockdown_notification_id);
unschedule_pop_up_location_context_menu (view);
if (view->details->location_popup_event != NULL) {
@@ -2136,7 +2146,7 @@ fm_directory_view_finalize (GObject *object)
*
* Display information about the current selection, and notify the view frame of the changed selection.
* @view: FMDirectoryView for which to display selection info.
- *
+ *
**/
void
fm_directory_view_display_selection_info (FMDirectoryView *view)
@@ -8736,7 +8746,7 @@ real_update_menus (FMDirectoryView *view)
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_SELECT_PATTERN);
gtk_action_set_sensitive (action, !fm_directory_view_is_empty (view));
-
+
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_INVERT_SELECTION);
gtk_action_set_sensitive (action, !fm_directory_view_is_empty (view));
@@ -8751,7 +8761,7 @@ real_update_menus (FMDirectoryView *view)
real_update_paste_menu (view, selection, selection_count);
- disable_command_line = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_LOCKDOWN_COMMAND_LINE);
+ disable_command_line = gconf_client_get_bool (nautilus_gconf_client, NAUTILUS_GCONF_LOCKDOWN_COMMAND_LINE, NULL);
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_NEW_LAUNCHER);
gtk_action_set_visible (action, vfolder_directory && !disable_command_line);
@@ -8768,7 +8778,7 @@ real_update_menus (FMDirectoryView *view)
action = gtk_action_group_get_action (view->details->dir_action_group,
FM_ACTION_NEW_DOCUMENTS);
gtk_action_set_sensitive (action, can_create_files);
-
+
if (can_create_files && view->details->templates_invalid) {
update_templates_menu (view);
}
diff --git a/src/nautilus-connect-server-dialog-main.c b/src/nautilus-connect-server-dialog-main.c
index cfb67b1..3d35089 100644
--- a/src/nautilus-connect-server-dialog-main.c
+++ b/src/nautilus-connect-server-dialog-main.c
@@ -37,6 +37,7 @@
#include <eel/eel-stock-dialogs.h>
#include <libnautilus-private/nautilus-icon-names.h>
+#include <libnautilus-private/nautilus-global-preferences.h>
#include "nautilus-window.h"
#include "nautilus-connect-server-dialog.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]