summaryrefslogtreecommitdiff
path: root/src/file-manager
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-09-05 20:43:59 +0200
committerStefano Karapetsas <[email protected]>2012-09-05 20:43:59 +0200
commite13142565949e577ae589c0e93527b6698614281 (patch)
treee0901b68fe0de61118f9aa605d945b794a8ce39e /src/file-manager
parentdb145cb919be1242260d06095660405f415774d6 (diff)
downloadcaja-e13142565949e577ae589c0e93527b6698614281.tar.bz2
caja-e13142565949e577ae589c0e93527b6698614281.tar.xz
convert list-view preferences to gsettings
also move the sort order prefs from view-specific to common prefs we already only have one UI setting that controls both, so it makes no sense to have two settings. (from nautilus 3.0)
Diffstat (limited to 'src/file-manager')
-rw-r--r--src/file-manager/fm-icon-view.c82
-rw-r--r--src/file-manager/fm-list-view.c91
2 files changed, 75 insertions, 98 deletions
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 1e643bb2..eee45185 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -198,7 +198,6 @@ static CajaFileSortType get_default_sort_order (CajaFile
static void default_sort_order_changed_callback (gpointer callback_data);
static void default_sort_in_reverse_order_changed_callback (gpointer callback_data);
static void default_use_tighter_layout_changed_callback (gpointer callback_data);
-static void default_use_manual_layout_changed_callback (gpointer callback_data);
static void default_zoom_level_changed_callback (gpointer callback_data);
static void labels_beside_icons_changed_callback (gpointer callback_data);
static void all_columns_same_width_changed_callback (gpointer callback_data);
@@ -251,19 +250,16 @@ fm_icon_view_finalize (GObject *object)
g_free (icon_view->details);
- g_signal_handlers_disconnect_by_func (caja_icon_view_preferences,
+ g_signal_handlers_disconnect_by_func (caja_preferences,
default_sort_order_changed_callback,
icon_view);
- g_signal_handlers_disconnect_by_func (caja_icon_view_preferences,
+ g_signal_handlers_disconnect_by_func (caja_preferences,
default_sort_in_reverse_order_changed_callback,
icon_view);
g_signal_handlers_disconnect_by_func (caja_icon_view_preferences,
default_use_tighter_layout_changed_callback,
icon_view);
g_signal_handlers_disconnect_by_func (caja_icon_view_preferences,
- default_use_manual_layout_changed_callback,
- icon_view);
- g_signal_handlers_disconnect_by_func (caja_icon_view_preferences,
default_zoom_level_changed_callback,
icon_view);
g_signal_handlers_disconnect_by_func (caja_icon_view_preferences,
@@ -830,11 +826,11 @@ get_default_sort_order (CajaFile *file, gboolean *reversed)
if (auto_storaged_added == FALSE)
{
auto_storaged_added = TRUE;
- eel_g_settings_add_auto_enum (caja_icon_view_preferences,
- CAJA_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
+ eel_g_settings_add_auto_enum (caja_preferences,
+ CAJA_PREFERENCES_DEFAULT_SORT_ORDER,
(int *) &default_sort_order);
- eel_g_settings_add_auto_boolean (caja_icon_view_preferences,
- CAJA_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
+ eel_g_settings_add_auto_boolean (caja_preferences,
+ CAJA_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER,
&default_sort_in_reverse_order);
}
@@ -990,25 +986,6 @@ fm_icon_view_set_directory_keep_aligned (FMIconView *icon_view,
keep_aligned);
}
-/* maintainence of auto layout boolean */
-static gboolean default_directory_manual_layout = FALSE;
-
-static gboolean
-get_default_directory_manual_layout (void)
-{
- static gboolean auto_storaged_added = FALSE;
-
- if (auto_storaged_added == FALSE)
- {
- auto_storaged_added = TRUE;
- eel_g_settings_add_auto_boolean (caja_icon_view_preferences,
- CAJA_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
- &default_directory_manual_layout);
- }
-
- return default_directory_manual_layout;
-}
-
static gboolean
fm_icon_view_get_directory_auto_layout (FMIconView *icon_view,
CajaFile *file)
@@ -1035,7 +1012,7 @@ fm_icon_view_real_get_directory_auto_layout (FMIconView *icon_view,
return caja_file_get_boolean_metadata
- (file, CAJA_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT, !get_default_directory_manual_layout ());
+ (file, CAJA_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT, TRUE);
}
static void
@@ -1065,7 +1042,7 @@ fm_icon_view_real_set_directory_auto_layout (FMIconView *icon_view,
caja_file_set_boolean_metadata
(file, CAJA_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT,
- !get_default_directory_manual_layout (),
+ TRUE,
auto_layout);
}
/* maintainence of tighter layout boolean */
@@ -1970,15 +1947,6 @@ fm_icon_view_reset_to_defaults (FMDirectoryView *view)
caja_icon_container_sort (icon_container);
- /* Switch to manual layout of the default calls for it.
- * This needs to happen last for the sort order menus
- * to be in sync.
- */
- if (get_default_directory_manual_layout ())
- {
- switch_to_manual_layout (icon_view);
- }
-
update_layout_menus (icon_view);
fm_icon_view_restore_default_zoom_level (view);
@@ -2792,28 +2760,6 @@ default_use_tighter_layout_changed_callback (gpointer callback_data)
}
static void
-default_use_manual_layout_changed_callback (gpointer callback_data)
-{
- FMIconView *icon_view;
- CajaFile *file;
- CajaIconContainer *icon_container;
-
- g_return_if_fail (FM_IS_ICON_VIEW (callback_data));
-
- icon_view = FM_ICON_VIEW (callback_data);
-
- file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (icon_view));
- icon_container = get_icon_container (icon_view);
- g_return_if_fail (CAJA_IS_ICON_CONTAINER (icon_container));
-
- caja_icon_container_set_auto_layout (
- icon_container,
- fm_icon_view_get_directory_auto_layout (icon_view, file));
-
- caja_icon_container_request_update_all (icon_container);
-}
-
-static void
default_zoom_level_changed_callback (gpointer callback_data)
{
FMIconView *icon_view;
@@ -3326,12 +3272,12 @@ fm_icon_view_init (FMIconView *icon_view)
setup_sound_preview = TRUE;
}
- g_signal_connect_swapped (caja_icon_view_preferences,
- "changed::" CAJA_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
+ g_signal_connect_swapped (caja_preferences,
+ "changed::" CAJA_PREFERENCES_DEFAULT_SORT_ORDER,
G_CALLBACK (default_sort_order_changed_callback),
icon_view);
- g_signal_connect_swapped (caja_icon_view_preferences,
- "changed::" CAJA_PREFERENCES_ICON_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
+ g_signal_connect_swapped (caja_preferences,
+ "changed::" CAJA_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER,
G_CALLBACK (default_sort_in_reverse_order_changed_callback),
icon_view);
g_signal_connect_swapped (caja_icon_view_preferences,
@@ -3339,10 +3285,6 @@ fm_icon_view_init (FMIconView *icon_view)
G_CALLBACK (default_use_tighter_layout_changed_callback),
icon_view);
g_signal_connect_swapped (caja_icon_view_preferences,
- "changed::" CAJA_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
- G_CALLBACK (default_use_manual_layout_changed_callback),
- icon_view);
- g_signal_connect_swapped (caja_icon_view_preferences,
"changed::" CAJA_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
G_CALLBACK (default_zoom_level_changed_callback),
icon_view);
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index 2a0aa693..e8eb16a8 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -133,7 +133,7 @@ struct SelectionForeachData
#define WAIT_FOR_RENAME_ON_ACTIVATE 200
static int click_policy_auto_value;
-static char * default_sort_order_auto_value;
+static CajaFileSortType default_sort_order_auto_value;
static gboolean default_sort_reversed_auto_value;
static CajaZoomLevel default_zoom_level_auto_value;
static char ** default_visible_columns_auto_value;
@@ -179,12 +179,24 @@ static const gchar*
get_default_sort_order (CajaFile *file, gboolean *reversed)
{
const gchar *retval;
+ const char *attributes[] = {
+ "name", /* is really "manually" which doesn't apply to lists */
+ "name",
+ "uri",
+ "size",
+ "type",
+ "date_modified",
+ "date_accessed",
+ "emblems",
+ "trashed_on",
+ NULL
+ };
retval = caja_file_get_default_sort_attribute (file, reversed);
if (retval == NULL)
{
- retval = default_sort_order_auto_value;
+ retval = attributes[default_sort_order_auto_value];
*reversed = default_sort_reversed_auto_value;
}
@@ -1264,7 +1276,7 @@ sort_column_changed_callback (GtkTreeSortable *sortable,
if (sort_attr == default_sort_attr)
{
/* use value from preferences */
- reversed = eel_preferences_get_boolean (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER);
+ reversed = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER);
}
else
{
@@ -3092,6 +3104,19 @@ fm_list_view_finalize (GObject *object)
g_free (list_view->details);
+ g_signal_handlers_disconnect_by_func (caja_preferences,
+ default_sort_order_changed_callback,
+ list_view);
+ g_signal_handlers_disconnect_by_func (caja_list_view_preferences,
+ default_zoom_level_changed_callback,
+ list_view);
+ g_signal_handlers_disconnect_by_func (caja_list_view_preferences,
+ default_visible_columns_changed_callback,
+ list_view);
+ g_signal_handlers_disconnect_by_func (caja_list_view_preferences,
+ default_column_order_changed_callback,
+ list_view);
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -3291,16 +3316,21 @@ fm_list_view_class_init (FMListViewClass *class)
eel_g_settings_add_auto_enum (caja_preferences,
CAJA_PREFERENCES_CLICK_POLICY,
&click_policy_auto_value);
- eel_preferences_add_auto_string (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER,
- (const char **) &default_sort_order_auto_value);
- eel_preferences_add_auto_boolean (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
- &default_sort_reversed_auto_value);
- eel_preferences_add_auto_enum (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
- (int *) &default_zoom_level_auto_value);
- eel_preferences_add_auto_string_array (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
- &default_visible_columns_auto_value);
- eel_preferences_add_auto_string_array (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER,
- &default_column_order_auto_value);
+ eel_g_settings_add_auto_enum (caja_preferences,
+ CAJA_PREFERENCES_DEFAULT_SORT_ORDER,
+ (int *) &default_sort_order_auto_value);
+ eel_g_settings_add_auto_boolean (caja_preferences,
+ CAJA_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER,
+ &default_sort_reversed_auto_value);
+ eel_g_settings_add_auto_enum (caja_list_view_preferences,
+ CAJA_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
+ (int *) &default_zoom_level_auto_value);
+ eel_g_settings_add_auto_strv (caja_list_view_preferences,
+ CAJA_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
+ &default_visible_columns_auto_value);
+ eel_g_settings_add_auto_strv (caja_list_view_preferences,
+ CAJA_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER,
+ &default_column_order_auto_value);
}
static const char *
@@ -3329,21 +3359,26 @@ fm_list_view_init (FMListView *list_view)
create_and_set_up_tree_view (list_view);
- eel_preferences_add_callback_while_alive (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER,
- default_sort_order_changed_callback,
- list_view, G_OBJECT (list_view));
- eel_preferences_add_callback_while_alive (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
- default_sort_order_changed_callback,
- list_view, G_OBJECT (list_view));
- eel_preferences_add_callback_while_alive (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
- default_zoom_level_changed_callback,
- list_view, G_OBJECT (list_view));
- eel_preferences_add_callback_while_alive (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
- default_visible_columns_changed_callback,
- list_view, G_OBJECT (list_view));
- eel_preferences_add_callback_while_alive (CAJA_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER,
- default_column_order_changed_callback,
- list_view, G_OBJECT (list_view));
+ g_signal_connect_swapped (caja_preferences,
+ "changed::" CAJA_PREFERENCES_DEFAULT_SORT_ORDER,
+ G_CALLBACK (default_sort_order_changed_callback),
+ list_view);
+ g_signal_connect_swapped (caja_preferences,
+ "changed::" CAJA_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER,
+ G_CALLBACK (default_sort_order_changed_callback),
+ list_view);
+ g_signal_connect_swapped (caja_list_view_preferences,
+ "changed::" CAJA_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
+ G_CALLBACK (default_zoom_level_changed_callback),
+ list_view);
+ g_signal_connect_swapped (caja_list_view_preferences,
+ "changed::" CAJA_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
+ G_CALLBACK (default_visible_columns_changed_callback),
+ list_view);
+ g_signal_connect_swapped (caja_list_view_preferences,
+ "changed::" CAJA_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER,
+ G_CALLBACK (default_column_order_changed_callback),
+ list_view);
fm_list_view_click_policy_changed (FM_DIRECTORY_VIEW (list_view));