Merge lp:~wingpanel-devs/audience/sound-indicator-in-fullscreen into lp:~audience-members/audience/trunk

Proposed by Marcus Wichelmann on 2015-10-22
Status: Rejected
Rejected by: Zisu Andrei on 2016-11-06
Proposed branch: lp:~wingpanel-devs/audience/sound-indicator-in-fullscreen
Merge into: lp:~audience-members/audience/trunk
Diff against target: 196 lines (+90/-1)
4 files modified
src/CMakeLists.txt (+3/-1)
src/Widgets/BottomBar.vala (+16/-0)
src/Widgets/IndicatorContainer.vala (+62/-0)
src/Widgets/PlayerPage.vala (+9/-0)
To merge this branch: bzr merge lp:~wingpanel-devs/audience/sound-indicator-in-fullscreen
Reviewer Review Type Date Requested Status
Viko Adi Rahmawan 2015-10-22 Disapprove on 2015-11-06
Review via email: mp+275313@code.launchpad.net

Commit message

Show sound indicator in fullscreen mode

Description of the change

Use the new wingpanel library to show a sound indicator in fullscreen mode like requested in #953272.

To post a comment you must log in.
Viko Adi Rahmawan (vikoadi) wrote :

depending on wingpanel sounds overkill
can we just copy the code?

Marcus Wichelmann (l-admin-3) wrote :

Of course we can copy the code, but duplicated code is imo never the right choice.
Why is depending on wingpanel overkill? The wingpanel api is built for being able to be integrated into different parts of the desktop enviroment. ;-)

Viko Adi Rahmawan (vikoadi) wrote :

i think the inclusion of wingpanel itself just for sound indicator is just too much, beside that audience dont have control over it, like we dont need the mpris, setting link and cant remove it.
Also we the hide observer cant get the status, is it toggle or shown

Marcus Wichelmann (l-admin-3) wrote :

The sound indigator is able to decide which contents are shown for audience.

Viko Adi Rahmawan (vikoadi) wrote :

i still got mpris and setting link here.
how to hide it?

Viko Adi Rahmawan (vikoadi) wrote :

otherwise i still think depending on wingpanel is a bad move as the dependency will be coupled together. if i want to have audience, then i need wingpanel, then wingpanel need gala, then gala need plank. i would go for minimum dependency as possible espessially if it only use in small portion of apps.
to overcome code duplication, if we can upload a stable indicator-sound tar.gz, we can script cmake to download and extract those tar.gz then we can simply include the class we want. of course its depend on how loosely sound indicator class

review: Disapprove
Adam BieĊ„kowski (donadigo) wrote :

As Viko said there shouldn't be a strict dependency on wingpanel. I suggest to define cmake variable, something like #HAS_WINGPANEL and then check it in the code.

Viko Adi Rahmawan (vikoadi) wrote :

check this out guys https://code.launchpad.net/~vikoadi/audience/volume-control
it need a compressed wingpanel-indicator-sound.tar.gz uploaded somewhere, which usually are done when its released. for the time being I just compressed sound indicator into wingpanel-indicator-sound-0.1.tar.gz and put it audience project directory. bzr will handle downloading and decompressing.

maybe we can upload an alpha tar.gz somewhere?

Marcus Wichelmann (l-admin-3) wrote :

Hi, I don't see how that fixes the problem. You're still duplicating code and since it looked like you added the wingpanel-indicator-sound dependency, wingpanel is a dependency, too.
Please explain what exactly the code in src/Volume is for and why that isn't a duplication.

Viko Adi Rahmawan (vikoadi) wrote :

the wingpanel-indicator-sound refer to cmake target that is created using ExternalProject_Add, not sound indicator package. It can be compiled event without libwingpanel installed.

So those ExternalProject_Add will download and extract the tar.gz file into wingpanel-indicator-sound folder. Then we can add the class that we need into vala_precompile package. Here i can only reuse Sound.Widget.Scale, Service.VolumeControl, and Service.Setting. I need to have a controller to wire up Widget.Scale view into VolumeControl model, thats why i need to write all that src/Volume class.

If we can abstract out the volume controller part of Indicator.vala into its own class, we can always reuse it in Audience.

Unmerged revisions

550. By Marcus Wichelmann on 2015-10-22

