mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 23:32:04 +02:00
clapper-app: Support creating multiple windows
This commit is contained in:
@@ -394,7 +394,7 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine
|
|||||||
{
|
{
|
||||||
ClapperAppApplication *self = CLAPPER_APP_APPLICATION_CAST (app);
|
ClapperAppApplication *self = CLAPPER_APP_APPLICATION_CAST (app);
|
||||||
struct ClapperAppOptions app_opts = { 0, };
|
struct ClapperAppOptions app_opts = { 0, };
|
||||||
GtkWindow *window;
|
GtkWindow *window = NULL;
|
||||||
GVariantDict *options;
|
GVariantDict *options;
|
||||||
GFile **files = NULL;
|
GFile **files = NULL;
|
||||||
gint n_files = 0;
|
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);
|
options = g_application_command_line_get_options_dict (cmd_line);
|
||||||
|
|
||||||
/* Enqueue only makes sense from remote invocation */
|
/* Some options only make sense from remote invocation */
|
||||||
if (g_application_command_line_get_is_remote (cmd_line))
|
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");
|
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 = -1;
|
app_opts.volume = -1;
|
||||||
@@ -425,9 +429,10 @@ clapper_app_application_command_line (GApplication *app, GApplicationCommandLine
|
|||||||
g_application_activate (app);
|
g_application_activate (app);
|
||||||
}
|
}
|
||||||
|
|
||||||
window = gtk_application_get_active_window (GTK_APPLICATION (app));
|
if (!window)
|
||||||
_apply_settings_to_window (self, CLAPPER_APP_WINDOW_CAST (window), &app_opts);
|
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);
|
_app_opts_free_contents (&app_opts);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
@@ -602,6 +607,7 @@ clapper_app_application_constructed (GObject *object)
|
|||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
const GOptionEntry app_options[] = {
|
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 },
|
{ "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 },
|
{ "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 },
|
{ "speed", 0, 0, G_OPTION_ARG_DOUBLE, NULL, _("Playback speed to set (0.05 - 2.0 range)"), NULL },
|
||||||
|
@@ -74,6 +74,8 @@ struct _ClapperAppWindow
|
|||||||
#define parent_class clapper_app_window_parent_class
|
#define parent_class clapper_app_window_parent_class
|
||||||
G_DEFINE_TYPE (ClapperAppWindow, clapper_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
G_DEFINE_TYPE (ClapperAppWindow, clapper_app_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||||
|
|
||||||
|
static guint16 instance_count = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_media_item_title_changed_cb (ClapperMediaItem *item,
|
_media_item_title_changed_cb (ClapperMediaItem *item,
|
||||||
GParamSpec *pspec G_GNUC_UNUSED, ClapperAppWindow *self)
|
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)
|
#if (CLAPPER_HAVE_MPRIS || CLAPPER_HAVE_SERVER || CLAPPER_HAVE_DISCOVERER)
|
||||||
ClapperFeature *feature = NULL;
|
ClapperFeature *feature = NULL;
|
||||||
#endif
|
#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->settings = g_settings_new (CLAPPER_APP_ID);
|
||||||
self->last_volume = PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"));
|
self->last_volume = PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"));
|
||||||
|
|
||||||
#if CLAPPER_HAVE_MPRIS
|
#if CLAPPER_HAVE_MPRIS
|
||||||
feature = CLAPPER_FEATURE (clapper_mpris_new (
|
feature = CLAPPER_FEATURE (clapper_mpris_new (
|
||||||
"org.mpris.MediaPlayer2.Clapper",
|
mpris_name, CLAPPER_APP_NAME, CLAPPER_APP_ID));
|
||||||
"Clapper", CLAPPER_APP_ID));
|
|
||||||
clapper_mpris_set_queue_controllable (CLAPPER_MPRIS (feature), TRUE);
|
clapper_mpris_set_queue_controllable (CLAPPER_MPRIS (feature), TRUE);
|
||||||
clapper_player_add_feature (player, feature);
|
clapper_player_add_feature (player, feature);
|
||||||
gst_object_unref (feature);
|
gst_object_unref (feature);
|
||||||
|
@@ -14,3 +14,8 @@ Type=Application
|
|||||||
Keywords=Video;Movie;Film;Clip;Series;Player;Playlist;DVD;TV;Disc;Album;Music;GNOME;Clapper;
|
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)!
|
# Translators: Do NOT translate or transliterate this text (these are enum types)!
|
||||||
X-Purism-FormFactor=Workstation;Mobile;
|
X-Purism-FormFactor=Workstation;Mobile;
|
||||||
|
Actions=new-window;
|
||||||
|
|
||||||
|
[Desktop Action new-window]
|
||||||
|
Name=New Window
|
||||||
|
Exec=clapper --new-window
|
||||||
|
Reference in New Issue
Block a user