Merge lp:~kurt.smolderen/beat-box/beat-box into lp:beat-box

Proposed by Scott Ringwelski
Status: Merged
Approved by: Scott Ringwelski
Approved revision: no longer in the source branch.
Merged at revision: 622
Proposed branch: lp:~kurt.smolderen/beat-box/beat-box
Merge into: lp:beat-box
Diff against target: 142 lines (+56/-15)
3 files modified
src/Core/LibraryWindow.vala (+50/-8)
src/DBus/MPRIS/MPRIS.vala (+5/-7)
src/DBus/UnityIntegration.vala (+1/-0)
To merge this branch: bzr merge lp:~kurt.smolderen/beat-box/beat-box
Reviewer Review Type Date Requested Status
Scott Ringwelski Approve
Review via email: mp+111311@code.launchpad.net

Description of the change

Kurt's sound menu changes

To post a comment you must log in.
Revision history for this message
Scott Ringwelski (sgringwe) wrote :

Hey Kurt, it's easier to just use merges rather than lots of patches.

Thanks for the work! Some things for you to work on further:

1. What if user clicks close while music is playing but DOESN'T have soundmenu to reshow it? It would be really bad for the window to be "lost" meaning it is running but not accessible and has to be killed.
2. What kind of performance regression is had by checking for sound menu or unity at startup? Also, I'm not positive, but I'm pretty sure those checks are dead code meaning HAVE_INDICATE is set during compile time anyways...
3. Your rev 623 change for the raised signal should also be implemented in MPRIS.vala, which is the fallback file for when a user does not have unity but still has MPRIS services (UnityIntegration.vala uses libunity, and libunity is just a higher level api for MPRIS).
4. What if the user is in the middle of importing their music library (or other similar operations) and clicks close?

Revision history for this message
Scott Ringwelski (sgringwe) :
review: Needs Fixing
Revision history for this message
Kurt Smolderen (kurt.smolderen) wrote :

Hey Scot,

Some feedback inline...

Regards
Kurt

On 20-06-12 23:50, Scott Ringwelski wrote:
> Hey Kurt, it's easier to just use merges rather than lots of patches.
>
> Thanks for the work! Some things for you to work on further:
>
> 1. What if user clicks close while music is playing but DOESN'T have soundmenu to reshow it? It would be really bad for the window to be "lost" meaning it is running but not accessible and has to be killed.
If soundmenu is not running, the hook which hides the main window
instead of closing it is not set (so it still points to destroy in this
case...)
> 2. What kind of performance regression is had by checking for sound menu or unity at startup? Also, I'm not positive, but I'm pretty sure those checks are dead code meaning HAVE_INDICATE is set during compile time anyways...
About 0.035 seconds on my system (Core i3 2.2GHz, 4GB ram).
HAVE_INDICATE is set during compile time indeed but that's ok. If the
indicate library is not found, we do not want any code relying on that
library to be compiled. The reason why this change is needed (according
to me at least) is because in the MPRIS class the creation of the Sound
menu integration object was let to the UnityIntegration object is
HAVE_UNITY was set. So when running Gnome Classic, unity library is
present but unity itself is not running and hence it is not optimal...
> 3. Your rev 623 change for the raised signal should also be implemented in MPRIS.vala, which is the fallback file for when a user does not have unity but still has MPRIS services (UnityIntegration.vala uses libunity, and libunity is just a higher level api for MPRIS).
This was correctly implemented in the MPRIS class...
> 4. What if the user is in the middle of importing their music library (or other similar operations) and clicks close?
At this point, the same would happen as when this patch is not
integrated I think as the Gtk Window will just handle the 'click on
close' event as it would do without this patch...

Revision history for this message
Scott Ringwelski (sgringwe) wrote :

Hmmm looks like I should have looked at the code a little more before I asked those questions. You are absolutely right.

As for #4, you are right on that too, but I was hoping to see if you would be willing to implement that :). I can do that though.

I really like your changes, and I am not worried about 0.035 seconds for the added stability/robustness. There are ways to gain that back and much more in better ways.

I'm going to go ahead and merge this. I wasn't sure about the sound menu hide/show ux, but I am ok with it now. Plus I know it will make lots of users happy.

If you want to help with the project more, please let me know :)

review: Approve
lp:~kurt.smolderen/beat-box/beat-box updated
622. By Scott Ringwelski