Show sound indicator in fullscreen mode

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2015-09-04 11:10:22 +0000
3+++ src/CMakeLists.txt 2015-10-22 11:44:48 +0000
4@@ -11,7 +11,7 @@
5 # pkgconfig, real C code
6 find_package (PkgConfig)
7
8-set (PKG_DEPS granite>=0.3.0 clutter-gtk-1.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0 gstreamer-tag-1.0)
9+set (PKG_DEPS granite>=0.3.0 clutter-gtk-1.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-video-1.0 gstreamer-tag-1.0 wingpanel-2.0)
10 set (VALA_DEPS
11 granite>=0.3.0
12 clutter-gtk-1.0
13@@ -20,6 +20,7 @@
14 gstreamer-pbutils-1.0
15 gstreamer-video-1.0
16 gstreamer-tag-1.0
17+ wingpanel-2.0
18 )
19
20 pkg_check_modules (DEPS REQUIRED ${PKG_DEPS})
21@@ -65,6 +66,7 @@
22 Widgets/VideoPlayer.vala
23 Widgets/WelcomePage.vala
24 Widgets/PlayerPage.vala
25+ Widgets/IndicatorContainer.vala
26 PACKAGES
27 ${VALA_DEPS}
28 OPTIONS
29
30=== modified file 'src/Widgets/BottomBar.vala'
31--- src/Widgets/BottomBar.vala 2015-06-14 07:02:09 +0000
32+++ src/Widgets/BottomBar.vala 2015-10-22 11:44:48 +0000
33@@ -34,6 +34,7 @@
34 private Gtk.Button play_button;
35 private Gtk.Button preferences_button;
36 private Gtk.Revealer unfullscreen_revealer;
37+ private Gtk.Revealer indicator_revealer;
38 private bool is_playing = false;
39 private uint hiding_timer = 0;
40
41@@ -91,8 +92,10 @@
42 notify["fullscreen"].connect (() => {
43 if (fullscreen == true && child_revealed == true) {
44 unfullscreen_revealer.set_reveal_child (true);
45+ indicator_revealer.set_reveal_child (true);
46 } else if (fullscreen == false && child_revealed == true) {
47 unfullscreen_revealer.set_reveal_child (false);
48+ indicator_revealer.set_reveal_child (false);
49 }
50 });
51
52@@ -123,6 +126,16 @@
53 return unfullscreen_revealer;
54 }
55
56+ public Gtk.Revealer get_indicator_container () {
57+ indicator_revealer = new Gtk.Revealer ();
58+ indicator_revealer.opacity = GLOBAL_OPACITY;
59+ indicator_revealer.transition_type = Gtk.RevealerTransitionType.CROSSFADE;
60+ var indicator_container = new IndicatorContainer ();
61+ indicator_revealer.add (indicator_container);
62+ indicator_revealer.show_all ();
63+ return indicator_revealer;
64+ }
65+
66 public void toggle_play_pause () {
67 is_playing = !is_playing;
68 if (is_playing == true) {
69@@ -140,8 +153,10 @@
70 base.set_reveal_child (reveal);
71 if (reveal == true && fullscreen == true) {
72 unfullscreen_revealer.set_reveal_child (reveal);
73+ indicator_revealer.set_reveal_child (reveal);
74 } else if (reveal == false) {
75 unfullscreen_revealer.set_reveal_child (reveal);
76+ indicator_revealer.set_reveal_child (reveal);
77 }
78 }
79
80@@ -174,6 +189,7 @@
81 }
82 set_reveal_child (false);
83 unfullscreen_revealer.set_reveal_child (false);
84+ indicator_revealer.set_reveal_child (false);
85 hiding_timer = 0;
86 return false;
87 });
88
89=== added file 'src/Widgets/IndicatorContainer.vala'
90--- src/Widgets/IndicatorContainer.vala 1970-01-01 00:00:00 +0000
91+++ src/Widgets/IndicatorContainer.vala 2015-10-22 11:44:48 +0000
92@@ -0,0 +1,62 @@
93+/*
94+ * Copyright (c) 2011-2015 Marcus Wichelmann (marcus.wichelmann@hotmail.de)
95+ *
96+ * This program is free software; you can redistribute it and/or
97+ * modify it under the terms of the GNU General Public
98+ * License as published by the Free Software Foundation; either
99+ * version 2 of the License, or (at your option) any later version.
100+ *
101+ * This program is distributed in the hope that it will be useful,
102+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
103+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
104+ * General Public License for more details.
105+ *
106+ * You should have received a copy of the GNU General Public
107+ * License along with this program; if not, write to the
108+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
109+ * Boston, MA 02111-1307, USA.
110+ */
111+
112+public class Audience.Widgets.IndicatorContainer : Gtk.Grid {
113+ public IndicatorContainer () {
114+ Wingpanel.IndicatorManager indicator_manager = Wingpanel.IndicatorManager.get_default ();
115+ indicator_manager.initialize (Wingpanel.IndicatorManager.ServerType.SESSION);
116+
117+ if (!indicator_manager.has_indicators ()) {
118+ return;
119+ }
120+
121+ foreach (Wingpanel.Indicator indicator in indicator_manager.get_indicators ()) {
122+ if (indicator.code_name == Wingpanel.Indicator.SOUND) {
123+ add_indicator (indicator);
124+ }
125+ }
126+ }
127+
128+ private void add_indicator (Wingpanel.Indicator indicator) {
129+ Gtk.Widget display_widget = indicator.get_display_widget ();
130+ display_widget.add_events (Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.SCROLL_MASK);
131+ display_widget.valign = Gtk.Align.START;
132+
133+ Gtk.Popover popover = new Gtk.Popover (display_widget);
134+ popover.add (indicator.get_widget ());
135+
136+ display_widget.button_press_event.connect ((e) => {
137+ if ((e.button == Gdk.BUTTON_PRIMARY || e.button == Gdk.BUTTON_SECONDARY) && e.type == Gdk.EventType.BUTTON_PRESS) {
138+ if (popover.get_visible ()) {
139+ popover.hide ();
140+ } else {
141+ popover.show_all ();
142+ }
143+
144+ return Gdk.EVENT_STOP;
145+ }
146+
147+ display_widget.button_press_event (e);
148+
149+ return Gdk.EVENT_PROPAGATE;
150+ });
151+
152+ this.add (display_widget);
153+ }
154+}
155\ No newline at end of file
156
157=== modified file 'src/Widgets/PlayerPage.vala'
158--- src/Widgets/PlayerPage.vala 2015-09-12 20:11:41 +0000
159+++ src/Widgets/PlayerPage.vala 2015-10-22 11:44:48 +0000
160@@ -14,6 +14,8 @@
161 private Clutter.Stage stage;
162 private Gtk.Revealer unfullscreen_bar;
163 private GtkClutter.Actor unfullscreen_actor;
164+ private Gtk.Revealer indicator_bar;
165+ private GtkClutter.Actor indicator_actor;
166 private GtkClutter.Actor bottom_actor;
167 private GnomeMediaKeys mediakeys;
168
169@@ -56,6 +58,7 @@
170 bottom_bar.set_repeat (false);
171
172 unfullscreen_bar = bottom_bar.get_unfullscreen_button ();
173+ indicator_bar = bottom_bar.get_indicator_container ();
174
175 bottom_actor = new GtkClutter.Actor.with_contents (bottom_bar);
176 bottom_actor.opacity = GLOBAL_OPACITY;
177@@ -65,6 +68,10 @@
178 unfullscreen_actor.opacity = GLOBAL_OPACITY;
179 stage.add_child (unfullscreen_actor);
180
181+ indicator_actor = new GtkClutter.Actor.with_contents (indicator_bar);
182+ indicator_actor.opacity = GLOBAL_OPACITY;
183+ stage.add_child (indicator_actor);
184+
185 this.size_allocate.connect (on_size_allocate);
186 App.get_instance ().mainwindow.key_press_event.connect (on_key_press_event);
187 App.get_instance ().mainwindow.window_state_event.connect (on_window_state_event);
188@@ -338,6 +345,8 @@
189 bottom_actor.y = stage.get_height () - bottom_bar_size;
190 unfullscreen_actor.y = 6;
191 unfullscreen_actor.x = stage.get_width () - bottom_bar_size - 6;
192+ indicator_actor.y = 6;
193+ indicator_actor.x = 6;
194 }
195
196 public bool update_pointer_position (double y, int window_height) {

Subscribers

People subscribed via source and target branches