[nautilus] Convert media handling preferences to gsettings
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Convert media handling preferences to gsettings
- Date: Fri, 23 Jul 2010 10:31:42 +0000 (UTC)
commit 924e9ee3ad889d9a8abc63c79c79c1cb25aaf0cf
Author: Alexander Larsson <alexl redhat com>
Date: Wed Jul 21 16:04:22 2010 +0200
Convert media handling preferences to gsettings
libnautilus-private/nautilus-autorun.c | 23 +++++++-------
libnautilus-private/nautilus-global-preferences.c | 25 +---------------
libnautilus-private/nautilus-global-preferences.h | 13 ++++----
src/nautilus-application.c | 6 ++--
src/nautilus-file-management-properties.c | 33 +++++++++++++-------
5 files changed, 44 insertions(+), 56 deletions(-)
---
diff --git a/libnautilus-private/nautilus-autorun.c b/libnautilus-private/nautilus-autorun.c
index 9b2c58f..c65f9e6 100644
--- a/libnautilus-private/nautilus-autorun.c
+++ b/libnautilus-private/nautilus-autorun.c
@@ -82,9 +82,9 @@ nautilus_autorun_get_preferences (const char *x_content_type,
*pref_start_app = FALSE;
*pref_ignore = FALSE;
*pref_open_folder = FALSE;
- x_content_start_app = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP);
- x_content_ignore = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE);
- x_content_open_folder = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER);
+ x_content_start_app = g_settings_get_strv (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP);
+ x_content_ignore = g_settings_get_strv (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE);
+ x_content_open_folder = g_settings_get_strv (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER);
if (x_content_start_app != NULL) {
*pref_start_app = eel_g_strv_find (x_content_start_app, x_content_type) != -1;
}
@@ -148,27 +148,27 @@ nautilus_autorun_set_preferences (const char *x_content_type,
g_assert (x_content_type != NULL);
- x_content_start_app = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP);
- x_content_ignore = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE);
- x_content_open_folder = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER);
+ x_content_start_app = g_settings_get_strv (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP);
+ x_content_ignore = g_settings_get_strv (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE);
+ x_content_open_folder = g_settings_get_strv (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER);
remove_elem_from_str_array (x_content_start_app, x_content_type);
if (pref_start_app) {
x_content_start_app = add_elem_to_str_array (x_content_start_app, x_content_type);
}
- eel_preferences_set_string_array (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP, x_content_start_app);
+ g_settings_set_strv (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP, (const gchar * const*) x_content_start_app);
remove_elem_from_str_array (x_content_ignore, x_content_type);
if (pref_ignore) {
x_content_ignore = add_elem_to_str_array (x_content_ignore, x_content_type);
}
- eel_preferences_set_string_array (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE, x_content_ignore);
+ g_settings_set_strv (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE, (const gchar * const*) x_content_ignore);
remove_elem_from_str_array (x_content_open_folder, x_content_type);
if (pref_open_folder) {
x_content_open_folder = add_elem_to_str_array (x_content_open_folder, x_content_type);
}
- eel_preferences_set_string_array (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER, x_content_open_folder);
+ g_settings_set_strv (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER, (const gchar * const*) x_content_open_folder);
g_strfreev (x_content_open_folder);
g_strfreev (x_content_ignore);
@@ -1088,8 +1088,9 @@ autorun_guessed_content_type_callback (GObject *source_object,
}
g_strfreev (guessed_content_type);
} else {
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT_OPEN))
+ if (g_settings_get_boolean (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT_OPEN)) {
open_folder = TRUE;
+ }
}
}
@@ -1108,7 +1109,7 @@ nautilus_autorun (GMount *mount, NautilusAutorunOpenWindow open_window_func, gpo
AutorunData *data;
if (!should_autorun_mount (mount) ||
- eel_preferences_get_boolean (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER)) {
+ g_settings_get_boolean (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER)) {
return;
}
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 1b922de..ad1171a 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -511,30 +511,6 @@ static const PreferenceDefault preference_defaults[] = {
default_network_link_name, g_free,
},
- { NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT,
- PREFERENCE_BOOLEAN,
- GINT_TO_POINTER (TRUE)
- },
- { NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT_OPEN,
- PREFERENCE_BOOLEAN,
- GINT_TO_POINTER (TRUE)
- },
- { NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER,
- PREFERENCE_BOOLEAN,
- GINT_TO_POINTER (FALSE)
- },
- { NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP,
- PREFERENCE_STRING_ARRAY,
- "", NULL, NULL, NULL
- },
- { NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE,
- PREFERENCE_STRING_ARRAY,
- "", NULL, NULL, NULL
- },
- { NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER,
- PREFERENCE_STRING_ARRAY,
- "", NULL, NULL, NULL
- },
{ NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT,
PREFERENCE_INTEGER,
GINT_TO_POINTER (3)
@@ -820,6 +796,7 @@ nautilus_global_preferences_init (void)
}
nautilus_preferences = g_settings_new("org.gnome.nautilus.preferences");
+ nautilus_media_preferences = g_settings_new("org.gnome.media-handling");
/* Set up storage for values accessed in this file */
eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER_OR_MANUAL_LAYOUT,
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index 486195a..394df4f 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -48,14 +48,14 @@ G_BEGIN_DECLS
#define NAUTILUS_PREFERENCES_SIDEBAR_WIDTH "sidebar-width"
/* Automount options */
-#define NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT "preferences/media_automount"
-#define NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT_OPEN "preferences/media_automount_open"
+#define NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT "automount"
+#define NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT_OPEN "automount-open"
/* Autorun options */
-#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER "preferences/media_autorun_never"
-#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP "preferences/media_autorun_x_content_start_app"
-#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE "preferences/media_autorun_x_content_ignore"
-#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER "preferences/media_autorun_x_content_open_folder"
+#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER "autorun-never"
+#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_START_APP "autorun-x-content-start-app"
+#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_IGNORE "autorun-x-content-ignore"
+#define NAUTILUS_PREFERENCES_MEDIA_AUTORUN_X_CONTENT_OPEN_FOLDER "autorun-x-content-open-folder"
/* Trash options */
#define NAUTILUS_PREFERENCES_CONFIRM_TRASH "preferences/confirm_trash"
@@ -232,6 +232,7 @@ void nautilus_global_preferences_init (void);
char *nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (void);
GSettings *nautilus_preferences;
+GSettings *nautilus_media_preferences;
G_END_DECLS
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 0caac03..df97207 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -156,8 +156,8 @@ automount_all_volumes (NautilusApplication *application)
GList *volumes, *l;
GMount *mount;
GVolume *volume;
-
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT)) {
+
+ if (g_settings_get_boolean (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT)) {
/* automount all mountable volumes at start-up */
volumes = g_volume_monitor_get_volumes (application->volume_monitor);
for (l = volumes; l != NULL; l = l->next) {
@@ -1533,7 +1533,7 @@ volume_added_callback (GVolumeMonitor *monitor,
GVolume *volume,
NautilusApplication *application)
{
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT) &&
+ if (g_settings_get_boolean (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT) &&
g_volume_should_automount (volume) &&
g_volume_can_mount (volume)) {
nautilus_file_operations_mount_volume (NULL, volume, TRUE);
diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c
index 7d9ea3e..a3a6671 100644
--- a/src/nautilus-file-management-properties.c
+++ b/src/nautilus-file-management-properties.c
@@ -161,6 +161,8 @@ static const char * const icon_captions_components[] = {
NULL
};
+static void nautilus_file_management_properties_dialog_update_media_sensitivity (GtkBuilder *builder);
+
static void
nautilus_file_management_properties_size_group_create (GtkBuilder *builder,
char *prefix,
@@ -251,6 +253,9 @@ nautilus_file_management_properties_dialog_response_cb (GtkDialog *parent,
eel_gconf_monitor_remove ("/apps/nautilus/list_view");
eel_gconf_monitor_remove ("/apps/nautilus/preferences");
eel_gconf_monitor_remove ("/desktop/gnome/file_views");
+ g_signal_handlers_disconnect_by_func (nautilus_media_preferences,
+ nautilus_file_management_properties_dialog_update_media_sensitivity,
+ builder);
}
}
@@ -523,8 +528,8 @@ nautilus_file_management_properties_dialog_setup_list_column_page (GtkBuilder *b
static void
nautilus_file_management_properties_dialog_update_media_sensitivity (GtkBuilder *builder)
{
- gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "media_handling_vbox")),
- ! eel_preferences_get_boolean (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER));
+ gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (builder, "media_handling_vbox")),
+ ! g_settings_get_boolean (nautilus_media_preferences, NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER));
}
static void
@@ -708,12 +713,16 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET,
NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER);
- eel_preferences_builder_connect_bool (builder,
- NAUTILUS_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTOMOUNT_OPEN,
- NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT_OPEN);
- eel_preferences_builder_connect_bool (builder,
- NAUTILUS_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTORUN_NEVER,
- NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER);
+ g_settings_bind (nautilus_media_preferences,
+ NAUTILUS_PREFERENCES_MEDIA_AUTOMOUNT_OPEN,
+ gtk_builder_get_object (builder,
+ NAUTILUS_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTOMOUNT_OPEN),
+ "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (nautilus_media_preferences,
+ NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER,
+ gtk_builder_get_object (builder,
+ NAUTILUS_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTORUN_NEVER),
+ "active", G_SETTINGS_BIND_DEFAULT);
eel_preferences_builder_connect_bool (builder,
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET,
@@ -794,11 +803,11 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
nautilus_file_management_properties_dialog_setup_list_column_page (builder);
nautilus_file_management_properties_dialog_setup_media_page (builder);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER,
- (EelPreferencesCallback ) nautilus_file_management_properties_dialog_update_media_sensitivity,
- g_object_ref (builder));
+ g_signal_connect_swapped (nautilus_media_preferences,
+ "changed::" NAUTILUS_PREFERENCES_MEDIA_AUTORUN_NEVER,
+ G_CALLBACK(nautilus_file_management_properties_dialog_update_media_sensitivity),
+ builder);
-
/* UI callbacks */
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "file_management_dialog"));
g_signal_connect_data (G_OBJECT (dialog), "response",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]