summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbud <robstenklippa@gmail.com>2020-10-12 14:21:50 +0200
committerAlexander Schwinn <alexxcons@xfce.org>2020-12-24 00:19:47 +0100
commitaeef7c581fe80bc427f30edf6085de29ae91ed84 (patch)
tree005a9b9b78905da6e76b7e6a402eb9cc3d6d5a77
parent607bd8928e666901b1bab09758c37f36fe229312 (diff)
downloadthunar-aeef7c581fe80bc427f30edf6085de29ae91ed84.tar.gz
Use sort menu as well for detailed view (#139)
Add "Arrange Items" sub-menu to details view (listview). Changes the behavior if one selects an action that is already applied. Sort order (Ascending/Descending) will get toggled if the currently active sort attribute is chosed. Previously the Arrange Items sub-menu was specific to icon-view. This means that all the functions where static in abstract-icon-view.c . Here I have moved all those functions to standard-view (which is the parent class of all views), now all views will inherit the menu, actions and functions related to sorting. This is why the line count is 100 lines less is more. Fix !39
-rw-r--r--thunar/thunar-abstract-icon-view.c313
-rw-r--r--thunar/thunar-abstract-icon-view.h12
-rw-r--r--thunar/thunar-details-view.c6
-rw-r--r--thunar/thunar-standard-view.c121
-rw-r--r--thunar/thunar-standard-view.h10
5 files changed, 178 insertions, 284 deletions
diff --git a/thunar/thunar-abstract-icon-view.c b/thunar/thunar-abstract-icon-view.c
index fcda72c4..a7562923 100644
--- a/thunar/thunar-abstract-icon-view.c
+++ b/thunar/thunar-abstract-icon-view.c
@@ -33,73 +33,57 @@
-static void thunar_abstract_icon_view_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
-static GList *thunar_abstract_icon_view_get_selected_items (ThunarStandardView *standard_view);
-static void thunar_abstract_icon_view_select_all (ThunarStandardView *standard_view);
-static void thunar_abstract_icon_view_unselect_all (ThunarStandardView *standard_view);
-static void thunar_abstract_icon_view_selection_invert (ThunarStandardView *standard_view);
-static void thunar_abstract_icon_view_select_path (ThunarStandardView *standard_view,
- GtkTreePath *path);
-static void thunar_abstract_icon_view_set_cursor (ThunarStandardView *standard_view,
- GtkTreePath *path,
- gboolean start_editing);
-static void thunar_abstract_icon_view_scroll_to_path (ThunarStandardView *standard_view,
- GtkTreePath *path,
- gboolean use_align,
- gfloat row_align,
- gfloat col_align);
-static GtkTreePath *thunar_abstract_icon_view_get_path_at_pos (ThunarStandardView *standard_view,
- gint x,
- gint y);
-static gboolean thunar_abstract_icon_view_get_visible_range (ThunarStandardView *standard_view,
- GtkTreePath **start_path,
- GtkTreePath **end_path);
-static void thunar_abstract_icon_view_highlight_path (ThunarStandardView *standard_view,
- GtkTreePath *path);
-static void thunar_abstract_icon_view_connect_accelerators (ThunarStandardView *standard_view,
- GtkAccelGroup *accel_group);
-static void thunar_abstract_icon_view_disconnect_accelerators(ThunarStandardView *standard_view,
- GtkAccelGroup *accel_group);
-static void thunar_abstract_icon_view_append_menu_items (ThunarStandardView *standard_view,
- GtkMenu *menu,
- GtkAccelGroup *accel_group);
-static void thunar_abstract_icon_view_notify_model (ExoIconView *view,
- GParamSpec *pspec,
- ThunarAbstractIconView *abstract_icon_view);
-static gboolean thunar_abstract_icon_view_button_press_event (ExoIconView *view,
- GdkEventButton *event,
- ThunarAbstractIconView *abstract_icon_view);
-static gboolean thunar_abstract_icon_view_button_release_event (ExoIconView *view,
- GdkEventButton *event,
- ThunarAbstractIconView *abstract_icon_view);
-static gboolean thunar_abstract_icon_view_draw (ExoIconView *view,
- cairo_t *cr,
- ThunarAbstractIconView *abstract_icon_view);
-static gboolean thunar_abstract_icon_view_key_press_event (ExoIconView *view,
- GdkEventKey *event,
- ThunarAbstractIconView *abstract_icon_view);
-static gboolean thunar_abstract_icon_view_motion_notify_event (ExoIconView *view,
- GdkEventMotion *event,
- ThunarAbstractIconView *abstract_icon_view);
-static void thunar_abstract_icon_view_item_activated (ExoIconView *view,
- GtkTreePath *path,
- ThunarAbstractIconView *abstract_icon_view);
-static void thunar_abstract_icon_view_sort_column_changed (GtkTreeSortable *sortable,
- ThunarAbstractIconView *abstract_icon_view);
-static void thunar_abstract_icon_view_zoom_level_changed (ThunarAbstractIconView *abstract_icon_view);
-static void thunar_abstract_icon_view_action_sort_by_name (ThunarStandardView *standard_view);
-static void thunar_abstract_icon_view_action_sort_by_size (ThunarStandardView *standard_view);
-static void thunar_abstract_icon_view_action_sort_by_type (ThunarStandardView *standard_view);
-static void thunar_abstract_icon_view_action_sort_by_date (ThunarStandardView *standard_view);
-static void thunar_abstract_icon_view_action_sort_ascending (ThunarStandardView *standard_view);
-static void thunar_abstract_icon_view_action_sort_descending(ThunarStandardView *standard_view);
+static void thunar_abstract_icon_view_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
+static GList *thunar_abstract_icon_view_get_selected_items (ThunarStandardView *standard_view);
+static void thunar_abstract_icon_view_select_all (ThunarStandardView *standard_view);
+static void thunar_abstract_icon_view_unselect_all (ThunarStandardView *standard_view);
+static void thunar_abstract_icon_view_selection_invert (ThunarStandardView *standard_view);
+static void thunar_abstract_icon_view_select_path (ThunarStandardView *standard_view,
+ GtkTreePath *path);
+static void thunar_abstract_icon_view_set_cursor (ThunarStandardView *standard_view,
+ GtkTreePath *path,
+ gboolean start_editing);
+static void thunar_abstract_icon_view_scroll_to_path (ThunarStandardView *standard_view,
+ GtkTreePath *path,
+ gboolean use_align,
+ gfloat row_align,
+ gfloat col_align);
+static GtkTreePath *thunar_abstract_icon_view_get_path_at_pos (ThunarStandardView *standard_view,
+ gint x,
+ gint y);
+static gboolean thunar_abstract_icon_view_get_visible_range (ThunarStandardView *standard_view,
+ GtkTreePath **start_path,
+ GtkTreePath **end_path);
+static void thunar_abstract_icon_view_highlight_path (ThunarStandardView *standard_view,
+ GtkTreePath *path);
+static void thunar_abstract_icon_view_notify_model (ExoIconView *view,
+ GParamSpec *pspec,
+ ThunarAbstractIconView *abstract_icon_view);
+static gboolean thunar_abstract_icon_view_button_press_event (ExoIconView *view,
+ GdkEventButton *event,
+ ThunarAbstractIconView *abstract_icon_view);
+static gboolean thunar_abstract_icon_view_button_release_event (ExoIconView *view,
+ GdkEventButton *event,
+ ThunarAbstractIconView *abstract_icon_view);
+static gboolean thunar_abstract_icon_view_draw (ExoIconView *view,
+ cairo_t *cr,
+ ThunarAbstractIconView *abstract_icon_view);
+static gboolean thunar_abstract_icon_view_key_press_event (ExoIconView *view,
+ GdkEventKey *event,
+ ThunarAbstractIconView *abstract_icon_view);
+static gboolean thunar_abstract_icon_view_motion_notify_event (ExoIconView *view,
+ GdkEventMotion *event,
+ ThunarAbstractIconView *abstract_icon_view);
+static void thunar_abstract_icon_view_item_activated (ExoIconView *view,
+ GtkTreePath *path,
+ ThunarAbstractIconView *abstract_icon_view);
+static void thunar_abstract_icon_view_zoom_level_changed (ThunarAbstractIconView *abstract_icon_view);
+
+
struct _ThunarAbstractIconViewPrivate
{
- GtkSortType sort_order;
- gint sort_column;
-
/* mouse gesture support */
gint gesture_start_x;
gint gesture_start_y;
@@ -113,21 +97,6 @@ struct _ThunarAbstractIconViewPrivate
};
-static XfceGtkActionEntry thunar_abstract_icon_view_action_entries[] =
-{
- { THUNAR_ABSTRACT_ICON_VIEW_ACTION_ARRANGE_ITEMS_MENU, "<Actions>/ThunarStandardView/arrange-items-menu", "", XFCE_GTK_MENU_ITEM, N_ ("Arran_ge Items"), NULL, NULL, G_CALLBACK (NULL), },
- { THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_NAME, "<Actions>/ThunarStandardView/sort-by-name", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("By _Name"), N_ ("Keep items sorted by their name"), NULL, G_CALLBACK (thunar_abstract_icon_view_action_sort_by_name), },
- { THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_SIZE, "<Actions>/ThunarStandardView/sort-by-size", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("By _Size"), N_ ("Keep items sorted by their size"), NULL, G_CALLBACK (thunar_abstract_icon_view_action_sort_by_size), },
- { THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_TYPE, "<Actions>/ThunarStandardView/sort-by-type", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("By _Type"), N_ ("Keep items sorted by their type"), NULL, G_CALLBACK (thunar_abstract_icon_view_action_sort_by_type), },
- { THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_MTIME, "<Actions>/ThunarStandardView/sort-by-mtime", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("By Modification _Date"), N_ ("Keep items sorted by their modification date"), NULL, G_CALLBACK (thunar_abstract_icon_view_action_sort_by_date), },
- { THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_ASCENDING, "<Actions>/ThunarStandardView/sort-ascending", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("_Ascending"), N_ ("Sort items in ascending order"), NULL, G_CALLBACK (thunar_abstract_icon_view_action_sort_ascending), },
- { THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_DESCENDING, "<Actions>/ThunarStandardView/sort-descending", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("_Descending"), N_ ("Sort items in descending order"), NULL, G_CALLBACK (thunar_abstract_icon_view_action_sort_descending), },
-};
-
-#define get_action_entry(id) xfce_gtk_get_action_entry_by_id(thunar_abstract_icon_view_action_entries,G_N_ELEMENTS(thunar_abstract_icon_view_action_entries),id)
-
-
-
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ThunarAbstractIconView, thunar_abstract_icon_view, THUNAR_TYPE_STANDARD_VIEW)
@@ -152,11 +121,6 @@ thunar_abstract_icon_view_class_init (ThunarAbstractIconViewClass *klass)
thunarstandard_view_class->get_path_at_pos = thunar_abstract_icon_view_get_path_at_pos;
thunarstandard_view_class->get_visible_range = thunar_abstract_icon_view_get_visible_range;
thunarstandard_view_class->highlight_path = thunar_abstract_icon_view_highlight_path;
- thunarstandard_view_class->append_menu_items = thunar_abstract_icon_view_append_menu_items;
- thunarstandard_view_class->connect_accelerators = thunar_abstract_icon_view_connect_accelerators;
- thunarstandard_view_class->disconnect_accelerators = thunar_abstract_icon_view_disconnect_accelerators;
-
- xfce_gtk_translate_action_entries (thunar_abstract_icon_view_action_entries, G_N_ELEMENTS (thunar_abstract_icon_view_action_entries));
/**
* ThunarAbstractIconView:column-spacing:
@@ -225,11 +189,6 @@ thunar_abstract_icon_view_init (ThunarAbstractIconView *abstract_icon_view)
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (view), THUNAR_STANDARD_VIEW (abstract_icon_view)->name_renderer,
"text", THUNAR_COLUMN_NAME);
- /* we need to listen to sort column changes to sync the menu items */
- g_signal_connect (G_OBJECT (THUNAR_STANDARD_VIEW (abstract_icon_view)->model), "sort-column-changed",
- G_CALLBACK (thunar_abstract_icon_view_sort_column_changed), abstract_icon_view);
- thunar_abstract_icon_view_sort_column_changed (GTK_TREE_SORTABLE (THUNAR_STANDARD_VIEW (abstract_icon_view)->model), abstract_icon_view);
-
/* update the icon view on size-allocate events */
/* TODO: issue not reproducible anymore as of gtk 3.24.18
* we can probably remove this in the future. */
@@ -371,94 +330,6 @@ thunar_abstract_icon_view_highlight_path (ThunarStandardView *standard_view,
-/**
- * thunar_abstract_icon_view_connect_accelerators:
- * @standard_view : a #ThunarStandardView
- * @accel_group : a #GtkAccelGroup to be used used for new menu items
- *
- * Connects all accelerators and corresponding default keys of this widget to the global accelerator list
- * The concrete implementation depends on the concrete widget which is implementing this view
- **/
-static void
-thunar_abstract_icon_view_connect_accelerators (ThunarStandardView *standard_view,
- GtkAccelGroup *accel_group)
-{
- ThunarAbstractIconView *abstract_icon_view = THUNAR_ABSTRACT_ICON_VIEW (standard_view);
-
- _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view));
-
- xfce_gtk_accel_map_add_entries (thunar_abstract_icon_view_action_entries,
- G_N_ELEMENTS (thunar_abstract_icon_view_action_entries));
- xfce_gtk_accel_group_connect_action_entries (accel_group,
- thunar_abstract_icon_view_action_entries,
- G_N_ELEMENTS (thunar_abstract_icon_view_action_entries),
- standard_view);
-}
-
-
-
-/**
- * thunar_abstract_icon_view_disconnect_accelerators:
- * @standard_view : a #ThunarStandardView
- * @accel_group : a #GtkAccelGroup to be used used for new menu items
- *
- * Disconnects all accelerators from the passed #GtkAccelGroup
- **/
-static void
-thunar_abstract_icon_view_disconnect_accelerators (ThunarStandardView *standard_view,
- GtkAccelGroup *accel_group)
-{
- /* Dont listen to the accel keys defined by the action entries any more */
- xfce_gtk_accel_group_disconnect_action_entries (accel_group,
- thunar_abstract_icon_view_action_entries,
- G_N_ELEMENTS (thunar_abstract_icon_view_action_entries));
-}
-
-
-
-/**
- * thunar_abstract_icon_view_append_menu_items:
- * @standard_view : a #ThunarStandardView
- * @menu : the #GtkMenu to add the menu items
- * @accel_group : a #GtkAccelGroup to be used used for new menu items
- *
- * Appends widget-specific menu items to a #GtkMenu and connects them to the passed #GtkAccelGroup
- * Implements method 'append_menu_items' of #ThunarStandardView
- **/
-static void
-thunar_abstract_icon_view_append_menu_items (ThunarStandardView *standard_view,
- GtkMenu *menu,
- GtkAccelGroup *accel_group)
-{
- ThunarAbstractIconView *abstract_icon_view = THUNAR_ABSTRACT_ICON_VIEW (standard_view);
- GtkWidget *submenu;
- GtkWidget *item;
-
- _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view));
-
- item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_ABSTRACT_ICON_VIEW_ACTION_ARRANGE_ITEMS_MENU), NULL, GTK_MENU_SHELL (menu));
- submenu = gtk_menu_new();
- if (accel_group != NULL)
- gtk_menu_set_accel_group (GTK_MENU (submenu), accel_group);
- xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_NAME), G_OBJECT (standard_view),
- abstract_icon_view->priv->sort_column == THUNAR_COLUMN_NAME, GTK_MENU_SHELL (submenu));
- xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_SIZE), G_OBJECT (standard_view),
- abstract_icon_view->priv->sort_column == THUNAR_COLUMN_SIZE, GTK_MENU_SHELL (submenu));
- xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_TYPE), G_OBJECT (standard_view),
- abstract_icon_view->priv->sort_column == THUNAR_COLUMN_TYPE, GTK_MENU_SHELL (submenu));
- xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_MTIME), G_OBJECT (standard_view),
- abstract_icon_view->priv->sort_column == THUNAR_COLUMN_DATE_MODIFIED, GTK_MENU_SHELL (submenu));
- xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu));
- xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_ASCENDING), G_OBJECT (standard_view),
- abstract_icon_view->priv->sort_order == GTK_SORT_ASCENDING, GTK_MENU_SHELL (submenu));
- xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_DESCENDING), G_OBJECT (standard_view),
- abstract_icon_view->priv->sort_order == GTK_SORT_DESCENDING, GTK_MENU_SHELL (submenu));
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), GTK_WIDGET (submenu));
- gtk_widget_show (item);
-}
-
-
-
static const XfceGtkActionEntry*
thunar_abstract_icon_view_gesture_action (ThunarAbstractIconView *abstract_icon_view, GtkTextDirection direction)
{
@@ -497,78 +368,6 @@ thunar_abstract_icon_view_gesture_action (ThunarAbstractIconView *abstract_icon_
static void
-thunar_abstract_icon_view_action_sort_by_name (ThunarStandardView *standard_view)
-{
- ThunarAbstractIconView *abstract_icon_view = THUNAR_ABSTRACT_ICON_VIEW (standard_view);
-
- _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view));
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), THUNAR_COLUMN_NAME, abstract_icon_view->priv->sort_order);
-}
-
-
-
-static void
-thunar_abstract_icon_view_action_sort_by_size (ThunarStandardView *standard_view)
-{
- ThunarAbstractIconView *abstract_icon_view = THUNAR_ABSTRACT_ICON_VIEW (standard_view);
-
- _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view));
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), THUNAR_COLUMN_SIZE, abstract_icon_view->priv->sort_order);
-}
-
-
-
-static void
-thunar_abstract_icon_view_action_sort_by_type (ThunarStandardView *standard_view)
-{
- ThunarAbstractIconView *abstract_icon_view = THUNAR_ABSTRACT_ICON_VIEW (standard_view);
-
- _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view));
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), THUNAR_COLUMN_TYPE, abstract_icon_view->priv->sort_order);
-}
-
-
-
-static void
-thunar_abstract_icon_view_action_sort_by_date (ThunarStandardView *standard_view)
-{
- ThunarAbstractIconView *abstract_icon_view = THUNAR_ABSTRACT_ICON_VIEW (standard_view);
-
- _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view));
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), THUNAR_COLUMN_DATE_MODIFIED, abstract_icon_view->priv->sort_order);
-}
-
-
-
-static void
-thunar_abstract_icon_view_action_sort_ascending (ThunarStandardView *standard_view)
-{
- ThunarAbstractIconView *abstract_icon_view = THUNAR_ABSTRACT_ICON_VIEW (standard_view);
-
- _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view));
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), abstract_icon_view->priv->sort_column, GTK_SORT_ASCENDING);
-}
-
-
-
-static void
-thunar_abstract_icon_view_action_sort_descending (ThunarStandardView *standard_view)
-{
- ThunarAbstractIconView *abstract_icon_view = THUNAR_ABSTRACT_ICON_VIEW (standard_view);
-
- _thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view));
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), abstract_icon_view->priv->sort_column, GTK_SORT_DESCENDING);
-}
-
-
-
-static void
thunar_abstract_icon_view_notify_model (ExoIconView *view,
GParamSpec *pspec,
ThunarAbstractIconView *abstract_icon_view)
@@ -838,22 +637,6 @@ thunar_abstract_icon_view_item_activated (ExoIconView *view,
static void
-thunar_abstract_icon_view_sort_column_changed (GtkTreeSortable *sortable,
- ThunarAbstractIconView *abstract_icon_view)
-{
- GtkSortType order;
- gint column;
-
- if (gtk_tree_sortable_get_sort_column_id (sortable, &column, &order))
- {
- abstract_icon_view->priv->sort_column = column;
- abstract_icon_view->priv->sort_order = order;
- }
-}
-
-
-
-static void
thunar_abstract_icon_view_zoom_level_changed (ThunarAbstractIconView *abstract_icon_view)
{
_thunar_return_if_fail (THUNAR_IS_ABSTRACT_ICON_VIEW (abstract_icon_view));
diff --git a/thunar/thunar-abstract-icon-view.h b/thunar/thunar-abstract-icon-view.h
index 15d5a375..84a3d045 100644
--- a/thunar/thunar-abstract-icon-view.h
+++ b/thunar/thunar-abstract-icon-view.h
@@ -35,18 +35,6 @@ typedef struct _ThunarAbstractIconView ThunarAbstractIconView;
#define THUNAR_IS_ABSTRACT_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), THUNAR_TYPE_ABSTRACT_ICON_VIEW))
#define THUNAR_ABSTRACT_ICON_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_ABSTRACT_ICON_VIEW, ThunarAbstractIconViewClass))
-/* #XfceGtkActionEntrys provided by this widget */
-typedef enum
-{
- THUNAR_ABSTRACT_ICON_VIEW_ACTION_ARRANGE_ITEMS_MENU,
- THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_NAME,
- THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_SIZE,
- THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_TYPE,
- THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_BY_MTIME,
- THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_ASCENDING,
- THUNAR_ABSTRACT_ICON_VIEW_ACTION_SORT_DESCENDING,
-} ThunarAbstractIconViewAction;
-
struct _ThunarAbstractIconViewClass
{
ThunarStandardViewClass __parent__;
diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c
index d8045534..2b34a9c8 100644
--- a/thunar/thunar-details-view.c
+++ b/thunar/thunar-details-view.c
@@ -112,12 +112,13 @@ static void thunar_details_view_append_menu_items (ThunarStandardV
GtkAccelGroup *accel_group);
-
struct _ThunarDetailsViewClass
{
ThunarStandardViewClass __parent__;
};
+
+
struct _ThunarDetailsView
{
ThunarStandardView __parent__;
@@ -136,13 +137,14 @@ struct _ThunarDetailsView
/* event source id for thunar_details_view_zoom_level_changed_reload_fixed_columns */
guint idle_id;
+
};
static XfceGtkActionEntry thunar_details_view_action_entries[] =
{
- { THUNAR_DETAILS_VIEW_ACTION_CONFIGURE_COLUMNS, "<Actions>/ThunarStandardView/configure-columns", "", XFCE_GTK_MENU_ITEM , N_ ("Configure _Columns..."), N_("Configure the columns in the detailed list view"), NULL, G_CALLBACK (thunar_show_column_editor), },
+ { THUNAR_DETAILS_VIEW_ACTION_CONFIGURE_COLUMNS, "<Actions>/ThunarStandardView/configure-columns", "", XFCE_GTK_MENU_ITEM , N_ ("Configure _Columns..."), N_("Configure the columns in the detailed list view"), NULL, G_CALLBACK (thunar_show_column_editor), },
};
#define get_action_entry(id) xfce_gtk_get_action_entry_by_id(thunar_details_view_action_entries,G_N_ELEMENTS(thunar_details_view_action_entries),id)
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 5b5a329e..0fcd4c55 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -268,7 +268,15 @@ static void thunar_standard_view_size_allocate (Thu
static void thunar_standard_view_connect_accelerators (ThunarStandardView *standard_view);
static void thunar_standard_view_disconnect_accelerators (ThunarStandardView *standard_view);
-
+static void thunar_standard_view_action_sort_by_name (ThunarStandardView *standard_view);
+static void thunar_standard_view_action_sort_by_type (ThunarStandardView *standard_view);
+static void thunar_standard_view_action_sort_by_date (ThunarStandardView *standard_view);
+static void thunar_standard_view_action_sort_by_size (ThunarStandardView *standard_view);
+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);
+static void thunar_standard_view_store_sort_column (ThunarStandardView *standard_view);
struct _ThunarStandardViewPrivate
{
@@ -341,6 +349,12 @@ struct _ThunarStandardViewPrivate
/* Tree path for restoring the selection after selecting and
* deleting an item */
GtkTreePath *selection_before_delete;
+
+ /* current sort column ID */
+ ThunarColumn sort_column;
+
+ /* current sort_order (GTK_SORT_ASCENDING || GTK_SORT_DESCENDING) */
+ GtkSortType sort_order;
};
static XfceGtkActionEntry thunar_standard_view_action_entries[] =
@@ -348,6 +362,13 @@ static XfceGtkActionEntry thunar_standard_view_action_entries[] =
{ THUNAR_STANDARD_VIEW_ACTION_SELECT_ALL_FILES, "<Actions>/ThunarStandardView/select-all-files", "<Primary>a", XFCE_GTK_MENU_ITEM, N_ ("Select _all Files"), N_ ("Select all files in this window"), NULL, G_CALLBACK (thunar_standard_view_select_all_files), },
{ THUNAR_STANDARD_VIEW_ACTION_SELECT_BY_PATTERN, "<Actions>/ThunarStandardView/select-by-pattern", "<Primary>s", XFCE_GTK_MENU_ITEM, N_ ("Select _by Pattern..."), N_ ("Select all files that match a certain pattern"), NULL, G_CALLBACK (thunar_standard_view_select_by_pattern), },
{ THUNAR_STANDARD_VIEW_ACTION_INVERT_SELECTION, "<Actions>/ThunarStandardView/invert-selection", "", XFCE_GTK_MENU_ITEM, N_ ("_Invert Selection"), N_ ("Select all files but not those currently selected"), NULL, G_CALLBACK (thunar_standard_view_selection_invert), },
+ { THUNAR_STANDARD_VIEW_ACTION_ARRANGE_ITEMS_MENU,"<Actions>/ThunarStandardView/arrange-items-menu", "", XFCE_GTK_MENU_ITEM, N_ ("Arran_ge Items"), NULL, NULL, G_CALLBACK (NULL), },
+ { THUNAR_STANDARD_VIEW_ACTION_SORT_BY_NAME, "<Actions>/ThunarStandardView/sort-by-name", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("By _Name"), N_ ("Keep items sorted by their name"), NULL, G_CALLBACK (thunar_standard_view_action_sort_by_name), },
+ { THUNAR_STANDARD_VIEW_ACTION_SORT_BY_SIZE, "<Actions>/ThunarStandardView/sort-by-size", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("By _Size"), N_ ("Keep items sorted by their size"), NULL, G_CALLBACK (thunar_standard_view_action_sort_by_size), },
+ { THUNAR_STANDARD_VIEW_ACTION_SORT_BY_TYPE, "<Actions>/ThunarStandardView/sort-by-type", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("By _Type"), N_ ("Keep items sorted by their type"), NULL, G_CALLBACK (thunar_standard_view_action_sort_by_type), },
+ { THUNAR_STANDARD_VIEW_ACTION_SORT_BY_MTIME, "<Actions>/ThunarStandardView/sort-by-mtime", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("By Modification _Date"), N_ ("Keep items sorted by their modification date"), NULL, G_CALLBACK (thunar_standard_view_action_sort_by_date), },
+ { THUNAR_STANDARD_VIEW_ACTION_SORT_ASCENDING, "<Actions>/ThunarStandardView/sort-ascending", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("_Ascending"), N_ ("Sort items in ascending order"), NULL, G_CALLBACK (thunar_standard_view_action_sort_ascending), },
+ { THUNAR_STANDARD_VIEW_ACTION_SORT_DESCENDING, "<Actions>/ThunarStandardView/sort-descending", "", XFCE_GTK_RADIO_MENU_ITEM, N_ ("_Descending"), N_ ("Sort items in descending order"), NULL, G_CALLBACK (thunar_standard_view_action_sort_descending), },
};
#define get_action_entry(id) xfce_gtk_get_action_entry_by_id(thunar_standard_view_action_entries,G_N_ELEMENTS(thunar_standard_view_action_entries),id)
@@ -380,6 +401,58 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ThunarStandardView, thunar_standard_view, GTK_
G_ADD_PRIVATE (ThunarStandardView))
+static void
+thunar_standard_view_action_sort_ascending (ThunarStandardView *standard_view)
+{
+
+ if (standard_view->priv->sort_order == GTK_SORT_DESCENDING)
+ thunar_standard_view_set_sort_column (standard_view, standard_view->priv->sort_column);
+}
+
+static void
+thunar_standard_view_action_sort_descending (ThunarStandardView *standard_view)
+{
+ if (standard_view->priv->sort_order == GTK_SORT_ASCENDING)
+ thunar_standard_view_set_sort_column (standard_view, standard_view->priv->sort_column);
+}
+
+static void
+thunar_standard_view_set_sort_column (ThunarStandardView *standard_view, ThunarColumn column)
+{
+ GtkSortType order = standard_view->priv->sort_order;
+
+ if (standard_view->priv->sort_column == column)
+ order = (order == GTK_SORT_ASCENDING ? GTK_SORT_DESCENDING: GTK_SORT_ASCENDING);
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), column, order);
+}
+
+
+static void
+thunar_standard_view_action_sort_by_name (ThunarStandardView *standard_view)
+{
+ thunar_standard_view_set_sort_column (standard_view, THUNAR_COLUMN_NAME);
+}
+
+static void
+thunar_standard_view_action_sort_by_size (ThunarStandardView *standard_view)
+{
+ thunar_standard_view_set_sort_column (standard_view, THUNAR_COLUMN_SIZE);
+}
+
+static void
+thunar_standard_view_action_sort_by_type (ThunarStandardView *standard_view)
+{
+ thunar_standard_view_set_sort_column (standard_view, THUNAR_COLUMN_TYPE);
+}
+
+static void
+thunar_standard_view_action_sort_by_date (ThunarStandardView *standard_view)
+{
+ thunar_standard_view_set_sort_column (standard_view, THUNAR_COLUMN_DATE_MODIFIED);
+}
+
+
static void
thunar_standard_view_class_init (ThunarStandardViewClass *klass)
@@ -647,6 +720,17 @@ thunar_standard_view_init (ThunarStandardView *standard_view)
standard_view->accel_group = NULL;
}
+static void thunar_standard_view_store_sort_column (ThunarStandardView *standard_view)
+{
+ GtkSortType sort_order;
+ gint sort_column;
+
+ if (gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (standard_view->model), &sort_column, &sort_order))
+ {
+ standard_view->priv->sort_column = sort_column;
+ standard_view->priv->sort_order = sort_order;
+ }
+}
static GObject*
@@ -984,6 +1068,8 @@ thunar_standard_view_realize (GtkWidget *widget)
/* apply the thumbnail frame preferences after icon_factory got initialized */
exo_binding_new (G_OBJECT (standard_view->preferences), "misc-thumbnail-draw-frames", G_OBJECT (standard_view), "thumbnail-draw-frames");
+ /* store sort information to keep indicators in menu in sync */
+ thunar_standard_view_store_sort_column (standard_view);
}
@@ -3124,6 +3210,8 @@ thunar_standard_view_sort_column_changed (GtkTreeSortable *tree_sortable,
/* determine the new sort column and sort order, and save them */
if (gtk_tree_sortable_get_sort_column_id (tree_sortable, &sort_column, &sort_order))
{
+ thunar_standard_view_store_sort_column (standard_view);
+
if (standard_view->priv->directory_specific_settings)
{
const gchar *sort_column_name;
@@ -3797,9 +3885,32 @@ thunar_standard_view_append_menu_items (ThunarStandardView *standard_view,
GtkMenu *menu,
GtkAccelGroup *accel_group)
{
+
+ GtkWidget *item;
+ GtkWidget *submenu;
+
_thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
- (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->append_menu_items) (standard_view, menu, accel_group);
+ item = xfce_gtk_menu_item_new_from_action_entry (get_action_entry (THUNAR_STANDARD_VIEW_ACTION_ARRANGE_ITEMS_MENU), NULL, GTK_MENU_SHELL (menu));
+ submenu = gtk_menu_new();
+ xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STANDARD_VIEW_ACTION_SORT_BY_NAME), G_OBJECT (standard_view),
+ standard_view->priv->sort_column == THUNAR_COLUMN_NAME, GTK_MENU_SHELL (submenu));
+ xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STANDARD_VIEW_ACTION_SORT_BY_SIZE), G_OBJECT (standard_view),
+ standard_view->priv->sort_column == THUNAR_COLUMN_SIZE, GTK_MENU_SHELL (submenu));
+ xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STANDARD_VIEW_ACTION_SORT_BY_TYPE), G_OBJECT (standard_view),
+ standard_view->priv->sort_column == THUNAR_COLUMN_TYPE, GTK_MENU_SHELL (submenu));
+ xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STANDARD_VIEW_ACTION_SORT_BY_MTIME), G_OBJECT (standard_view),
+ standard_view->priv->sort_column == THUNAR_COLUMN_DATE_MODIFIED, GTK_MENU_SHELL (submenu));
+ xfce_gtk_menu_append_seperator (GTK_MENU_SHELL (submenu));
+ xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STANDARD_VIEW_ACTION_SORT_ASCENDING), G_OBJECT (standard_view),
+ standard_view->priv->sort_order == GTK_SORT_ASCENDING, GTK_MENU_SHELL (submenu));
+ xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STANDARD_VIEW_ACTION_SORT_DESCENDING), G_OBJECT (standard_view),
+ standard_view->priv->sort_order == GTK_SORT_DESCENDING, GTK_MENU_SHELL (submenu));
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), GTK_WIDGET (submenu));
+ gtk_widget_show (item);
+
+ if (THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->append_menu_items != NULL)
+ (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->append_menu_items) (standard_view, menu, accel_group);
}
@@ -3848,7 +3959,8 @@ thunar_standard_view_connect_accelerators (ThunarStandardView *standard_view)
standard_view);
/* as well append accelerators of derived widgets */
- (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->connect_accelerators) (standard_view, standard_view->accel_group);
+ if (THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->connect_accelerators != NULL)
+ (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->connect_accelerators) (standard_view, standard_view->accel_group);
}
@@ -3874,7 +3986,8 @@ thunar_standard_view_disconnect_accelerators (ThunarStandardView *standard_view)
G_N_ELEMENTS (thunar_standard_view_action_entries));
/* as well disconnect accelerators of derived widgets */
- (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->disconnect_accelerators) (standard_view, standard_view->accel_group);
+ if (THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->disconnect_accelerators != NULL)
+ (*THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->disconnect_accelerators) (standard_view, standard_view->accel_group);
/* and release the accel group */
g_object_unref (standard_view->accel_group);
diff --git a/thunar/thunar-standard-view.h b/thunar/thunar-standard-view.h
index 0051b843..8a7c6c68 100644
--- a/thunar/thunar-standard-view.h
+++ b/thunar/thunar-standard-view.h
@@ -46,7 +46,14 @@ typedef enum
THUNAR_STANDARD_VIEW_ACTION_SELECT_ALL_FILES,
THUNAR_STANDARD_VIEW_ACTION_SELECT_BY_PATTERN,
THUNAR_STANDARD_VIEW_ACTION_INVERT_SELECTION,
-
+ THUNAR_STANDARD_VIEW_ACTION_ARRANGE_ITEMS_MENU,
+ THUNAR_STANDARD_VIEW_ACTION_SORT_BY_NAME,
+ THUNAR_STANDARD_VIEW_ACTION_SORT_BY_SIZE,
+ THUNAR_STANDARD_VIEW_ACTION_SORT_BY_TYPE,
+ THUNAR_STANDARD_VIEW_ACTION_SORT_BY_MTIME,
+ THUNAR_STANDARD_VIEW_ACTION_SORT_ASCENDING,
+ THUNAR_STANDARD_VIEW_ACTION_SORT_DESCENDING,
+
} ThunarStandardViewAction;
struct _ThunarStandardViewClass
@@ -167,6 +174,7 @@ void thunar_standard_view_append_menu_item (ThunarStandardView
void _thunar_standard_view_open_on_middle_click (ThunarStandardView *standard_view,
GtkTreePath *tree_path,
guint event_state);
+
G_END_DECLS;
#endif /* !__THUNAR_STANDARD_VIEW_H__ */