diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index 0f9ca4e6e12f27646bbc4536eeca8b0a1799fd81..581f08b509f3d0c881ecd9765666131a98f68bc4 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -74,6 +74,8 @@ enum PROP_ZOOM_LEVEL, PROP_DIRECTORY_SPECIFIC_SETTINGS, PROP_THUMBNAIL_DRAW_FRAMES, + PROP_SORT_COLUMN, + PROP_SORT_ORDER, PROP_ACCEL_GROUP, N_PROPERTIES }; @@ -273,7 +275,9 @@ static void thunar_standard_view_action_sort_by_size static void thunar_standard_view_action_sort_ascending (ThunarStandardView *standard_view); static void thunar_standard_view_action_sort_descending (ThunarStandardView *standard_view); static void thunar_standard_view_set_sort_column (ThunarStandardView *standard_view, - ThunarColumn column); + ThunarColumn column); +static void thunar_standard_view_set_sort_order (ThunarStandardView *standard_view, + GtkSortType order); static void thunar_standard_view_toggle_sort_order (ThunarStandardView *standard_view); static void thunar_standard_view_store_sort_column (ThunarStandardView *standard_view); @@ -429,6 +433,20 @@ thunar_standard_view_set_sort_column (ThunarStandardView *standard_view, ThunarC } + +static void +thunar_standard_view_set_sort_order (ThunarStandardView *standard_view, + GtkSortType order) +{ + if (standard_view->priv->sort_order == order) + return; + + standard_view->priv->sort_order = order; + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), standard_view->priv->sort_column, order); +} + + + static void thunar_standard_view_action_sort_by_name (ThunarStandardView *standard_view) { @@ -554,6 +572,32 @@ thunar_standard_view_class_init (ThunarStandardViewClass *klass) FALSE, EXO_PARAM_READWRITE); + /** + * ThunarStandardView:sort-column: + * + * The sort column currently used for this view. + **/ + standard_view_props[PROP_SORT_COLUMN] = + g_param_spec_enum ("sort-column", + "SortColumn", + NULL, + THUNAR_TYPE_COLUMN, + THUNAR_COLUMN_NAME, + EXO_PARAM_READWRITE); + + /** + * ThunarStandardView:sort-order: + * + * The sort order currently used for this view. + **/ + standard_view_props[PROP_SORT_ORDER] = + g_param_spec_enum ("sort-order", + "SortOrder", + NULL, + GTK_TYPE_SORT_TYPE, + GTK_SORT_ASCENDING, + EXO_PARAM_READWRITE); + /* override ThunarComponent's properties */ g_iface = g_type_default_interface_peek (THUNAR_TYPE_COMPONENT); standard_view_props[PROP_SELECTED_FILES] = @@ -1008,6 +1052,14 @@ thunar_standard_view_get_property (GObject *object, g_value_set_boolean (value, thumbnail_draw_frames); break; + case PROP_SORT_COLUMN: + g_value_set_enum (value, THUNAR_STANDARD_VIEW (object)->priv->sort_column); + break; + + case PROP_SORT_ORDER: + g_value_set_enum (value, THUNAR_STANDARD_VIEW (object)->priv->sort_order); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1055,6 +1107,14 @@ thunar_standard_view_set_property (GObject *object, thunar_standard_view_reload(THUNAR_VIEW (object), TRUE); break; + case PROP_SORT_COLUMN: + thunar_standard_view_set_sort_column (standard_view, g_value_get_enum (value)); + break; + + case PROP_SORT_ORDER: + thunar_standard_view_set_sort_order (standard_view, g_value_get_enum (value)); + break; + case PROP_ACCEL_GROUP: thunar_standard_view_disconnect_accelerators (standard_view); standard_view->accel_group = g_value_dup_object (value); diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index b27520d02292fc730a8372f0f0514bad284646f8..889d085eae115ca17781897b71a62fa1843f2381 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -2287,6 +2287,8 @@ thunar_window_notebook_insert_page (ThunarWindow *window, GtkWidget *label_box; GtkWidget *button; GtkWidget *icon; + ThunarColumn sort_column; + GtkSortType sort_order; _thunar_return_val_if_fail (THUNAR_IS_WINDOW (window), NULL); _thunar_return_val_if_fail (THUNAR_IS_FILE (directory), NULL); @@ -2296,6 +2298,14 @@ thunar_window_notebook_insert_page (ThunarWindow *window, /* allocate and setup a new view */ view = g_object_new (view_type, "current-directory", directory, NULL); thunar_view_set_show_hidden (THUNAR_VIEW (view), window->show_hidden); + + /* inherit sort settings from current view */ + if (window->view != NULL) + { + g_object_get (window->view, "sort-column", &sort_column, "sort-order", &sort_order, NULL); + g_object_set (view, "sort-column", sort_column, "sort-order", sort_order, NULL); + } + gtk_widget_show (view); /* set the history of the view if a history is provided */