Commit f6208969 authored by Igor's avatar Igor

Implement sorting by file type option

Resolves https://bugzilla.xfce.org/show_bug.cgi?id=12749
parent 44cf184a
......@@ -175,6 +175,8 @@ static RsttoImageListIter * rstto_image_list_iter_new ();
static gint
cb_rstto_image_list_image_name_compare_func (RsttoFile *a, RsttoFile *b);
static gint
cb_rstto_image_list_image_type_compare_func (RsttoFile *a, RsttoFile *b);
static gint
cb_rstto_image_list_exif_date_compare_func (RsttoFile *a, RsttoFile *b);
static GObjectClass *parent_class = NULL;
......@@ -1350,6 +1352,12 @@ rstto_image_list_set_sort_by_name (RsttoImageList *image_list)
rstto_image_list_set_compare_func (image_list, (GCompareFunc)cb_rstto_image_list_image_name_compare_func);
}
void
rstto_image_list_set_sort_by_type (RsttoImageList *image_list)
{
rstto_image_list_set_compare_func (image_list, (GCompareFunc)cb_rstto_image_list_image_type_compare_func);
}
void
rstto_image_list_set_sort_by_date (RsttoImageList *image_list)
{
......@@ -1373,6 +1381,23 @@ cb_rstto_image_list_image_name_compare_func (RsttoFile *a, RsttoFile *b)
return g_strcmp0(a_collate_key, b_collate_key);
}
/**
* cb_rstto_image_list_image_type_compare_func:
* @a:
* @b:
*
*
* Return value: (see strcmp)
*/
static gint
cb_rstto_image_list_image_type_compare_func (RsttoFile *a, RsttoFile *b)
{
const gchar *a_content_type = rstto_file_get_content_type (a);
const gchar *b_content_type = rstto_file_get_content_type (b);
return g_strcmp0(a_content_type, b_content_type);
}
/**
* cb_rstto_image_list_exif_date_compare_func:
* @a:
......
......@@ -133,6 +133,10 @@ void
rstto_image_list_set_sort_by_name (
RsttoImageList *image_list);
void
rstto_image_list_set_sort_by_type (
RsttoImageList *image_list);
void
rstto_image_list_set_sort_by_date (
RsttoImageList *image_list);
......
......@@ -610,20 +610,24 @@ static const GtkToggleActionEntry toggle_action_entries[] =
/** Image sorting options*/
static const GtkRadioActionEntry radio_action_sort_entries[] =
{
/* Sort by Filename */
{"sort-filename",
NULL, /* Icon-name */
N_("sort by filename"), /* Label-text */
NULL, /* Keyboard shortcut */
NULL, /* Tooltip text */
0},
/* Sort by Date*/
SORT_TYPE_NAME},
{"sort-filetype",
NULL, /* Icon-name */
N_("sort by filetype"), /* Label-text */
NULL, /* Keyboard shortcut */
NULL, /* Tooltip text */
SORT_TYPE_TYPE},
{"sort-date",
NULL, /* Icon-name */
N_("sort by date"), /* Label-text */
NULL, /* Keyboard shortcut */
NULL, /* Tooltip text */
1},
SORT_TYPE_DATE},
};
/** Navigationbar+Thumbnailbar positioning options*/
......@@ -1085,6 +1089,14 @@ rstto_main_window_init (RsttoMainWindow *window)
"/main-menu/edit-menu/sorting-menu/sort-filename")),
TRUE);
break;
case SORT_TYPE_TYPE:
gtk_check_menu_item_set_active (
GTK_CHECK_MENU_ITEM (
gtk_ui_manager_get_widget (
window->priv->ui_manager,
"/main-menu/edit-menu/sorting-menu/sort-filetype")),
TRUE);
break;
case SORT_TYPE_DATE:
gtk_check_menu_item_set_active (
GTK_CHECK_MENU_ITEM (
......@@ -2066,7 +2078,7 @@ cb_rstto_main_window_sorting_function_changed (GtkRadioAction *action, GtkRadioA
{
switch (gtk_radio_action_get_current_value (current))
{
case 0: /* Sort by filename */
case SORT_TYPE_NAME:
default:
if (window->priv->image_list != NULL)
{
......@@ -2074,7 +2086,14 @@ cb_rstto_main_window_sorting_function_changed (GtkRadioAction *action, GtkRadioA
rstto_settings_set_uint_property (window->priv->settings_manager, "sort-type", SORT_TYPE_NAME);
}
break;
case 1: /* Sort by date */
case SORT_TYPE_TYPE:
if (window->priv->image_list != NULL)
{
rstto_image_list_set_sort_by_type (window->priv->image_list);
rstto_settings_set_uint_property (window->priv->settings_manager, "sort-type", SORT_TYPE_TYPE);
}
break;
case SORT_TYPE_DATE:
if (window->priv->image_list != NULL)
{
rstto_image_list_set_sort_by_date (window->priv->image_list);
......
......@@ -21,6 +21,7 @@
<separator/>
<menu action="sorting-menu">
<menuitem action="sort-filename"/>
<menuitem action="sort-filetype"/>
<menuitem action="sort-date"/>
</menu>
<menuitem action="delete"/>
......
......@@ -44,6 +44,7 @@ typedef enum {
typedef enum {
SORT_TYPE_NAME = 0,
SORT_TYPE_TYPE,
SORT_TYPE_DATE,
SORT_TYPE_COUNT,
} RsttoSortType;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment