[PATCH] Make list view update when defaults change
- From: David Emory Watson <dwatson cs ucr edu>
- To: nautilus-list gnome org
- Subject: [PATCH] Make list view update when defaults change
- Date: 10 May 2002 13:13:20 -0400
The only preferences which this does not handle are the font and
font_size preferences. We need to decide if we want to keep these. I
think we should either a) keep them for both the icon view and the list
view or b) eliminate them but create an additional font preference for
the desktop only. Also, I already have a partial implementation of the
font preferences for the list view. Once we decide I can polish it up
or throw it out...
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5283
diff -p -u -r1.5283 ChangeLog
--- ChangeLog 9 May 2002 20:49:44 -0000 1.5283
+++ ChangeLog 10 May 2002 16:30:36 -0000
@@ -1,3 +1,22 @@
+2002-05-10 David Emory Watson <dwatson cs ucr edu>
+
+ * src/file-manager/fm-list-view.c:
+ (list_activate_callback),
+ (click_policy_changed),
+ (fm_list_view_class_init): Update to use click_policy_auto_value.
+ (rows_reordered_callback): Renamed to
+ (sort_column_changed_callback): this and only write preferences out to
+ disk when they differ from the defaults.
+ (default_sort_order_changed_callback)
+ (fm_list_view_instance_init): React to changes in the defaults.
+
+ * src/file-manager/fm-list-model.c:
+ * src/file-manager/fm-list-model.h:
+ (fm_list_model_get_nautilus_file_sort_type): Changed to
+ (fm_list_model_get_sort_type_from_sort_column_id): this.
+ (fm_list_model_compare_func): Update.
+ (fm_list_model_add_file): Update.
+
2002-05-09 Damon Chaplin <damon ximian com>
* components/text/nautilus-text-view.c (read_file_callback): if the
Index: src/file-manager/fm-list-model.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-model.c,v
retrieving revision 1.14
diff -p -u -r1.14 fm-list-model.c
--- src/file-manager/fm-list-model.c 2 May 2002 23:03:29 -0000 1.14
+++ src/file-manager/fm-list-model.c 10 May 2002 16:30:51 -0000
@@ -354,30 +354,6 @@ typedef struct _SortTuple
GSList *el;
} SortTuple;
-static NautilusFileSortType
-fm_list_model_get_nautilus_file_sort_type (FMListModel *model)
-{
- if (model->details->sort_column_id == -1) {
- return NAUTILUS_FILE_SORT_NONE;
- }
-
- switch (model->details->sort_column_id) {
- case FM_LIST_MODEL_NAME_COLUMN:
- return NAUTILUS_FILE_SORT_BY_DISPLAY_NAME;
- case FM_LIST_MODEL_SIZE_COLUMN:
- return NAUTILUS_FILE_SORT_BY_SIZE;
- case FM_LIST_MODEL_TYPE_COLUMN:
- return NAUTILUS_FILE_SORT_BY_TYPE;
- case FM_LIST_MODEL_DATE_MODIFIED_COLUMN:
- return NAUTILUS_FILE_SORT_BY_MTIME;
- default:
- g_assert_not_reached ();
- }
-
- /* Should not be reached */
- return NAUTILUS_FILE_SORT_NONE;
-}
-
static int
fm_list_model_compare_func (gconstpointer a,
gconstpointer b,
@@ -394,7 +370,7 @@ fm_list_model_compare_func (gconstpointe
file2 = ((SortTuple *)b)->el->data;
result = nautilus_file_compare_for_sort (file1, file2,
- fm_list_model_get_nautilus_file_sort_type (model),
+ fm_list_model_get_sort_type_from_sort_column_id (model->details->sort_column_id),
model->details->sort_directories_first,
(model->details->order == GTK_SORT_DESCENDING));
@@ -553,7 +529,7 @@ fm_list_model_add_file (FMListModel *mod
file1 = tmp->data;
result = nautilus_file_compare_for_sort (file, file1,
- fm_list_model_get_nautilus_file_sort_type (model),
+ fm_list_model_get_sort_type_from_sort_column_id (model->details->sort_column_id),
model->details->sort_directories_first,
(model->details->order == GTK_SORT_DESCENDING));
if (result < 0) {
@@ -766,6 +742,23 @@ fm_list_model_get_sort_column_id_from_so
}
g_return_val_if_reached (-1);
+}
+
+NautilusFileSortType
+fm_list_model_get_sort_type_from_sort_column_id (int sort_column_id)
+{
+ switch (sort_column_id) {
+ case FM_LIST_MODEL_NAME_COLUMN:
+ return NAUTILUS_FILE_SORT_BY_DISPLAY_NAME;
+ case FM_LIST_MODEL_TYPE_COLUMN:
+ return NAUTILUS_FILE_SORT_BY_TYPE;
+ case FM_LIST_MODEL_SIZE_COLUMN:
+ return NAUTILUS_FILE_SORT_BY_SIZE;
+ case FM_LIST_MODEL_DATE_MODIFIED_COLUMN:
+ return NAUTILUS_FILE_SORT_BY_MTIME;
+ }
+
+ g_return_val_if_reached (NAUTILUS_FILE_SORT_NONE);
}
NautilusZoomLevel
Index: src/file-manager/fm-list-model.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-model.h,v
retrieving revision 1.5
diff -p -u -r1.5 fm-list-model.h
--- src/file-manager/fm-list-model.h 2 May 2002 23:03:29 -0000 1.5
+++ src/file-manager/fm-list-model.h 10 May 2002 16:30:51 -0000
@@ -77,9 +77,12 @@ gboolean fm_list_model_get_tree_iter_fro
GtkTreeIter *iter);
void fm_list_model_set_should_sort_directories_first (FMListModel *model,
gboolean sort_directories_first);
+
int fm_list_model_get_sort_column_id_from_attribute (const char *attribute);
-int fm_list_model_get_sort_column_id_from_sort_type (NautilusFileSortType sort_type);
char *fm_list_model_get_attribute_from_sort_column_id (int sort_column_id);
+
+int fm_list_model_get_sort_column_id_from_sort_type (NautilusFileSortType sort_type);
+NautilusFileSortType fm_list_model_get_sort_type_from_sort_column_id (int sort_column_id);
NautilusZoomLevel fm_list_model_get_zoom_level_from_column_id (int column);
int fm_list_model_get_column_id_from_zoom_level (NautilusZoomLevel zoom_level);
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.170
diff -p -u -r1.170 fm-list-view.c
--- src/file-manager/fm-list-view.c 5 May 2002 19:03:34 -0000 1.170
+++ src/file-manager/fm-list-view.c 10 May 2002 16:30:52 -0000
@@ -70,6 +70,7 @@ static GtkTargetEntry drag_types [] = {
*/
#define LIST_VIEW_MINIMUM_ROW_HEIGHT 28
+static int click_policy_auto_value;
static NautilusFileSortType default_sort_order_auto_value;
static gboolean default_sort_reversed_auto_value;
static NautilusZoomLevel default_zoom_level_auto_value;
@@ -100,7 +101,7 @@ list_activate_callback (GtkTreeView *tre
view = FM_DIRECTORY_VIEW (user_data);
- if (eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_DOUBLE) {
+ if (click_policy_auto_value == NAUTILUS_CLICK_POLICY_DOUBLE) {
file_list = fm_list_view_get_selection (view);
fm_directory_view_activate_files (view, file_list);
nautilus_file_list_free (file_list);
@@ -198,7 +199,7 @@ button_release_callback (GtkWidget *widg
if (event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)) &&
event->button == 1 &&
- eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_SINGLE) {
+ click_policy_auto_value == NAUTILUS_CLICK_POLICY_SINGLE) {
/* Handle single click activation preference. */
file_list = fm_list_view_get_selection (view);
fm_directory_view_activate_files (view, file_list);
@@ -209,24 +210,31 @@ button_release_callback (GtkWidget *widg
}
static void
-rows_reordered_callback (GtkTreeSortable *sortable,
- FMListView *view)
+sort_column_changed_callback (GtkTreeSortable *sortable,
+ FMListView *view)
{
NautilusFile *file;
gint sort_column_id;
- GtkSortType order;
- char *attr_column, *attr_order;
+ GtkSortType reversed;
+ char *sort_attr, *default_sort_attr;
+ char *reversed_attr, *default_reversed_attr;
file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (view));
- gtk_tree_sortable_get_sort_column_id (sortable, &sort_column_id, &order);
- attr_column = fm_list_model_get_attribute_from_sort_column_id (sort_column_id);
- nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN, NULL, attr_column);
+ gtk_tree_sortable_get_sort_column_id (sortable, &sort_column_id, &reversed);
- attr_order = (order ? "true" : "false");
- nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED, NULL, attr_order);
-
- g_free (attr_column);
+ sort_attr = fm_list_model_get_attribute_from_sort_column_id (sort_column_id);
+ sort_column_id = fm_list_model_get_sort_column_id_from_sort_type (default_sort_order_auto_value);
+ default_sort_attr = fm_list_model_get_attribute_from_sort_column_id (sort_column_id);
+ nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN,
+ default_sort_attr, sort_attr);
+ g_free (default_sort_attr);
+ g_free (sort_attr);
+
+ default_reversed_attr = (default_sort_reversed_auto_value ? "true" : "false");
+ reversed_attr = (reversed ? "true" : "false");
+ nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED,
+ default_reversed_attr, reversed_attr);
}
static void
@@ -257,24 +265,6 @@ cell_renderer_edited (GtkCellRendererTex
}
static void
-click_policy_changed_callback (gpointer callback_data)
-{
- FMListView *view;
-
- view = FM_LIST_VIEW (callback_data);
-
- if (eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_SINGLE) {
- g_object_set (G_OBJECT (view->details->file_name_cell),
- "underline", PANGO_UNDERLINE_SINGLE,
- NULL);
- } else {
- g_object_set (G_OBJECT (view->details->file_name_cell),
- "underline", PANGO_UNDERLINE_NONE,
- NULL);
- }
-}
-
-static void
create_and_set_up_tree_view (FMListView *view)
{
GtkCellRenderer *cell;
@@ -299,7 +289,7 @@ create_and_set_up_tree_view (FMListView
gtk_tree_view_set_model (view->details->tree_view, GTK_TREE_MODEL (view->details->model));
g_signal_connect_object (view->details->model, "sort_column_changed",
- G_CALLBACK (rows_reordered_callback), view, 0);
+ G_CALLBACK (sort_column_changed_callback), view, 0);
g_object_unref (view->details->model);
@@ -404,7 +394,6 @@ set_sort_order_from_metadata_and_prefere
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_view->details->model),
sort_column_id,
sort_reversed ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING);
-
}
static void
@@ -533,15 +522,17 @@ fm_list_view_reset_to_defaults (FMDirect
NautilusFile *file;
file = fm_directory_view_get_directory_as_file (view);
+
nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN, NULL, NULL);
nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED, NULL, NULL);
+ nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_LIST_VIEW_ZOOM_LEVEL, NULL, NULL);
gtk_tree_sortable_set_sort_column_id
(GTK_TREE_SORTABLE (FM_LIST_VIEW (view)->details->model),
fm_list_model_get_sort_column_id_from_sort_type (default_sort_order_auto_value),
default_sort_reversed_auto_value ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING);
- fm_directory_view_restore_default_zoom_level (view);
+ fm_list_view_set_zoom_level (FM_LIST_VIEW (view), default_zoom_level_auto_value, FALSE);
}
static void
@@ -687,6 +678,34 @@ fm_list_view_start_renaming_file (FMDire
}
static void
+click_policy_changed_callback (gpointer callback_data)
+{
+ FMListView *view;
+
+ view = FM_LIST_VIEW (callback_data);
+
+ if (click_policy_auto_value == NAUTILUS_CLICK_POLICY_SINGLE) {
+ g_object_set (G_OBJECT (view->details->file_name_cell),
+ "underline", PANGO_UNDERLINE_SINGLE,
+ NULL);
+ } else {
+ g_object_set (G_OBJECT (view->details->file_name_cell),
+ "underline", PANGO_UNDERLINE_NONE,
+ NULL);
+ }
+}
+
+static void
+default_sort_order_changed_callback (gpointer callback_data)
+{
+ FMListView *list_view;
+
+ list_view = FM_LIST_VIEW (callback_data);
+
+ set_sort_order_from_metadata_and_preferences (list_view);
+}
+
+static void
default_zoom_level_changed_callback (gpointer callback_data)
{
FMListView *list_view;
@@ -760,6 +779,8 @@ fm_list_view_class_init (FMListViewClass
fm_directory_view_class->sort_directories_first_changed = fm_list_view_sort_directories_first_changed;
fm_directory_view_class->start_renaming_file = fm_list_view_start_renaming_file;
+ eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
+ &click_policy_auto_value);
eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER,
(int *) &default_sort_order_auto_value);
eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_IN_REVERSE_ORDER,
@@ -775,11 +796,17 @@ fm_list_view_instance_init (FMListView *
create_and_set_up_tree_view (list_view);
- eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
- default_zoom_level_changed_callback,
- list_view, G_OBJECT (list_view));
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
+ list_view, G_OBJECT (list_view));
+ eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER,
+ default_sort_order_changed_callback,
+ list_view, G_OBJECT (list_view));
+ eel_preferences_add_callback_while_alive (NAUTILUS_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 (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
+ default_zoom_level_changed_callback,
list_view, G_OBJECT (list_view));
click_policy_changed_callback (list_view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]