Merge lp:~simon-d-bull/cappella/cappella10_task_manager_plugin into lp:cappella

Proposed by Simon Bull
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 96
Merged at revision: 97
Proposed branch: lp:~simon-d-bull/cappella/cappella10_task_manager_plugin
Merge into: lp:cappella
Diff against target: 184 lines (+114/-10)
5 files modified
cappella/__init__.py (+7/-7)
cappella/data/default/plugins.js (+3/-2)
cappella/gui/widget/status.py (+4/-1)
cappella/plugin/unity_launcher.py (+96/-0)
cappella/signalhandler.py (+4/-0)
To merge this branch: bzr merge lp:~simon-d-bull/cappella/cappella10_task_manager_plugin
Reviewer Review Type Date Requested Status
Simon Bull Approve
Andrew Hayzen Approve
Review via email: mp+161340@code.launchpad.net

Description of the change

* Added unity_launcher.py file which handles launcher notifications based on task manager activity.

To post a comment you must log in.
Revision history for this message
Andrew Hayzen (ahayzen) :
review: Approve
Revision history for this message
Simon Bull (simon-d-bull) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cappella/__init__.py'
2--- cappella/__init__.py 2013-04-27 18:48:25 +0000
3+++ cappella/__init__.py 2013-04-28 20:22:28 +0000
4@@ -135,13 +135,6 @@
5
6 Logger.debug("Loaded Media")
7
8- #----------------------------------------------------------- Load GUI Views
9- from .gui import view # Add views to gui interface
10-
11- gui_man.do_load_from_settings() # Load settings to gui
12-
13- Logger.debug("Loaded GUI Phase 2")
14-
15 #------------------------------------------------------------- Load Plugins
16 if optpar.disable_plugins is False:
17 from .management.plugin import management as plugin_man
18@@ -153,6 +146,13 @@
19
20 Logger.debug("Loaded Plugin")
21
22+ #----------------------------------------------------------- Load GUI Views
23+ from .gui import view # Add views to gui interface
24+
25+ gui_man.do_load_from_settings() # Load settings to gui
26+
27+ Logger.debug("Loaded GUI Phase 2")
28+
29 from .tool.garbage import Collect
30
31 Collect() # Force garbage collection
32
33=== modified file 'cappella/data/default/plugins.js'
34--- cappella/data/default/plugins.js 2013-04-21 19:24:31 +0000
35+++ cappella/data/default/plugins.js 2013-04-28 20:22:28 +0000
36@@ -2,5 +2,6 @@
37 "Media Keys": {"location": "media_keys", "autostart": true},
38 "Title Bar": {"location": "titlebar", "autostart": true},
39 "Unity Sound Menu": {"location": "unity_soundmenu", "autostart": true},
40- "Unity Quicklist": { "location": "unity_quicklist", "autostart": true}
41-}
42\ No newline at end of file
43+ "Unity Quicklist": { "location": "unity_quicklist", "autostart": true},
44+ "Unity Launcher": {"location": "unity_launcher", "autostart": true}
45+}
46
47=== modified file 'cappella/gui/widget/status.py'
48--- cappella/gui/widget/status.py 2013-04-02 22:48:35 +0000
49+++ cappella/gui/widget/status.py 2013-04-28 20:22:28 +0000
50@@ -26,7 +26,7 @@
51 from ...gui.widget.progress import ProgressWidget
52 from ...management.library import LibraryType, LibraryPurpose, LibraryMode
53 from ...signalhandler import signal
54-from ...tool import skipx, thread_safe
55+from ...tool import emit_signal, skipx, thread_safe
56
57
58 class StatusBar():
59@@ -99,6 +99,9 @@
60
61 self.spinner.set_state(True) # Force spinner spinning
62
63+ GObject.idle_add(emit_signal, "_task_progress_", avg,
64+ priority=GObject.PRIORITY_HIGH)
65+
66 sleep(0.50) # Only refresh twice a second
67
68 @thread_safe
69
70=== added file 'cappella/plugin/unity_launcher.py'
71--- cappella/plugin/unity_launcher.py 1970-01-01 00:00:00 +0000
72+++ cappella/plugin/unity_launcher.py 2013-04-28 20:22:28 +0000
73@@ -0,0 +1,96 @@
74+#!/usr/bin/env python3
75+'''
76+ Copyright (C) 2011-2013 Andrew Hayzen and Simon Bull.
77+
78+ Cappella is a simple media player based on PyGObject for Ubuntu.
79+
80+ This file is free software: you can redistribute it and/or modify it
81+ under the terms of the GNU General Public License as published by the
82+ Free Software Foundation, either version 3 of the License,
83+ or (at your option) any later version.
84+
85+ This file is distributed in the hope that it will be useful, but WITHOUT
86+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
87+ FITNESS FOR A PARTICULAR PURPOSE. See the
88+ GNU General Public License for more details.
89+
90+ You should have received a copy of the GNU General Public License along with
91+ this file. If not, see <http://www.gnu.org/licenses/>.
92+'''
93+
94+try:
95+ from gi.repository import Dbusmenu, Unity
96+ unity = True
97+except ImportError:
98+ unity = False
99+
100+from ..config.cappella import settings
101+from ..tool import thread_safe, skipx
102+
103+class Plugin():
104+ """
105+ PLUGIN FOR UNITY LAUNCHER
106+ """
107+ info = {"name": "Unity Launcher",
108+ "description": "Adds progress bar and cunter to the unity "
109+ "launcher that monitors tasks in cappella.",
110+ "author": ["Andrew Hayzen", "Simon Bull"],
111+ "copyright": "Copyright \u00A9 Andrew Hayzen & Simon Bull",
112+ "website": "http://www.andrewhayzen.co.uk/",
113+ "configure": False}
114+
115+ def __init__(self, plugin_object):
116+ # Load variables
117+ self.plugin_object = plugin_object
118+
119+ self.signal = self.plugin_object.signalhandler
120+ self.name = self.plugin_object.name
121+ self.ids = []
122+
123+ self.quicklist_items = {}
124+
125+ if unity:
126+ desk_id = "cappella.desktop"
127+ self.launcher = Unity.LauncherEntry.get_for_desktop_id(desk_id)
128+
129+ self.counter = 0
130+
131+ def on_task_add(self, signal, task):
132+ self.counter += 1
133+
134+ if unity:
135+ self.launcher.set_property("count", self.counter)
136+ self.launcher.set_property("count_visible", self.counter != 0)
137+ self.launcher.set_property("progress_visible", self.counter != 0)
138+
139+ def on_task_progress(self, signal, fraction):
140+ if unity:
141+ self.launcher.set_property("progress", fraction)
142+
143+ def on_task_remove(self, signal, task):
144+ self.counter -= 1
145+
146+ if unity:
147+ self.launcher.set_property("count", self.counter)
148+ self.launcher.set_property("count_visible", self.counter != 0)
149+ self.launcher.set_property("progress_visible", self.counter != 0)
150+
151+ def start(self):
152+ i = self.signal.connect('_task_add_', self.on_task_add)
153+ self.ids.append(i)
154+
155+ i = self.signal.connect('_task_remove_', self.on_task_remove)
156+ self.ids.append(i)
157+
158+ i = self.signal.connect('_task_progress_', self.on_task_progress)
159+ self.ids.append(i)
160+
161+ @thread_safe
162+ def stop(self):
163+ for i in self.ids:
164+ self.signal.disconnect(i)
165+
166+ self.ids = []
167+
168+ if not unity:
169+ return
170
171=== modified file 'cappella/signalhandler.py'
172--- cappella/signalhandler.py 2013-04-28 18:40:19 +0000
173+++ cappella/signalhandler.py 2013-04-28 20:22:28 +0000
174@@ -333,6 +333,10 @@
175 # Add new task task(object)
176 '_task_remove_' : (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE,
177 (GObject.TYPE_PYOBJECT,)),
178+
179+ # Add new task progress(float)
180+ '_task_progress_' : (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE,
181+ (GObject.TYPE_DOUBLE,)),
182
183 # Show progress widget
184 '_task_show_' : (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ()),

Subscribers

People subscribed via source and target branches

to all changes: