[nautilus] Convert always-use-browser to gsettings
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Convert always-use-browser to gsettings
- Date: Fri, 23 Jul 2010 10:32:48 +0000 (UTC)
commit 42e9d22c84a3f54dfaa6da39243dd07c18a7cb9c
Author: Alexander Larsson <alexl redhat com>
Date: Thu Jul 22 16:27:58 2010 +0200
Convert always-use-browser to gsettings
libnautilus-private/nautilus-global-preferences.c | 4 --
libnautilus-private/nautilus-global-preferences.h | 2 +-
src/file-manager/fm-directory-view.c | 10 +++---
src/nautilus-application.c | 10 +++---
src/nautilus-bookmarks-window.c | 6 ++--
src/nautilus-connect-server-dialog-nonmain.c | 2 +-
src/nautilus-file-management-properties.c | 37 +++++++++++++++++++--
src/nautilus-navigation-window-menus.c | 2 +-
src/nautilus-navigation-window.c | 17 ++++++---
src/nautilus-window-manage-views.c | 2 +-
10 files changed, 62 insertions(+), 30 deletions(-)
---
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index c5c0011..873c60e 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -262,10 +262,6 @@ static const PreferenceDefault preference_defaults[] = {
NULL, NULL,
NULL
},
- { NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER,
- PREFERENCE_BOOLEAN,
- GINT_TO_POINTER (TRUE)
- },
{ NAUTILUS_PREFERENCES_NEW_TAB_POSITION,
PREFERENCE_STRING,
"after_current_tab",
diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h
index 01417ff..b57d7fa 100644
--- a/libnautilus-private/nautilus-global-preferences.h
+++ b/libnautilus-private/nautilus-global-preferences.h
@@ -102,7 +102,7 @@ typedef enum
#define NAUTILUS_PREFERENCES_INSTALL_MIME_ACTIVATION "preferences/install_mime_activation"
/* Spatial or browser mode */
-#define NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER "preferences/always_use_browser"
+#define NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER "always-use-browser"
#define NAUTILUS_PREFERENCES_NEW_TAB_POSITION "preferences/tabs_open_position"
/* Which views should be displayed for new windows */
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 673e4c9..1fb13de 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -8274,7 +8274,7 @@ real_update_location_menu (FMDirectoryView *view)
show_open_in_new_tab = FALSE;
if (nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION) {
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
label = _("Open in New _Window");
} else {
label = _("Browse in New _Window");
@@ -8297,7 +8297,7 @@ real_update_location_menu (FMDirectoryView *view)
gtk_action_set_visible (action, show_open_in_new_tab);
if (show_open_in_new_tab) {
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
label = _("Open in New _Tab");
} else {
label = _("Browse in New _Tab");
@@ -8579,10 +8579,10 @@ real_update_menus (FMDirectoryView *view)
show_open_alternate = file_list_all_are_folders (selection) &&
selection_count > 0 &&
!(nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_DESKTOP &&
- eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER));
+ g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER));
show_open_folder_window = FALSE;
if (nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION) {
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
if (selection_count == 0 || selection_count == 1) {
label_with_underscore = g_strdup (_("Open in New _Window"));
} else {
@@ -8621,7 +8621,7 @@ real_update_menus (FMDirectoryView *view)
/* Open in New Tab action */
if (nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION) {
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
if (selection_count == 0 || selection_count == 1) {
label_with_underscore = g_strdup (_("Open in New _Tab"));
} else {
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 90f1526..3254606 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -702,7 +702,7 @@ open_window (NautilusApplication *application,
NautilusWindow *window;
if (browser_window ||
- eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = nautilus_application_create_navigation_window (application,
startup_id,
screen);
@@ -1600,11 +1600,11 @@ autorun_show_window (GMount *mount, gpointer user_data)
{
GFile *location;
NautilusApplication *application = user_data;
-
+
location = g_mount_get_root (mount);
-
- /* Ther should probably be an easier way to do this */
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+
+ /* There should probably be an easier way to do this */
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
NautilusWindow *window;
window = nautilus_application_create_navigation_window (application,
NULL,
diff --git a/src/nautilus-bookmarks-window.c b/src/nautilus-bookmarks-window.c
index b468823..0202f34 100644
--- a/src/nautilus-bookmarks-window.c
+++ b/src/nautilus-bookmarks-window.c
@@ -571,13 +571,13 @@ open_selected_bookmark (gpointer user_data, GdkScreen *screen)
location,
screen);
} else { /* window that opened bookmarks window has been closed */
- if (parent_is_browser_window || eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
- window = nautilus_application_create_navigation_window (application,
+ if (parent_is_browser_window || g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ window = nautilus_application_create_navigation_window (application,
NULL,
screen);
nautilus_window_go_to (window, location);
} else {
- window = nautilus_application_present_spatial_window (application,
+ window = nautilus_application_present_spatial_window (application,
NULL,
NULL,
location,
diff --git a/src/nautilus-connect-server-dialog-nonmain.c b/src/nautilus-connect-server-dialog-nonmain.c
index 885f6a1..0dd015f 100644
--- a/src/nautilus-connect-server-dialog-nonmain.c
+++ b/src/nautilus-connect-server-dialog-nonmain.c
@@ -38,7 +38,7 @@ nautilus_connect_server_dialog_present_uri (NautilusApplication *application,
{
NautilusWindow *window;
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = nautilus_application_create_navigation_window (application,
NULL,
gtk_widget_get_screen (widget));
diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c
index 4b4eed8..bc235a9 100644
--- a/src/nautilus-file-management-properties.c
+++ b/src/nautilus-file-management-properties.c
@@ -679,6 +679,37 @@ bind_builder_bool (GtkBuilder *builder,
}
static gboolean
+inverted_get_mapping (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
+{
+ g_value_set_boolean (value, !g_variant_get_boolean (variant));
+ return TRUE;
+}
+
+static GVariant *
+inverted_set_mapping (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer user_data)
+{
+ return g_variant_new_boolean (!g_value_get_boolean (value));
+}
+
+static void
+bind_builder_bool_inverted (GtkBuilder *builder,
+ GSettings *settings,
+ const char *widget_name,
+ const char *prefs)
+{
+ g_settings_bind_with_mapping (settings, prefs,
+ gtk_builder_get_object (builder, widget_name),
+ "active", G_SETTINGS_BIND_DEFAULT,
+ inverted_get_mapping,
+ inverted_set_mapping,
+ NULL, NULL);
+}
+
+static gboolean
enum_get_mapping (GValue *value,
GVariant *variant,
gpointer user_data)
@@ -843,9 +874,9 @@ nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow
eel_preferences_builder_connect_bool (builder,
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET,
NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST);
- eel_preferences_builder_connect_inverted_bool (builder,
- NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET,
- NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER);
+ bind_builder_bool_inverted (builder, nautilus_preferences,
+ NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET,
+ NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER);
bind_builder_bool (builder, nautilus_media_preferences,
NAUTILUS_FILE_MANAGEMENT_PROPERTIES_MEDIA_AUTOMOUNT_OPEN,
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index 83c72ee..2b1ff9d 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -321,7 +321,7 @@ nautilus_navigation_window_update_spatial_menu_item (NautilusNavigationWindow *w
action = gtk_action_group_get_action (window->details->navigation_action_group,
NAUTILUS_ACTION_FOLDER_WINDOW);
gtk_action_set_visible (action,
- !eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER));
+ !g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER));
}
static void
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index 0d05e03..cfa20b5 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -194,9 +194,10 @@ nautilus_navigation_window_init (NautilusNavigationWindow *window)
always_use_location_entry_changed,
window, G_OBJECT (window));
- eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER,
- always_use_browser_changed,
- window, G_OBJECT (window));
+ g_signal_connect_swapped (nautilus_preferences,
+ "changed::" NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER,
+ G_CALLBACK(always_use_browser_changed),
+ window);
}
static void
@@ -467,7 +468,7 @@ nautilus_navigation_window_tear_down_sidebar (NautilusNavigationWindow *window)
{
GList *node, *next;
NautilusSidebar *sidebar_panel;
-
+
g_signal_handlers_disconnect_by_func (window->sidebar,
side_pane_switch_page_callback,
window);
@@ -588,11 +589,15 @@ static void
nautilus_navigation_window_finalize (GObject *object)
{
NautilusNavigationWindow *window;
-
+
window = NAUTILUS_NAVIGATION_WINDOW (object);
nautilus_navigation_window_remove_go_menu_callback (window);
+ g_signal_handlers_disconnect_by_func (nautilus_preferences,
+ always_use_browser_changed,
+ window);
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -720,7 +725,7 @@ real_sync_title (NautilusWindow *window,
/* if spatial mode is default, we keep "File Browser" in the window title
* to recognize browser windows. Otherwise, we default to the directory name.
*/
- if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ if (!g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
full_title = g_strdup_printf (_("%s - File Browser"), slot->title);
window_title = eel_str_middle_truncate (full_title, MAX_TITLE_LENGTH);
g_free (full_title);
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 40e68e2..bcdd53e 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -516,7 +516,7 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
old_location = nautilus_window_slot_get_location (slot);
switch (mode) {
case NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE :
- if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
target_window = window;
if (NAUTILUS_IS_SPATIAL_WINDOW (window)) {
if (!NAUTILUS_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]