Merged Kurt Smolderen's sound menu/unity changes.

Revision history for this message
Kurt Smolderen (kurt.smolderen) wrote :

#4: OK, didn't interpret the question/ remark that way :-), but it's
not a problem to have a look at it, because you have a point there are
some other situations for which it's preferable the application to be
hidden instead of closed (importing library, ripping CD,...). I'll have
a look at it...

What would be the expected behaviour? I would suggest:

  * Check whether a 'non-interruptible' task is going on
  * If it is
not: close the program
  * If it is:

  * Finish the task
  * Check
again whether a non-interruptible task is going on
  * etc...

BTW: for
your interest: I'm currently working on a solution for
https://bugs.launchpad.net/beat-box/+bug/1014554. So yes, I'm kind of
interested in supporting this project. But as my Vala knowledge is
pretty limited at this stage, I'm cvurrently picking up the 'easy to
fix' bugs to get into the language and into the program structure... But
I do hope to send you a few more merge requests :-)

Regards Kurt

On
21.06.2012 04:50, Scott Ringwelski wrote:

> Review: Approve
>
> Hmmm
looks like I should have looked at the code a little more before I asked
those questions. You are absolutely right.
>
> As for #4, you are right
on that too, but I was hoping to see if you would be willing to
implement that :). I can do that though.
>
> I really like your
changes, and I am not worried about 0.035 seconds for the added
stability/robustness. There are ways to gain that back and much more in
better ways.
>
> I'm going to go ahead and merge this. I wasn't sure
about the sound menu hide/show ux, but I am ok with it now. Plus I know
it will make lots of users happy.
>
> If you want to help with the
project more, please let me know :)
> --
https://code.launchpad.net/~kurt.smolderen/beat-box/beat-box/+merge/111311
You are the owner of lp:~kurt.smolderen/beat-box/beat-box.

Revision history for this message
Scott Ringwelski (sgringwe) wrote :

That's roughly what I was thinking. Really, you can just check for
lm.doing_file_operations the same way you do for lm.playing,and then add a
signal handler to file_operations_finished to potentially close if it is
hidden (maybe do same with playback_stopped?)

Remember though that merges should be specific to the feature you are
working on.

For https://bugs.launchpad.net/beat-box/+bug/1014554 look for key_pressed
in library window

Thanks!

On Thu, Jun 21, 2012 at 4:40 AM, Kurt Smolderen <email address hidden>wrote:

>
>
> #4: OK, didn't interpret the question/ remark that way :-), but it's
> not a problem to have a look at it, because you have a point there are
> some other situations for which it's preferable the application to be
> hidden instead of closed (importing library, ripping CD,...). I'll have
> a look at it...
>
> What would be the expected behaviour? I would suggest:
>
>
> * Check whether a 'non-interruptible' task is going on
> * If it is
> not: close the program
> * If it is:
>
> * Finish the task
> * Check
> again whether a non-interruptible task is going on
> * etc...
>
> BTW: for
> your interest: I'm currently working on a solution for
> https://bugs.launchpad.net/beat-box/+bug/1014554. So yes, I'm kind of
> interested in supporting this project. But as my Vala knowledge is
> pretty limited at this stage, I'm cvurrently picking up the 'easy to
> fix' bugs to get into the language and into the program structure... But
> I do hope to send you a few more merge requests :-)
>
> Regards Kurt
>
> On
> 21.06.2012 04:50, Scott Ringwelski wrote:
>
> > Review: Approve
> >
> > Hmmm
> looks like I should have looked at the code a little more before I asked
> those questions. You are absolutely right.
> >
> > As for #4, you are right
> on that too, but I was hoping to see if you would be willing to
> implement that :). I can do that though.
> >
> > I really like your
> changes, and I am not worried about 0.035 seconds for the added
> stability/robustness. There are ways to gain that back and much more in
> better ways.
> >
> > I'm going to go ahead and merge this. I wasn't sure
> about the sound menu hide/show ux, but I am ok with it now. Plus I know
> it will make lots of users happy.
> >
> > If you want to help with the
> project more, please let me know :)
> > --
> https://code.launchpad.net/~kurt.smolderen/beat-box/beat-box/+merge/111311
> You are the owner of lp:~kurt.smolderen/beat-box/beat-box.
>
>
> --
> https://code.launchpad.net/~kurt.smolderen/beat-box/beat-box/+merge/111311
> You proposed lp:~kurt.smolderen/beat-box/beat-box for merging.
>

