summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeteHemery <[email protected]>2025-06-20 08:03:56 +0100
committerGitHub <[email protected]>2025-06-20 07:03:56 +0000
commitbe3bbcc4144c69d0f65ab07aeb3e4e69e74d12a9 (patch)
treebb75c214c099c8e601ad080d4ab9efe4d83c7bec
parent891c063168f0d794228fd8069deca1f513453c4f (diff)
downloadeom-master.tar.bz2
eom-master.tar.xz
Add 'preserve-order' flag to allow viewing order specified on cmd line (#354)HEADmaster
-rw-r--r--.github/workflows/release.yml2
-rw-r--r--src/eom-jobs.c6
-rw-r--r--src/eom-jobs.h4
-rw-r--r--src/eom-list-store.c10
-rw-r--r--src/eom-list-store.h3
-rw-r--r--src/eom-window.c9
-rw-r--r--src/eom-window.h3
-rw-r--r--src/main.c5
8 files changed, 30 insertions, 12 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8d60b7f..929b8ad 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -24,7 +24,7 @@ jobs:
run: .github/workflows/builds.sh meson
- name: Install GH CLI
- uses: dev-hanz-ops/[email protected]
+ uses: dev-hanz-ops/[email protected]
with:
gh-cli-version: 2.39.1
diff --git a/src/eom-jobs.c b/src/eom-jobs.c
index bde2517..7104268 100644
--- a/src/eom-jobs.c
+++ b/src/eom-jobs.c
@@ -351,6 +351,7 @@ eom_job_model_class_init (EomJobModelClass *class)
/**
* eom_job_model_new:
* @file_list: (element-type GFile): a #GFile list
+ * @preserve_order: Flag to indicate whether to honor the order of input parameters.
*
* Creates a new #EomJob model.
*
@@ -358,13 +359,14 @@ eom_job_model_class_init (EomJobModelClass *class)
*/
EomJob *
-eom_job_model_new (GSList *file_list)
+eom_job_model_new (GSList *file_list, gboolean preserve_order)
{
EomJobModel *job;
job = g_object_new (EOM_TYPE_JOB_MODEL, NULL);
job->file_list = file_list;
+ job->preserve_order = preserve_order;
return EOM_JOB (job);
}
@@ -438,7 +440,7 @@ eom_job_model_run (EomJob *ejob)
job->store = EOM_LIST_STORE (eom_list_store_new ());
- eom_list_store_add_files (job->store, filtered_list);
+ eom_list_store_add_files (job->store, filtered_list, job->preserve_order);
g_list_free_full (filtered_list, g_object_unref);
g_list_free_full (error_list, g_free);
diff --git a/src/eom-jobs.h b/src/eom-jobs.h
index df2283e..37bc26e 100644
--- a/src/eom-jobs.h
+++ b/src/eom-jobs.h
@@ -163,6 +163,7 @@ struct _EomJobModel
EomJob parent;
EomListStore *store;
GSList *file_list;
+ gboolean preserve_order;
};
struct _EomJobModelClass
@@ -247,7 +248,8 @@ EomJob *eom_job_load_new (EomImage *image,
/* EomJobModel */
GType eom_job_model_get_type (void) G_GNUC_CONST;
-EomJob *eom_job_model_new (GSList *file_list);
+EomJob *eom_job_model_new (GSList *file_list,
+ gboolean preserve_order);
/* EomJobTransform */
GType eom_job_transform_get_type (void) G_GNUC_CONST;
diff --git a/src/eom-list-store.c b/src/eom-list-store.c
index 0115b1d..3d1a9c6 100644
--- a/src/eom-list-store.c
+++ b/src/eom-list-store.c
@@ -34,7 +34,8 @@ struct _EomListStorePrivate {
gint initial_image; /* The image that should be selected firstly by the view. */
GdkPixbuf *busy_image; /* Loading image icon */
GdkPixbuf *missing_image; /* Missing image icon */
- GMutex mutex; /* Mutex for saving the jobs in the model */
+ GMutex mutex; /* Mutex for saving the jobs in the model */
+ gboolean preserve_order; /* If TRUE, preserves the original order of files */
};
G_DEFINE_TYPE_WITH_PRIVATE (EomListStore, eom_list_store, GTK_TYPE_LIST_STORE);
@@ -529,6 +530,7 @@ eom_list_store_append_directory (EomListStore *store,
* eom_list_store_add_files:
* @store: An #EomListStore.
* @file_list: (element-type GFile): A %NULL-terminated list of #GFile's.
+ * @preserve_order: Flag to indicate whether to honor the order of input parameters.
*
* Adds a list of #GFile's to @store. The given list
* must be %NULL-terminated.
@@ -540,7 +542,7 @@ eom_list_store_append_directory (EomListStore *store,
*
**/
void
-eom_list_store_add_files (EomListStore *store, GList *file_list)
+eom_list_store_add_files (EomListStore *store, GList *file_list, gboolean preserve_order)
{
GList *it;
GFileInfo *file_info;
@@ -624,7 +626,11 @@ eom_list_store_add_files (EomListStore *store, GList *file_list)
g_free (caption);
}
+ /* Set the sort behaviour depending on the toggle option.
+ If preserve_order is TRUE, then preserve the order in which files were provided.
+ Otherwise, use the default sort function. */
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ preserve_order ? GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID : \
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
GTK_SORT_ASCENDING);
diff --git a/src/eom-list-store.h b/src/eom-list-store.h
index 6536b10..bc5052b 100644
--- a/src/eom-list-store.h
+++ b/src/eom-list-store.h
@@ -81,7 +81,8 @@ void eom_list_store_append_image (EomListStore *store,
EomImage *image);
void eom_list_store_add_files (EomListStore *store,
- GList *file_list);
+ GList *file_list,
+ gboolean preserve_order);
void eom_list_store_remove_image (EomListStore *store,
EomImage *image);
diff --git a/src/eom-window.c b/src/eom-window.c
index fb01794..c039d67 100644
--- a/src/eom-window.c
+++ b/src/eom-window.c
@@ -5329,9 +5329,10 @@ eom_window_class_init (EomWindowClass *class)
* @flags: the initialization parameters for the new window.
*
*
- * Creates a new and empty #EomWindow. Use @flags to indicate
- * if the window should be initialized fullscreen, in slideshow mode,
- * and/or without the thumbnails collection visible. See #EomStartupFlags.
+ * Creates a new and empty #EomWindow. Use @flags to indicate if the window
+ * should be initialized fullscreen, in slideshow mode, and/or without the
+ * thumbnails collection visible. Use preserve-order to maintain
+ * the order of input parameters instead of sorting. See #EomStartupFlags.
*
* Returns: a newly created #EomWindow.
**/
@@ -5471,7 +5472,7 @@ eom_window_open_file_list (EomWindow *window, GSList *file_list)
g_slist_foreach (file_list, (GFunc) g_object_ref, NULL);
window->priv->file_list = file_list;
- job = eom_job_model_new (file_list);
+ job = eom_job_model_new (file_list, !!(window->priv->flags & EOM_STARTUP_PRESERVE_ORDER));
g_signal_connect (job, "finished",
G_CALLBACK (eom_job_model_cb),
diff --git a/src/eom-window.h b/src/eom-window.h
index 04e028b..cd1d7b5 100644
--- a/src/eom-window.h
+++ b/src/eom-window.h
@@ -78,7 +78,8 @@ typedef enum {
typedef enum {
EOM_STARTUP_FULLSCREEN = 1 << 0,
EOM_STARTUP_SLIDE_SHOW = 1 << 1,
- EOM_STARTUP_DISABLE_COLLECTION = 1 << 2
+ EOM_STARTUP_DISABLE_COLLECTION = 1 << 2,
+ EOM_STARTUP_PRESERVE_ORDER = 1 << 3
} EomStartupFlags;
struct _EomWindow {
diff --git a/src/main.c b/src/main.c
index 1c4d725..94487d8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -52,6 +52,7 @@ static gboolean fullscreen = FALSE;
static gboolean slide_show = FALSE;
static gboolean disable_collection = FALSE;
static gboolean force_new_instance = FALSE;
+static gboolean preserve_order = FALSE;
static gchar **startup_files = NULL;
static gboolean
@@ -71,6 +72,7 @@ static const GOptionEntry goption_options[] =
{ "disable-image-collection", 'c', 0, G_OPTION_ARG_NONE, &disable_collection, N_("Disable image collection"), NULL },
{ "slide-show", 's', 0, G_OPTION_ARG_NONE, &slide_show, N_("Open in slideshow mode"), NULL },
{ "new-instance", 'n', 0, G_OPTION_ARG_NONE, &force_new_instance, N_("Start a new instance instead of reusing an existing one"), NULL },
+ { "preserve-order", 'p', 0, G_OPTION_ARG_NONE, &preserve_order, N_("Preserve the input file order (disable default sorting)"), NULL },
{ "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
_print_version_and_exit, N_("Show the application's version"), NULL},
{ NULL }
@@ -87,6 +89,9 @@ set_startup_flags (void)
if (slide_show)
flags |= EOM_STARTUP_SLIDE_SHOW;
+
+ if (preserve_order)
+ flags |= EOM_STARTUP_PRESERVE_ORDER;
}
int