From 306e6b79148e98dcc58ee90df30d8546bb59687f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 30 Dec 2023 11:45:29 +0100 Subject: [PATCH 1/7] resources: Sort icons alphabetically --- src/livi.gresource.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/livi.gresource.xml b/src/livi.gresource.xml index b4d3e14..e9cc9f8 100644 --- a/src/livi.gresource.xml +++ b/src/livi.gresource.xml @@ -6,10 +6,10 @@ style.css gtk/help-overlay.ui ../data/org.sigxcpu.Livi.metainfo.xml - ../data/icons/view-restore-symbolic.svg ../data/icons/play-large-symbolic.svg - ../data/icons/speedometer4-symbolic.svg + ../data/icons/view-restore-symbolic.svg ../data/icons/skip-backwards-10-symbolic.svg ../data/icons/skip-forward-30-symbolic.svg + ../data/icons/speedometer4-symbolic.svg -- GitLab From d0a0144ad2420855d1f90fc5efc3489482c887c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sat, 30 Dec 2023 11:46:45 +0100 Subject: [PATCH 2/7] icons: Add region-symbolic Taken from GNOME Settings 45 --- data/icons/region-symbolic.svg | 4 ++++ src/livi.gresource.xml | 1 + 2 files changed, 5 insertions(+) create mode 100644 data/icons/region-symbolic.svg diff --git a/data/icons/region-symbolic.svg b/data/icons/region-symbolic.svg new file mode 100644 index 0000000..11ac471 --- /dev/null +++ b/data/icons/region-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/livi.gresource.xml b/src/livi.gresource.xml index e9cc9f8..287181d 100644 --- a/src/livi.gresource.xml +++ b/src/livi.gresource.xml @@ -11,5 +11,6 @@ ../data/icons/skip-backwards-10-symbolic.svg ../data/icons/skip-forward-30-symbolic.svg ../data/icons/speedometer4-symbolic.svg + ../data/icons/region-symbolic.svg -- GitLab From e61ad30a1f1670032a94eb280f4981419a1ff9c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 29 Dec 2023 15:41:37 +0100 Subject: [PATCH 3/7] window: Move stream related bits to struct This allows us to reset in one place --- src/livi-window.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/livi-window.c b/src/livi-window.c index a15f696..cb7f630 100644 --- a/src/livi-window.c +++ b/src/livi-window.c @@ -65,8 +65,10 @@ struct _LiviWindow GstPlayState state; guint cookie; - gboolean muted; - int playback_speed; + struct { + gboolean muted; + int playback_speed; + } stream; GtkFileFilter *video_filter; char *last_local_uri; @@ -75,18 +77,26 @@ struct _LiviWindow G_DEFINE_TYPE (LiviWindow, livi_window, ADW_TYPE_APPLICATION_WINDOW) +static void +reset_stream (LiviWindow *self) +{ + memset (&self->stream, 0, sizeof (self->stream)); + self->stream.playback_speed = 100; +} + + static void livi_window_set_playback_speed (LiviWindow *self, int percent) { g_debug ("Setting Rate to : %f", percent / 100.0); - if (percent == self->playback_speed) + if (percent == self->stream.playback_speed) return; if (self->player) gst_play_set_rate (self->player, percent / 100.0); - self->playback_speed = percent; + self->stream.playback_speed = percent; g_object_notify_by_pspec (G_OBJECT (self), props[PROP_PLAYBACK_SPEED]); } @@ -106,7 +116,7 @@ livi_window_set_property (GObject *object, if (self->player) gst_play_set_mute (self->player, muted); else - self->muted = muted; + self->stream.muted = muted; break; case PROP_PLAYBACK_SPEED: livi_window_set_playback_speed (self, g_value_get_int (value)); @@ -128,10 +138,10 @@ livi_window_get_property (GObject *object, switch (property_id) { case PROP_MUTED: - g_value_set_boolean (value, self->muted); + g_value_set_boolean (value, self->stream.muted); break; case PROP_PLAYBACK_SPEED: - g_value_set_int (value, self->playback_speed); + g_value_set_int (value, self->stream.playback_speed); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -441,10 +451,10 @@ on_player_mute_changed (GstPlaySignalAdapter *adapter, gboolean muted, gpointer g_assert (LIVI_IS_WINDOW (self)); - if (self->muted == muted) + if (self->stream.muted == muted) return; - self->muted = muted; + self->stream.muted = muted; g_debug ("Muted %d", muted); icon = muted ? "audio-volume-medium-symbolic" : "audio-volume-muted-symbolic"; livi_controls_set_mute_icon (self->controls, icon); @@ -626,7 +636,7 @@ add_controls_toggle (LiviWindow *self, GtkWidget *widget) static void livi_window_init (LiviWindow *self) { - self->playback_speed = 100; + reset_stream (self); gtk_widget_init_template (GTK_WIDGET (self)); @@ -641,6 +651,7 @@ livi_window_init (LiviWindow *self) void livi_window_set_uri (LiviWindow *self, const char *uri) { + reset_stream (self); gtk_stack_set_visible_child (self->stack_content, GTK_WIDGET (self->box_content)); gst_play_set_uri (self->player, uri); } -- GitLab From 9c61f539d073ed8570ccb935c43092a46af2520c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Fri, 29 Dec 2023 16:58:52 +0100 Subject: [PATCH 4/7] Handle multiple audio stream languages We ignore different bitrates, etc for now. --- src/livi-controls.c | 24 +++++++++++++++++- src/livi-controls.h | 1 + src/livi-controls.ui | 45 +++++++++++++++++++++++++++++++-- src/livi-window.c | 60 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 3 deletions(-) diff --git a/src/livi-controls.c b/src/livi-controls.c index 98aa994..470593e 100644 --- a/src/livi-controls.c +++ b/src/livi-controls.c @@ -35,6 +35,7 @@ struct _LiviControls { /* wide layout */ GtkAdjustment *adj_duration; GtkMenuButton *btn_menu; + GtkMenuButton *btn_lang_menu; GtkButton *btn_play; GtkImage *img_play; GtkButton *btn_mute; @@ -42,11 +43,13 @@ struct _LiviControls { GtkLabel *lbl_time; /* narrow layout */ GtkMenuButton *nrw_btn_menu; + GtkMenuButton *nrw_btn_lang_menu; guint64 duration; guint64 position; GtkPopover *playback_menu; + GtkPopoverMenu *lang_menu; gboolean narrow; }; @@ -66,11 +69,16 @@ set_narrow (LiviControls *self, gboolean narrow) if (narrow) { gtk_menu_button_set_popover (self->btn_menu, NULL); gtk_menu_button_set_popover (self->nrw_btn_menu, GTK_WIDGET (self->playback_menu)); + + gtk_menu_button_set_popover (self->btn_lang_menu, NULL); + gtk_menu_button_set_popover (self->nrw_btn_lang_menu, GTK_WIDGET (self->lang_menu)); } else { gtk_menu_button_set_popover (self->nrw_btn_menu, NULL); gtk_menu_button_set_popover (self->btn_menu, GTK_WIDGET (self->playback_menu)); - } + gtk_menu_button_set_popover (self->nrw_btn_lang_menu, NULL); + gtk_menu_button_set_popover (self->btn_lang_menu, GTK_WIDGET (self->lang_menu)); + } g_object_notify_by_pspec (G_OBJECT (self), props[PROP_NARROW]); } @@ -167,11 +175,14 @@ livi_controls_class_init (LiviControlsClass *klass) gtk_widget_class_bind_template_child (widget_class, LiviControls, adj_duration); gtk_widget_class_bind_template_child (widget_class, LiviControls, btn_menu); gtk_widget_class_bind_template_child (widget_class, LiviControls, btn_mute); + gtk_widget_class_bind_template_child (widget_class, LiviControls, btn_lang_menu); gtk_widget_class_bind_template_child (widget_class, LiviControls, btn_play); gtk_widget_class_bind_template_child (widget_class, LiviControls, img_mute); gtk_widget_class_bind_template_child (widget_class, LiviControls, img_play); + gtk_widget_class_bind_template_child (widget_class, LiviControls, lang_menu); gtk_widget_class_bind_template_child (widget_class, LiviControls, lbl_time); gtk_widget_class_bind_template_child (widget_class, LiviControls, nrw_btn_menu); + gtk_widget_class_bind_template_child (widget_class, LiviControls, nrw_btn_lang_menu); gtk_widget_class_bind_template_child (widget_class, LiviControls, playback_menu); gtk_widget_class_bind_template_child (widget_class, LiviControls, stack); gtk_widget_class_bind_template_callback (widget_class, on_slider_value_changed); @@ -238,3 +249,14 @@ livi_controls_set_play_icon (LiviControls *self, const char *icon_name) g_object_set (self->img_play, "icon-name", icon_name, NULL); } + + +void +livi_controls_set_langs (LiviControls *self, GMenuModel *lang) +{ + g_assert (LIVI_IS_CONTROLS (self)); + g_assert (lang == NULL || G_IS_MENU_MODEL (lang)); + + gtk_popover_menu_set_menu_model (self->lang_menu, lang); + gtk_widget_set_visible (GTK_WIDGET (self->btn_lang_menu), !!lang); +} diff --git a/src/livi-controls.h b/src/livi-controls.h index a985a31..0e56a86 100644 --- a/src/livi-controls.h +++ b/src/livi-controls.h @@ -20,5 +20,6 @@ void livi_controls_set_position (LiviControls *self, guint64 position_n void livi_controls_show_mute_button (LiviControls *self, gboolean show); void livi_controls_set_mute_icon (LiviControls *self, const char *icon_name); void livi_controls_set_play_icon (LiviControls *self, const char *icon_name); +void livi_controls_set_langs (LiviControls *self, GMenuModel *lang); G_END_DECLS diff --git a/src/livi-controls.ui b/src/livi-controls.ui index a62e8e7..77658ed 100644 --- a/src/livi-controls.ui +++ b/src/livi-controls.ui @@ -115,6 +115,24 @@ + + + + + up + 64 + + + region-symbolic + 24 + + + + + + up 64 @@ -128,8 +146,10 @@ - - + + + + + + + up 64 @@ -266,6 +303,8 @@ + + vertical @@ -340,6 +343,10 @@ start Speed + -- GitLab From bb1fd375e7663023064496c707e2023f8de7778b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 28 Dec 2023 17:22:48 +0100 Subject: [PATCH 7/7] controls: Reindent No functional change. Do this in a separate commit to ease rebasing. --- src/livi-controls.ui | 340 +++++++++++++++++++++---------------------- 1 file changed, 170 insertions(+), 170 deletions(-) diff --git a/src/livi-controls.ui b/src/livi-controls.ui index 2af1f2c..c8815bd 100644 --- a/src/livi-controls.ui +++ b/src/livi-controls.ui @@ -115,41 +115,41 @@ - - - - - up - 64 - - - region-symbolic - 24 - - - - - - - - up - 64 + - - emblem-system-symbolic - 24 + + + up + 64 + + + region-symbolic + 24 + + + + + + + + up + 64 + + + emblem-system-symbolic + 24 + + + - - - - - + + - - - + + horizontal + + + Skip backwards + False + 64 + win.rev + -10000 + + + skip-backwards-10-symbolic + 24 + + + + + + - - Play/Pause - False - 64 - win.toggle-play - - - media-playback-pause-symbolic - 24 - - - - + + Play/Pause + False + 64 + win.toggle-play + + + media-playback-pause-symbolic + 24 + + + + - - - - Skip forward - True - 64 - win.ff - 30000 - - - skip-forward-30-symbolic - 24 - - - - - - - - - - 6 - 6 - True - adj_duration - True - - - - - - 24 - True - False - start - center - 6 - - - - - - Mute - win.mute - 64 - - - audio-volume-muted-symbolic - 24 - - - - - - - - - - up - 64 - - - region-symbolic - 24 - - - - - - - - up - 64 - - - emblem-system-symbolic - 24 - - - - - - - - - + + + + Skip forward + True + 64 + win.ff + 30000 + + + skip-forward-30-symbolic + 24 + + + + + + + + + + 6 + 6 + True + adj_duration + True + + + + + + 24 + True + False + start + center + 6 + + + + + + Mute + win.mute + 64 + + + audio-volume-muted-symbolic + 24 + + + + + + + + + + up + 64 + + + region-symbolic + 24 + + + + + + + + up + 64 + + + emblem-system-symbolic + 24 + + + + + + + + + -- GitLab