From 6edffb9a4bb14a05436e0f1213b09fcb43287073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Thu, 2 May 2024 20:54:23 +0200 Subject: [PATCH 01/12] clapper-app: Add command line options to set GStreamer elements Allows setting audio/video filters and sinks. By setting value to "none" default filter can be disabled. --- src/bin/clapper-app/clapper-app-application.c | 44 ++++++++++++++++++- src/bin/clapper-app/clapper-app-utils.c | 26 +++++++++++ src/bin/clapper-app/clapper-app-utils.h | 3 ++ src/bin/clapper-app/po/POTFILES | 1 + 4 files changed, 72 insertions(+), 2 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index d5d5206b..d983aaac 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -18,6 +18,7 @@ #include "config.h" #include +#include #include #include @@ -57,6 +58,15 @@ struct ClapperPluginData struct ClapperPluginFeatureData features[10]; }; +struct ClapperAppOptions +{ + gchar *video_filter; + gchar *audio_filter; + + gchar *video_sink; + gchar *audio_sink; +}; + typedef struct { const gchar *action; @@ -66,6 +76,18 @@ typedef struct #define parent_class clapper_app_application_parent_class G_DEFINE_TYPE (ClapperAppApplication, clapper_app_application, GTK_TYPE_APPLICATION); +static struct ClapperAppOptions app_opts = { 0, }; + +static inline void +_app_opts_free (void) +{ + g_free (app_opts.video_filter); + g_free (app_opts.audio_filter); + + g_free (app_opts.video_sink); + g_free (app_opts.audio_sink); +} + static inline void _set_initial_plugin_feature_ranks (void) { @@ -233,6 +255,15 @@ _restore_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_ GST_DEBUG ("Restoring saved GSettings values to: %" GST_PTR_FORMAT, app_window); + if (app_opts.video_filter) + clapper_player_set_video_filter (player, clapper_app_utils_make_element (app_opts.video_filter)); + if (app_opts.audio_filter) + clapper_player_set_audio_filter (player, clapper_app_utils_make_element (app_opts.audio_filter)); + if (app_opts.video_sink) + clapper_player_set_video_sink (player, clapper_app_utils_make_element (app_opts.video_sink)); + if (app_opts.audio_sink) + clapper_player_set_audio_sink (player, clapper_app_utils_make_element (app_opts.audio_sink)); + clapper_player_set_volume (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"))); clapper_player_set_mute (player, g_settings_get_boolean (self->settings, "mute")); clapper_player_set_speed (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "speed"))); @@ -512,7 +543,14 @@ clapper_app_application_constructed (GObject *object) GApplication *app = G_APPLICATION (self); guint i; - static const GActionEntry app_entries[] = { + const GOptionEntry app_options[] = { + { "video-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_filter, _("Video filter to use (\"none\" to disable)"), NULL }, + { "audio-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.audio_filter, _("Audio filter to use (\"none\" to disable)"), NULL }, + { "video-sink", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_sink, _("Video sink to use"), NULL }, + { "audio-sink", 0, 0, G_OPTION_ARG_STRING, &app_opts.audio_sink, _("Audio sink to use"), NULL }, + { NULL } + }; + static const GActionEntry app_actions[] = { { "add-files", add_files, NULL, NULL, NULL }, { "add-uri", add_uri, NULL, NULL, NULL }, { "info", show_info, NULL, NULL, NULL }, @@ -542,11 +580,12 @@ clapper_app_application_constructed (GObject *object) plugin_feature_ranks_settings_changed_cb (self->settings, NULL, NULL); g_action_map_add_action_entries (G_ACTION_MAP (app), - app_entries, G_N_ELEMENTS (app_entries), app); + app_actions, G_N_ELEMENTS (app_actions), app); for (i = 0; i < G_N_ELEMENTS (app_shortcuts); ++i) gtk_application_set_accels_for_action (GTK_APPLICATION (app), app_shortcuts[i].action, app_shortcuts[i].accels); + g_application_add_main_option_entries (app, app_options); g_application_add_option_group (app, gst_init_get_option_group ()); G_OBJECT_CLASS (parent_class)->constructed (object); @@ -560,6 +599,7 @@ clapper_app_application_finalize (GObject *object) GST_TRACE ("Finalize"); g_object_unref (self->settings); + _app_opts_free (); G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/src/bin/clapper-app/clapper-app-utils.c b/src/bin/clapper-app/clapper-app-utils.c index b328ef72..1aaf9eea 100644 --- a/src/bin/clapper-app/clapper-app-utils.c +++ b/src/bin/clapper-app/clapper-app-utils.c @@ -324,3 +324,29 @@ parse_overrides: g_free (stored_overrides); } + +GstElement * +clapper_app_utils_make_element (const gchar *string) +{ + gchar *char_loc; + + if (strcmp (string, "none") == 0) + return NULL; + + char_loc = strchr (string, ' '); + + if (char_loc) { + GstElement *element; + GError *error = NULL; + + element = gst_parse_bin_from_description (string, TRUE, &error); + if (error) { + GST_ERROR ("Bin parse error: \"%s\", reason: %s", string, error->message); + g_error_free (error); + } + + return element; + } + + return gst_element_factory_make (string, NULL); +} diff --git a/src/bin/clapper-app/clapper-app-utils.h b/src/bin/clapper-app/clapper-app-utils.h index cf854bd8..54dbbc0e 100644 --- a/src/bin/clapper-app/clapper-app-utils.h +++ b/src/bin/clapper-app/clapper-app-utils.h @@ -59,4 +59,7 @@ void clapper_app_utils_files_free (GFile **files); G_GNUC_INTERNAL void clapper_app_utils_iterate_plugin_feature_ranks (GSettings *settings, ClapperAppUtilsIterRanks callback, gpointer user_data); +G_GNUC_INTERNAL +GstElement * clapper_app_utils_make_element (const gchar *string); + G_END_DECLS diff --git a/src/bin/clapper-app/po/POTFILES b/src/bin/clapper-app/po/POTFILES index 025c0a8f..d5312691 100644 --- a/src/bin/clapper-app/po/POTFILES +++ b/src/bin/clapper-app/po/POTFILES @@ -10,6 +10,7 @@ src/bin/clapper-app/ui/clapper-app-uri-dialog.ui src/bin/clapper-app/ui/clapper-app-video-stream-list-item.ui src/bin/clapper-app/clapper-app-about-window.c +src/bin/clapper-app/clapper-app-application.c src/bin/clapper-app/clapper-app-info-window.c src/bin/clapper-app/clapper-app-list-item-utils.c src/bin/clapper-app/clapper-app-preferences-window.c From 1001fda2560a94411c9bf699e0d730b824c4f5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 3 May 2024 17:18:17 +0200 Subject: [PATCH 02/12] clapper-app: Add command line option to set volume --- src/bin/clapper-app/clapper-app-application.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index d983aaac..fccda1cc 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -60,6 +60,8 @@ struct ClapperPluginData struct ClapperAppOptions { + gdouble volume; + gchar *video_filter; gchar *audio_filter; @@ -264,7 +266,12 @@ _restore_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_ if (app_opts.audio_sink) clapper_player_set_audio_sink (player, clapper_app_utils_make_element (app_opts.audio_sink)); - clapper_player_set_volume (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"))); + /* NOTE: Not using ternary operator to avoid accidental typecasting */ + if (app_opts.volume >= 0) + clapper_player_set_volume (player, PERCENTAGE_ROUND (app_opts.volume)); + else + clapper_player_set_volume (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"))); + clapper_player_set_mute (player, g_settings_get_boolean (self->settings, "mute")); clapper_player_set_speed (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "speed"))); clapper_player_set_subtitles_enabled (player, g_settings_get_boolean (self->settings, "subtitles-enabled")); @@ -533,6 +540,8 @@ clapper_app_application_open (GApplication *app, static void clapper_app_application_init (ClapperAppApplication *self) { + app_opts.volume = -1; + self->need_init_state = TRUE; } @@ -544,6 +553,7 @@ clapper_app_application_constructed (GObject *object) guint i; const GOptionEntry app_options[] = { + { "volume", 0, 0, G_OPTION_ARG_DOUBLE, &app_opts.volume, _("Audio volume to set (0 - 2.0 range)"), NULL }, { "video-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_filter, _("Video filter to use (\"none\" to disable)"), NULL }, { "audio-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.audio_filter, _("Audio filter to use (\"none\" to disable)"), NULL }, { "video-sink", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_sink, _("Video sink to use"), NULL }, From eb0baa6fe660b0c28a91d0733f95e43d9137a486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 3 May 2024 17:37:16 +0200 Subject: [PATCH 03/12] clapper-app: Add command line option to set speed --- src/bin/clapper-app/clapper-app-application.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index fccda1cc..a9791c83 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -61,6 +61,7 @@ struct ClapperPluginData struct ClapperAppOptions { gdouble volume; + gdouble speed; gchar *video_filter; gchar *audio_filter; @@ -273,7 +274,12 @@ _restore_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_ clapper_player_set_volume (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"))); clapper_player_set_mute (player, g_settings_get_boolean (self->settings, "mute")); - clapper_player_set_speed (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "speed"))); + + if (app_opts.speed >= 0) + clapper_player_set_speed (player, PERCENTAGE_ROUND (app_opts.speed)); + else + clapper_player_set_speed (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "speed"))); + clapper_player_set_subtitles_enabled (player, g_settings_get_boolean (self->settings, "subtitles-enabled")); clapper_queue_set_progression_mode (queue, g_settings_get_int (self->settings, "progression-mode")); @@ -541,6 +547,7 @@ static void clapper_app_application_init (ClapperAppApplication *self) { app_opts.volume = -1; + app_opts.speed = -1; self->need_init_state = TRUE; } @@ -554,6 +561,7 @@ clapper_app_application_constructed (GObject *object) const GOptionEntry app_options[] = { { "volume", 0, 0, G_OPTION_ARG_DOUBLE, &app_opts.volume, _("Audio volume to set (0 - 2.0 range)"), NULL }, + { "speed", 0, 0, G_OPTION_ARG_DOUBLE, &app_opts.speed, _("Playback speed to set (0.05 - 2.0 range)"), NULL }, { "video-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_filter, _("Video filter to use (\"none\" to disable)"), NULL }, { "audio-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.audio_filter, _("Audio filter to use (\"none\" to disable)"), NULL }, { "video-sink", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_sink, _("Video sink to use"), NULL }, From a257d3f0031e809d9de3dfc3a117525cfc16ee25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 3 May 2024 20:17:56 +0200 Subject: [PATCH 04/12] clapper-app: Add command line option to enqueue files --- src/bin/clapper-app/clapper-app-application.c | 32 ++++++++++++++++++- src/bin/clapper-app/clapper-app-utils.c | 24 ++++++++++++++ src/bin/clapper-app/clapper-app-utils.h | 3 ++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index a9791c83..a78f54b0 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -317,7 +317,7 @@ clapper_app_application_new (void) { return g_object_new (CLAPPER_APP_TYPE_APPLICATION, "application-id", CLAPPER_APP_ID, - "flags", G_APPLICATION_HANDLES_OPEN, + "flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_HANDLES_COMMAND_LINE, NULL); } @@ -375,6 +375,8 @@ clapper_app_application_local_command_line (GApplication *app, gchar **argv = *arguments; guint i; + GST_INFO ("Handling local command line"); + /* NOTE: argv is never NULL, so no need to check */ for (i = 0; argv[i]; ++i) { @@ -388,6 +390,32 @@ clapper_app_application_local_command_line (GApplication *app, return G_APPLICATION_CLASS (parent_class)->local_command_line (app, arguments, exit_status); } +static gint +clapper_app_application_command_line (GApplication *app, GApplicationCommandLine *cmd_line) +{ + GVariantDict *options; + GFile **files = NULL; + gint n_files = 0; + gboolean enqueue = FALSE; + + GST_INFO ("Handling command line"); + + options = g_application_command_line_get_options_dict (cmd_line); + + /* Enqueue only makes sense from remote invocation */ + if (g_application_command_line_get_is_remote (cmd_line)) + enqueue = g_variant_dict_contains (options, "enqueue"); + + if (clapper_app_utils_files_from_command_line (cmd_line, &files, &n_files)) { + g_application_open (app, files, n_files, (enqueue) ? "add-only" : ""); + clapper_app_utils_files_free (files); + } else { + g_application_activate (app); + } + + return EXIT_SUCCESS; +} + static gboolean _is_claps_file (GFile *file) { @@ -560,6 +588,7 @@ clapper_app_application_constructed (GObject *object) guint i; const GOptionEntry app_options[] = { + { "enqueue", 0, 0, G_OPTION_ARG_NONE, NULL, _("Add media to queue in primary application instance"), NULL }, { "volume", 0, 0, G_OPTION_ARG_DOUBLE, &app_opts.volume, _("Audio volume to set (0 - 2.0 range)"), NULL }, { "speed", 0, 0, G_OPTION_ARG_DOUBLE, &app_opts.speed, _("Playback speed to set (0.05 - 2.0 range)"), NULL }, { "video-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_filter, _("Video filter to use (\"none\" to disable)"), NULL }, @@ -639,5 +668,6 @@ clapper_app_application_class_init (ClapperAppApplicationClass *klass) application_class->activate = clapper_app_application_activate; application_class->local_command_line = clapper_app_application_local_command_line; + application_class->command_line = clapper_app_application_command_line; application_class->open = clapper_app_application_open; } diff --git a/src/bin/clapper-app/clapper-app-utils.c b/src/bin/clapper-app/clapper-app-utils.c index 1aaf9eea..6852d152 100644 --- a/src/bin/clapper-app/clapper-app-utils.c +++ b/src/bin/clapper-app/clapper-app-utils.c @@ -185,6 +185,30 @@ clapper_app_utils_files_from_string (const gchar *string, GFile ***files, gint * return success; } +gboolean +clapper_app_utils_files_from_command_line (GApplicationCommandLine *cmd_line, GFile ***files, gint *n_files) +{ + GSList *slist = NULL; + gchar **argv; + gint i, argc = 0; + gboolean success; + + argv = g_application_command_line_get_arguments (cmd_line, &argc); + + for (i = 1; i < argc; ++i) + slist = g_slist_append (slist, g_application_command_line_create_file_for_arg (cmd_line, argv[i])); + + g_strfreev (argv); + + if (!slist) + return FALSE; + + success = clapper_app_utils_files_from_slist (slist, files, n_files); + g_slist_free_full (slist, g_object_unref); + + return success; +} + static inline gboolean _files_from_file (GFile *file, GFile ***files, gint *n_files) { diff --git a/src/bin/clapper-app/clapper-app-utils.h b/src/bin/clapper-app/clapper-app-utils.h index 54dbbc0e..4044b573 100644 --- a/src/bin/clapper-app/clapper-app-utils.h +++ b/src/bin/clapper-app/clapper-app-utils.h @@ -50,6 +50,9 @@ gboolean clapper_app_utils_files_from_slist (GSList *file_list, GFile ***files, G_GNUC_INTERNAL gboolean clapper_app_utils_files_from_string (const gchar *string, GFile ***files, gint *n_files); +G_GNUC_INTERNAL +gboolean clapper_app_utils_files_from_command_line (GApplicationCommandLine *cmd_line, GFile ***files, gint *n_files); + G_GNUC_INTERNAL gboolean clapper_app_utils_files_from_value (const GValue *value, GFile ***files, gint *n_files); From 8e14ec1697ec287c3311b0607e5f88fd50049bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sat, 11 May 2024 18:01:20 +0200 Subject: [PATCH 05/12] clapper-app: Cleanup to not store app options as global and static Now that we are using both local and global command line vfuncs, we can just get and apply options in them and free values later. This avoids having options global and static. --- src/bin/clapper-app/clapper-app-application.c | 107 ++++++++++-------- 1 file changed, 60 insertions(+), 47 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index a78f54b0..8fe08031 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -45,6 +45,9 @@ struct _ClapperAppApplication gboolean need_init_state; }; +#define parent_class clapper_app_application_parent_class +G_DEFINE_TYPE (ClapperAppApplication, clapper_app_application, GTK_TYPE_APPLICATION); + struct ClapperPluginFeatureData { const gchar *name; @@ -58,8 +61,16 @@ struct ClapperPluginData struct ClapperPluginFeatureData features[10]; }; +typedef struct +{ + const gchar *action; + const gchar *accels[3]; +} ClapperAppShortcut; + struct ClapperAppOptions { + gboolean enqueue; + gdouble volume; gdouble speed; @@ -70,25 +81,14 @@ struct ClapperAppOptions gchar *audio_sink; }; -typedef struct -{ - const gchar *action; - const gchar *accels[3]; -} ClapperAppShortcut; - -#define parent_class clapper_app_application_parent_class -G_DEFINE_TYPE (ClapperAppApplication, clapper_app_application, GTK_TYPE_APPLICATION); - -static struct ClapperAppOptions app_opts = { 0, }; - static inline void -_app_opts_free (void) +_app_opts_free_contents (struct ClapperAppOptions *app_opts) { - g_free (app_opts.video_filter); - g_free (app_opts.audio_filter); + g_free (app_opts->video_filter); + g_free (app_opts->audio_filter); - g_free (app_opts.video_sink); - g_free (app_opts.audio_sink); + g_free (app_opts->video_sink); + g_free (app_opts->audio_sink); } static inline void @@ -251,32 +251,33 @@ show_about (GSimpleAction *action, GVariant *param, gpointer user_data) } static inline void -_restore_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_window) +_apply_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_window, + const struct ClapperAppOptions *app_opts) { ClapperPlayer *player = clapper_app_window_get_player (app_window); ClapperQueue *queue = clapper_player_get_queue (player); - GST_DEBUG ("Restoring saved GSettings values to: %" GST_PTR_FORMAT, app_window); + GST_DEBUG ("Applying settings values to: %" GST_PTR_FORMAT, app_window); - if (app_opts.video_filter) - clapper_player_set_video_filter (player, clapper_app_utils_make_element (app_opts.video_filter)); - if (app_opts.audio_filter) - clapper_player_set_audio_filter (player, clapper_app_utils_make_element (app_opts.audio_filter)); - if (app_opts.video_sink) - clapper_player_set_video_sink (player, clapper_app_utils_make_element (app_opts.video_sink)); - if (app_opts.audio_sink) - clapper_player_set_audio_sink (player, clapper_app_utils_make_element (app_opts.audio_sink)); + if (app_opts->video_filter) + clapper_player_set_video_filter (player, clapper_app_utils_make_element (app_opts->video_filter)); + if (app_opts->audio_filter) + clapper_player_set_audio_filter (player, clapper_app_utils_make_element (app_opts->audio_filter)); + if (app_opts->video_sink) + clapper_player_set_video_sink (player, clapper_app_utils_make_element (app_opts->video_sink)); + if (app_opts->audio_sink) + clapper_player_set_audio_sink (player, clapper_app_utils_make_element (app_opts->audio_sink)); /* NOTE: Not using ternary operator to avoid accidental typecasting */ - if (app_opts.volume >= 0) - clapper_player_set_volume (player, PERCENTAGE_ROUND (app_opts.volume)); + if (app_opts->volume >= 0) + clapper_player_set_volume (player, PERCENTAGE_ROUND (app_opts->volume)); else clapper_player_set_volume (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"))); clapper_player_set_mute (player, g_settings_get_boolean (self->settings, "mute")); - if (app_opts.speed >= 0) - clapper_player_set_speed (player, PERCENTAGE_ROUND (app_opts.speed)); + if (app_opts->speed >= 0) + clapper_player_set_speed (player, PERCENTAGE_ROUND (app_opts->speed)); else clapper_player_set_speed (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "speed"))); @@ -288,7 +289,7 @@ _restore_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_ else if (g_settings_get_boolean (self->settings, "maximized")) gtk_window_maximize (GTK_WINDOW (app_window)); - GST_DEBUG ("Configuration restored"); + GST_DEBUG ("Configuration applied"); } static inline void @@ -355,10 +356,8 @@ clapper_app_application_activate (GApplication *app) GST_INFO ("Activate"); G_APPLICATION_CLASS (parent_class)->activate (app); - if (!(window = gtk_application_get_active_window (GTK_APPLICATION (app)))) { + if (!(window = gtk_application_get_active_window (GTK_APPLICATION (app)))) window = GTK_WINDOW (clapper_app_window_new (GTK_APPLICATION (app))); - _restore_settings_to_window (self, CLAPPER_APP_WINDOW_CAST (window)); - } if (self->need_init_state) { _assemble_initial_state (window); @@ -393,10 +392,12 @@ clapper_app_application_local_command_line (GApplication *app, static gint clapper_app_application_command_line (GApplication *app, GApplicationCommandLine *cmd_line) { + ClapperAppApplication *self = CLAPPER_APP_APPLICATION_CAST (app); + struct ClapperAppOptions app_opts = { 0, }; + GtkWindow *window; GVariantDict *options; GFile **files = NULL; gint n_files = 0; - gboolean enqueue = FALSE; GST_INFO ("Handling command line"); @@ -404,15 +405,31 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine /* Enqueue only makes sense from remote invocation */ if (g_application_command_line_get_is_remote (cmd_line)) - enqueue = g_variant_dict_contains (options, "enqueue"); + app_opts.enqueue = g_variant_dict_contains (options, "enqueue"); + + if (!g_variant_dict_lookup (options, "volume", "d", &app_opts.volume)) + app_opts.volume = -1; + if (!g_variant_dict_lookup (options, "speed", "d", &app_opts.speed)) + app_opts.speed = -1; + + g_variant_dict_lookup (options, "video-filter", "s", &app_opts.video_filter); + g_variant_dict_lookup (options, "audio-filter", "s", &app_opts.audio_filter); + + g_variant_dict_lookup (options, "video-sink", "s", &app_opts.video_sink); + g_variant_dict_lookup (options, "audio-sink", "s", &app_opts.audio_sink); if (clapper_app_utils_files_from_command_line (cmd_line, &files, &n_files)) { - g_application_open (app, files, n_files, (enqueue) ? "add-only" : ""); + g_application_open (app, files, n_files, (app_opts.enqueue) ? "add-only" : ""); clapper_app_utils_files_free (files); } else { g_application_activate (app); } + window = gtk_application_get_active_window (GTK_APPLICATION (app)); + _apply_settings_to_window (self, CLAPPER_APP_WINDOW_CAST (window), &app_opts); + + _app_opts_free_contents (&app_opts); + return EXIT_SUCCESS; } @@ -574,9 +591,6 @@ clapper_app_application_open (GApplication *app, static void clapper_app_application_init (ClapperAppApplication *self) { - app_opts.volume = -1; - app_opts.speed = -1; - self->need_init_state = TRUE; } @@ -589,12 +603,12 @@ clapper_app_application_constructed (GObject *object) const GOptionEntry app_options[] = { { "enqueue", 0, 0, G_OPTION_ARG_NONE, NULL, _("Add media to queue in primary application instance"), NULL }, - { "volume", 0, 0, G_OPTION_ARG_DOUBLE, &app_opts.volume, _("Audio volume to set (0 - 2.0 range)"), NULL }, - { "speed", 0, 0, G_OPTION_ARG_DOUBLE, &app_opts.speed, _("Playback speed to set (0.05 - 2.0 range)"), NULL }, - { "video-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_filter, _("Video filter to use (\"none\" to disable)"), NULL }, - { "audio-filter", 0, 0, G_OPTION_ARG_STRING, &app_opts.audio_filter, _("Audio filter to use (\"none\" to disable)"), NULL }, - { "video-sink", 0, 0, G_OPTION_ARG_STRING, &app_opts.video_sink, _("Video sink to use"), NULL }, - { "audio-sink", 0, 0, G_OPTION_ARG_STRING, &app_opts.audio_sink, _("Audio sink to use"), NULL }, + { "volume", 0, 0, G_OPTION_ARG_DOUBLE, NULL, _("Audio volume to set (0 - 2.0 range)"), NULL }, + { "speed", 0, 0, G_OPTION_ARG_DOUBLE, NULL, _("Playback speed to set (0.05 - 2.0 range)"), NULL }, + { "video-filter", 0, 0, G_OPTION_ARG_STRING, NULL, _("Video filter to use (\"none\" to disable)"), NULL }, + { "audio-filter", 0, 0, G_OPTION_ARG_STRING, NULL, _("Audio filter to use (\"none\" to disable)"), NULL }, + { "video-sink", 0, 0, G_OPTION_ARG_STRING, NULL, _("Video sink to use"), NULL }, + { "audio-sink", 0, 0, G_OPTION_ARG_STRING, NULL, _("Audio sink to use"), NULL }, { NULL } }; static const GActionEntry app_actions[] = { @@ -646,7 +660,6 @@ clapper_app_application_finalize (GObject *object) GST_TRACE ("Finalize"); g_object_unref (self->settings); - _app_opts_free (); G_OBJECT_CLASS (parent_class)->finalize (object); } From 22fb88d0f28c061d41f552254e59f15bcbc6b372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sat, 11 May 2024 19:20:33 +0200 Subject: [PATCH 06/12] clapper-app: Support creating multiple windows --- src/bin/clapper-app/clapper-app-application.c | 16 +++++++++++----- src/bin/clapper-app/clapper-app-window.c | 10 ++++++++-- .../com.github.rafostar.Clapper.desktop | 5 +++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index 8fe08031..e8112080 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -394,7 +394,7 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine { ClapperAppApplication *self = CLAPPER_APP_APPLICATION_CAST (app); struct ClapperAppOptions app_opts = { 0, }; - GtkWindow *window; + GtkWindow *window = NULL; GVariantDict *options; GFile **files = NULL; gint n_files = 0; @@ -403,9 +403,13 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine options = g_application_command_line_get_options_dict (cmd_line); - /* Enqueue only makes sense from remote invocation */ - if (g_application_command_line_get_is_remote (cmd_line)) + /* Some options only make sense from remote invocation */ + if (g_application_command_line_get_is_remote (cmd_line)) { + if (g_variant_dict_contains (options, "new-window")) + window = GTK_WINDOW (clapper_app_window_new (GTK_APPLICATION (app))); + app_opts.enqueue = g_variant_dict_contains (options, "enqueue"); + } if (!g_variant_dict_lookup (options, "volume", "d", &app_opts.volume)) app_opts.volume = -1; @@ -425,9 +429,10 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine g_application_activate (app); } - window = gtk_application_get_active_window (GTK_APPLICATION (app)); - _apply_settings_to_window (self, CLAPPER_APP_WINDOW_CAST (window), &app_opts); + if (!window) + window = gtk_application_get_active_window (GTK_APPLICATION (app)); + _apply_settings_to_window (self, CLAPPER_APP_WINDOW_CAST (window), &app_opts); _app_opts_free_contents (&app_opts); return EXIT_SUCCESS; @@ -602,6 +607,7 @@ clapper_app_application_constructed (GObject *object) guint i; const GOptionEntry app_options[] = { + { "new-window", 'n', 0, G_OPTION_ARG_NONE, NULL, _("Create a new window"), NULL }, { "enqueue", 0, 0, G_OPTION_ARG_NONE, NULL, _("Add media to queue in primary application instance"), NULL }, { "volume", 0, 0, G_OPTION_ARG_DOUBLE, NULL, _("Audio volume to set (0 - 2.0 range)"), NULL }, { "speed", 0, 0, G_OPTION_ARG_DOUBLE, NULL, _("Playback speed to set (0.05 - 2.0 range)"), NULL }, diff --git a/src/bin/clapper-app/clapper-app-window.c b/src/bin/clapper-app/clapper-app-window.c index d591e573..fd071bcf 100644 --- a/src/bin/clapper-app/clapper-app-window.c +++ b/src/bin/clapper-app/clapper-app-window.c @@ -74,6 +74,8 @@ struct _ClapperAppWindow #define parent_class clapper_app_window_parent_class G_DEFINE_TYPE (ClapperAppWindow, clapper_app_window, GTK_TYPE_APPLICATION_WINDOW) +static guint16 instance_count = 0; + static void _media_item_title_changed_cb (ClapperMediaItem *item, GParamSpec *pspec G_GNUC_UNUSED, ClapperAppWindow *self) @@ -1008,14 +1010,18 @@ clapper_app_window_constructed (GObject *object) #if (CLAPPER_HAVE_MPRIS || CLAPPER_HAVE_SERVER || CLAPPER_HAVE_DISCOVERER) ClapperFeature *feature = NULL; #endif +#if CLAPPER_HAVE_MPRIS + gchar mpris_name[45]; + g_snprintf (mpris_name, sizeof (mpris_name), + "org.mpris.MediaPlayer2.Clapper.instance%" G_GUINT16_FORMAT, instance_count++); +#endif self->settings = g_settings_new (CLAPPER_APP_ID); self->last_volume = PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume")); #if CLAPPER_HAVE_MPRIS feature = CLAPPER_FEATURE (clapper_mpris_new ( - "org.mpris.MediaPlayer2.Clapper", - "Clapper", CLAPPER_APP_ID)); + mpris_name, CLAPPER_APP_NAME, CLAPPER_APP_ID)); clapper_mpris_set_queue_controllable (CLAPPER_MPRIS (feature), TRUE); clapper_player_add_feature (player, feature); gst_object_unref (feature); diff --git a/src/bin/clapper-app/data/applications/com.github.rafostar.Clapper.desktop b/src/bin/clapper-app/data/applications/com.github.rafostar.Clapper.desktop index e84b8d72..c0b2be3e 100644 --- a/src/bin/clapper-app/data/applications/com.github.rafostar.Clapper.desktop +++ b/src/bin/clapper-app/data/applications/com.github.rafostar.Clapper.desktop @@ -14,3 +14,8 @@ Type=Application Keywords=Video;Movie;Film;Clip;Series;Player;Playlist;DVD;TV;Disc;Album;Music;GNOME;Clapper; # Translators: Do NOT translate or transliterate this text (these are enum types)! X-Purism-FormFactor=Workstation;Mobile; +Actions=new-window; + +[Desktop Action new-window] +Name=New Window +Exec=clapper --new-window From 1330e49ed848a0da352dba1ee4b6438d388c6b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 12 May 2024 14:56:42 +0200 Subject: [PATCH 07/12] clapper-app: Add command line option to set progression mode --- src/bin/clapper-app/clapper-app-application.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index e8112080..d026ab70 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -74,6 +74,8 @@ struct ClapperAppOptions gdouble volume; gdouble speed; + gint progression_mode; + gchar *video_filter; gchar *audio_filter; @@ -282,7 +284,11 @@ _apply_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_wi clapper_player_set_speed (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "speed"))); clapper_player_set_subtitles_enabled (player, g_settings_get_boolean (self->settings, "subtitles-enabled")); - clapper_queue_set_progression_mode (queue, g_settings_get_int (self->settings, "progression-mode")); + + if (app_opts->progression_mode >= 0) + clapper_queue_set_progression_mode (queue, app_opts->progression_mode); + else + clapper_queue_set_progression_mode (queue, g_settings_get_int (self->settings, "progression-mode")); if (g_settings_get_boolean (self->settings, "fullscreened")) gtk_window_fullscreen (GTK_WINDOW (app_window)); @@ -415,6 +421,8 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine app_opts.volume = -1; if (!g_variant_dict_lookup (options, "speed", "d", &app_opts.speed)) app_opts.speed = -1; + if (!g_variant_dict_lookup (options, "progression-mode", "i", &app_opts.progression_mode)) + app_opts.progression_mode = -1; g_variant_dict_lookup (options, "video-filter", "s", &app_opts.video_filter); g_variant_dict_lookup (options, "audio-filter", "s", &app_opts.audio_filter); @@ -611,6 +619,7 @@ clapper_app_application_constructed (GObject *object) { "enqueue", 0, 0, G_OPTION_ARG_NONE, NULL, _("Add media to queue in primary application instance"), NULL }, { "volume", 0, 0, G_OPTION_ARG_DOUBLE, NULL, _("Audio volume to set (0 - 2.0 range)"), NULL }, { "speed", 0, 0, G_OPTION_ARG_DOUBLE, NULL, _("Playback speed to set (0.05 - 2.0 range)"), NULL }, + { "progression-mode", 0, 0, G_OPTION_ARG_INT, NULL, _("Initial queue progression mode (0=none, 1=consecutive, 2=repeat-item, 3=carousel, 4=shuffle)"), NULL }, { "video-filter", 0, 0, G_OPTION_ARG_STRING, NULL, _("Video filter to use (\"none\" to disable)"), NULL }, { "audio-filter", 0, 0, G_OPTION_ARG_STRING, NULL, _("Audio filter to use (\"none\" to disable)"), NULL }, { "video-sink", 0, 0, G_OPTION_ARG_STRING, NULL, _("Video sink to use"), NULL }, From aac050e25201016383477ce91e8eee81f274fd23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 12 May 2024 15:04:44 +0200 Subject: [PATCH 08/12] clapper-app: Add command line option to enter fullscreen --- src/bin/clapper-app/clapper-app-application.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index d026ab70..3d0b977a 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -76,6 +76,8 @@ struct ClapperAppOptions gint progression_mode; + gboolean fullscreen; + gchar *video_filter; gchar *audio_filter; @@ -290,7 +292,7 @@ _apply_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_wi else clapper_queue_set_progression_mode (queue, g_settings_get_int (self->settings, "progression-mode")); - if (g_settings_get_boolean (self->settings, "fullscreened")) + if (app_opts->fullscreen || g_settings_get_boolean (self->settings, "fullscreened")) gtk_window_fullscreen (GTK_WINDOW (app_window)); else if (g_settings_get_boolean (self->settings, "maximized")) gtk_window_maximize (GTK_WINDOW (app_window)); @@ -424,6 +426,8 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine if (!g_variant_dict_lookup (options, "progression-mode", "i", &app_opts.progression_mode)) app_opts.progression_mode = -1; + app_opts.fullscreen = g_variant_dict_contains (options, "fullscreen"); + g_variant_dict_lookup (options, "video-filter", "s", &app_opts.video_filter); g_variant_dict_lookup (options, "audio-filter", "s", &app_opts.audio_filter); @@ -620,6 +624,7 @@ clapper_app_application_constructed (GObject *object) { "volume", 0, 0, G_OPTION_ARG_DOUBLE, NULL, _("Audio volume to set (0 - 2.0 range)"), NULL }, { "speed", 0, 0, G_OPTION_ARG_DOUBLE, NULL, _("Playback speed to set (0.05 - 2.0 range)"), NULL }, { "progression-mode", 0, 0, G_OPTION_ARG_INT, NULL, _("Initial queue progression mode (0=none, 1=consecutive, 2=repeat-item, 3=carousel, 4=shuffle)"), NULL }, + { "fullscreen", 'f', 0, G_OPTION_ARG_NONE, NULL, _("Set window to be fullscreen"), NULL }, { "video-filter", 0, 0, G_OPTION_ARG_STRING, NULL, _("Video filter to use (\"none\" to disable)"), NULL }, { "audio-filter", 0, 0, G_OPTION_ARG_STRING, NULL, _("Audio filter to use (\"none\" to disable)"), NULL }, { "video-sink", 0, 0, G_OPTION_ARG_STRING, NULL, _("Video sink to use"), NULL }, From bcd1d489228dad06bd144b8f404667b4a7405ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 12 May 2024 16:28:34 +0200 Subject: [PATCH 09/12] clapper-app: Add command line context params string Describe what kind of remaining (non-options) strings can be passed when launching via command line. --- src/bin/clapper-app/clapper-app-application.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index 3d0b977a..d1f3f28b 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -666,6 +666,8 @@ clapper_app_application_constructed (GObject *object) for (i = 0; i < G_N_ELEMENTS (app_shortcuts); ++i) gtk_application_set_accels_for_action (GTK_APPLICATION (app), app_shortcuts[i].action, app_shortcuts[i].accels); + g_application_set_option_context_parameter_string (app, "[URI1|FILE1] [URI2|FILE2] …"); + g_application_add_main_option_entries (app, app_options); g_application_add_option_group (app, gst_init_get_option_group ()); From 10e0421342b3d7e03fdd8d385a816a2c22b75ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 12 May 2024 17:15:21 +0200 Subject: [PATCH 10/12] clapper-app: Clamp command line args to allowed values Instead of running into warnings or other problems when user specifies an out of range value for command line option, just clamp them to nearest allowed one. --- src/bin/clapper-app/clapper-app-application.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index d1f3f28b..fabce697 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -419,11 +419,19 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine app_opts.enqueue = g_variant_dict_contains (options, "enqueue"); } - if (!g_variant_dict_lookup (options, "volume", "d", &app_opts.volume)) + if (g_variant_dict_lookup (options, "volume", "d", &app_opts.volume)) + app_opts.volume = CLAMP (app_opts.volume, 0, 2.0); // clamp to allowed range + else app_opts.volume = -1; - if (!g_variant_dict_lookup (options, "speed", "d", &app_opts.speed)) + + if (g_variant_dict_lookup (options, "speed", "d", &app_opts.speed)) + app_opts.speed = CLAMP (app_opts.speed, 0.05, 2.0); // clamp to allowed range + else app_opts.speed = -1; - if (!g_variant_dict_lookup (options, "progression-mode", "i", &app_opts.progression_mode)) + + if (g_variant_dict_lookup (options, "progression-mode", "i", &app_opts.progression_mode)) + app_opts.progression_mode = CLAMP (app_opts.progression_mode, 0, 4); // clamp to possible modes + else app_opts.progression_mode = -1; app_opts.fullscreen = g_variant_dict_contains (options, "fullscreen"); From 6f0ed93b08e40aebde4d8f67c6fc6b6f863ea053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 12 May 2024 18:35:17 +0200 Subject: [PATCH 11/12] clapper-app: Only restore saved settings to new windows --- src/bin/clapper-app/clapper-app-application.c | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index fabce697..aade7323 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -256,7 +256,7 @@ show_about (GSimpleAction *action, GVariant *param, gpointer user_data) static inline void _apply_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_window, - const struct ClapperAppOptions *app_opts) + const struct ClapperAppOptions *app_opts, gboolean restore) { ClapperPlayer *player = clapper_app_window_get_player (app_window); ClapperQueue *queue = clapper_player_get_queue (player); @@ -275,26 +275,28 @@ _apply_settings_to_window (ClapperAppApplication *self, ClapperAppWindow *app_wi /* NOTE: Not using ternary operator to avoid accidental typecasting */ if (app_opts->volume >= 0) clapper_player_set_volume (player, PERCENTAGE_ROUND (app_opts->volume)); - else + else if (restore) clapper_player_set_volume (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"))); - clapper_player_set_mute (player, g_settings_get_boolean (self->settings, "mute")); + if (restore) + clapper_player_set_mute (player, g_settings_get_boolean (self->settings, "mute")); if (app_opts->speed >= 0) clapper_player_set_speed (player, PERCENTAGE_ROUND (app_opts->speed)); - else + else if (restore) clapper_player_set_speed (player, PERCENTAGE_ROUND (g_settings_get_double (self->settings, "speed"))); - clapper_player_set_subtitles_enabled (player, g_settings_get_boolean (self->settings, "subtitles-enabled")); + if (restore) + clapper_player_set_subtitles_enabled (player, g_settings_get_boolean (self->settings, "subtitles-enabled")); if (app_opts->progression_mode >= 0) clapper_queue_set_progression_mode (queue, app_opts->progression_mode); - else + else if (restore) clapper_queue_set_progression_mode (queue, g_settings_get_int (self->settings, "progression-mode")); - if (app_opts->fullscreen || g_settings_get_boolean (self->settings, "fullscreened")) + if (app_opts->fullscreen || (restore && g_settings_get_boolean (self->settings, "fullscreened"))) gtk_window_fullscreen (GTK_WINDOW (app_window)); - else if (g_settings_get_boolean (self->settings, "maximized")) + else if (restore && g_settings_get_boolean (self->settings, "maximized")) gtk_window_maximize (GTK_WINDOW (app_window)); GST_DEBUG ("Configuration applied"); @@ -406,13 +408,15 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine GVariantDict *options; GFile **files = NULL; gint n_files = 0; + gboolean is_remote, restore; GST_INFO ("Handling command line"); options = g_application_command_line_get_options_dict (cmd_line); + is_remote = g_application_command_line_get_is_remote (cmd_line); /* Some options only make sense from remote invocation */ - if (g_application_command_line_get_is_remote (cmd_line)) { + if (is_remote) { if (g_variant_dict_contains (options, "new-window")) window = GTK_WINDOW (clapper_app_window_new (GTK_APPLICATION (app))); @@ -449,10 +453,14 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine g_application_activate (app); } + /* We want to restore settings when starting main process + * or a new window is being added from the remote one */ + restore = (!is_remote || window != NULL); + if (!window) window = gtk_application_get_active_window (GTK_APPLICATION (app)); - _apply_settings_to_window (self, CLAPPER_APP_WINDOW_CAST (window), &app_opts); + _apply_settings_to_window (self, CLAPPER_APP_WINDOW_CAST (window), &app_opts, restore); _app_opts_free_contents (&app_opts); return EXIT_SUCCESS; From cc8ed7b48852c047bca2ccd04b22597b5550e434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 12 May 2024 19:58:02 +0200 Subject: [PATCH 12/12] clapper-app: Do not store "enqueue" value in options It is used immediately, so no need to store it. --- src/bin/clapper-app/clapper-app-application.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index aade7323..85616278 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -69,8 +69,6 @@ typedef struct struct ClapperAppOptions { - gboolean enqueue; - gdouble volume; gdouble speed; @@ -408,7 +406,7 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine GVariantDict *options; GFile **files = NULL; gint n_files = 0; - gboolean is_remote, restore; + gboolean is_remote, restore, enqueue = FALSE; GST_INFO ("Handling command line"); @@ -420,7 +418,7 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine if (g_variant_dict_contains (options, "new-window")) window = GTK_WINDOW (clapper_app_window_new (GTK_APPLICATION (app))); - app_opts.enqueue = g_variant_dict_contains (options, "enqueue"); + enqueue = g_variant_dict_contains (options, "enqueue"); } if (g_variant_dict_lookup (options, "volume", "d", &app_opts.volume)) @@ -447,7 +445,7 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine g_variant_dict_lookup (options, "audio-sink", "s", &app_opts.audio_sink); if (clapper_app_utils_files_from_command_line (cmd_line, &files, &n_files)) { - g_application_open (app, files, n_files, (app_opts.enqueue) ? "add-only" : ""); + g_application_open (app, files, n_files, (enqueue) ? "add-only" : ""); clapper_app_utils_files_free (files); } else { g_application_activate (app);