Revision history for this message
Kurt Smolderen (kurt.smolderen) wrote :

Changes for #4 have been pushed to my branch. Once all file operations
are finished, Beatbox is closed. I did not implement 'close on
playback_stopped' as this would require the user to completely restart
beatbox once his queue is empty...

Regards
Kurt

On 21-06-12 14:28, Scott Ringwelski wrote:
> That's roughly what I was thinking. Really, you can just check for
> lm.doing_file_operations the same way you do for lm.playing,and then add a
> signal handler to file_operations_finished to potentially close if it is
> hidden (maybe do same with playback_stopped?)
>
> Remember though that merges should be specific to the feature you are
> working on.
>
> For https://bugs.launchpad.net/beat-box/+bug/1014554 look for key_pressed
> in library window
>
> Thanks!
>
> On Thu, Jun 21, 2012 at 4:40 AM, Kurt Smolderen<email address hidden>wrote:
>
>>
>> #4: OK, didn't interpret the question/ remark that way :-), but it's
>> not a problem to have a look at it, because you have a point there are
>> some other situations for which it's preferable the application to be
>> hidden instead of closed (importing library, ripping CD,...). I'll have
>> a look at it...
>>
>> What would be the expected behaviour? I would suggest:
>>
>>
>> * Check whether a 'non-interruptible' task is going on
>> * If it is
>> not: close the program
>> * If it is:
>>
>> * Finish the task
>> * Check
>> again whether a non-interruptible task is going on
>> * etc...
>>
>> BTW: for
>> your interest: I'm currently working on a solution for
>> https://bugs.launchpad.net/beat-box/+bug/1014554. So yes, I'm kind of
>> interested in supporting this project. But as my Vala knowledge is
>> pretty limited at this stage, I'm cvurrently picking up the 'easy to
>> fix' bugs to get into the language and into the program structure... But
>> I do hope to send you a few more merge requests :-)
>>
>> Regards Kurt
>>
>> On
>> 21.06.2012 04:50, Scott Ringwelski wrote:
>>
>>> Review: Approve
>>>
>>> Hmmm
>> looks like I should have looked at the code a little more before I asked
>> those questions. You are absolutely right.
>>> As for #4, you are right
>> on that too, but I was hoping to see if you would be willing to
>> implement that :). I can do that though.
>>> I really like your
>> changes, and I am not worried about 0.035 seconds for the added
>> stability/robustness. There are ways to gain that back and much more in
>> better ways.
>>> I'm going to go ahead and merge this. I wasn't sure
>> about the sound menu hide/show ux, but I am ok with it now. Plus I know
>> it will make lots of users happy.
>>> If you want to help with the
>> project more, please let me know :)
>>> --
>> https://code.launchpad.net/~kurt.smolderen/beat-box/beat-box/+merge/111311
>> You are the owner of lp:~kurt.smolderen/beat-box/beat-box.
>>
>>
>> --
>> https://code.launchpad.net/~kurt.smolderen/beat-box/beat-box/+merge/111311
>> You proposed lp:~kurt.smolderen/beat-box/beat-box for merging.
>>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Core/LibraryWindow.vala'
2--- src/Core/LibraryWindow.vala 2012-06-19 22:50:13 +0000
3+++ src/Core/LibraryWindow.vala 2012-06-20 21:41:18 +0000
4@@ -24,6 +24,9 @@
5 using Gee;
6 using Notify;
7
8+const string PROCESS_INDICATOR_SOUND = "indicator-sound-service";
9+const string PROCESS_UNITY = "unity-panel-service";
10+
11 public class BeatBox.LibraryWindow : LibraryWindowInterface, Gtk.Window {
12
13 // signals
14@@ -88,6 +91,10 @@
15 private Gtk.MenuItem fileRescanMusicFolder;
16 private Gtk.MenuItem editEqualizer;
17 private ImageMenuItem editPreferences;
18+
19+ // Unity and sound menu integration flags
20+ public bool enableUnityIntegration { get; private set; }
21+ public bool enableSoundmenuIntegration { get; private set; }
22
23 public Notify.Notification notification { get; private set; }
24
25@@ -106,21 +113,31 @@
26
27 //various objects
28 mkl = new MediaKeyListener(lm, this);
29+
30+ // Check for Unity and sound menu availability
31+ enableUnityIntegration = is_process_running(PROCESS_UNITY);
32+ enableSoundmenuIntegration = is_process_running(PROCESS_INDICATOR_SOUND);
33
34 #if HAVE_INDICATE
35 #if HAVE_DBUSMENU
36- message("Initializing MPRIS and sound menu\n");
37- var mpris = new BeatBox.MPRIS(lm, this);
38- mpris.initialize();
39+ if (enableSoundmenuIntegration) {
40+ message("Initializing MPRIS and sound menu\n");
41+ var mpris = new BeatBox.MPRIS(lm, this);
42+ mpris.initialize();
43+ this.delete_event.connect(on_delete);
44+ }
45 #endif
46 #endif
47
48 #if HAVE_UNITY
49 #if HAVE_DBUSMENU
50- message("Initializing Unity integration\n");
51- unity = new BeatBox.UnityIntegration(lm, this);
52- if(!unity.initialize())
53- warning("Unity integration failed\n");
54+ if (enableUnityIntegration) {
55+ message("Initializing Unity integration\n");
56+ unity = new BeatBox.UnityIntegration(lm, this);
57+ if(!unity.initialize()) {
58+ warning("Unity integration failed\n");
59+ }
60+ }
61 #endif
62 #endif
63
64@@ -996,7 +1013,16 @@
65 w.focus(DirectionType.UP);
66 }
67
68- void on_quit() {
69+ bool on_delete() {
70+ bool hide_on_close = false;
71+ if (lm.playing) {
72+ this.hide();
73+ hide_on_close = true;
74+ }
75+ return hide_on_close;
76+ }
77+
78+ void on_quit() {
79 lm.settings.setLastMediaPosition((int)((double)lm.player.getPosition()/1000000000));
80 if(lm.media_active) {
81 lm.media_info.media.resume_pos = (int)((double)lm.player.getPosition()/1000000000);
82@@ -1421,5 +1447,21 @@
83 now_playing.hide_video_mode();
84 showSongInfo.set_image(Icons.INFO.render_image (IconSize.MENU, viewSelector.get_style_context()));
85 }
86+
87+ bool is_process_running(string process_name) {
88+ bool is_running = false;
89+ string cmd = "pidof " + process_name;
90+ string pid;
91+ try {
92+ Process.spawn_command_line_sync(cmd, out pid);
93+ debug("PID of %s: %s", process_name, pid);
94+ if (pid.length > 0) {
95+ is_running = true;
96+ }
97+ } catch (SpawnError e) {
98+ debug("Unable to spawn process: %s", e.message);
99+ }
100+ return is_running;
101+ }
102 }
103
104
105=== modified file 'src/DBus/MPRIS/MPRIS.vala'
106--- src/DBus/MPRIS/MPRIS.vala 2012-06-19 22:50:13 +0000
107+++ src/DBus/MPRIS/MPRIS.vala 2012-06-20 21:41:18 +0000
108@@ -49,18 +49,16 @@
109 warning("Could not initialize MPRIS session.\n");
110 }
111 else {
112- bool have_unity = false;
113-#if HAVE_UNITY
114- have_unity = true;
115-#endif
116-
117- // If we have libunity, let the implementation in UnityIntegration
118+ // If Unity is running, let the implementation in UnityIntegration
119 // handle the sound menu since it is cleaner and has playlists.
120 // Otherwise, use this as a backup.
121- if(!have_unity) {
122+ if(lw.enableSoundmenuIntegration && !lw.enableUnityIntegration) {
123 var soundMenu = new SoundMenuIntegration(lm, lw);
124 soundMenu.initialize();
125 }
126+ else {
127+ debug("It's up to unity to take care for sound menu integration");
128+ }
129 }
130 }
131
132
133=== modified file 'src/DBus/UnityIntegration.vala'
134--- src/DBus/UnityIntegration.vala 2012-06-01 22:54:35 +0000
135+++ src/DBus/UnityIntegration.vala 2012-06-20 21:41:18 +0000
136@@ -94,6 +94,7 @@
137 player.previous.connect(lw.previousClicked);
138 player.play_pause.connect(lw.playClicked);
139 player.activate_playlist.connect(playlist_activated);
140+ player.raise.connect(lw.present);
141
142 lw.playPauseChanged.connect(playing_changed);
143

Subscribers

People subscribed via source and target branches