Merge lp:~diegotoral/season-one/season-one into lp:season-one
- season-one
- Merge into trunk
Proposed by
Diego Toral
Status: | Merged |
---|---|
Merged at revision: | 7 |
Proposed branch: | lp:~diegotoral/season-one/season-one |
Merge into: | lp:season-one |
Diff against target: |
417 lines (+301/-27) 8 files modified
bin/season-one (+45/-0) data/ui/season-window.ui (+131/-0) src/__init__.py (+1/-13) src/config.py (+19/-1) src/core/__init__.py (+18/-0) src/ui/application.py (+23/-8) src/ui/builder.py (+35/-0) src/ui/window.py (+29/-5) |
To merge this branch: | bzr merge lp:~diegotoral/season-one/season-one |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Season Team | Pending | ||
Review via email: mp+111692@code.launchpad.net |
Commit message
Description of the change
Created bin/season-one executable. Cleanup Application e Window classes. Application class now proper records the dbus application name and set flags.
To post a comment you must log in.
- 7. By Diego Toral
-
UI file definition added. Created class Builder.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'bin' |
2 | === added file 'bin/season-one' |
3 | --- bin/season-one 1970-01-01 00:00:00 +0000 |
4 | +++ bin/season-one 2012-06-23 01:12:18 +0000 |
5 | @@ -0,0 +1,45 @@ |
6 | +#!/usr/bin/env python |
7 | +""" |
8 | +Copyright (C) 2012 Caio Oliveira <caio.freitaso@gmail.com> |
9 | +Copyright (C) 2012 Diego Toral <diegotoral@gmail.com> |
10 | +Copyright (C) 2012 Thiago Abreu <thiagoa7@gmail.com> |
11 | + |
12 | +This program is free software: you can redistribute it and/or modify |
13 | +it under the terms of the GNU General Public License as published by |
14 | +the Free Software Foundation, either version 3 of the License, or |
15 | +(at your option) any later version. |
16 | + |
17 | +This program is distributed in the hope that it will be useful, |
18 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | +GNU General Public License for more details. |
21 | + |
22 | +You should have received a copy of the GNU General Public License |
23 | +along with this program. If not, see <http://www.gnu.org/licenses/>. |
24 | +""" |
25 | + |
26 | +import os |
27 | +import sys, dbus |
28 | + |
29 | +from gi.repository import GLib |
30 | + |
31 | +import gettext |
32 | +from gettext import gettext as _ |
33 | +gettext.textdomain('season-one') |
34 | + |
35 | +PROJECT_ROOT_DIRECTORY = os.path.abspath( |
36 | + os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))) |
37 | +) |
38 | + |
39 | +if os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'src')) and PROJECT_ROOT_DIRECTORY not in sys.path: |
40 | + sys.path.append(os.path.join(PROJECT_ROOT_DIRECTORY, 'src')) |
41 | + |
42 | +# The magic starts here |
43 | +try: |
44 | + from ui.application import Application |
45 | + |
46 | + app = Application() |
47 | + app.run(sys.argv) |
48 | +except ImportError: |
49 | + # TODO Make proper loggin using logging module |
50 | + print "Error while importing!" |
51 | \ No newline at end of file |
52 | |
53 | === added directory 'data/ui' |
54 | === added file 'data/ui/season-window.ui' |
55 | --- data/ui/season-window.ui 1970-01-01 00:00:00 +0000 |
56 | +++ data/ui/season-window.ui 2012-06-23 01:12:18 +0000 |
57 | @@ -0,0 +1,131 @@ |
58 | +<?xml version="1.0" encoding="UTF-8"?> |
59 | +<interface> |
60 | + <!-- interface-requires gtk+ 3.0 --> |
61 | + <object class="GtkBox" id="vbox"> |
62 | + <property name="visible">True</property> |
63 | + <property name="can_focus">False</property> |
64 | + <property name="orientation">vertical</property> |
65 | + <child> |
66 | + <object class="GtkToolbar" id="toolbar"> |
67 | + <property name="visible">True</property> |
68 | + <property name="can_focus">False</property> |
69 | + <property name="toolbar_style">icons</property> |
70 | + <property name="show_arrow">False</property> |
71 | + <property name="icon_size">2</property> |
72 | + <child> |
73 | + <object class="GtkToggleToolButton" id="power"> |
74 | + <property name="use_action_appearance">False</property> |
75 | + <property name="visible">True</property> |
76 | + <property name="can_focus">False</property> |
77 | + <property name="use_action_appearance">False</property> |
78 | + <property name="label" translatable="yes">toolbutton1</property> |
79 | + <property name="use_underline">True</property> |
80 | + <property name="stock_id">gtk-media-play</property> |
81 | + </object> |
82 | + <packing> |
83 | + <property name="expand">False</property> |
84 | + <property name="homogeneous">True</property> |
85 | + </packing> |
86 | + </child> |
87 | + <child> |
88 | + <object class="GtkToolButton" id="toolbutton1"> |
89 | + <property name="use_action_appearance">False</property> |
90 | + <property name="visible">True</property> |
91 | + <property name="can_focus">False</property> |
92 | + <property name="use_action_appearance">False</property> |
93 | + <property name="label" translatable="yes">toolbutton1</property> |
94 | + <property name="use_underline">True</property> |
95 | + <property name="stock_id">gtk-add</property> |
96 | + </object> |
97 | + <packing> |
98 | + <property name="expand">False</property> |
99 | + <property name="homogeneous">True</property> |
100 | + </packing> |
101 | + </child> |
102 | + <child> |
103 | + <object class="GtkToolButton" id="toolbutton2"> |
104 | + <property name="use_action_appearance">False</property> |
105 | + <property name="visible">True</property> |
106 | + <property name="can_focus">False</property> |
107 | + <property name="use_action_appearance">False</property> |
108 | + <property name="label" translatable="yes">toolbutton2</property> |
109 | + <property name="use_underline">True</property> |
110 | + <property name="stock_id">gtk-info</property> |
111 | + </object> |
112 | + <packing> |
113 | + <property name="expand">False</property> |
114 | + <property name="homogeneous">True</property> |
115 | + </packing> |
116 | + </child> |
117 | + <child> |
118 | + <object class="GtkSeparatorToolItem" id="toolbutton4"> |
119 | + <property name="use_action_appearance">False</property> |
120 | + <property name="visible">True</property> |
121 | + <property name="can_focus">False</property> |
122 | + <property name="hexpand">True</property> |
123 | + <property name="use_action_appearance">False</property> |
124 | + <property name="draw">False</property> |
125 | + </object> |
126 | + <packing> |
127 | + <property name="expand">True</property> |
128 | + <property name="homogeneous">True</property> |
129 | + </packing> |
130 | + </child> |
131 | + <child> |
132 | + <object class="GtkToggleToolButton" id="toolbutton3"> |
133 | + <property name="use_action_appearance">False</property> |
134 | + <property name="visible">True</property> |
135 | + <property name="can_focus">False</property> |
136 | + <property name="halign">end</property> |
137 | + <property name="use_action_appearance">False</property> |
138 | + <property name="label" translatable="yes">toolbutton3</property> |
139 | + <property name="use_underline">True</property> |
140 | + <property name="stock_id">gtk-properties</property> |
141 | + </object> |
142 | + <packing> |
143 | + <property name="expand">False</property> |
144 | + </packing> |
145 | + </child> |
146 | + </object> |
147 | + <packing> |
148 | + <property name="expand">False</property> |
149 | + <property name="fill">True</property> |
150 | + <property name="position">0</property> |
151 | + </packing> |
152 | + </child> |
153 | + <child> |
154 | + <object class="GtkNotebook" id="notebook"> |
155 | + <property name="visible">True</property> |
156 | + <property name="can_focus">True</property> |
157 | + <property name="show_tabs">False</property> |
158 | + <property name="show_border">False</property> |
159 | + <child> |
160 | + <object class="GtkIconView" id="iconview1"> |
161 | + <property name="visible">True</property> |
162 | + <property name="can_focus">True</property> |
163 | + </object> |
164 | + </child> |
165 | + <child type="tab"> |
166 | + <placeholder/> |
167 | + </child> |
168 | + <child> |
169 | + <placeholder/> |
170 | + </child> |
171 | + <child type="tab"> |
172 | + <placeholder/> |
173 | + </child> |
174 | + <child> |
175 | + <placeholder/> |
176 | + </child> |
177 | + <child type="tab"> |
178 | + <placeholder/> |
179 | + </child> |
180 | + </object> |
181 | + <packing> |
182 | + <property name="expand">True</property> |
183 | + <property name="fill">True</property> |
184 | + <property name="position">1</property> |
185 | + </packing> |
186 | + </child> |
187 | + </object> |
188 | +</interface> |
189 | |
190 | === modified file 'src/__init__.py' |
191 | --- src/__init__.py 2012-06-21 22:51:54 +0000 |
192 | +++ src/__init__.py 2012-06-23 01:12:18 +0000 |
193 | @@ -15,16 +15,4 @@ |
194 | |
195 | You should have received a copy of the GNU General Public License |
196 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
197 | -""" |
198 | - |
199 | -from ui import application |
200 | - |
201 | -import gettext |
202 | -from gettext import gettext as _ |
203 | -gettext.textdomain('season-one') |
204 | - |
205 | -def main(): |
206 | - """The magic starts here""" |
207 | - |
208 | - app = Application() |
209 | - app.run() |
210 | \ No newline at end of file |
211 | +""" |
212 | \ No newline at end of file |
213 | |
214 | === modified file 'src/config.py' |
215 | --- src/config.py 2012-06-21 22:51:54 +0000 |
216 | +++ src/config.py 2012-06-23 01:12:18 +0000 |
217 | @@ -17,5 +17,23 @@ |
218 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
219 | """ |
220 | |
221 | +import os |
222 | + |
223 | __version__ = "0.1" |
224 | -__license__ = "GPL v3.0" |
225 | \ No newline at end of file |
226 | +__license__ = "GPL v3.0" |
227 | +__data_dir__ = "../data/" |
228 | + |
229 | +def get_data_path(): |
230 | + path = os.path.abspath(os.path.join(os.path.dirname(__file__), __data_dir__)) |
231 | + |
232 | + if os.path.exists(path): |
233 | + return path |
234 | + |
235 | +def get_ui_path(): |
236 | + return os.path.join(get_data_path(), "ui/") |
237 | + |
238 | +def get_media_path(): |
239 | + return os.path.join(get_data_path(), "media/") |
240 | + |
241 | +def get_version(): |
242 | + return __version__ |
243 | |
244 | === added file 'src/core/__init__.py' |
245 | --- src/core/__init__.py 1970-01-01 00:00:00 +0000 |
246 | +++ src/core/__init__.py 2012-06-23 01:12:18 +0000 |
247 | @@ -0,0 +1,18 @@ |
248 | +""" |
249 | +Copyright (C) 2012 Caio Oliveira <caio.freitaso@gmail.com> |
250 | +Copyright (C) 2012 Diego Toral <diegotoral@gmail.com> |
251 | +Copyright (C) 2012 Thiago Abreu <thiagoa7@gmail.com> |
252 | + |
253 | +This program is free software: you can redistribute it and/or modify |
254 | +it under the terms of the GNU General Public License as published by |
255 | +the Free Software Foundation, either version 3 of the License, or |
256 | +(at your option) any later version. |
257 | + |
258 | +This program is distributed in the hope that it will be useful, |
259 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
260 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
261 | +GNU General Public License for more details. |
262 | + |
263 | +You should have received a copy of the GNU General Public License |
264 | +along with this program. If not, see <http://www.gnu.org/licenses/>. |
265 | +""" |
266 | \ No newline at end of file |
267 | |
268 | === modified file 'src/ui/application.py' |
269 | --- src/ui/application.py 2012-06-21 22:51:54 +0000 |
270 | +++ src/ui/application.py 2012-06-23 01:12:18 +0000 |
271 | @@ -20,32 +20,47 @@ |
272 | |
273 | import optparse |
274 | |
275 | -from ui import window as Window |
276 | +from ui.window import Window |
277 | from gi.repository import Gtk, Gio |
278 | |
279 | class Application(Gtk.Application): |
280 | """Application class""" |
281 | |
282 | - app_id = "season-one" |
283 | - flags = Gio.ApplicationFlags.HANDLES_COMMAND_LINE |
284 | + app_id = "com.SeasonOne" |
285 | + flags = Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.IS_SERVICE |
286 | |
287 | window = None |
288 | |
289 | def __init__(self): |
290 | - super(Application, self).__init__(self.app_id, self.flags) |
291 | - |
292 | + super(Application, self).__init__() |
293 | + |
294 | + # Application configuration |
295 | + self.set_application_id(self.app_id) |
296 | + self.set_flags(self.flags) |
297 | + |
298 | + # Connect signals |
299 | self.connect("activate", self.on_activate) |
300 | + self.connect("shutdown", self.on_shutdown) |
301 | self.connect("command-line", self.on_command_line) |
302 | |
303 | def on_hide(self, data): |
304 | - self.remove_window(data) |
305 | + self.window.hide() |
306 | |
307 | def on_activate(self, data): |
308 | - if self.window is None: |
309 | + if self.window == None: |
310 | self.window = Window(self) |
311 | self.add_window(self.window) |
312 | + else: |
313 | + self.window.present() |
314 | + |
315 | + def on_shutdown(self, data): |
316 | + """print shutdown""" |
317 | |
318 | def on_command_line(self, commandline, data): |
319 | - parser = optparse.OptionParser(version="%%prog %s" % __version__) |
320 | + #parser = optparse.OptionParser(version="%%prog %s" % __version__) |
321 | |
322 | #parser.add_option("-v", "--verbose") |
323 | + |
324 | + self.activate() |
325 | + |
326 | + return 1 |
327 | |
328 | === added file 'src/ui/builder.py' |
329 | --- src/ui/builder.py 1970-01-01 00:00:00 +0000 |
330 | +++ src/ui/builder.py 2012-06-23 01:12:18 +0000 |
331 | @@ -0,0 +1,35 @@ |
332 | +#!/usr/bin/env python |
333 | +""" |
334 | +Copyright (C) 2012 Caio Oliveira <caio.freitaso@gmail.com> |
335 | +Copyright (C) 2012 Diego Toral <diegotoral@gmail.com> |
336 | +Copyright (C) 2012 Thiago Abreu <thiagoa7@gmail.com> |
337 | + |
338 | +This program is free software: you can redistribute it and/or modify |
339 | +it under the terms of the GNU General Public License as published by |
340 | +the Free Software Foundation, either version 3 of the License, or |
341 | +(at your option) any later version. |
342 | + |
343 | +This program is distributed in the hope that it will be useful, |
344 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
345 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
346 | +GNU General Public License for more details. |
347 | + |
348 | +You should have received a copy of the GNU General Public License |
349 | +along with this program. If not, see <http://www.gnu.org/licenses/>. |
350 | +""" |
351 | + |
352 | +import os |
353 | + |
354 | +from gi.repository import Gtk |
355 | +from config import get_ui_path |
356 | + |
357 | +class Builder(Gtk.Builder): |
358 | + """Builder class handles ui creation""" |
359 | + |
360 | + def __init__(self): |
361 | + super(Builder, self).__init__() |
362 | + |
363 | + def add_from_file(self, file): |
364 | + path = os.path.join(get_ui_path(), file) |
365 | + |
366 | + return Gtk.Builder.add_from_file(self, path) |
367 | |
368 | === modified file 'src/ui/window.py' |
369 | --- src/ui/window.py 2012-06-21 22:51:54 +0000 |
370 | +++ src/ui/window.py 2012-06-23 01:12:18 +0000 |
371 | @@ -18,18 +18,42 @@ |
372 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
373 | """ |
374 | |
375 | +import os |
376 | + |
377 | from gi.repository import Gtk |
378 | +from ui.builder import Builder |
379 | +from config import get_data_path |
380 | |
381 | class Window(Gtk.ApplicationWindow): |
382 | """The main window of Season One""" |
383 | |
384 | title = "Season One" |
385 | - width = 300 |
386 | - height = 200 |
387 | + min_width = 559 |
388 | + min_height = 562 |
389 | + |
390 | + vbox = None |
391 | + toolbar = None |
392 | + notebook = None |
393 | |
394 | def __init__(self, app): |
395 | - super(Window, self).__init__(app) |
396 | - |
397 | - self.connect("hide", app.on_hide, self) |
398 | + super(Window, self).__init__(type=Gtk.WindowType.TOPLEVEL, application=app) |
399 | + |
400 | + # Default window configuration |
401 | + self.set_title(self.title) |
402 | + self.set_default_size(self.min_width, self.min_height) |
403 | + |
404 | + self.create_ui() |
405 | + self.show_all() |
406 | |
407 | + def create_ui(self): |
408 | + builder = Builder() |
409 | + builder.add_from_file("season-window.ui") |
410 | + |
411 | + self.vbox = builder.get_object("vbox") |
412 | + self.toolbar = builder.get_object("toolbar") |
413 | + self.notebook = builder.get_object("notebook") |
414 | + |
415 | + self.add(self.vbox) |
416 | + |
417 | + |
418 |