Merge lp:~vikoadi/audience/fix-1040729 into lp:~audience-members/audience/trunk

Proposed by Viko Adi Rahmawan
Status: Merged
Merged at revision: 270
Proposed branch: lp:~vikoadi/audience/fix-1040729
Merge into: lp:~audience-members/audience/trunk
Diff against target: 59 lines (+25/-0)
2 files modified
Audience/Utils.vala (+7/-0)
Audience/Widgets/VideoPlayer.vala (+18/-0)
To merge this branch: bzr merge lp:~vikoadi/audience/fix-1040729
Reviewer Review Type Date Requested Status
Cody Garver Approve
Tom Beckmann Approve
Review via email: mp+160981@code.launchpad.net

Description of the change

1. Create Utils.GnomeSessionManager
2. create VideoPlayer.set_screenlock method and call it from VideoPlayer.playing setter

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

I have been testing this and it works as advertised.

Just waiting on Tom Beckmann to get some time to check it out before merge.

Revision history for this message
Tom Beckmann (tombeckmann) wrote :

Code looks fine to me.

review: Approve
Revision history for this message
Cody Garver (codygarver) wrote :

Thanks Viko Adi!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Audience/Utils.vala'
2--- Audience/Utils.vala 2013-04-06 11:45:41 +0000
3+++ Audience/Utils.vala 2013-04-25 18:38:24 +0000
4@@ -6,6 +6,13 @@
5 public signal void MediaPlayerKeyPressed (string application, string key);
6 }
7
8+[DBus (name = "org.gnome.SessionManager")]
9+public interface GnomeSessionManager : GLib.Object {
10+ public abstract bool isSessionRunning() throws GLib.IOError;
11+ public abstract uint32 Inhibit (string app_id, uint32 toplevel_xid, string reason, uint32 flags) throws GLib.IOError;
12+ public abstract void Uninhibit (uint32 inhibit_cookie) throws GLib.IOError;
13+}
14+
15 namespace Audience {
16 public delegate void FuncOverDir (File file_under_dir);
17 public static void recurse_over_dir (File file_to_process, FuncOverDir func) {
18
19=== modified file 'Audience/Widgets/VideoPlayer.vala'
20--- Audience/Widgets/VideoPlayer.vala 2013-04-07 18:53:17 +0000
21+++ Audience/Widgets/VideoPlayer.vala 2013-04-25 18:38:24 +0000
22@@ -36,6 +36,7 @@
23 playbin.set_state (value ? Gst.State.PLAYING : Gst.State.PAUSED);
24
25 set_screensaver (!value);
26+ set_screenlock (!value);
27
28 if (!value) {
29 paused = true;
30@@ -201,6 +202,9 @@
31
32 uint hiding_timer;
33
34+ public GnomeSessionManager session_manager;
35+ uint32 inhibit_cookie;
36+
37 public bool fullscreened { get; set; }
38
39 public signal void ended ();
40@@ -624,5 +628,19 @@
41 dpy.get_screensaver (out timeout, out interval, out prefer_blanking, out allow_exposures);
42 dpy.set_screensaver (enable ? timeout : 0, interval, prefer_blanking, allow_exposures);
43 }
44+
45+ //prevent screenlocking in Gnome 3 using org.gnome.SessionManager
46+ void set_screenlock (bool enable)
47+ {
48+ try{
49+ session_manager = Bus.get_proxy_sync (BusType.SESSION,
50+ "org.gnome.SessionManager", "/org/gnome/SessionManager");
51+ if (enable) {
52+ session_manager.Uninhibit (inhibit_cookie);
53+ }else{
54+ inhibit_cookie = session_manager.Inhibit ("audience", 0, "Playing Video using Audience", 12);
55+ }
56+ } catch (Error e) { warning (e.message); }
57+ }
58 }
59 }

Subscribers

People subscribed via source and target branches