Merge lp:~robin-gloster/ubuntu-accomplishments-viewer/pep8 into lp:ubuntu-accomplishments-viewer
- pep8
- Merge into accomplishments-viewer
Status: | Merged |
---|---|
Merged at revision: | 223 |
Proposed branch: | lp:~robin-gloster/ubuntu-accomplishments-viewer/pep8 |
Merge into: | lp:ubuntu-accomplishments-viewer |
Diff against target: |
2812 lines (+637/-620) 16 files modified
Changelog (+3/-1) accomplishments_viewer/AboutAccomplishmentsViewerDialog.py (+18/-16) accomplishments_viewer/AccomplishmentsViewerWindow.py (+365/-354) accomplishments_viewer/EditExtrainfoDialog.py (+74/-79) accomplishments_viewer/PreferencesAccomplishmentsViewerDialog.py (+23/-26) accomplishments_viewer/__init__.py (+18/-15) accomplishments_viewer_lib/AboutDialog.py (+13/-13) accomplishments_viewer_lib/Builder.py (+20/-21) accomplishments_viewer_lib/PreferencesDialog.py (+13/-13) accomplishments_viewer_lib/Window.py (+20/-19) accomplishments_viewer_lib/__init__.py (+8/-9) accomplishments_viewer_lib/accomplishments_viewerconfig.py (+9/-10) accomplishments_viewer_lib/helpers.py (+18/-12) bin/accomplishments-viewer (+11/-11) tests/test_example.py (+13/-10) tests/test_lint.py (+11/-11) |
To merge this branch: | bzr merge lp:~robin-gloster/ubuntu-accomplishments-viewer/pep8 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Rafał Cieślak | Approve | ||
Matt Fischer | Approve | ||
Review via email: mp+136211@code.launchpad.net |
Commit message
Description of the change
Fixed most pep8 issues
Matt Fischer (mfisch) wrote : | # |
Matt Fischer (mfisch) wrote : | # |
Looks fine to me, but Cielak should also look, also what testing did you do?
Robin Gloster (robin-gloster) wrote : | # |
Visited all pages and changed everything in the viewer i could find and
think of.
From what I could tell it should work exactly as before except for the k ->
kid fix which should have killed the viewer before.
2012/11/26 Matt Fischer <email address hidden>
> Review: Approve
>
> Looks fine to me, but Cielak should also look, also what testing did you
> do?
> --
>
> https:/
> You are the owner of lp:~robin-gloster/ubuntu-accomplishments-viewer/pep8.
>
Rafał Cieślak (rafalcieslak256) wrote : | # |
I have carefully reviewed these changes, and they seem perfectly fine. I have also did a bunch of tests for the viewer, and as expected - nothing suspicious could be detected. Thanks Robin for these fixes!
- 221. By Rafał Cieślak
-
Merging in the branch that introduces use of GtkInfoBars for notifications
- 222. By Rafał Cieślak
-
Fixed #1084058.
Matt Fischer (mfisch) wrote : | # |
Rafal,
Are you going to merge this?
- 223. By Rafał Cieślak
-
Merged in Robin's PEP fixes
Rafał Cieślak (rafalcieslak256) wrote : | # |
Just merged it in.
Preview Diff
1 | === modified file 'Changelog' | |||
2 | --- Changelog 2012-11-22 10:45:38 +0000 | |||
3 | +++ Changelog 2012-11-26 16:03:25 +0000 | |||
4 | @@ -6,7 +6,7 @@ | |||
5 | 6 | Add items using the following format: | 6 | Add items using the following format: |
6 | 7 | 7 | ||
7 | 8 | [Name] | 8 | [Name] |
9 | 9 | * What you did | 9 | * What you did |
10 | 10 | * If a bug (LP: #BUGNUMBER) | 10 | * If a bug (LP: #BUGNUMBER) |
11 | 11 | 11 | ||
12 | 12 | For example: | 12 | For example: |
13 | @@ -30,4 +30,6 @@ | |||
14 | 30 | * Fix lintian issues | 30 | * Fix lintian issues |
15 | 31 | * Added a manpage (LP: #1069264) | 31 | * Added a manpage (LP: #1069264) |
16 | 32 | 32 | ||
17 | 33 | [Robin Gloster] | ||
18 | 34 | * Fixed most PEP8 issues | ||
19 | 33 | ------------------------------------------------------------------------- | 35 | ------------------------------------------------------------------------- |
20 | 34 | 36 | ||
21 | === modified file 'accomplishments_viewer/AboutAccomplishmentsViewerDialog.py' | |||
22 | --- accomplishments_viewer/AboutAccomplishmentsViewerDialog.py 2012-09-13 19:19:11 +0000 | |||
23 | +++ accomplishments_viewer/AboutAccomplishmentsViewerDialog.py 2012-11-26 16:03:25 +0000 | |||
24 | @@ -1,24 +1,25 @@ | |||
25 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
26 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
27 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
30 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
31 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
32 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
37 | 7 | # | 7 | # |
38 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
39 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
40 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
41 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
44 | 12 | # | 12 | # |
45 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
46 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
47 | 15 | ### END LICENSE | 15 | ### END LICENSE |
48 | 16 | 16 | ||
50 | 17 | import gettext, locale | 17 | import gettext |
51 | 18 | import locale | ||
52 | 18 | from locale import gettext as _ | 19 | from locale import gettext as _ |
53 | 19 | from accomplishments.util.paths import locale_dir | 20 | from accomplishments.util.paths import locale_dir |
54 | 20 | locale.bindtextdomain('accomplishments-viewer', locale_dir) | 21 | locale.bindtextdomain('accomplishments-viewer', locale_dir) |
56 | 21 | gettext.bindtextdomain('accomplishments-viewer',locale_dir) | 22 | gettext.bindtextdomain('accomplishments-viewer', locale_dir) |
57 | 22 | locale.textdomain('accomplishments-viewer') | 23 | locale.textdomain('accomplishments-viewer') |
58 | 23 | 24 | ||
59 | 24 | from accomplishments.daemon import dbusapi | 25 | from accomplishments.daemon import dbusapi |
60 | @@ -28,11 +29,12 @@ | |||
61 | 28 | 29 | ||
62 | 29 | from accomplishments_viewer_lib.AboutDialog import AboutDialog | 30 | from accomplishments_viewer_lib.AboutDialog import AboutDialog |
63 | 30 | 31 | ||
64 | 32 | |||
65 | 31 | # See accomplishments_viewer_lib.AboutDialog.py for more details about how this class works. | 33 | # See accomplishments_viewer_lib.AboutDialog.py for more details about how this class works. |
66 | 32 | class AboutAccomplishmentsViewerDialog(AboutDialog): | 34 | class AboutAccomplishmentsViewerDialog(AboutDialog): |
67 | 33 | __gtype_name__ = "AboutAccomplishmentsViewerDialog" | 35 | __gtype_name__ = "AboutAccomplishmentsViewerDialog" |
70 | 34 | 36 | ||
71 | 35 | def finish_initializing(self, builder): # pylint: disable=E1002 | 37 | def finish_initializing(self, builder): # pylint: disable=E1002 |
72 | 36 | """Set up the about dialog""" | 38 | """Set up the about dialog""" |
73 | 37 | super(AboutAccomplishmentsViewerDialog, self).finish_initializing(builder) | 39 | super(AboutAccomplishmentsViewerDialog, self).finish_initializing(builder) |
74 | 38 | 40 | ||
75 | @@ -41,17 +43,17 @@ | |||
76 | 41 | self.libaccom = dbusapi.Accomplishments() | 43 | self.libaccom = dbusapi.Accomplishments() |
77 | 42 | 44 | ||
78 | 43 | # add app authors | 45 | # add app authors |
81 | 44 | authors = sorted([ "Jono Bacon <jono@ubuntu.com>", "Rafal Cieślak <rafalcieslak256@gmail.com>", "Matt Fischer <matt@mattfischer.com>", "Stuart Langridge <sil@kryogenix.org>"]) | 46 | authors = sorted(["Jono Bacon <jono@ubuntu.com>", "Rafal Cieślak <rafalcieslak256@gmail.com>", "Matt Fischer <matt@mattfischer.com>", "Stuart Langridge <sil@kryogenix.org>"]) |
82 | 45 | 47 | ||
83 | 46 | for col in self.libaccom.list_collections(): | 48 | for col in self.libaccom.list_collections(): |
84 | 47 | authors.append(" ") | 49 | authors.append(" ") |
85 | 48 | authors.append("'" + self.libaccom.get_collection_name(col) + "' " + _("Collection Authors:")) | 50 | authors.append("'" + self.libaccom.get_collection_name(col) + "' " + _("Collection Authors:")) |
86 | 49 | authors.append(" ") | 51 | authors.append(" ") |
88 | 50 | 52 | ||
89 | 51 | tempauthors = [] | 53 | tempauthors = [] |
90 | 52 | for a in self.libaccom.get_collection_authors(col): | 54 | for a in self.libaccom.get_collection_authors(col): |
91 | 53 | tempauthors.append(a) | 55 | tempauthors.append(a) |
92 | 54 | 56 | ||
93 | 55 | authors = authors + sorted(tempauthors) | 57 | authors = authors + sorted(tempauthors) |
95 | 56 | 58 | ||
96 | 57 | self.set_authors(authors) | 59 | self.set_authors(authors) |
97 | 58 | 60 | ||
98 | === modified file 'accomplishments_viewer/AccomplishmentsViewerWindow.py' | |||
99 | --- accomplishments_viewer/AccomplishmentsViewerWindow.py 2012-11-22 10:04:35 +0000 | |||
100 | +++ accomplishments_viewer/AccomplishmentsViewerWindow.py 2012-11-26 16:03:25 +0000 | |||
101 | @@ -1,25 +1,27 @@ | |||
102 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
103 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
104 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
107 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
108 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
109 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
114 | 7 | # | 7 | # |
115 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
116 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
117 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
118 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
121 | 12 | # | 12 | # |
122 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
123 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
124 | 15 | ### END LICENSE | 15 | ### END LICENSE |
125 | 16 | 16 | ||
126 | 17 | import urllib2 | 17 | import urllib2 |
128 | 18 | import gettext, locale, datetime | 18 | import gettext |
129 | 19 | import locale | ||
130 | 20 | import datetime | ||
131 | 19 | from locale import gettext as _ | 21 | from locale import gettext as _ |
132 | 20 | from accomplishments.util.paths import locale_dir | 22 | from accomplishments.util.paths import locale_dir |
133 | 21 | locale.bindtextdomain('accomplishments-viewer', locale_dir) | 23 | locale.bindtextdomain('accomplishments-viewer', locale_dir) |
135 | 22 | gettext.bindtextdomain('accomplishments-viewer',locale_dir) | 24 | gettext.bindtextdomain('accomplishments-viewer', locale_dir) |
136 | 23 | locale.textdomain('accomplishments-viewer') | 25 | locale.textdomain('accomplishments-viewer') |
137 | 24 | 26 | ||
138 | 25 | import traceback | 27 | import traceback |
139 | @@ -32,7 +34,7 @@ | |||
140 | 32 | import dbus.service | 34 | import dbus.service |
141 | 33 | from dbus.mainloop.glib import DBusGMainLoop | 35 | from dbus.mainloop.glib import DBusGMainLoop |
142 | 34 | 36 | ||
144 | 35 | from gi.repository import Gtk, GObject, GdkPixbuf, WebKit # pylint: disable=E0611 | 37 | from gi.repository import Gtk, GObject, GdkPixbuf, WebKit # pylint: disable=E0611 |
145 | 36 | from gi.repository import Unity | 38 | from gi.repository import Unity |
146 | 37 | 39 | ||
147 | 38 | import logging | 40 | import logging |
148 | @@ -96,23 +98,24 @@ | |||
149 | 96 | 98 | ||
150 | 97 | TROPHY_GALLERY_URL = 'http://213.138.100.229:8000' | 99 | TROPHY_GALLERY_URL = 'http://213.138.100.229:8000' |
151 | 98 | 100 | ||
152 | 101 | |||
153 | 99 | # See accomplishments_viewer_lib.Window.py for more details about how this class works | 102 | # See accomplishments_viewer_lib.Window.py for more details about how this class works |
154 | 100 | class AccomplishmentsViewerWindow(Window): | 103 | class AccomplishmentsViewerWindow(Window): |
155 | 101 | __gtype_name__ = "AccomplishmentsViewerWindow" | 104 | __gtype_name__ = "AccomplishmentsViewerWindow" |
158 | 102 | 105 | ||
159 | 103 | def finish_initializing(self, builder): # pylint: disable=E1002 | 106 | def finish_initializing(self, builder): # pylint: disable=E1002 |
160 | 104 | """Set up the main window.""" | 107 | """Set up the main window.""" |
162 | 105 | 108 | ||
163 | 106 | super(AccomplishmentsViewerWindow, self).finish_initializing(builder) | 109 | super(AccomplishmentsViewerWindow, self).finish_initializing(builder) |
164 | 107 | 110 | ||
165 | 108 | self.AboutDialog = AboutAccomplishmentsViewerDialog | 111 | self.AboutDialog = AboutAccomplishmentsViewerDialog |
168 | 109 | self.PreferencesDialog = PreferencesAccomplishmentsViewerDialog #class | 112 | self.PreferencesDialog = PreferencesAccomplishmentsViewerDialog # class |
169 | 110 | self.preferences_dialog = None #instance | 113 | self.preferences_dialog = None # instance |
170 | 111 | self.EditExtraDialog = EditExtrainfoDialog() | 114 | self.EditExtraDialog = EditExtrainfoDialog() |
171 | 112 | self.EditExtraDialog.parent = self | 115 | self.EditExtraDialog.parent = self |
172 | 113 | self.curr_height = 0 | 116 | self.curr_height = 0 |
173 | 114 | self.curr_width = 0 | 117 | self.curr_width = 0 |
175 | 115 | 118 | ||
176 | 116 | # Following variables store current display settings. | 119 | # Following variables store current display settings. |
177 | 117 | self.display_mytrophies_filtermode = MYTROPHIES_FILTER_ALL | 120 | self.display_mytrophies_filtermode = MYTROPHIES_FILTER_ALL |
178 | 118 | self.display_mode = DISPLAY_MODE_OPPORTUNITIES | 121 | self.display_mode = DISPLAY_MODE_OPPORTUNITIES |
179 | @@ -121,13 +124,12 @@ | |||
180 | 121 | self.display_filter_category = "" | 124 | self.display_filter_category = "" |
181 | 122 | self.display_filter_subcat = "" | 125 | self.display_filter_subcat = "" |
182 | 123 | self.display_filter_search = "" | 126 | self.display_filter_search = "" |
184 | 124 | 127 | ||
185 | 125 | # These two store list of pairs [filter, iconview] for all accomplishment groups in mytrophies view. | 128 | # These two store list of pairs [filter, iconview] for all accomplishment groups in mytrophies view. |
186 | 126 | self.trophies_collection_filters = [] | 129 | self.trophies_collection_filters = [] |
187 | 127 | self.mytrophies_latest_boxes = [] | 130 | self.mytrophies_latest_boxes = [] |
188 | 128 | # Code for other initialization actions should be added here. | 131 | # Code for other initialization actions should be added here. |
189 | 129 | 132 | ||
190 | 130 | |||
191 | 131 | # set up autostart dir | 133 | # set up autostart dir |
192 | 132 | self.autostartdir = None | 134 | self.autostartdir = None |
193 | 133 | 135 | ||
194 | @@ -144,7 +146,7 @@ | |||
195 | 144 | # reference to the Unity Launchcher | 146 | # reference to the Unity Launchcher |
196 | 145 | self.launcher = Unity.LauncherEntry.get_for_desktop_id("accomplishments-viewer.desktop") | 147 | self.launcher = Unity.LauncherEntry.get_for_desktop_id("accomplishments-viewer.desktop") |
197 | 146 | self.newtrophies = 0 | 148 | self.newtrophies = 0 |
199 | 147 | 149 | ||
200 | 148 | # set up all of the different UI references | 150 | # set up all of the different UI references |
201 | 149 | self.tb_mytrophies = self.builder.get_object("tb_mytrophies") | 151 | self.tb_mytrophies = self.builder.get_object("tb_mytrophies") |
202 | 150 | self.tb_opportunities = self.builder.get_object("tb_opportunities") | 152 | self.tb_opportunities = self.builder.get_object("tb_opportunities") |
203 | @@ -192,38 +194,38 @@ | |||
204 | 192 | sb_v = self.subcats_scroll.get_vscrollbar() | 194 | sb_v = self.subcats_scroll.get_vscrollbar() |
205 | 193 | sb_h.set_child_visible(False) | 195 | sb_h.set_child_visible(False) |
206 | 194 | sb_v.set_child_visible(False) | 196 | sb_v.set_child_visible(False) |
208 | 195 | 197 | ||
209 | 196 | #h = self.subcats_scroll.get_hadjustment() | 198 | #h = self.subcats_scroll.get_hadjustment() |
210 | 197 | self.subcat = None | 199 | self.subcat = None |
211 | 198 | self.subcats_container.hide() | 200 | self.subcats_container.hide() |
213 | 199 | 201 | ||
214 | 200 | # make the toolbar black in Ubuntu | 202 | # make the toolbar black in Ubuntu |
215 | 201 | context = self.toolbar.get_style_context() | 203 | context = self.toolbar.get_style_context() |
216 | 202 | context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR) | 204 | context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR) |
217 | 203 | 205 | ||
218 | 204 | # Create stores and corelated filters | 206 | # Create stores and corelated filters |
219 | 205 | 207 | ||
221 | 206 | self.oppstore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, bool, bool, str, str, str, str, str) # title, icon, accomplished, locked, col, accomplishment, date-accomplished, categories, keywords | 208 | self.oppstore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, bool, bool, str, str, str, str, str) # title, icon, accomplished, locked, col, accomplishment, date-accomplished, categories, keywords |
222 | 207 | self.oppstore.set_sort_column_id(COL_TITLE, Gtk.SortType.ASCENDING) | 209 | self.oppstore.set_sort_column_id(COL_TITLE, Gtk.SortType.ASCENDING) |
223 | 208 | self.oppstore_filtered = self.oppstore.filter_new() | 210 | self.oppstore_filtered = self.oppstore.filter_new() |
224 | 209 | # The following sets the function for tree model filter. That function has | 211 | # The following sets the function for tree model filter. That function has |
225 | 210 | # to return true if a given row has to be visible. This way we can control | 212 | # to return true if a given row has to be visible. This way we can control |
226 | 211 | # which opportunities are displayed, and which are not. | 213 | # which opportunities are displayed, and which are not. |
227 | 212 | self.oppstore_filtered.set_visible_func(self._opp_visible_func) | 214 | self.oppstore_filtered.set_visible_func(self._opp_visible_func) |
230 | 213 | 215 | ||
231 | 214 | self.trophiesstore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, bool, bool, str, str, str, str, str) # title, icon, accomplished, locked, col, accomplishment, date-accomplished, categories, keywords | 216 | self.trophiesstore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, bool, bool, str, str, str, str, str) # title, icon, accomplished, locked, col, accomplishment, date-accomplished, categories, keywords |
232 | 215 | self.trophiesstore.set_sort_column_id(COL_TITLE, Gtk.SortType.ASCENDING) | 217 | self.trophiesstore.set_sort_column_id(COL_TITLE, Gtk.SortType.ASCENDING) |
233 | 216 | self.trophiesstore_filter_today = self.trophiesstore.filter_new() | 218 | self.trophiesstore_filter_today = self.trophiesstore.filter_new() |
235 | 217 | self.trophiesstore_filter_today.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_TODAY) | 219 | self.trophiesstore_filter_today.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_TODAY) |
236 | 218 | self.trophiesstore_filter_week = self.trophiesstore.filter_new() | 220 | self.trophiesstore_filter_week = self.trophiesstore.filter_new() |
238 | 219 | self.trophiesstore_filter_week.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_WEEK) | 221 | self.trophiesstore_filter_week.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_WEEK) |
239 | 220 | self.trophiesstore_filter_month = self.trophiesstore.filter_new() | 222 | self.trophiesstore_filter_month = self.trophiesstore.filter_new() |
241 | 221 | self.trophiesstore_filter_month.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_MONTH) | 223 | self.trophiesstore_filter_month.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_MONTH) |
242 | 222 | self.trophiesstore_filter_sixmonths = self.trophiesstore.filter_new() | 224 | self.trophiesstore_filter_sixmonths = self.trophiesstore.filter_new() |
244 | 223 | self.trophiesstore_filter_sixmonths.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_SIXMONTHS) | 225 | self.trophiesstore_filter_sixmonths.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_SIXMONTHS) |
245 | 224 | self.trophiesstore_filter_earlier = self.trophiesstore.filter_new() | 226 | self.trophiesstore_filter_earlier = self.trophiesstore.filter_new() |
248 | 225 | self.trophiesstore_filter_earlier.set_visible_func(self._trophy_recent_visible_func,TROPHIES_FILTER_EARLIER) | 227 | self.trophiesstore_filter_earlier.set_visible_func(self._trophy_recent_visible_func, TROPHIES_FILTER_EARLIER) |
249 | 226 | 228 | ||
250 | 227 | self.opp_icon.set_model(self.oppstore_filtered) | 229 | self.opp_icon.set_model(self.oppstore_filtered) |
251 | 228 | self.opp_icon.set_text_column(COL_TITLE) | 230 | self.opp_icon.set_text_column(COL_TITLE) |
252 | 229 | self.opp_icon.set_pixbuf_column(COL_PIXBUF) | 231 | self.opp_icon.set_pixbuf_column(COL_PIXBUF) |
253 | @@ -232,13 +234,13 @@ | |||
254 | 232 | self.webview = WebKit.WebView() | 234 | self.webview = WebKit.WebView() |
255 | 233 | self.scrolledwindow.add(self.webview) | 235 | self.scrolledwindow.add(self.webview) |
256 | 234 | self.webview.props.settings.props.enable_default_context_menu = False | 236 | self.webview.props.settings.props.enable_default_context_menu = False |
258 | 235 | self.webkitlink = self.webview.connect("navigation-policy-decision-requested",self.webkit_link_clicked) | 237 | self.webkitlink = self.webview.connect("navigation-policy-decision-requested", self.webkit_link_clicked) |
259 | 236 | 238 | ||
260 | 237 | self.webview.show() | 239 | self.webview.show() |
262 | 238 | 240 | ||
263 | 239 | if GWIBBER_OK: | 241 | if GWIBBER_OK: |
266 | 240 | self.messageentry = GwibberGtk.Entry() | 242 | self.messageentry = GwibberGtk.Entry() |
267 | 241 | self.messageentry.text_view.connect("submit",self.close_gwibber_window) | 243 | self.messageentry.text_view.connect("submit", self.close_gwibber_window) |
268 | 242 | self.messagewindow = Gtk.Window() | 244 | self.messagewindow = Gtk.Window() |
269 | 243 | self.messagewindow.set_transient_for(self) | 245 | self.messagewindow.set_transient_for(self) |
270 | 244 | self.messagevbox = Gtk.VBox() | 246 | self.messagevbox = Gtk.VBox() |
271 | @@ -246,15 +248,15 @@ | |||
272 | 246 | self.messagewindow.set_icon_name("gwibber") | 248 | self.messagewindow.set_icon_name("gwibber") |
273 | 247 | self.messagewindow.resize(400, 150) | 249 | self.messagewindow.resize(400, 150) |
274 | 248 | self.messagewindow.set_resizable(False) | 250 | self.messagewindow.set_resizable(False) |
276 | 249 | self.messagevbox.pack_start(self.messageentry,True,True,0) | 251 | self.messagevbox.pack_start(self.messageentry, True, True, 0) |
277 | 250 | self.messagelabel = Gtk.Label() | 252 | self.messagelabel = Gtk.Label() |
278 | 251 | self.messagelabel.set_markup(_("<b>Always add the link to your trophy on the web when sharing a trophy.</b>\nThis link works as a <b>proof</b> that you have really accomplished this trophy.")) | 253 | self.messagelabel.set_markup(_("<b>Always add the link to your trophy on the web when sharing a trophy.</b>\nThis link works as a <b>proof</b> that you have really accomplished this trophy.")) |
280 | 252 | self.messagevbox.pack_start(self.messagelabel,False,False,0) | 254 | self.messagevbox.pack_start(self.messagelabel, False, False, 0) |
281 | 253 | self.messagewindow.add(self.messagevbox) | 255 | self.messagewindow.add(self.messagevbox) |
283 | 254 | self.messagevbox.show_all() | 256 | self.messagevbox.show_all() |
284 | 255 | self.messagewindow.hide() | 257 | self.messagewindow.hide() |
287 | 256 | self.messagewindow.connect("delete-event",self.close_gwibber_window) | 258 | self.messagewindow.connect("delete-event", self.close_gwibber_window) |
288 | 257 | 259 | ||
289 | 258 | self.opp_col_store = Gtk.ListStore(str, str) | 260 | self.opp_col_store = Gtk.ListStore(str, str) |
290 | 259 | self.col_combo_renderer_text = Gtk.CellRendererText() | 261 | self.col_combo_renderer_text = Gtk.CellRendererText() |
291 | 260 | self.opp_combo_col.pack_start(self.col_combo_renderer_text, True) | 262 | self.opp_combo_col.pack_start(self.col_combo_renderer_text, True) |
292 | @@ -291,26 +293,23 @@ | |||
293 | 291 | os.makedirs(os.path.join(self.dir_cache, "logs")) | 293 | os.makedirs(os.path.join(self.dir_cache, "logs")) |
294 | 292 | 294 | ||
295 | 293 | # IMPORTANT: This function should do no initialisations that depend | 295 | # IMPORTANT: This function should do no initialisations that depend |
298 | 294 | # on having the daemon running. This is because if the daemon is not | 296 | # on having the daemon running. This is because if the daemon is not |
299 | 295 | # yet started it will take some time to connect to it. Such | 297 | # yet started it will take some time to connect to it. Such |
300 | 296 | # initialistions should land in appropriate place in finalise_daemon_connection(...). | 298 | # initialistions should land in appropriate place in finalise_daemon_connection(...). |
301 | 297 | 299 | ||
302 | 298 | self.datapath = get_data_path() | 300 | self.datapath = get_data_path() |
303 | 299 | 301 | ||
304 | 300 | self.update_widgets_sensitivity() | 302 | self.update_widgets_sensitivity() |
305 | 301 | 303 | ||
306 | 302 | |||
307 | 303 | |||
308 | 304 | def add_no_collections_installed(self): | 304 | def add_no_collections_installed(self): |
309 | 305 | """Display the message that no collections are installed.""" | 305 | """Display the message that no collections are installed.""" |
311 | 306 | 306 | ||
312 | 307 | ### Commented out the following as it is confusing, and opens a lot of | 307 | ### Commented out the following as it is confusing, and opens a lot of |
313 | 308 | ### possible scenarios where these buttons are left insensitive. | 308 | ### possible scenarios where these buttons are left insensitive. |
314 | 309 | ## set bits of the user interface to be insensitive | 309 | ## set bits of the user interface to be insensitive |
315 | 310 | # self.tb_mytrophies.set_sensitive(False) | 310 | # self.tb_mytrophies.set_sensitive(False) |
316 | 311 | # self.opp_frame.set_visible(False) | 311 | # self.opp_frame.set_visible(False) |
319 | 312 | 312 | ||
318 | 313 | |||
320 | 314 | # show the message | 313 | # show the message |
321 | 315 | self.additional_no_collections.set_visible(True) | 314 | self.additional_no_collections.set_visible(True) |
322 | 316 | 315 | ||
323 | @@ -322,28 +321,28 @@ | |||
324 | 322 | self.additional_no_collections.set_visible(False) | 321 | self.additional_no_collections.set_visible(False) |
325 | 323 | self.reload_accomplishments() | 322 | self.reload_accomplishments() |
326 | 324 | self.set_display(DISPLAY_MODE_OPPORTUNITIES) | 323 | self.set_display(DISPLAY_MODE_OPPORTUNITIES) |
328 | 325 | 324 | ||
329 | 326 | def reload_accomplishments(self): | 325 | def reload_accomplishments(self): |
330 | 327 | if not self.connected: | 326 | if not self.connected: |
331 | 328 | return | 327 | return |
333 | 329 | 328 | ||
334 | 330 | self.statusbar_reload_msg_start() | 329 | self.statusbar_reload_msg_start() |
336 | 331 | Gtk.main_iteration_do(False) # Force UI refresh | 330 | Gtk.main_iteration_do(False) # Force UI refresh |
337 | 332 | self.libaccom.reload_accom_database() | 331 | self.libaccom.reload_accom_database() |
338 | 333 | self.statusbar_reload_msg_stop() | 332 | self.statusbar_reload_msg_stop() |
340 | 334 | 333 | ||
341 | 335 | self._load_accomplishments() | 334 | self._load_accomplishments() |
342 | 336 | if len(self.accomdb) == 0: | 335 | if len(self.accomdb) == 0: |
343 | 337 | self.add_no_collections_installed() | 336 | self.add_no_collections_installed() |
345 | 338 | 337 | ||
346 | 339 | def statusbar_reload_msg_start(self): | 338 | def statusbar_reload_msg_start(self): |
347 | 340 | self.statusbar.set_text(_("Reloading accomplishments collections...")) | 339 | self.statusbar.set_text(_("Reloading accomplishments collections...")) |
348 | 341 | self.spinner.start() | 340 | self.spinner.start() |
349 | 342 | self.spinner.show() | 341 | self.spinner.show() |
350 | 343 | self.statusbox.show() | 342 | self.statusbox.show() |
351 | 344 | self.statusbar_reload_msg = 0 | 343 | self.statusbar_reload_msg = 0 |
354 | 345 | GObject.timeout_add(1000,self.statusbar_reload_msg_stop) | 344 | GObject.timeout_add(1000, self.statusbar_reload_msg_stop) |
355 | 346 | 345 | ||
356 | 347 | def statusbar_reload_msg_stop(self): | 346 | def statusbar_reload_msg_stop(self): |
357 | 348 | if self.statusbar_reload_msg is 0: | 347 | if self.statusbar_reload_msg is 0: |
358 | 349 | # That would be too quick and the user wouldn't even notice the message | 348 | # That would be too quick and the user wouldn't even notice the message |
359 | @@ -351,23 +350,22 @@ | |||
360 | 351 | elif self.statusbar_reload_msg is 1: | 350 | elif self.statusbar_reload_msg is 1: |
361 | 352 | self.spinner.hide() | 351 | self.spinner.hide() |
362 | 353 | self.statusbox.hide() | 352 | self.statusbox.hide() |
365 | 354 | 353 | ||
364 | 355 | |||
366 | 356 | def trophy_received(self, message): | 354 | def trophy_received(self, message): |
367 | 357 | """Called when a new trophy is detected on the system.""" | 355 | """Called when a new trophy is detected on the system.""" |
369 | 358 | 356 | ||
370 | 359 | self.newtrophies = self.newtrophies + 1 | 357 | self.newtrophies = self.newtrophies + 1 |
372 | 360 | 358 | ||
373 | 361 | # run this to refresh our accomplishments list | 359 | # run this to refresh our accomplishments list |
374 | 362 | self._load_accomplishments() | 360 | self._load_accomplishments() |
376 | 363 | 361 | ||
377 | 364 | #XXX: It would be MUCH faster if we determined the new accomID and added just it, not recreating whole trees! | 362 | #XXX: It would be MUCH faster if we determined the new accomID and added just it, not recreating whole trees! |
378 | 365 | self.prepare_models() | 363 | self.prepare_models() |
380 | 366 | 364 | ||
381 | 367 | # set the Launcher icon to be urgent and show new trophy count | 365 | # set the Launcher icon to be urgent and show new trophy count |
382 | 368 | self.launcher.set_property("urgent", True) | 366 | self.launcher.set_property("urgent", True) |
383 | 369 | self.launcher.set_property("count", self.newtrophies) | 367 | self.launcher.set_property("count", self.newtrophies) |
385 | 370 | 368 | ||
386 | 371 | if self.newtrophies > 0: | 369 | if self.newtrophies > 0: |
387 | 372 | self.launcher.set_property("count_visible", True) | 370 | self.launcher.set_property("count_visible", True) |
388 | 373 | else: | 371 | else: |
389 | @@ -379,10 +377,10 @@ | |||
390 | 379 | def check_and_ask_for_info(self): | 377 | def check_and_ask_for_info(self): |
391 | 380 | """Asks the daemon for additional info needed, and asks | 378 | """Asks the daemon for additional info needed, and asks |
392 | 381 | the user for it, in case it has not been yet given""" | 379 | the user for it, in case it has not been yet given""" |
394 | 382 | 380 | ||
395 | 383 | if self.connected is False: | 381 | if self.connected is False: |
396 | 384 | return | 382 | return |
398 | 385 | 383 | ||
399 | 386 | self.has_u1 = self.libaccom.get_config_value("config", "has_u1") | 384 | self.has_u1 = self.libaccom.get_config_value("config", "has_u1") |
400 | 387 | self.has_verif = self.libaccom.get_config_value("config", "has_verif") | 385 | self.has_verif = self.libaccom.get_config_value("config", "has_verif") |
401 | 388 | 386 | ||
402 | @@ -397,90 +395,90 @@ | |||
403 | 397 | 395 | ||
404 | 398 | def connect_to_daemon(self): | 396 | def connect_to_daemon(self): |
405 | 399 | """Tries to connect to the daemon""" | 397 | """Tries to connect to the daemon""" |
407 | 400 | 398 | ||
408 | 401 | self.connected = False | 399 | self.connected = False |
410 | 402 | 400 | ||
411 | 403 | if dbusapi.daemon_is_registered(): | 401 | if dbusapi.daemon_is_registered(): |
412 | 404 | self.libaccom = dbusapi.Accomplishments() | 402 | self.libaccom = dbusapi.Accomplishments() |
413 | 405 | else: | 403 | else: |
414 | 406 | return False | 404 | return False |
416 | 407 | 405 | ||
417 | 408 | dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | 406 | dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
418 | 409 | 407 | ||
419 | 410 | bus = dbus.SessionBus() | 408 | bus = dbus.SessionBus() |
421 | 411 | 409 | ||
422 | 412 | try: | 410 | try: |
425 | 413 | object = bus.get_object("org.ubuntu.accomplishments", | 411 | object = bus.get_object("org.ubuntu.accomplishments", |
426 | 414 | "/org/ubuntu/accomplishments") | 412 | "/org/ubuntu/accomplishments") |
427 | 415 | object.connect_to_signal("trophy_recieved", | 413 | object.connect_to_signal("trophy_recieved", |
430 | 416 | self.trophy_received, | 414 | self.trophy_received, |
431 | 417 | dbus_interface="org.ubuntu.accomplishments", arg0="Hello") | 415 | dbus_interface="org.ubuntu.accomplishments", arg0="Hello") |
432 | 418 | object.connect_to_signal("publish_trophies_online_completed", | 416 | object.connect_to_signal("publish_trophies_online_completed", |
435 | 419 | self.publish_trophies_online_completed, | 417 | self.publish_trophies_online_completed, |
436 | 420 | dbus_interface="org.ubuntu.accomplishments", arg0="Hello") | 418 | dbus_interface="org.ubuntu.accomplishments", arg0="Hello") |
437 | 421 | object.connect_to_signal("scriptrunner_start", | 419 | object.connect_to_signal("scriptrunner_start", |
440 | 422 | self.scriptrunner_start, | 420 | self.scriptrunner_start, |
441 | 423 | dbus_interface="org.ubuntu.accomplishments") | 421 | dbus_interface="org.ubuntu.accomplishments") |
442 | 424 | object.connect_to_signal("scriptrunner_finish", | 422 | object.connect_to_signal("scriptrunner_finish", |
445 | 425 | self.scriptrunner_finish, | 423 | self.scriptrunner_finish, |
446 | 426 | dbus_interface="org.ubuntu.accomplishments") | 424 | dbus_interface="org.ubuntu.accomplishments") |
447 | 427 | object.connect_to_signal("ubuntu_one_account_ready", | 425 | object.connect_to_signal("ubuntu_one_account_ready", |
451 | 428 | self.ubuntu_one_account_ready, | 426 | self.ubuntu_one_account_ready, |
452 | 429 | dbus_interface="org.ubuntu.accomplishments", arg0="Hello") | 427 | dbus_interface="org.ubuntu.accomplishments", arg0="Hello") |
453 | 430 | 428 | ||
454 | 431 | except dbus.DBusException: | 429 | except dbus.DBusException: |
455 | 432 | print "DBus exception when connecting to daemon." | 430 | print "DBus exception when connecting to daemon." |
456 | 433 | traceback.print_exc() | 431 | traceback.print_exc() |
457 | 434 | return False | 432 | return False |
458 | 435 | 433 | ||
459 | 436 | bus.add_signal_receiver(self.trophy_received, | 434 | bus.add_signal_receiver(self.trophy_received, |
462 | 437 | dbus_interface = "org.ubuntu.accomplishments", | 435 | dbus_interface="org.ubuntu.accomplishments", |
463 | 438 | signal_name = "trophy_received") | 436 | signal_name="trophy_received") |
464 | 439 | bus.add_signal_receiver(self.publish_trophies_online_completed, | 437 | bus.add_signal_receiver(self.publish_trophies_online_completed, |
467 | 440 | dbus_interface = "org.ubuntu.accomplishments", | 438 | dbus_interface="org.ubuntu.accomplishments", |
468 | 441 | signal_name = "publish_trophies_online_completed") | 439 | signal_name="publish_trophies_online_completed") |
469 | 442 | bus.add_signal_receiver(self.scriptrunner_start, | 440 | bus.add_signal_receiver(self.scriptrunner_start, |
472 | 443 | dbus_interface = "org.ubuntu.accomplishments", | 441 | dbus_interface="org.ubuntu.accomplishments", |
473 | 444 | signal_name = "scriptrunner_start") | 442 | signal_name="scriptrunner_start") |
474 | 445 | bus.add_signal_receiver(self.scriptrunner_finish, | 443 | bus.add_signal_receiver(self.scriptrunner_finish, |
477 | 446 | dbus_interface = "org.ubuntu.accomplishments", | 444 | dbus_interface="org.ubuntu.accomplishments", |
478 | 447 | signal_name = "scriptrunner_finish") | 445 | signal_name="scriptrunner_finish") |
479 | 448 | bus.add_signal_receiver(self.ubuntu_one_account_ready, | 446 | bus.add_signal_receiver(self.ubuntu_one_account_ready, |
483 | 449 | dbus_interface = "org.ubuntu.accomplishments", | 447 | dbus_interface="org.ubuntu.accomplishments", |
484 | 450 | signal_name = "ubuntu_one_account_ready") | 448 | signal_name="ubuntu_one_account_ready") |
485 | 451 | 449 | ||
486 | 452 | self.connected = True | 450 | self.connected = True |
488 | 453 | 451 | ||
489 | 454 | self.check_daemon_session() | 452 | self.check_daemon_session() |
491 | 455 | 453 | ||
492 | 456 | return True | 454 | return True |
493 | 457 | 455 | ||
494 | 458 | def publish_trophies_online_completed(self, url): | 456 | def publish_trophies_online_completed(self, url): |
495 | 459 | webbrowser.open(url) | 457 | webbrowser.open(url) |
496 | 460 | 458 | ||
498 | 461 | def ubuntu_one_account_ready(self): | 459 | def ubuntu_one_account_ready(self): |
499 | 462 | if not self.has_u1 == 1: | 460 | if not self.has_u1 == 1: |
500 | 463 | self.register_with_verif(None) | 461 | self.register_with_verif(None) |
502 | 464 | 462 | ||
503 | 465 | def run_daemon(self): | 463 | def run_daemon(self): |
517 | 466 | """Starts the daemon process""" | 464 | """Starts the daemon process""" |
518 | 467 | 465 | ||
519 | 468 | # Not importing this globally, as it will be very rarely used. | 466 | # Not importing this globally, as it will be very rarely used. |
520 | 469 | import subprocess | 467 | import subprocess |
521 | 470 | import threading | 468 | import threading |
522 | 471 | 469 | ||
523 | 472 | # Starting the daemon is realised in a separete thread, it can | 470 | # Starting the daemon is realised in a separete thread, it can |
524 | 473 | # wait for launcher to exit without blocking gtk main event loop. | 471 | # wait for launcher to exit without blocking gtk main event loop. |
525 | 474 | def run_in_thread_and_call_when_done(args,onexit): | 472 | def run_in_thread_and_call_when_done(args, onexit): |
526 | 475 | launcher_process = subprocess.Popen(args.split(" ")) | 473 | launcher_process = subprocess.Popen(args.split(" ")) |
527 | 476 | launcher_process.wait() | 474 | launcher_process.wait() |
528 | 477 | GObject.idle_add(onexit) | 475 | GObject.idle_add(onexit) |
529 | 478 | return | 476 | return |
530 | 479 | command = os.path.join(daemon_exec_dir, "accomplishments-daemon") + " --start" | 477 | command = os.path.join(daemon_exec_dir, "accomplishments-daemon") + " --start" |
531 | 480 | print ("Starting the daemon using command `%s`" % command) | 478 | print ("Starting the daemon using command `%s`" % command) |
533 | 481 | th = threading.Thread(target=run_in_thread_and_call_when_done,args=(command, self.run_daemon_continue)) | 479 | th = threading.Thread(target=run_in_thread_and_call_when_done, args=(command, self.run_daemon_continue)) |
534 | 482 | th.start() | 480 | th.start() |
536 | 483 | 481 | ||
537 | 484 | self.statusbar.set_text(_("Starting the daemon...")) | 482 | self.statusbar.set_text(_("Starting the daemon...")) |
538 | 485 | self.spinner.start() | 483 | self.spinner.start() |
539 | 486 | self.spinner.show() | 484 | self.spinner.show() |
540 | @@ -489,26 +487,26 @@ | |||
541 | 489 | def run_daemon_continue(self): | 487 | def run_daemon_continue(self): |
542 | 490 | """Called from run_daemon when the daemon launcher exits. | 488 | """Called from run_daemon when the daemon launcher exits. |
543 | 491 | Finishes what run_daemon would do""" | 489 | Finishes what run_daemon would do""" |
545 | 492 | 490 | ||
546 | 493 | self.connect_to_daemon() | 491 | self.connect_to_daemon() |
548 | 494 | 492 | ||
549 | 495 | self.statusbox.hide() | 493 | self.statusbox.hide() |
551 | 496 | 494 | ||
552 | 497 | if self.connected is False: | 495 | if self.connected is False: |
553 | 498 | #Either failed to start the daemon, or failed to connect to | 496 | #Either failed to start the daemon, or failed to connect to |
554 | 499 | #It may either be not installed, or may have crashed on startup | 497 | #It may either be not installed, or may have crashed on startup |
555 | 500 | self.statusbar.set_text("Failed to connect to the daemon.") | 498 | self.statusbar.set_text("Failed to connect to the daemon.") |
556 | 501 | self.spinner.hide() | 499 | self.spinner.hide() |
557 | 502 | self.statusbox.show() | 500 | self.statusbox.show() |
559 | 503 | GObject.timeout_add(10000,self.run_daemon) | 501 | GObject.timeout_add(10000, self.run_daemon) |
560 | 504 | else: | 502 | else: |
561 | 505 | #successfully started and connected | 503 | #successfully started and connected |
562 | 506 | self.finalise_daemon_connection() | 504 | self.finalise_daemon_connection() |
564 | 507 | 505 | ||
565 | 508 | self.update_widgets_sensitivity() | 506 | self.update_widgets_sensitivity() |
567 | 509 | 507 | ||
568 | 510 | #returning false removes the timeout | 508 | #returning false removes the timeout |
570 | 511 | return False | 509 | return False |
571 | 512 | 510 | ||
572 | 513 | def finalise_daemon_connection(self): | 511 | def finalise_daemon_connection(self): |
573 | 514 | self.libaccom.create_all_trophy_icons() | 512 | self.libaccom.create_all_trophy_icons() |
574 | @@ -518,7 +516,6 @@ | |||
575 | 518 | if len(self.accomdb) == 0: | 516 | if len(self.accomdb) == 0: |
576 | 519 | self.add_no_collections_installed() | 517 | self.add_no_collections_installed() |
577 | 520 | self.set_display(DISPLAY_MODE_OPPORTUNITIES) | 518 | self.set_display(DISPLAY_MODE_OPPORTUNITIES) |
578 | 521 | |||
579 | 522 | 519 | ||
580 | 523 | def update_widgets_sensitivity(self): | 520 | def update_widgets_sensitivity(self): |
581 | 524 | """Disables/enables some GUI elemets, according to whether the client is connected to the daemon or nor""" | 521 | """Disables/enables some GUI elemets, according to whether the client is connected to the daemon or nor""" |
582 | @@ -532,7 +529,7 @@ | |||
583 | 532 | self.mnu_edit_ident.set_sensitive(False) | 529 | self.mnu_edit_ident.set_sensitive(False) |
584 | 533 | return | 530 | return |
585 | 534 | 531 | ||
587 | 535 | def edit_identification_clicked(self,w): | 532 | def edit_identification_clicked(self, w): |
588 | 536 | """Called when user clicks Edit->Identification...""" | 533 | """Called when user clicks Edit->Identification...""" |
589 | 537 | if self.connected is False: | 534 | if self.connected is False: |
590 | 538 | return | 535 | return |
591 | @@ -544,9 +541,9 @@ | |||
592 | 544 | pass | 541 | pass |
593 | 545 | 542 | ||
594 | 546 | self.EditExtraDialog.prepare(self.libaccom) | 543 | self.EditExtraDialog.prepare(self.libaccom) |
596 | 547 | result = self.EditExtraDialog.run() #the dialog's response handlers will take care about storing the result | 544 | result = self.EditExtraDialog.run() # the dialog's response handlers will take care about storing the result |
597 | 548 | self.EditExtraDialog.hide() | 545 | self.EditExtraDialog.hide() |
599 | 549 | 546 | ||
600 | 550 | # re-load accoms and show the opps view, which will update both views | 547 | # re-load accoms and show the opps view, which will update both views |
601 | 551 | # XXX we should probably do this inside EditExtraInfoDialog.py | 548 | # XXX we should probably do this inside EditExtraInfoDialog.py |
602 | 552 | self._load_accomplishments() | 549 | self._load_accomplishments() |
603 | @@ -558,7 +555,7 @@ | |||
604 | 558 | self.subcats_forward.set_sensitive(True) | 555 | self.subcats_forward.set_sensitive(True) |
605 | 559 | 556 | ||
606 | 560 | def subcat_clicked(self, button, data): | 557 | def subcat_clicked(self, button, data): |
608 | 561 | self.set_display(filter_subcat = data) | 558 | self.set_display(filter_subcat=data) |
609 | 562 | 559 | ||
610 | 563 | def subcats_back_button(self, widget): | 560 | def subcats_back_button(self, widget): |
611 | 564 | h = self.subcats_scroll.get_hadjustment() | 561 | h = self.subcats_scroll.get_hadjustment() |
612 | @@ -572,33 +569,33 @@ | |||
613 | 572 | h.set_value(new) | 569 | h.set_value(new) |
614 | 573 | self.subcats_scroll.set_hadjustment(h) | 570 | self.subcats_scroll.set_hadjustment(h) |
615 | 574 | 571 | ||
617 | 575 | def show_gwibber_widget(self,accomID,name): | 572 | def show_gwibber_widget(self, accomID, name): |
618 | 576 | if GWIBBER_OK: | 573 | if GWIBBER_OK: |
619 | 577 | # Temporarily using trophies.ubuntu.com | 574 | # Temporarily using trophies.ubuntu.com |
620 | 578 | #trophyURL = TROPHY_GALLERY_URL+'/gallery/trophies/'+name+'/'+accomID | 575 | #trophyURL = TROPHY_GALLERY_URL+'/gallery/trophies/'+name+'/'+accomID |
623 | 579 | trophyURL = 'http://trophies.ubuntu.com/gallery/trophies/'+name+'/'+accomID | 576 | trophyURL = 'http://trophies.ubuntu.com/gallery/trophies/' + name + '/' + accomID |
624 | 580 | trophy_name = self.libaccom.get_accom_title(accomID); | 577 | trophy_name = self.libaccom.get_accom_title(accomID) |
625 | 581 | self.messageentry.text_view.get_buffer().set_text(_("I've just got the trophy '%s' in #ubuntu accomplishments!") % (trophy_name)) | 578 | self.messageentry.text_view.get_buffer().set_text(_("I've just got the trophy '%s' in #ubuntu accomplishments!") % (trophy_name)) |
626 | 582 | self.messagewindow.show() | 579 | self.messagewindow.show() |
627 | 583 | self.messagewindow.present() | 580 | self.messagewindow.present() |
628 | 584 | 581 | ||
630 | 585 | def close_gwibber_window(self,widget=None,event=None): | 582 | def close_gwibber_window(self, widget=None, event=None): |
631 | 586 | self.messagewindow.hide() | 583 | self.messagewindow.hide() |
632 | 587 | return True | 584 | return True |
634 | 588 | 585 | ||
635 | 589 | def webkit_link_clicked(self, view, frame, net_req, nav_act, pol_dec): | 586 | def webkit_link_clicked(self, view, frame, net_req, nav_act, pol_dec): |
636 | 590 | """Load a link from the webkit view in an external system browser.""" | 587 | """Load a link from the webkit view in an external system browser.""" |
637 | 591 | 588 | ||
640 | 592 | uri=net_req.get_uri() | 589 | uri = net_req.get_uri() |
641 | 593 | if uri.startswith ('file:///gwibber-share'): | 590 | if uri.startswith('file:///gwibber-share'): |
642 | 594 | if GWIBBER_OK: | 591 | if GWIBBER_OK: |
643 | 595 | share_name = self.libaccom.get_share_name() | 592 | share_name = self.libaccom.get_share_name() |
644 | 596 | share_name = urllib2.quote(share_name.encode('utf8')) | 593 | share_name = urllib2.quote(share_name.encode('utf8')) |
645 | 597 | share_ID = self.libaccom.get_share_id() | 594 | share_ID = self.libaccom.get_share_id() |
647 | 598 | nameURL = TROPHY_GALLERY_URL+"/user/getusername?share_name="+share_name+"&share_id="+share_ID | 595 | nameURL = TROPHY_GALLERY_URL + "/user/getusername?share_name=" + share_name + "&share_id=" + share_ID |
648 | 599 | 596 | ||
649 | 600 | publish_status = self.libaccom.get_published_status() | 597 | publish_status = self.libaccom.get_published_status() |
651 | 601 | if publish_status==0: | 598 | if publish_status == 0: |
652 | 602 | dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, _("Your trophies are not yet published")) | 599 | dialog = Gtk.MessageDialog(self, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, _("Your trophies are not yet published")) |
653 | 603 | dialog.format_secondary_text(_("You can do it from Edit->Preferences menu.")) | 600 | dialog.format_secondary_text(_("You can do it from Edit->Preferences menu.")) |
654 | 604 | dialog.run() | 601 | dialog.run() |
655 | @@ -608,9 +605,9 @@ | |||
656 | 608 | response = urllib2.urlopen(nameURL) | 605 | response = urllib2.urlopen(nameURL) |
657 | 609 | for line in response: | 606 | for line in response: |
658 | 610 | name = line.rstrip() | 607 | name = line.rstrip() |
662 | 611 | break | 608 | break |
663 | 612 | uri = uri.replace("file:///gwibber-share?accomID=", ''); | 609 | uri = uri.replace("file:///gwibber-share?accomID=", '') |
664 | 613 | gwibberPopup = self.show_gwibber_widget(uri,name) | 610 | gwibberPopup = self.show_gwibber_widget(uri, name) |
665 | 614 | except urllib2.HTTPError: | 611 | except urllib2.HTTPError: |
666 | 615 | print 'HTTPError while getting username.' | 612 | print 'HTTPError while getting username.' |
667 | 616 | return True | 613 | return True |
668 | @@ -621,23 +618,23 @@ | |||
669 | 621 | return False | 618 | return False |
670 | 622 | 619 | ||
671 | 623 | if uri.startswith('file:'): | 620 | if uri.startswith('file:'): |
674 | 624 | return False | 621 | return False |
675 | 625 | 622 | ||
676 | 626 | if uri.startswith('http'): | 623 | if uri.startswith('http'): |
677 | 627 | webbrowser.open_new_tab(uri) | 624 | webbrowser.open_new_tab(uri) |
678 | 628 | return True | 625 | return True |
679 | 629 | 626 | ||
680 | 630 | if uri.startswith('accomplishment:'): | 627 | if uri.startswith('accomplishment:'): |
681 | 631 | id = uri[17:] | 628 | id = uri[17:] |
683 | 632 | self.set_display(DISPLAY_MODE_DETAILS,accomID=id) | 629 | self.set_display(DISPLAY_MODE_DETAILS, accomID=id) |
684 | 633 | return True | 630 | return True |
685 | 634 | 631 | ||
686 | 635 | pol_dec.ignore() | 632 | pol_dec.ignore() |
688 | 636 | return True | 633 | return True |
689 | 637 | 634 | ||
690 | 638 | def scriptrunner_start(self): | 635 | def scriptrunner_start(self): |
691 | 639 | """Indicate that the script runner is starting.""" | 636 | """Indicate that the script runner is starting.""" |
693 | 640 | 637 | ||
694 | 641 | self.statusbar.set_text("Checking for new accomplishments...") | 638 | self.statusbar.set_text("Checking for new accomplishments...") |
695 | 642 | self.spinner.start() | 639 | self.spinner.start() |
696 | 643 | self.spinner.show() | 640 | self.spinner.show() |
697 | @@ -645,7 +642,7 @@ | |||
698 | 645 | 642 | ||
699 | 646 | def scriptrunner_finish(self): | 643 | def scriptrunner_finish(self): |
700 | 647 | """Indicate that the script runner has stopped.""" | 644 | """Indicate that the script runner has stopped.""" |
702 | 648 | 645 | ||
703 | 649 | self.statusbar.set_text("") | 646 | self.statusbar.set_text("") |
704 | 650 | self.spinner.stop() | 647 | self.spinner.stop() |
705 | 651 | self.spinner.hide() | 648 | self.spinner.hide() |
706 | @@ -663,7 +660,7 @@ | |||
707 | 663 | def verify_u1_account(self): | 660 | def verify_u1_account(self): |
708 | 664 | ver = self.libaccom.verify_ubuntu_one_account() | 661 | ver = self.libaccom.verify_ubuntu_one_account() |
709 | 665 | 662 | ||
711 | 666 | if bool(ver) == True: | 663 | if bool(ver) is True: |
712 | 667 | self.u1_button.disconnect(self.u1_button_sig) | 664 | self.u1_button.disconnect(self.u1_button_sig) |
713 | 668 | self.u1_button.set_label("Click here to confirm your Ubuntu One account") | 665 | self.u1_button.set_label("Click here to confirm your Ubuntu One account") |
714 | 669 | self.u1_button_sig = self.u1_button.connect("clicked", self.register_with_verif) | 666 | self.u1_button_sig = self.u1_button.connect("clicked", self.register_with_verif) |
715 | @@ -694,7 +691,7 @@ | |||
716 | 694 | def complete_share_process(self): | 691 | def complete_share_process(self): |
717 | 695 | self.has_u1 = True | 692 | self.has_u1 = True |
718 | 696 | self.libaccom.write_config_file_item("config", "has_u1", True) | 693 | self.libaccom.write_config_file_item("config", "has_u1", True) |
720 | 697 | 694 | ||
721 | 698 | self.additional_ubuntu1.set_visible(False) | 695 | self.additional_ubuntu1.set_visible(False) |
722 | 699 | 696 | ||
723 | 700 | # ACCOMPLISHMENT: Editing Credentials | 697 | # ACCOMPLISHMENT: Editing Credentials |
724 | @@ -702,7 +699,7 @@ | |||
725 | 702 | self.libaccom.accomplish("ubuntu-desktop/accomplishments-shared-with-validation-server") | 699 | self.libaccom.accomplish("ubuntu-desktop/accomplishments-shared-with-validation-server") |
726 | 703 | except: | 700 | except: |
727 | 704 | pass | 701 | pass |
729 | 705 | 702 | ||
730 | 706 | self.check_for_extra_info_required() | 703 | self.check_for_extra_info_required() |
731 | 707 | 704 | ||
732 | 708 | def register_with_verif(self, widget): | 705 | def register_with_verif(self, widget): |
733 | @@ -716,20 +713,20 @@ | |||
734 | 716 | self.u1_button.show() | 713 | self.u1_button.show() |
735 | 717 | self.additional_ubuntu1.set_visible(True) | 714 | self.additional_ubuntu1.set_visible(True) |
736 | 718 | 715 | ||
744 | 719 | def on_window_resized(self,widget): | 716 | def on_window_resized(self, widget): |
745 | 720 | # Workaround for GtkIconView bug in precise | 717 | # Workaround for GtkIconView bug in precise |
746 | 721 | if self.display_mode is DISPLAY_MODE_OPPORTUNITIES: | 718 | if self.display_mode is DISPLAY_MODE_OPPORTUNITIES: |
747 | 722 | self._update_opportunities_view() | 719 | self._update_opportunities_view() |
748 | 723 | elif self.display_mode is DISPLAY_MODE_TROPHIES: | 720 | elif self.display_mode is DISPLAY_MODE_TROPHIES: |
749 | 724 | self._update_mytrophy_view() | 721 | self._update_mytrophy_view() |
750 | 725 | 722 | ||
751 | 726 | def populate_opp_combos(self): | 723 | def populate_opp_combos(self): |
752 | 727 | temp = [] | 724 | temp = [] |
753 | 728 | for i in self.accomdb: | 725 | for i in self.accomdb: |
755 | 729 | temp.append({i["collection"] : i["collection-human"] }) | 726 | temp.append({i["collection"]: i["collection-human"]}) |
756 | 730 | # uniqify the values | 727 | # uniqify the values |
757 | 731 | result = [dict(tupleized) for tupleized in set(tuple(item.items()) for item in temp)] | 728 | result = [dict(tupleized) for tupleized in set(tuple(item.items()) for item in temp)] |
759 | 732 | 729 | ||
760 | 733 | # set up app | 730 | # set up app |
761 | 734 | self.opp_col_store.append(["", "All"]) | 731 | self.opp_col_store.append(["", "All"]) |
762 | 735 | for i in sorted(result): | 732 | for i in sorted(result): |
763 | @@ -741,73 +738,73 @@ | |||
764 | 741 | # Prepare categories combo | 738 | # Prepare categories combo |
765 | 742 | self.opp_combo_cat.set_model(self.opp_cat_store) | 739 | self.opp_combo_cat.set_model(self.opp_cat_store) |
766 | 743 | self.opp_combo_cat.show() | 740 | self.opp_combo_cat.show() |
769 | 744 | 741 | ||
770 | 745 | def on_filter_collection_changed(self,widget): | 742 | def on_filter_collection_changed(self, widget): |
771 | 746 | tree_iter = widget.get_active_iter() | 743 | tree_iter = widget.get_active_iter() |
772 | 747 | model = widget.get_model() | 744 | model = widget.get_model() |
773 | 748 | collection, name = model[tree_iter][:2] | 745 | collection, name = model[tree_iter][:2] |
775 | 749 | self.set_display(filter_collection = collection) | 746 | self.set_display(filter_collection=collection) |
776 | 750 | 747 | ||
777 | 751 | def on_filter_category_changed(self, widget): | 748 | def on_filter_category_changed(self, widget): |
778 | 752 | tree_iter = widget.get_active_iter() | 749 | tree_iter = widget.get_active_iter() |
780 | 753 | if tree_iter == None: # Special case if the categories combo is not sensitive | 750 | if tree_iter is None: # Special case if the categories combo is not sensitive |
781 | 754 | return | 751 | return |
782 | 755 | model = widget.get_model() | 752 | model = widget.get_model() |
783 | 756 | category, name = model[tree_iter][:2] | 753 | category, name = model[tree_iter][:2] |
786 | 757 | self.set_display(filter_category = category) | 754 | self.set_display(filter_category=category) |
787 | 758 | 755 | ||
788 | 759 | def on_filter_show_locked_clicked(self, widget): | 756 | def on_filter_show_locked_clicked(self, widget): |
799 | 760 | if widget.get_active(): | 757 | if widget.get_active(): |
800 | 761 | self.set_display(filter_locked=DISPLAY_FILTER_LOCKED_SHOW) | 758 | self.set_display(filter_locked=DISPLAY_FILTER_LOCKED_SHOW) |
801 | 762 | else: | 759 | else: |
802 | 763 | self.set_display(filter_locked=DISPLAY_FILTER_LOCKED_HIDE) | 760 | self.set_display(filter_locked=DISPLAY_FILTER_LOCKED_HIDE) |
803 | 764 | 761 | ||
804 | 765 | def on_search_changed(self,widget): | 762 | def on_search_changed(self, widget): |
805 | 766 | value = widget.get_text() | 763 | value = widget.get_text() |
806 | 767 | self.set_display(search_query=value) | 764 | self.set_display(search_query=value) |
807 | 768 | 765 | ||
808 | 769 | def on_search_clear_clicked(self,widget,icon,data): | 766 | def on_search_clear_clicked(self, widget, icon, data): |
809 | 770 | self.searchbar.set_text("") | 767 | self.searchbar.set_text("") |
811 | 771 | 768 | ||
812 | 772 | def check_accomplishments(self, widget): | 769 | def check_accomplishments(self, widget): |
813 | 773 | """Called when Check Accomplishments is selected in the interface.""" | 770 | """Called when Check Accomplishments is selected in the interface.""" |
814 | 774 | self.libaccom.run_scripts(True) | 771 | self.libaccom.run_scripts(True) |
816 | 775 | 772 | ||
817 | 776 | def on_mytrophies_filter_latest_toggled(self, widget): | 773 | def on_mytrophies_filter_latest_toggled(self, widget): |
819 | 777 | self.set_display(trophies_mode=MYTROPHIES_FILTER_LATEST) | 774 | self.set_display(trophies_mode=MYTROPHIES_FILTER_LATEST) |
820 | 778 | 775 | ||
823 | 779 | def on_mytrophies_filter_all_toggled(self, widget): | 776 | def on_mytrophies_filter_all_toggled(self, widget): |
824 | 780 | self.set_display(trophies_mode=MYTROPHIES_FILTER_ALL) | 777 | self.set_display(trophies_mode=MYTROPHIES_FILTER_ALL) |
825 | 781 | 778 | ||
826 | 782 | def on_tb_mytrophies_clicked(self, widget): | 779 | def on_tb_mytrophies_clicked(self, widget): |
827 | 783 | """Called when the My Trophies button is clicked.""" | 780 | """Called when the My Trophies button is clicked.""" |
829 | 784 | 781 | ||
830 | 785 | mytrophies_toggled = self.tb_mytrophies.get_active() | 782 | mytrophies_toggled = self.tb_mytrophies.get_active() |
831 | 786 | opportunities_toggled = self.tb_opportunities.get_active() | 783 | opportunities_toggled = self.tb_opportunities.get_active() |
834 | 787 | 784 | ||
835 | 788 | if mytrophies_toggled == True: | 785 | if mytrophies_toggled is True: |
836 | 789 | self.set_display(DISPLAY_MODE_TROPHIES) | 786 | self.set_display(DISPLAY_MODE_TROPHIES) |
837 | 790 | else: | 787 | else: |
839 | 791 | self.tb_mytrophies.set_active(True) # This also fires the signal handler | 788 | self.tb_mytrophies.set_active(True) # This also fires the signal handler |
840 | 792 | 789 | ||
841 | 793 | def on_tb_opportunities_clicked(self, widget): | 790 | def on_tb_opportunities_clicked(self, widget): |
842 | 794 | """Called when the Opportunities button is clicked.""" | 791 | """Called when the Opportunities button is clicked.""" |
844 | 795 | 792 | ||
845 | 796 | self.launcher.set_property("urgent", False) | 793 | self.launcher.set_property("urgent", False) |
846 | 797 | self.newtrophies = 0 | 794 | self.newtrophies = 0 |
847 | 798 | self.launcher.set_property("count_visible", False) | 795 | self.launcher.set_property("count_visible", False) |
849 | 799 | 796 | ||
850 | 800 | mytrophies_toggled = self.tb_mytrophies.get_active() | 797 | mytrophies_toggled = self.tb_mytrophies.get_active() |
851 | 801 | opportunities_toggled = self.tb_opportunities.get_active() | 798 | opportunities_toggled = self.tb_opportunities.get_active() |
854 | 802 | 799 | ||
855 | 803 | if opportunities_toggled == True: | 800 | if opportunities_toggled is True: |
856 | 804 | self.set_display(DISPLAY_MODE_OPPORTUNITIES) | 801 | self.set_display(DISPLAY_MODE_OPPORTUNITIES) |
857 | 805 | else: | 802 | else: |
859 | 806 | self.tb_opportunities.set_active(True) # This also fires the signal handler | 803 | self.tb_opportunities.set_active(True) # This also fires the signal handler |
860 | 807 | 804 | ||
862 | 808 | def menu_prefs_clicked(self,widget): | 805 | def menu_prefs_clicked(self, widget): |
863 | 809 | """Display the preferences window.""" | 806 | """Display the preferences window.""" |
865 | 810 | 807 | ||
866 | 811 | # If the window already is in use, when user clicks the menu | 808 | # If the window already is in use, when user clicks the menu |
867 | 812 | # item, present() is used instead, to bring the window to front | 809 | # item, present() is used instead, to bring the window to front |
868 | 813 | # etc. | 810 | # etc. |
869 | @@ -819,24 +816,24 @@ | |||
870 | 819 | self.preferences_dialog.prepare(self.libaccom) | 816 | self.preferences_dialog.prepare(self.libaccom) |
871 | 820 | self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed) | 817 | self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed) |
872 | 821 | self.preferences_dialog.show() | 818 | self.preferences_dialog.show() |
875 | 822 | 819 | ||
876 | 823 | def on_preferences_dialog_destroyed(self,widget): | 820 | def on_preferences_dialog_destroyed(self, widget): |
877 | 824 | self.preferences_dialog = None | 821 | self.preferences_dialog = None |
879 | 825 | 822 | ||
880 | 826 | def get_icon(self, name): | 823 | def get_icon(self, name): |
881 | 827 | theme = Gtk.IconTheme.get_default() | 824 | theme = Gtk.IconTheme.get_default() |
882 | 828 | return theme.load_icon(name, 48, 0) | 825 | return theme.load_icon(name, 48, 0) |
883 | 829 | 826 | ||
884 | 830 | def check_for_extra_info_required(self): | 827 | def check_for_extra_info_required(self): |
885 | 831 | """Check if the installed accomplishments require additional information to be gathered from the user.""" | 828 | """Check if the installed accomplishments require additional information to be gathered from the user.""" |
887 | 832 | 829 | ||
888 | 833 | infoneeded = self.libaccom.get_all_extra_information_required() | 830 | infoneeded = self.libaccom.get_all_extra_information_required() |
889 | 834 | 831 | ||
890 | 835 | if len(infoneeded) is not 0: | 832 | if len(infoneeded) is not 0: |
891 | 836 | # kick of the process of gathering the information needed | 833 | # kick of the process of gathering the information needed |
892 | 837 | try: | 834 | try: |
893 | 838 | seen = self.libaccom.get_config_value("config", "extrainfo_seen") | 835 | seen = self.libaccom.get_config_value("config", "extrainfo_seen") |
895 | 839 | 836 | ||
896 | 840 | if seen == "NoOption" or seen == 0: | 837 | if seen == "NoOption" or seen == 0: |
897 | 841 | self.additional_info_req.set_visible(True) | 838 | self.additional_info_req.set_visible(True) |
898 | 842 | self.libaccom.write_config_file_item("config", "extrainfo_seen", 1) | 839 | self.libaccom.write_config_file_item("config", "extrainfo_seen", 1) |
899 | @@ -857,22 +854,22 @@ | |||
900 | 857 | self.libaccom.set_daemon_session_start(True) | 854 | self.libaccom.set_daemon_session_start(True) |
901 | 858 | self.additional_daemon_session.set_visible(False) | 855 | self.additional_daemon_session.set_visible(False) |
902 | 859 | 856 | ||
904 | 860 | def edit_auth_info(self,widget): | 857 | def edit_auth_info(self, widget): |
905 | 861 | """Called when user clicks "Edit credentials" from notification""" | 858 | """Called when user clicks "Edit credentials" from notification""" |
906 | 862 | self.additional_info_req.set_visible(False) | 859 | self.additional_info_req.set_visible(False) |
908 | 863 | self.edit_identification_clicked(widget) #that's maily the same thing | 860 | self.edit_identification_clicked(widget) # that's maily the same thing |
909 | 864 | return | 861 | return |
910 | 865 | 862 | ||
912 | 866 | def edit_auth_info_cancel(self,widget): | 863 | def edit_auth_info_cancel(self, widget): |
913 | 867 | """Called when user clicks "Later" from extrainfo-needed notification""" | 864 | """Called when user clicks "Later" from extrainfo-needed notification""" |
914 | 868 | self.additional_info_req.set_visible(False) | 865 | self.additional_info_req.set_visible(False) |
915 | 869 | return | 866 | return |
917 | 870 | 867 | ||
918 | 871 | def _load_accomplishments(self): | 868 | def _load_accomplishments(self): |
919 | 872 | # clear the local cache of accomplishments | 869 | # clear the local cache of accomplishments |
920 | 873 | self.accomdb = [] | 870 | self.accomdb = [] |
921 | 874 | self.accomdb = self.libaccom.build_viewer_database() | 871 | self.accomdb = self.libaccom.build_viewer_database() |
923 | 875 | 872 | ||
924 | 876 | def opp_clicked(self, widget): | 873 | def opp_clicked(self, widget): |
925 | 877 | selection = widget.get_selected_items() | 874 | selection = widget.get_selected_items() |
926 | 878 | if len(selection) is 0: | 875 | if len(selection) is 0: |
927 | @@ -881,7 +878,7 @@ | |||
928 | 881 | widget.unselect_path(item) | 878 | widget.unselect_path(item) |
929 | 882 | model = widget.get_model() | 879 | model = widget.get_model() |
930 | 883 | accomID = model[item][COL_ID] | 880 | accomID = model[item][COL_ID] |
932 | 884 | self.set_display(DISPLAY_MODE_DETAILS,accomID=accomID) | 881 | self.set_display(DISPLAY_MODE_DETAILS, accomID=accomID) |
933 | 885 | 882 | ||
934 | 886 | def mytrophy_clicked(self, widget): | 883 | def mytrophy_clicked(self, widget): |
935 | 887 | selection = widget.get_selected_items() | 884 | selection = widget.get_selected_items() |
936 | @@ -891,7 +888,7 @@ | |||
937 | 891 | widget.unselect_path(item) | 888 | widget.unselect_path(item) |
938 | 892 | model = widget.get_model() | 889 | model = widget.get_model() |
939 | 893 | accomID = model[item][COL_ID] | 890 | accomID = model[item][COL_ID] |
941 | 894 | self.set_display(DISPLAY_MODE_DETAILS,accomID=accomID) | 891 | self.set_display(DISPLAY_MODE_DETAILS, accomID=accomID) |
942 | 895 | 892 | ||
943 | 896 | def optparse_accomplishment(self, accom_id): | 893 | def optparse_accomplishment(self, accom_id): |
944 | 897 | """Process the -a command line option""" | 894 | """Process the -a command line option""" |
945 | @@ -899,8 +896,8 @@ | |||
946 | 899 | # this accomplishment does not exist! aborting... | 896 | # this accomplishment does not exist! aborting... |
947 | 900 | print "There is no accomplishment with this ID." | 897 | print "There is no accomplishment with this ID." |
948 | 901 | return | 898 | return |
951 | 902 | 899 | ||
952 | 903 | self.set_display(DISPLAY_MODE_DETAILS,accomID=accom_id) | 900 | self.set_display(DISPLAY_MODE_DETAILS, accomID=accom_id) |
953 | 904 | 901 | ||
954 | 905 | def prepare_models(self): | 902 | def prepare_models(self): |
955 | 906 | """ | 903 | """ |
956 | @@ -919,31 +916,31 @@ | |||
957 | 919 | # Prepare latest trophies iconviews | 916 | # Prepare latest trophies iconviews |
958 | 920 | if len(self.mytrophies_box_latest.get_children()) == 0: | 917 | if len(self.mytrophies_box_latest.get_children()) == 0: |
959 | 921 | self.mytrophies_latest_boxes = [] | 918 | self.mytrophies_latest_boxes = [] |
971 | 922 | box = self.add_mytrophies_view(self.mytrophies_box_latest,_("Today"), self.trophiesstore_filter_today) | 919 | box = self.add_mytrophies_view(self.mytrophies_box_latest, _("Today"), self.trophiesstore_filter_today) |
972 | 923 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_today,box]) | 920 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_today, box]) |
973 | 924 | box = self.add_mytrophies_view(self.mytrophies_box_latest,_("This Week"), self.trophiesstore_filter_week) | 921 | box = self.add_mytrophies_view(self.mytrophies_box_latest, _("This Week"), self.trophiesstore_filter_week) |
974 | 925 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_week,box]) | 922 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_week, box]) |
975 | 926 | box = self.add_mytrophies_view(self.mytrophies_box_latest,_("This Month"), self.trophiesstore_filter_month) | 923 | box = self.add_mytrophies_view(self.mytrophies_box_latest, _("This Month"), self.trophiesstore_filter_month) |
976 | 927 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_month,box]) | 924 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_month, box]) |
977 | 928 | box = self.add_mytrophies_view(self.mytrophies_box_latest,_("Last Six Months"), self.trophiesstore_filter_sixmonths) | 925 | box = self.add_mytrophies_view(self.mytrophies_box_latest, _("Last Six Months"), self.trophiesstore_filter_sixmonths) |
978 | 929 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_sixmonths,box]) | 926 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_sixmonths, box]) |
979 | 930 | box = self.add_mytrophies_view(self.mytrophies_box_latest,_("Earlier"), self.trophiesstore_filter_earlier) | 927 | box = self.add_mytrophies_view(self.mytrophies_box_latest, _("Earlier"), self.trophiesstore_filter_earlier) |
980 | 931 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_earlier,box]) | 928 | self.mytrophies_latest_boxes.append([self.trophiesstore_filter_earlier, box]) |
981 | 932 | 929 | ||
982 | 933 | # Prepare all trophies iconviews | 930 | # Prepare all trophies iconviews |
983 | 934 | kids = self.mytrophies_box_all.get_children() | 931 | kids = self.mytrophies_box_all.get_children() |
984 | 935 | for kid in kids: | 932 | for kid in kids: |
986 | 936 | self.mytrophies_box_all.remove(k) | 933 | self.mytrophies_box_all.remove(kid) |
987 | 937 | for f in self.trophies_collection_filters: | 934 | for f in self.trophies_collection_filters: |
989 | 938 | del f[0] #Remove the filter! | 935 | del f[0] # Remove the filter! |
990 | 939 | self.trophies_collection_filters = [] | 936 | self.trophies_collection_filters = [] |
991 | 940 | collections = self.libaccom.list_collections() | 937 | collections = self.libaccom.list_collections() |
992 | 941 | for c in collections: | 938 | for c in collections: |
993 | 942 | new_filter = self.trophiesstore.filter_new() | 939 | new_filter = self.trophiesstore.filter_new() |
995 | 943 | new_filter.set_visible_func(self._trophy_all_visible_func,c) | 940 | new_filter.set_visible_func(self._trophy_all_visible_func, c) |
996 | 944 | box = self.add_mytrophies_view(self.mytrophies_box_all, self.libaccom.get_collection_name(c), new_filter) | 941 | box = self.add_mytrophies_view(self.mytrophies_box_all, self.libaccom.get_collection_name(c), new_filter) |
999 | 945 | self.trophies_collection_filters.append([new_filter,box]) | 942 | self.trophies_collection_filters.append([new_filter, box]) |
1000 | 946 | 943 | ||
1001 | 947 | def add_mytrophies_view(self, parent, section, model): | 944 | def add_mytrophies_view(self, parent, section, model): |
1002 | 948 | """ | 945 | """ |
1003 | 949 | This function is used for adding a new group of accomplishments in mytrophies view. | 946 | This function is used for adding a new group of accomplishments in mytrophies view. |
1004 | @@ -961,95 +958,95 @@ | |||
1005 | 961 | separator = Gtk.Separator() | 958 | separator = Gtk.Separator() |
1006 | 962 | separator.set_property("margin_left", 10) | 959 | separator.set_property("margin_left", 10) |
1007 | 963 | separator.set_property("margin_right", 10) | 960 | separator.set_property("margin_right", 10) |
1009 | 964 | 961 | ||
1010 | 965 | iconview = Gtk.IconView() | 962 | iconview = Gtk.IconView() |
1011 | 966 | iconview.set_model(model) | 963 | iconview.set_model(model) |
1012 | 967 | iconview.set_text_column(COL_TITLE) | 964 | iconview.set_text_column(COL_TITLE) |
1013 | 968 | iconview.set_pixbuf_column(COL_PIXBUF) | 965 | iconview.set_pixbuf_column(COL_PIXBUF) |
1014 | 969 | iconview.set_item_width(120) | 966 | iconview.set_item_width(120) |
1015 | 970 | iconview.set_columns(-1) | 967 | iconview.set_columns(-1) |
1017 | 971 | iconview.connect("selection-changed",self.mytrophy_clicked) | 968 | iconview.connect("selection-changed", self.mytrophy_clicked) |
1018 | 972 | 969 | ||
1019 | 973 | outerbox.pack_start(header, False, False, 0) | 970 | outerbox.pack_start(header, False, False, 0) |
1020 | 974 | outerbox.pack_start(separator, False, False, 0) | 971 | outerbox.pack_start(separator, False, False, 0) |
1021 | 975 | outerbox.pack_start(iconview, False, False, 0) | 972 | outerbox.pack_start(iconview, False, False, 0) |
1022 | 976 | outerbox.show_all() | 973 | outerbox.show_all() |
1024 | 977 | 974 | ||
1025 | 978 | parent.add(outerbox) | 975 | parent.add(outerbox) |
1026 | 979 | return outerbox | 976 | return outerbox |
1027 | 980 | 977 | ||
1039 | 981 | def set_display(self, | 978 | def set_display(self, |
1040 | 982 | mode = DISPLAY_MODE_UNSPECIFIED, | 979 | mode=DISPLAY_MODE_UNSPECIFIED, |
1041 | 983 | accomID = "", | 980 | accomID="", |
1042 | 984 | trophies_mode = MYTROPHIES_FILTER_UNSPECIFIED, | 981 | trophies_mode=MYTROPHIES_FILTER_UNSPECIFIED, |
1043 | 985 | filter_locked = DISPLAY_FILTER_LOCKED_UNSPECIFIED, | 982 | filter_locked=DISPLAY_FILTER_LOCKED_UNSPECIFIED, |
1044 | 986 | filter_collection = DISPLAY_FILTER_COLLECTION_UNSPECIFIED, | 983 | filter_collection=DISPLAY_FILTER_COLLECTION_UNSPECIFIED, |
1045 | 987 | filter_category = DISPLAY_FILTER_CATEGORY_UNSPECIFIED, | 984 | filter_category=DISPLAY_FILTER_CATEGORY_UNSPECIFIED, |
1046 | 988 | filter_subcat = DISPLAY_FILTER_SUBCAT_UNSPECIFIED, | 985 | filter_subcat=DISPLAY_FILTER_SUBCAT_UNSPECIFIED, |
1047 | 989 | search_query = DISPLAY_FILTER_SEARCH_UNSPECIFIED): | 986 | search_query=DISPLAY_FILTER_SEARCH_UNSPECIFIED): |
1048 | 990 | """ | 987 | """ |
1049 | 991 | Switches display mode as specified in arguments. | 988 | Switches display mode as specified in arguments. |
1050 | 992 | It takes care about flipping notebook pages, hiding unnecessary UI pieces etc. | 989 | It takes care about flipping notebook pages, hiding unnecessary UI pieces etc. |
1051 | 993 | This function shouldn't be called with many arguments, pass only these that you want to override. | 990 | This function shouldn't be called with many arguments, pass only these that you want to override. |
1053 | 994 | """ | 991 | """ |
1054 | 995 | # The ordering of following IF statements *IS* important! | 992 | # The ordering of following IF statements *IS* important! |
1055 | 996 | # For example, passing both collection and category to this function | 993 | # For example, passing both collection and category to this function |
1056 | 997 | # may not result in skipping some of these data as they get cleared | 994 | # may not result in skipping some of these data as they get cleared |
1057 | 998 | # later on. Therefore hierarhical order is desired. | 995 | # later on. Therefore hierarhical order is desired. |
1060 | 999 | if mode is not DISPLAY_MODE_UNSPECIFIED: | 996 | if mode is not DISPLAY_MODE_UNSPECIFIED: |
1061 | 1000 | self.display_mode = mode | 997 | self.display_mode = mode |
1062 | 1001 | # Reflect changes in the UI | 998 | # Reflect changes in the UI |
1063 | 1002 | if self.display_mode is DISPLAY_MODE_DETAILS: | 999 | if self.display_mode is DISPLAY_MODE_DETAILS: |
1064 | 1003 | #Displaying details for an accomplishment | 1000 | #Displaying details for an accomplishment |
1066 | 1004 | 1001 | ||
1067 | 1005 | if accomID == "": | 1002 | if accomID == "": |
1068 | 1006 | print "Unable to display details view, you probably forgot the accomID argument." | 1003 | print "Unable to display details view, you probably forgot the accomID argument." |
1069 | 1007 | return | 1004 | return |
1071 | 1008 | 1005 | ||
1072 | 1009 | # Set togglable buttons to reflect current state | 1006 | # Set togglable buttons to reflect current state |
1076 | 1010 | self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked) | 1007 | self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked) |
1077 | 1011 | self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked) | 1008 | self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked) |
1078 | 1012 | self.tb_mytrophies.set_active(False) | 1009 | self.tb_mytrophies.set_active(False) |
1079 | 1013 | self.tb_opportunities.set_active(False) | 1010 | self.tb_opportunities.set_active(False) |
1080 | 1014 | self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked) | 1011 | self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked) |
1081 | 1015 | self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked) | 1012 | self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked) |
1083 | 1016 | 1013 | ||
1084 | 1017 | # Select all characters in searchbar | 1014 | # Select all characters in searchbar |
1085 | 1018 | self.searchbar.grab_focus() | 1015 | self.searchbar.grab_focus() |
1087 | 1019 | 1016 | ||
1088 | 1020 | self.notebook.set_current_page(0) | 1017 | self.notebook.set_current_page(0) |
1089 | 1021 | self.searchbar_box.hide() | 1018 | self.searchbar_box.hide() |
1091 | 1022 | 1019 | ||
1092 | 1023 | elif self.display_mode is DISPLAY_MODE_TROPHIES: | 1020 | elif self.display_mode is DISPLAY_MODE_TROPHIES: |
1093 | 1024 | #Display the list of trophies | 1021 | #Display the list of trophies |
1095 | 1025 | 1022 | ||
1096 | 1026 | # Set togglable buttons to reflect current state | 1023 | # Set togglable buttons to reflect current state |
1100 | 1027 | self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked) | 1024 | self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked) |
1101 | 1028 | self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked) | 1025 | self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked) |
1102 | 1029 | self.tb_mytrophies.set_active(True) | 1026 | self.tb_mytrophies.set_active(True) |
1103 | 1030 | self.tb_opportunities.set_active(False) | 1027 | self.tb_opportunities.set_active(False) |
1104 | 1031 | self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked) | 1028 | self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked) |
1105 | 1032 | self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked) | 1029 | self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked) |
1107 | 1033 | 1030 | ||
1108 | 1034 | # Select all characters in searchbar | 1031 | # Select all characters in searchbar |
1109 | 1035 | self.searchbar.grab_focus() | 1032 | self.searchbar.grab_focus() |
1111 | 1036 | 1033 | ||
1112 | 1037 | self.notebook.set_current_page(1) | 1034 | self.notebook.set_current_page(1) |
1113 | 1038 | self.searchbar_box.show() | 1035 | self.searchbar_box.show() |
1115 | 1039 | 1036 | ||
1116 | 1040 | elif self.display_mode is DISPLAY_MODE_OPPORTUNITIES: | 1037 | elif self.display_mode is DISPLAY_MODE_OPPORTUNITIES: |
1118 | 1041 | 1038 | ||
1119 | 1042 | # Set togglable buttons to reflect current state | 1039 | # Set togglable buttons to reflect current state |
1123 | 1043 | self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked) | 1040 | self.tb_mytrophies.handler_block_by_func(self.on_tb_mytrophies_clicked) |
1124 | 1044 | self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked) | 1041 | self.tb_opportunities.handler_block_by_func(self.on_tb_opportunities_clicked) |
1125 | 1045 | self.tb_mytrophies.set_active(False) | 1042 | self.tb_mytrophies.set_active(False) |
1126 | 1046 | self.tb_opportunities.set_active(True) | 1043 | self.tb_opportunities.set_active(True) |
1127 | 1047 | self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked) | 1044 | self.tb_mytrophies.handler_unblock_by_func(self.on_tb_mytrophies_clicked) |
1128 | 1048 | self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked) | 1045 | self.tb_opportunities.handler_unblock_by_func(self.on_tb_opportunities_clicked) |
1130 | 1049 | 1046 | ||
1131 | 1050 | self.notebook.set_current_page(2) | 1047 | self.notebook.set_current_page(2) |
1132 | 1051 | self.searchbar_box.show() | 1048 | self.searchbar_box.show() |
1134 | 1052 | 1049 | ||
1135 | 1053 | if trophies_mode is not MYTROPHIES_FILTER_UNSPECIFIED: | 1050 | if trophies_mode is not MYTROPHIES_FILTER_UNSPECIFIED: |
1136 | 1054 | self.display_mytrophies_filtermode = trophies_mode | 1051 | self.display_mytrophies_filtermode = trophies_mode |
1137 | 1055 | # Show/hide appropriate iconview | 1052 | # Show/hide appropriate iconview |
1138 | @@ -1057,12 +1054,12 @@ | |||
1139 | 1057 | self.mytrophies_notebook.set_current_page(0) | 1054 | self.mytrophies_notebook.set_current_page(0) |
1140 | 1058 | elif self.display_mytrophies_filtermode is MYTROPHIES_FILTER_LATEST: | 1055 | elif self.display_mytrophies_filtermode is MYTROPHIES_FILTER_LATEST: |
1141 | 1059 | self.mytrophies_notebook.set_current_page(1) | 1056 | self.mytrophies_notebook.set_current_page(1) |
1143 | 1060 | 1057 | ||
1144 | 1061 | if filter_locked is not DISPLAY_FILTER_LOCKED_UNSPECIFIED: | 1058 | if filter_locked is not DISPLAY_FILTER_LOCKED_UNSPECIFIED: |
1145 | 1062 | self.display_filter_locked = filter_locked | 1059 | self.display_filter_locked = filter_locked |
1146 | 1063 | if filter_collection is not DISPLAY_FILTER_COLLECTION_UNSPECIFIED: | 1060 | if filter_collection is not DISPLAY_FILTER_COLLECTION_UNSPECIFIED: |
1147 | 1064 | self.display_filter_collection = filter_collection | 1061 | self.display_filter_collection = filter_collection |
1149 | 1065 | 1062 | ||
1150 | 1066 | # As the requested collection changed, we need to update the categories combo. | 1063 | # As the requested collection changed, we need to update the categories combo. |
1151 | 1067 | if filter_collection == "": | 1064 | if filter_collection == "": |
1152 | 1068 | self.opp_cat_store.clear() | 1065 | self.opp_cat_store.clear() |
1153 | @@ -1075,28 +1072,27 @@ | |||
1154 | 1075 | for i in sorted(cats): | 1072 | for i in sorted(cats): |
1155 | 1076 | self.opp_cat_store.append([i, i]) | 1073 | self.opp_cat_store.append([i, i]) |
1156 | 1077 | self.opp_combo_cat.set_sensitive(True) | 1074 | self.opp_combo_cat.set_sensitive(True) |
1158 | 1078 | 1075 | ||
1159 | 1079 | # Set the active item to "everything". | 1076 | # Set the active item to "everything". |
1160 | 1080 | self.display_filter_category = "" | 1077 | self.display_filter_category = "" |
1161 | 1081 | self.opp_combo_cat.handler_block_by_func(self.on_filter_category_changed) | 1078 | self.opp_combo_cat.handler_block_by_func(self.on_filter_category_changed) |
1162 | 1082 | self.opp_combo_cat.set_active(0) | 1079 | self.opp_combo_cat.set_active(0) |
1163 | 1083 | self.opp_combo_cat.handler_unblock_by_func(self.on_filter_category_changed) | 1080 | self.opp_combo_cat.handler_unblock_by_func(self.on_filter_category_changed) |
1165 | 1084 | 1081 | ||
1166 | 1085 | # It is likely that we need to update the subcategories. | 1082 | # It is likely that we need to update the subcategories. |
1167 | 1086 | # A special case is when it needs to be hidden after collection change. | 1083 | # A special case is when it needs to be hidden after collection change. |
1168 | 1087 | self._update_subcats() | 1084 | self._update_subcats() |
1170 | 1088 | 1085 | ||
1171 | 1089 | if filter_category is not DISPLAY_FILTER_CATEGORY_UNSPECIFIED: | 1086 | if filter_category is not DISPLAY_FILTER_CATEGORY_UNSPECIFIED: |
1172 | 1090 | self.display_filter_category = filter_category | 1087 | self.display_filter_category = filter_category |
1174 | 1091 | 1088 | ||
1175 | 1092 | # Changing category, therefore we should display the subcats bar too. | 1089 | # Changing category, therefore we should display the subcats bar too. |
1176 | 1093 | self._update_subcats() | 1090 | self._update_subcats() |
1178 | 1094 | 1091 | ||
1179 | 1095 | if filter_subcat is not DISPLAY_FILTER_SUBCAT_UNSPECIFIED: | 1092 | if filter_subcat is not DISPLAY_FILTER_SUBCAT_UNSPECIFIED: |
1184 | 1096 | self.display_filter_subcat = filter_subcat | 1093 | self.display_filter_subcat = filter_subcat |
1185 | 1097 | if search_query is not DISPLAY_FILTER_SEARCH_UNSPECIFIED: | 1094 | if search_query is not DISPLAY_FILTER_SEARCH_UNSPECIFIED: |
1186 | 1098 | self.display_filter_search = search_query | 1095 | self.display_filter_search = search_query |
1183 | 1099 | |||
1187 | 1100 | 1096 | ||
1188 | 1101 | # Finally, pass refreshing/rerendering to specialised functions | 1097 | # Finally, pass refreshing/rerendering to specialised functions |
1189 | 1102 | if self.display_mode is DISPLAY_MODE_DETAILS: | 1098 | if self.display_mode is DISPLAY_MODE_DETAILS: |
1190 | @@ -1105,7 +1101,7 @@ | |||
1191 | 1105 | self._update_mytrophy_view() | 1101 | self._update_mytrophy_view() |
1192 | 1106 | elif self.display_mode is DISPLAY_MODE_OPPORTUNITIES: | 1102 | elif self.display_mode is DISPLAY_MODE_OPPORTUNITIES: |
1193 | 1107 | self._update_opportunities_view() | 1103 | self._update_opportunities_view() |
1195 | 1108 | 1104 | ||
1196 | 1109 | def _update_mytrophy_view(self): | 1105 | def _update_mytrophy_view(self): |
1197 | 1110 | # Causes the treemodel to call visible_func for all rows. | 1106 | # Causes the treemodel to call visible_func for all rows. |
1198 | 1111 | # It also hides/shows boxes depending on whether they are empty. | 1107 | # It also hides/shows boxes depending on whether they are empty. |
1199 | @@ -1113,7 +1109,7 @@ | |||
1200 | 1113 | filterlist = self.trophies_collection_filters | 1109 | filterlist = self.trophies_collection_filters |
1201 | 1114 | elif self.display_mytrophies_filtermode is MYTROPHIES_FILTER_LATEST: | 1110 | elif self.display_mytrophies_filtermode is MYTROPHIES_FILTER_LATEST: |
1202 | 1115 | filterlist = self.mytrophies_latest_boxes | 1111 | filterlist = self.mytrophies_latest_boxes |
1204 | 1116 | 1112 | ||
1205 | 1117 | for f in filterlist: | 1113 | for f in filterlist: |
1206 | 1118 | f[0].refilter() | 1114 | f[0].refilter() |
1207 | 1119 | if len(f[0]) is 0: | 1115 | if len(f[0]) is 0: |
1208 | @@ -1124,7 +1120,7 @@ | |||
1209 | 1124 | def _update_opportunities_view(self): | 1120 | def _update_opportunities_view(self): |
1210 | 1125 | # Causes the treemodel to call visible_func for all rows. | 1121 | # Causes the treemodel to call visible_func for all rows. |
1211 | 1126 | self.oppstore_filtered.refilter() | 1122 | self.oppstore_filtered.refilter() |
1213 | 1127 | 1123 | ||
1214 | 1128 | def _opp_visible_func(self, model, iterator, data): | 1124 | def _opp_visible_func(self, model, iterator, data): |
1215 | 1129 | """ | 1125 | """ |
1216 | 1130 | This function is crucial for filtering opportunities. It is called | 1126 | This function is crucial for filtering opportunities. It is called |
1217 | @@ -1133,26 +1129,29 @@ | |||
1218 | 1133 | should be displayed or not. | 1129 | should be displayed or not. |
1219 | 1134 | """ | 1130 | """ |
1220 | 1135 | # If we are hiding locked accoms: | 1131 | # If we are hiding locked accoms: |
1222 | 1136 | if (self.display_filter_locked is DISPLAY_FILTER_LOCKED_HIDE) and model.get_value(iterator,COL_LOCKED): | 1132 | if (self.display_filter_locked is DISPLAY_FILTER_LOCKED_HIDE) and model.get_value(iterator, COL_LOCKED): |
1223 | 1137 | return False | 1133 | return False |
1224 | 1138 | # If we ale looking for a certain collection: | 1134 | # If we ale looking for a certain collection: |
1226 | 1139 | if (self.display_filter_collection != "") and (self.display_filter_collection != model.get_value(iterator,COL_COLLECTION)): | 1135 | if (self.display_filter_collection != "") and (self.display_filter_collection != model.get_value(iterator, COL_COLLECTION)): |
1227 | 1140 | return False | 1136 | return False |
1228 | 1141 | # If we ale looking for a certain category... | 1137 | # If we ale looking for a certain category... |
1229 | 1142 | if (self.display_filter_category != ""): | 1138 | if (self.display_filter_category != ""): |
1230 | 1143 | #...and a subcategory | 1139 | #...and a subcategory |
1231 | 1144 | if (self.display_filter_subcat != ""): | 1140 | if (self.display_filter_subcat != ""): |
1232 | 1145 | q = self.display_filter_category + ":" + self.display_filter_subcat | 1141 | q = self.display_filter_category + ":" + self.display_filter_subcat |
1234 | 1146 | if not (q in model.get_value(iterator,COL_CATEGORIES)): | 1142 | if not (q in model.get_value(iterator, COL_CATEGORIES)): |
1235 | 1147 | return False | 1143 | return False |
1237 | 1148 | if not (self.display_filter_category in model.get_value(iterator,COL_CATEGORIES)): | 1144 | if not (self.display_filter_category in model.get_value(iterator, COL_CATEGORIES)): |
1238 | 1149 | return False | 1145 | return False |
1239 | 1150 | # If there is a search term and this row does not match the query: | 1146 | # If there is a search term and this row does not match the query: |
1242 | 1151 | if (self.display_filter_search != "") and not (self.display_filter_search.lower() in model.get_value(iterator,COL_TITLE).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_KEYWORDS).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_ID).split("/")[1].lower()): | 1147 | if (self.display_filter_search != "") \ |
1243 | 1152 | return False | 1148 | and not (self.display_filter_search.lower() in model.get_value(iterator, COL_TITLE).lower()) \ |
1244 | 1149 | and not (self.display_filter_search.lower() in model.get_value(iterator, COL_KEYWORDS).lower()) \ | ||
1245 | 1150 | and not (self.display_filter_search.lower() in model.get_value(iterator, COL_ID).split("/")[1].lower()): | ||
1246 | 1151 | return False | ||
1247 | 1153 | return True | 1152 | return True |
1248 | 1154 | 1153 | ||
1250 | 1155 | def _trophy_recent_visible_func(self,model,iterator,data): | 1154 | def _trophy_recent_visible_func(self, model, iterator, data): |
1251 | 1156 | """ | 1155 | """ |
1252 | 1157 | This function is crucial for filtering recently awarded trophies. It is called | 1156 | This function is crucial for filtering recently awarded trophies. It is called |
1253 | 1158 | by some internal GTK callbacks, whenever the treemodel changes. | 1157 | by some internal GTK callbacks, whenever the treemodel changes. |
1254 | @@ -1164,50 +1163,53 @@ | |||
1255 | 1164 | 1163 | ||
1256 | 1165 | #XXX: Making these constants global might save some filtering time. | 1164 | #XXX: Making these constants global might save some filtering time. |
1257 | 1166 | today = datetime.date.today() | 1165 | today = datetime.date.today() |
1264 | 1167 | margin_today = datetime.timedelta(days = 1) | 1166 | margin_today = datetime.timedelta(days=1) |
1265 | 1168 | margin_week = datetime.timedelta(days = 7) | 1167 | margin_week = datetime.timedelta(days=7) |
1266 | 1169 | margin_month = datetime.timedelta(days = 31) | 1168 | margin_month = datetime.timedelta(days=31) |
1267 | 1170 | margin_sixmonths = datetime.timedelta(days = 180) | 1169 | margin_sixmonths = datetime.timedelta(days=180) |
1268 | 1171 | 1170 | ||
1269 | 1172 | when = model.get_value(iterator,COL_DATE_ACCOMPLISHED) | 1171 | when = model.get_value(iterator, COL_DATE_ACCOMPLISHED) |
1270 | 1173 | if when == "None": | 1172 | if when == "None": |
1271 | 1174 | return False | 1173 | return False |
1272 | 1175 | year, month, day = when.split("-") | 1174 | year, month, day = when.split("-") |
1273 | 1176 | when = datetime.date(int(year), int(month), int(day.split(" ")[0])) | 1175 | when = datetime.date(int(year), int(month), int(day.split(" ")[0])) |
1275 | 1177 | 1176 | ||
1276 | 1178 | if (today - margin_today <= when <= today + margin_today): | 1177 | if (today - margin_today <= when <= today + margin_today): |
1277 | 1179 | if data is TROPHIES_FILTER_TODAY: | 1178 | if data is TROPHIES_FILTER_TODAY: |
1279 | 1180 | pass #proceed to further filtering | 1179 | pass # proceed to further filtering |
1280 | 1181 | else: | 1180 | else: |
1281 | 1182 | return False | 1181 | return False |
1282 | 1183 | elif (today - margin_week <= when <= today + margin_week): | 1182 | elif (today - margin_week <= when <= today + margin_week): |
1283 | 1184 | if data is TROPHIES_FILTER_WEEK: | 1183 | if data is TROPHIES_FILTER_WEEK: |
1285 | 1185 | pass #proceed to further filtering | 1184 | pass # proceed to further filtering |
1286 | 1186 | else: | 1185 | else: |
1287 | 1187 | return False | 1186 | return False |
1288 | 1188 | elif (today - margin_month <= when <= today + margin_month): | 1187 | elif (today - margin_month <= when <= today + margin_month): |
1289 | 1189 | if data is TROPHIES_FILTER_MONTH: | 1188 | if data is TROPHIES_FILTER_MONTH: |
1291 | 1190 | pass #proceed to further filtering | 1189 | pass # proceed to further filtering |
1292 | 1191 | else: | 1190 | else: |
1293 | 1192 | return False | 1191 | return False |
1294 | 1193 | elif (today - margin_sixmonths <= when <= today + margin_sixmonths): | 1192 | elif (today - margin_sixmonths <= when <= today + margin_sixmonths): |
1295 | 1194 | if data is TROPHIES_FILTER_SIXMONTHS: | 1193 | if data is TROPHIES_FILTER_SIXMONTHS: |
1297 | 1195 | pass #proceed to further filtering | 1194 | pass # proceed to further filtering |
1298 | 1196 | else: | 1195 | else: |
1299 | 1197 | return False | 1196 | return False |
1300 | 1198 | else: | 1197 | else: |
1301 | 1199 | if data is TROPHIES_FILTER_EARLIER: | 1198 | if data is TROPHIES_FILTER_EARLIER: |
1303 | 1200 | pass #proceed to further filtering | 1199 | pass # proceed to further filtering |
1304 | 1201 | else: | 1200 | else: |
1305 | 1202 | return False | 1201 | return False |
1307 | 1203 | 1202 | ||
1308 | 1204 | # If there is a search term and this row does not match the query: | 1203 | # If there is a search term and this row does not match the query: |
1312 | 1205 | if (self.display_filter_search != "") and not (self.display_filter_search.lower() in model.get_value(iterator,COL_TITLE).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_KEYWORDS).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_ID).split("/")[1].lower()): | 1204 | if (self.display_filter_search != "") \ |
1313 | 1206 | return False | 1205 | and not (self.display_filter_search.lower() in model.get_value(iterator, COL_TITLE).lower()) \ |
1314 | 1207 | 1206 | and not (self.display_filter_search.lower() in model.get_value(iterator, COL_KEYWORDS).lower()) \ | |
1315 | 1207 | and not (self.display_filter_search.lower() in model.get_value(iterator, COL_ID).split("/")[1].lower()): | ||
1316 | 1208 | return False | ||
1317 | 1209 | |||
1318 | 1208 | return True | 1210 | return True |
1321 | 1209 | 1211 | ||
1322 | 1210 | def _trophy_all_visible_func(self,model,iterator,collection): | 1212 | def _trophy_all_visible_func(self, model, iterator, collection): |
1323 | 1211 | """ | 1213 | """ |
1324 | 1212 | This function is crucial for filtering mytrophies. It is called | 1214 | This function is crucial for filtering mytrophies. It is called |
1325 | 1213 | by some internal GTK callbacks, whenever the treemodel changes. | 1215 | by some internal GTK callbacks, whenever the treemodel changes. |
1326 | @@ -1216,14 +1218,16 @@ | |||
1327 | 1216 | The @data argument specifies filtered collection. | 1218 | The @data argument specifies filtered collection. |
1328 | 1217 | """ | 1219 | """ |
1329 | 1218 | # If row's collection matches the desired for this filter | 1220 | # If row's collection matches the desired for this filter |
1331 | 1219 | if (collection != model.get_value(iterator,COL_COLLECTION)): | 1221 | if (collection != model.get_value(iterator, COL_COLLECTION)): |
1332 | 1220 | return False | 1222 | return False |
1333 | 1221 | # If there is a search term and this row does not match the query: | 1223 | # If there is a search term and this row does not match the query: |
1336 | 1222 | if (self.display_filter_search != "") and not (self.display_filter_search.lower() in model.get_value(iterator,COL_TITLE).lower()) and not (self.display_filter_search.lower() in model.get_value(iterator,COL_ID).split("/")[1].lower()): | 1224 | if (self.display_filter_search != "") \ |
1337 | 1223 | return False | 1225 | and not (self.display_filter_search.lower() in model.get_value(iterator, COL_TITLE).lower()) \ |
1338 | 1226 | and not (self.display_filter_search.lower() in model.get_value(iterator, COL_ID).split("/")[1].lower()): | ||
1339 | 1227 | return False | ||
1340 | 1224 | return True | 1228 | return True |
1341 | 1225 | 1229 | ||
1343 | 1226 | def _update_subcats(self): | 1230 | def _update_subcats(self): |
1344 | 1227 | """ | 1231 | """ |
1345 | 1228 | This function creates the buttons for subcategories, requesting required data from the daemon. | 1232 | This function creates the buttons for subcategories, requesting required data from the daemon. |
1346 | 1229 | """ | 1233 | """ |
1347 | @@ -1238,15 +1242,17 @@ | |||
1348 | 1238 | tempcats = cats[c] | 1242 | tempcats = cats[c] |
1349 | 1239 | 1243 | ||
1350 | 1240 | finalcats = [] | 1244 | finalcats = [] |
1352 | 1241 | 1245 | ||
1353 | 1242 | for s in tempcats: | 1246 | for s in tempcats: |
1354 | 1243 | for i in self.accomdb: | 1247 | for i in self.accomdb: |
1356 | 1244 | if i["collection"] == self.display_filter_collection and i["categories"][0] == self.display_filter_category + ":" + s and i["accomplished"] == False: | 1248 | if i["collection"] == self.display_filter_collection \ |
1357 | 1249 | and i["categories"][0] == self.display_filter_category + ":" + s \ | ||
1358 | 1250 | and i["accomplished"] is False: | ||
1359 | 1245 | finalcats.append(s) | 1251 | finalcats.append(s) |
1360 | 1246 | 1252 | ||
1361 | 1247 | # convert to a set to remove dupes | 1253 | # convert to a set to remove dupes |
1362 | 1248 | finalcats = set(finalcats) | 1254 | finalcats = set(finalcats) |
1364 | 1249 | 1255 | ||
1365 | 1250 | # remove previous buttons from the button box | 1256 | # remove previous buttons from the button box |
1366 | 1251 | for b in self.subcats_buttonbox.get_children(): | 1257 | for b in self.subcats_buttonbox.get_children(): |
1367 | 1252 | self.subcats_buttonbox.remove(b) | 1258 | self.subcats_buttonbox.remove(b) |
1368 | @@ -1258,7 +1264,7 @@ | |||
1369 | 1258 | button.connect("clicked", self.subcat_clicked, "") | 1264 | button.connect("clicked", self.subcat_clicked, "") |
1370 | 1259 | self.subcats_buttonbox.add(button) | 1265 | self.subcats_buttonbox.add(button) |
1371 | 1260 | button.show() | 1266 | button.show() |
1373 | 1261 | 1267 | ||
1374 | 1262 | # fill the button box with the sub categories | 1268 | # fill the button box with the sub categories |
1375 | 1263 | for s in finalcats: | 1269 | for s in finalcats: |
1376 | 1264 | button = Gtk.Button(s) | 1270 | button = Gtk.Button(s) |
1377 | @@ -1266,34 +1272,37 @@ | |||
1378 | 1266 | button.connect("clicked", self.subcat_clicked, s) | 1272 | button.connect("clicked", self.subcat_clicked, s) |
1379 | 1267 | self.subcats_buttonbox.add(button) | 1273 | self.subcats_buttonbox.add(button) |
1380 | 1268 | button.show() | 1274 | button.show() |
1382 | 1269 | 1275 | ||
1383 | 1270 | self.subcats_buttonbox.show_all() | 1276 | self.subcats_buttonbox.show_all() |
1384 | 1271 | self.subcats_container.show() | 1277 | self.subcats_container.show() |
1385 | 1272 | else: | 1278 | else: |
1386 | 1273 | self.subcats_container.hide() | 1279 | self.subcats_container.hide() |
1388 | 1274 | 1280 | ||
1389 | 1275 | def _accomplishment_info(self, accomID): | 1281 | def _accomplishment_info(self, accomID): |
1390 | 1276 | """Display information about the selected accomplishment.""" | 1282 | """Display information about the selected accomplishment.""" |
1391 | 1277 | data = [] | 1283 | data = [] |
1393 | 1278 | 1284 | ||
1394 | 1279 | # determine dependencies | 1285 | # determine dependencies |
1396 | 1280 | 1286 | ||
1397 | 1281 | deps = [] | 1287 | deps = [] |
1398 | 1282 | depstatus = [] | 1288 | depstatus = [] |
1400 | 1283 | 1289 | ||
1401 | 1284 | deps = self.libaccom.get_accom_depends(accomID) | 1290 | deps = self.libaccom.get_accom_depends(accomID) |
1403 | 1285 | 1291 | ||
1404 | 1286 | for acc in self.accomdb: | 1292 | for acc in self.accomdb: |
1405 | 1287 | for d in deps: | 1293 | for d in deps: |
1406 | 1288 | if acc["id"] == d: | 1294 | if acc["id"] == d: |
1410 | 1289 | depstatus.append({ "id" : acc["id"], "accomplished" : acc["accomplished"], "collection-human" : acc["collection-human"], "title" : acc["title"] }) | 1295 | depstatus.append({ |
1411 | 1290 | 1296 | "id": acc["id"], | |
1412 | 1291 | 1297 | "accomplished": acc["accomplished"], | |
1413 | 1298 | "collection-human": acc["collection-human"], | ||
1414 | 1299 | "title": acc["title"] | ||
1415 | 1300 | }) | ||
1416 | 1301 | |||
1417 | 1292 | achieved = self.libaccom.get_accom_is_accomplished(accomID) | 1302 | achieved = self.libaccom.get_accom_is_accomplished(accomID) |
1418 | 1293 | data = self.libaccom.get_accom_data(accomID) | 1303 | data = self.libaccom.get_accom_data(accomID) |
1419 | 1294 | if achieved: | 1304 | if achieved: |
1420 | 1295 | trophydata = self.libaccom.get_trophy_data(accomID) | 1305 | trophydata = self.libaccom.get_trophy_data(accomID) |
1421 | 1296 | |||
1422 | 1297 | 1306 | ||
1423 | 1298 | html = None | 1307 | html = None |
1424 | 1299 | 1308 | ||
1425 | @@ -1311,17 +1320,16 @@ | |||
1426 | 1311 | html = html + "<div id='header' class='grid_8'> \ | 1320 | html = html + "<div id='header' class='grid_8'> \ |
1427 | 1312 | <h1>" + data['title'] + "</h1> \ | 1321 | <h1>" + data['title'] + "</h1> \ |
1428 | 1313 | </div>" | 1322 | </div>" |
1429 | 1314 | |||
1430 | 1315 | |||
1431 | 1316 | 1323 | ||
1432 | 1317 | ## summary table | 1324 | ## summary table |
1433 | 1318 | html = html + "<div id='accomplishment' class='grid_8 clearfix'> \ | 1325 | html = html + "<div id='accomplishment' class='grid_8 clearfix'> \ |
1434 | 1319 | <div id='accomplishment-badge' class='grid_8 clearfix'>" | 1326 | <div id='accomplishment-badge' class='grid_8 clearfix'>" |
1435 | 1320 | 1327 | ||
1436 | 1321 | if achieved and GWIBBER_OK: | 1328 | if achieved and GWIBBER_OK: |
1438 | 1322 | html = html + "<div id='social-share'><a href='gwibber-share?accomID="+accomID+"' id='gwibber-share'>+SHARE</a></div>" | 1329 | html = html + "<div id='social-share'><a href='gwibber-share?accomID=" + accomID + \ |
1439 | 1330 | "' id='gwibber-share'>+SHARE</a></div>" | ||
1440 | 1323 | 1331 | ||
1442 | 1324 | html = html +"<img class='icon' src='" + str(iconpath) + "'> \ | 1332 | html = html + "<img class='icon' src='" + str(iconpath) + "'> \ |
1443 | 1325 | <div class='grid_3 block'> \ | 1333 | <div class='grid_3 block'> \ |
1444 | 1326 | <h4>" + _("Opportunity Information").decode('utf-8') + ":</h4> \ | 1334 | <h4>" + _("Opportunity Information").decode('utf-8') + ":</h4> \ |
1445 | 1327 | <ul class='none'> \ | 1335 | <ul class='none'> \ |
1446 | @@ -1332,53 +1340,59 @@ | |||
1447 | 1332 | html = html + description | 1340 | html = html + description |
1448 | 1333 | else: | 1341 | else: |
1449 | 1334 | html = html + _("No information available.").decode('utf-8') | 1342 | html = html + _("No information available.").decode('utf-8') |
1452 | 1335 | 1343 | ||
1451 | 1336 | |||
1453 | 1337 | html = html + "</li> \ | 1344 | html = html + "</li> \ |
1454 | 1338 | </ul> \ | 1345 | </ul> \ |
1455 | 1339 | </div>" | 1346 | </div>" |
1456 | 1340 | 1347 | ||
1457 | 1341 | if not achieved: | 1348 | if not achieved: |
1459 | 1342 | 1349 | ||
1460 | 1343 | html = html + "<div class='grid_3 block'> \ | 1350 | html = html + "<div class='grid_3 block'> \ |
1461 | 1344 | <h4>" + _("Getting Help").decode('utf-8') + ":</h4> \ | 1351 | <h4>" + _("Getting Help").decode('utf-8') + ":</h4> \ |
1462 | 1345 | <ul class='none'>" | 1352 | <ul class='none'>" |
1464 | 1346 | 1353 | ||
1465 | 1347 | if "help" in data: | 1354 | if "help" in data: |
1466 | 1348 | help = data["help"] | 1355 | help = data["help"] |
1467 | 1349 | 1356 | ||
1468 | 1350 | for l in help.split('\n'): | 1357 | for l in help.split('\n'): |
1472 | 1351 | channelName = l[l.find("#")+1:l.find(" ")] | 1358 | channelName = l[l.find("#") + 1:l.find(" ")] |
1473 | 1352 | if l.startswith( '#'+channelName ): | 1359 | if l.startswith('#' + channelName): |
1474 | 1353 | l = "<a style='color:#FFF' href='http://webchat.freenode.net/?channels="+channelName+"'>"+'#'+channelName+" on freenode</a>" | 1360 | l = "<a style='color:#FFF' href='http://webchat.freenode.net/?channels=" + channelName + "'>" \ |
1475 | 1361 | + '#' + channelName + " on freenode</a>" | ||
1476 | 1354 | html = html + "<li>" + l + "</li>" | 1362 | html = html + "<li>" + l + "</li>" |
1477 | 1355 | else: | 1363 | else: |
1479 | 1356 | html = html + "<li>" + l + "</li>" | 1364 | html = html + "<li>" + l + "</li>" |
1480 | 1357 | else: | 1365 | else: |
1481 | 1358 | html = html + "<li>" + _("No help available.").decode('utf-8') + "</li>" | 1366 | html = html + "<li>" + _("No help available.").decode('utf-8') + "</li>" |
1483 | 1359 | 1367 | ||
1484 | 1360 | html = html + "</ul></div>" | 1368 | html = html + "</ul></div>" |
1485 | 1361 | 1369 | ||
1486 | 1362 | |||
1487 | 1363 | html = html + "</div>" | 1370 | html = html + "</div>" |
1488 | 1364 | 1371 | ||
1489 | 1365 | html = html + "<div id='accomplishment-conditions' class='grid_8'> \ | 1372 | html = html + "<div id='accomplishment-conditions' class='grid_8'> \ |
1490 | 1366 | <ul class='none'>" | 1373 | <ul class='none'>" |
1492 | 1367 | 1374 | ||
1493 | 1368 | if "depends" in data: | 1375 | if "depends" in data: |
1494 | 1369 | # check if it is locked | 1376 | # check if it is locked |
1495 | 1370 | if not self.libaccom.get_accom_is_unlocked(accomID): | 1377 | if not self.libaccom.get_accom_is_unlocked(accomID): |
1496 | 1371 | if len(depstatus) > 0: | 1378 | if len(depstatus) > 0: |
1497 | 1372 | if len(depstatus) == 1: | 1379 | if len(depstatus) == 1: |
1499 | 1373 | html = html + "<li><i class='icon-key icon-large'></i>" + _("This opportunity is locked. You need to complete").decode('utf-8') + " <a href='accomplishment://" + depstatus[0]["id"] + "'><strong>" + depstatus[0]["title"] + "</strong></a> " + _("from").decode('utf-8') +" <strong>" + depstatus[0]["collection-human"] + "</strong> " + _("first").decode('utf-8') + ".</li>" | 1380 | html = html + "<li><i class='icon-key icon-large'></i>" + \ |
1500 | 1381 | _("This opportunity is locked. You need to complete").decode('utf-8') + \ | ||
1501 | 1382 | " <a href='accomplishment://" + depstatus[0]["id"] + "'><strong>" + \ | ||
1502 | 1383 | depstatus[0]["title"] + "</strong></a> " + _("from").decode('utf-8') + \ | ||
1503 | 1384 | " <strong>" + depstatus[0]["collection-human"] + "</strong> " + \ | ||
1504 | 1385 | _("first").decode('utf-8') + ".</li>" | ||
1505 | 1374 | else: | 1386 | else: |
1506 | 1375 | html = html + "<li><i class='icon-key icon-large'></i>" + _("This opportunity is locked. You need to complete the following opportunities first:").decode('utf-8') + "</li>" | 1387 | html = html + "<li><i class='icon-key icon-large'></i>" + _("This opportunity is locked. You need to complete the following opportunities first:").decode('utf-8') + "</li>" |
1507 | 1376 | for d in depstatus: | 1388 | for d in depstatus: |
1510 | 1377 | if d["accomplished"] == False: | 1389 | if d["accomplished"] is False: |
1511 | 1378 | html = html + "<li class='deps_child'><a href='accomplishment://" + d["id"] + "'><strong>" + d["title"] + "</strong></a> " + _("from").decode('utf-8') +" <strong>" + d["collection-human"] + "</strong></li>" | 1390 | html = html + "<li class='deps_child'><a href='accomplishment://" + d["id"] + \ |
1512 | 1391 | "'><strong>" + d["title"] + "</strong></a> " + _("from").decode('utf-8') + \ | ||
1513 | 1392 | " <strong>" + d["collection-human"] + "</strong></li>" | ||
1514 | 1379 | if achieved: | 1393 | if achieved: |
1515 | 1380 | #achieved | 1394 | #achieved |
1517 | 1381 | 1395 | ||
1518 | 1382 | html = html + "<li><img src='" + str(get_media_file("verify-icon.png")) + "' height='20' />" + _("This trophy <strong>was awarded</strong>").decode('utf-8') | 1396 | html = html + "<li><img src='" + str(get_media_file("verify-icon.png")) + "' height='20' />" + _("This trophy <strong>was awarded</strong>").decode('utf-8') |
1519 | 1383 | 1397 | ||
1520 | 1384 | if "date-accomplished" in trophydata: | 1398 | if "date-accomplished" in trophydata: |
1521 | @@ -1389,10 +1403,10 @@ | |||
1522 | 1389 | extrainfo = trophydata["needs-information"].split(" ") | 1403 | extrainfo = trophydata["needs-information"].split(" ") |
1523 | 1390 | html = html + ", " + _("using the following credentials").decode('utf-8') + ":</li><li><ul class='big'>" | 1404 | html = html + ", " + _("using the following credentials").decode('utf-8') + ":</li><li><ul class='big'>" |
1524 | 1391 | for i in extrainfo: | 1405 | for i in extrainfo: |
1526 | 1392 | e = self.libaccom.get_extra_information(accomID.split("/")[0],i) | 1406 | e = self.libaccom.get_extra_information(accomID.split("/")[0], i) |
1527 | 1393 | html = html + "<li>" + e[0]["label"] + ": " + trophydata[i] + "</li>" | 1407 | html = html + "<li>" + e[0]["label"] + ": " + trophydata[i] + "</li>" |
1528 | 1394 | html = html + "</ul></li>" | 1408 | html = html + "</ul></li>" |
1530 | 1395 | else: | 1409 | else: |
1531 | 1396 | html = html + ".</li>" | 1410 | html = html + ".</li>" |
1532 | 1397 | 1411 | ||
1533 | 1398 | if "needs-signing" in data: | 1412 | if "needs-signing" in data: |
1534 | @@ -1430,17 +1444,15 @@ | |||
1535 | 1430 | else: | 1444 | else: |
1536 | 1431 | #details not hidden by default | 1445 | #details not hidden by default |
1537 | 1432 | html = html + "<div>" | 1446 | html = html + "<div>" |
1540 | 1433 | 1447 | ||
1539 | 1434 | |||
1541 | 1435 | if "summary" in data: | 1448 | if "summary" in data: |
1542 | 1436 | html = html + "<div id='accompilshment-info' class='grid_8'>" | 1449 | html = html + "<div id='accompilshment-info' class='grid_8'>" |
1543 | 1437 | summary = data["summary"] | 1450 | summary = data["summary"] |
1544 | 1438 | for l in summary.split('\n'): | 1451 | for l in summary.split('\n'): |
1546 | 1439 | html = html + "<p>" + l + "</p>" | 1452 | html = html + "<p>" + l + "</p>" |
1547 | 1440 | html = html + "</div>" | 1453 | html = html + "</div>" |
1548 | 1441 | 1454 | ||
1551 | 1442 | 1455 | html = html + "<div id='accomplishment-more' class='grid_8'>" | |
1550 | 1443 | html = html + "<div id='accomplishment-more' class='grid_8'>" | ||
1552 | 1444 | 1456 | ||
1553 | 1445 | if "steps" in data: | 1457 | if "steps" in data: |
1554 | 1446 | 1458 | ||
1555 | @@ -1448,7 +1460,7 @@ | |||
1556 | 1448 | <i class='icon-list'></i> \ | 1460 | <i class='icon-list'></i> \ |
1557 | 1449 | <h2>" + _("How to accomplish this opportunity").decode('utf-8') + "</h2> \ | 1461 | <h2>" + _("How to accomplish this opportunity").decode('utf-8') + "</h2> \ |
1558 | 1450 | <ol>" | 1462 | <ol>" |
1560 | 1451 | 1463 | ||
1561 | 1452 | steps = data["steps"] | 1464 | steps = data["steps"] |
1562 | 1453 | for l in steps.split('\n'): | 1465 | for l in steps.split('\n'): |
1563 | 1454 | html = html + "<li class='icon-pushpin'>" + l + "</li>" | 1466 | html = html + "<li class='icon-pushpin'>" + l + "</li>" |
1564 | @@ -1458,7 +1470,7 @@ | |||
1565 | 1458 | showtipspitfalls = False | 1470 | showtipspitfalls = False |
1566 | 1459 | haspitfalls = False | 1471 | haspitfalls = False |
1567 | 1460 | hastips = False | 1472 | hastips = False |
1569 | 1461 | 1473 | ||
1570 | 1462 | if "tips" in data or "pitfalls" in data: | 1474 | if "tips" in data or "pitfalls" in data: |
1571 | 1463 | try: | 1475 | try: |
1572 | 1464 | if not data["tips"] == "None": | 1476 | if not data["tips"] == "None": |
1573 | @@ -1466,51 +1478,51 @@ | |||
1574 | 1466 | hastips = True | 1478 | hastips = True |
1575 | 1467 | except: | 1479 | except: |
1576 | 1468 | hastips = False | 1480 | hastips = False |
1578 | 1469 | 1481 | ||
1579 | 1470 | try: | 1482 | try: |
1580 | 1471 | if not data["pitfalls"] == "None": | 1483 | if not data["pitfalls"] == "None": |
1582 | 1472 | showtipspitfalls = True | 1484 | showtipspitfalls = True |
1583 | 1473 | haspitfalls = True | 1485 | haspitfalls = True |
1584 | 1474 | except: | 1486 | except: |
1585 | 1475 | haspitfalls = False | 1487 | haspitfalls = False |
1588 | 1476 | 1488 | ||
1589 | 1477 | if showtipspitfalls == True: | 1489 | if showtipspitfalls is True: |
1590 | 1478 | html = html + " <div id='tipspitfalls' class='grid_8 clearfix'>" | 1490 | html = html + " <div id='tipspitfalls' class='grid_8 clearfix'>" |
1591 | 1479 | else: | 1491 | else: |
1595 | 1480 | showtipspitfalls == False | 1492 | showtipspitfalls is False |
1596 | 1481 | 1493 | ||
1597 | 1482 | if showtipspitfalls == True: | 1494 | if showtipspitfalls is True: |
1598 | 1483 | html = html + "<div class='grid_4 block left' id='tips'>" | 1495 | html = html + "<div class='grid_4 block left' id='tips'>" |
1599 | 1484 | html = html + "<h2>" + _("Tips and Tricks").decode('utf-8') + ":</h2>" | 1496 | html = html + "<h2>" + _("Tips and Tricks").decode('utf-8') + ":</h2>" |
1602 | 1485 | 1497 | ||
1603 | 1486 | if hastips == True: | 1498 | if hastips is True: |
1604 | 1487 | tips = data["tips"] | 1499 | tips = data["tips"] |
1605 | 1488 | else: | 1500 | else: |
1606 | 1489 | tips = None | 1501 | tips = None |
1608 | 1490 | 1502 | ||
1609 | 1491 | html = html + "<ul>" | 1503 | html = html + "<ul>" |
1610 | 1492 | 1504 | ||
1612 | 1493 | if tips == None: | 1505 | if tips is None: |
1613 | 1494 | html = html + "<li class='icon-ok'>" + _("None.").decode('utf-8') + "</li>" | 1506 | html = html + "<li class='icon-ok'>" + _("None.").decode('utf-8') + "</li>" |
1614 | 1495 | else: | 1507 | else: |
1615 | 1496 | for t in tips.split('\n'): | 1508 | for t in tips.split('\n'): |
1616 | 1497 | html = html + "<li class='icon-ok'>" + t + "</li>" | 1509 | html = html + "<li class='icon-ok'>" + t + "</li>" |
1618 | 1498 | 1510 | ||
1619 | 1499 | html = html + "</ul>" | 1511 | html = html + "</ul>" |
1620 | 1500 | html = html + "</div>" | 1512 | html = html + "</div>" |
1621 | 1501 | 1513 | ||
1622 | 1502 | html = html + "<div id='divider' class='left'> </div>" | 1514 | html = html + "<div id='divider' class='left'> </div>" |
1623 | 1503 | html = html + "<div class='grid_3 block left' id='pitfals'>" | 1515 | html = html + "<div class='grid_3 block left' id='pitfals'>" |
1624 | 1504 | html = html + "<h2>" + _("Pitfalls To Avoid").decode('utf-8') + ":</h2>" | 1516 | html = html + "<h2>" + _("Pitfalls To Avoid").decode('utf-8') + ":</h2>" |
1627 | 1505 | 1517 | ||
1628 | 1506 | if haspitfalls == True: | 1518 | if haspitfalls is True: |
1629 | 1507 | pitfalls = data["pitfalls"] | 1519 | pitfalls = data["pitfalls"] |
1630 | 1508 | else: | 1520 | else: |
1631 | 1509 | pitfalls = None | 1521 | pitfalls = None |
1633 | 1510 | 1522 | ||
1634 | 1511 | html = html + "<ul>" | 1523 | html = html + "<ul>" |
1635 | 1512 | 1524 | ||
1637 | 1513 | if pitfalls == None: | 1525 | if pitfalls is None: |
1638 | 1514 | html = html + "<li class='icon-remove'>" + _("None.").decode('utf-8') + "</li>" | 1526 | html = html + "<li class='icon-remove'>" + _("None.").decode('utf-8') + "</li>" |
1639 | 1515 | else: | 1527 | else: |
1640 | 1516 | for p in pitfalls.split('\n'): | 1528 | for p in pitfalls.split('\n'): |
1641 | @@ -1537,4 +1549,3 @@ | |||
1642 | 1537 | 1549 | ||
1643 | 1538 | self.webview.load_html_string(html, "file:///") | 1550 | self.webview.load_html_string(html, "file:///") |
1644 | 1539 | self.webview.show() | 1551 | self.webview.show() |
1645 | 1540 | |||
1646 | 1541 | 1552 | ||
1647 | === modified file 'accomplishments_viewer/EditExtrainfoDialog.py' | |||
1648 | --- accomplishments_viewer/EditExtrainfoDialog.py 2012-11-22 10:42:15 +0000 | |||
1649 | +++ accomplishments_viewer/EditExtrainfoDialog.py 2012-11-26 16:03:25 +0000 | |||
1650 | @@ -1,48 +1,45 @@ | |||
1651 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
1652 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
1653 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
1656 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
1657 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
1658 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
1663 | 7 | # | 7 | # |
1664 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
1665 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
1666 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1667 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
1670 | 12 | # | 12 | # |
1671 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
1672 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
1673 | 15 | ### END LICENSE | 15 | ### END LICENSE |
1674 | 16 | import logging | ||
1675 | 17 | 16 | ||
1677 | 18 | from gi.repository import Gtk # pylint: disable=E0611 | 17 | from gi.repository import Gtk # pylint: disable=E0611 |
1678 | 19 | from operator import itemgetter | 18 | from operator import itemgetter |
1679 | 20 | from accomplishments_viewer_lib.helpers import get_builder | 19 | from accomplishments_viewer_lib.helpers import get_builder |
1680 | 21 | from accomplishments.daemon import dbusapi | ||
1681 | 22 | 20 | ||
1684 | 23 | import gettext, locale | 21 | import gettext |
1685 | 24 | from locale import gettext as _ | 22 | import locale |
1686 | 25 | from accomplishments.util.paths import locale_dir | 23 | from accomplishments.util.paths import locale_dir |
1687 | 26 | locale.bindtextdomain('accomplishments-viewer', locale_dir) | 24 | locale.bindtextdomain('accomplishments-viewer', locale_dir) |
1689 | 27 | gettext.bindtextdomain('accomplishments-viewer',locale_dir) | 25 | gettext.bindtextdomain('accomplishments-viewer', locale_dir) |
1690 | 28 | locale.textdomain('accomplishments-viewer') | 26 | locale.textdomain('accomplishments-viewer') |
1694 | 29 | 27 | ||
1695 | 30 | 28 | ||
1693 | 31 | |||
1696 | 32 | class EditExtrainfoDialog(Gtk.Dialog): | 29 | class EditExtrainfoDialog(Gtk.Dialog): |
1697 | 33 | __gtype_name__ = "EditExtrainfoDialog" | 30 | __gtype_name__ = "EditExtrainfoDialog" |
1699 | 34 | 31 | ||
1700 | 35 | def __new__(cls): | 32 | def __new__(cls): |
1702 | 36 | """Special static method that's automatically called by Python when | 33 | """Special static method that's automatically called by Python when |
1703 | 37 | constructing a new instance of this class. | 34 | constructing a new instance of this class. |
1705 | 38 | 35 | ||
1706 | 39 | Returns a fully instantiated EditExtrainfoDialog object. | 36 | Returns a fully instantiated EditExtrainfoDialog object. |
1707 | 40 | """ | 37 | """ |
1708 | 41 | builder = get_builder('EditExtrainfoDialog') | 38 | builder = get_builder('EditExtrainfoDialog') |
1709 | 42 | new_object = builder.get_object('edit_extrainfo_dialog') | 39 | new_object = builder.get_object('edit_extrainfo_dialog') |
1710 | 43 | new_object.finish_initializing(builder) | 40 | new_object.finish_initializing(builder) |
1711 | 44 | return new_object | 41 | return new_object |
1713 | 45 | 42 | ||
1714 | 46 | def finish_initializing(self, builder): | 43 | def finish_initializing(self, builder): |
1715 | 47 | """Called when we're finished initializing. | 44 | """Called when we're finished initializing. |
1716 | 48 | 45 | ||
1717 | @@ -54,33 +51,33 @@ | |||
1718 | 54 | # Get a reference to the builder and set up the signals. | 51 | # Get a reference to the builder and set up the signals. |
1719 | 55 | self.builder = builder | 52 | self.builder = builder |
1720 | 56 | self.ui = builder.get_ui(self) | 53 | self.ui = builder.get_ui(self) |
1725 | 57 | self.auth_box = builder.get_object('auth_box') | 54 | self.auth_box = builder.get_object('auth_box') |
1726 | 58 | self.btn_ok = builder.get_object('btn_ok') | 55 | self.btn_ok = builder.get_object('btn_ok') |
1727 | 59 | 56 | ||
1728 | 60 | def prepare(self,libaccom): | 57 | def prepare(self, libaccom): |
1729 | 61 | """Called before run()nig, setups the window""" | 58 | """Called before run()nig, setups the window""" |
1730 | 62 | # use self.parent.libaccom for calling | 59 | # use self.parent.libaccom for calling |
1731 | 63 | # use self.parent.connected to check if connected to daemon | 60 | # use self.parent.connected to check if connected to daemon |
1732 | 64 | self.libaccom = libaccom | 61 | self.libaccom = libaccom |
1734 | 65 | 62 | ||
1735 | 66 | i = self.libaccom.get_all_extra_information() | 63 | i = self.libaccom.get_all_extra_information() |
1737 | 67 | 64 | ||
1738 | 68 | self.entries_map = {} | 65 | self.entries_map = {} |
1740 | 69 | 66 | ||
1741 | 70 | #remove all widgets that are contained in the auth_box | 67 | #remove all widgets that are contained in the auth_box |
1742 | 71 | #they will be there since the previous prepare() call | 68 | #they will be there since the previous prepare() call |
1743 | 72 | c = self.auth_box.get_child() | 69 | c = self.auth_box.get_child() |
1744 | 73 | if c is not None: | 70 | if c is not None: |
1745 | 74 | self.auth_box.remove(c) | 71 | self.auth_box.remove(c) |
1747 | 75 | 72 | ||
1748 | 76 | if len(i) is not 0: | 73 | if len(i) is not 0: |
1749 | 77 | #there what to ask for | 74 | #there what to ask for |
1750 | 78 | self.main_box = Gtk.VBox() | 75 | self.main_box = Gtk.VBox() |
1751 | 79 | self.auth_box.add(self.main_box) | 76 | self.auth_box.add(self.main_box) |
1753 | 80 | 77 | ||
1754 | 81 | #essential. It ensures we'll append items to section_dict, in an unchanging order. | 78 | #essential. It ensures we'll append items to section_dict, in an unchanging order. |
1755 | 82 | infoneeded = sorted(i, key=itemgetter('collection')) | 79 | infoneeded = sorted(i, key=itemgetter('collection')) |
1757 | 83 | 80 | ||
1758 | 84 | section_dict = {} | 81 | section_dict = {} |
1759 | 85 | extrainfo_dict = {} | 82 | extrainfo_dict = {} |
1760 | 86 | #section dict looks like: { "launchpad-email" : ["ubuntu-community","ubuntu-community-italy"], | 83 | #section dict looks like: { "launchpad-email" : ["ubuntu-community","ubuntu-community-italy"], |
1761 | @@ -96,43 +93,42 @@ | |||
1762 | 96 | extrainfo_dict[i["needs-information"]] = i | 93 | extrainfo_dict[i["needs-information"]] = i |
1763 | 97 | for a in section_dict: | 94 | for a in section_dict: |
1764 | 98 | section_dict[a] = tuple(section_dict[a]) | 95 | section_dict[a] = tuple(section_dict[a]) |
1767 | 99 | 96 | ||
1766 | 100 | |||
1768 | 101 | rev_section_dict = {} | 97 | rev_section_dict = {} |
1769 | 102 | #the rev_section_dict shal be the grouped inverse of section_dict: | 98 | #the rev_section_dict shal be the grouped inverse of section_dict: |
1770 | 103 | # { ("ubuntu-community","ubuntu-community-italy",) : ["launchpad-email","magic-token"], | 99 | # { ("ubuntu-community","ubuntu-community-italy",) : ["launchpad-email","magic-token"], |
1771 | 104 | # ("askubuntu",) : ["askubuntu-login"], | 100 | # ("askubuntu",) : ["askubuntu-login"], |
1772 | 105 | # ("openshot", "otherapp",) : ["github-id"] } | 101 | # ("openshot", "otherapp",) : ["github-id"] } |
1775 | 106 | # | 102 | # |
1776 | 107 | 103 | ||
1777 | 108 | for i in section_dict: | 104 | for i in section_dict: |
1778 | 109 | d = section_dict[i] | 105 | d = section_dict[i] |
1779 | 110 | if d not in rev_section_dict: | 106 | if d not in rev_section_dict: |
1780 | 111 | rev_section_dict[d] = list([i]) | 107 | rev_section_dict[d] = list([i]) |
1781 | 112 | else: | 108 | else: |
1782 | 113 | rev_section_dict[d].append(i) | 109 | rev_section_dict[d].append(i) |
1786 | 114 | 110 | ||
1787 | 115 | #print rev_section_dict | 111 | #print rev_section_dict |
1788 | 116 | 112 | ||
1789 | 117 | for i in sorted(rev_section_dict.keys(), reverse=True, key=len): | 113 | for i in sorted(rev_section_dict.keys(), reverse=True, key=len): |
1790 | 118 | #the gui code is here - done for every GROUP of entry fields | 114 | #the gui code is here - done for every GROUP of entry fields |
1791 | 119 | d = rev_section_dict[i] | 115 | d = rev_section_dict[i] |
1793 | 120 | 116 | ||
1794 | 121 | g_box = Gtk.VBox() | 117 | g_box = Gtk.VBox() |
1795 | 122 | g_box.set_margin_bottom(20) | 118 | g_box.set_margin_bottom(20) |
1796 | 123 | g_box.set_margin_left(10) | 119 | g_box.set_margin_left(10) |
1799 | 124 | self.main_box.pack_start(g_box,True,False,0) | 120 | self.main_box.pack_start(g_box, True, False, 0) |
1800 | 125 | 121 | ||
1801 | 126 | g_upbox = Gtk.HBox() | 122 | g_upbox = Gtk.HBox() |
1804 | 127 | g_box.pack_start(g_upbox,True,False,0) | 123 | g_box.pack_start(g_upbox, True, False, 0) |
1805 | 128 | 124 | ||
1806 | 129 | g_upimage = Gtk.Image() | 125 | g_upimage = Gtk.Image() |
1807 | 130 | g_upimage.set_margin_left(5) | 126 | g_upimage.set_margin_left(5) |
1808 | 131 | g_upimage.set_margin_top(5) | 127 | g_upimage.set_margin_top(5) |
1809 | 132 | g_upimage.set_margin_bottom(5) | 128 | g_upimage.set_margin_bottom(5) |
1810 | 133 | g_upimage.set_margin_right(5) | 129 | g_upimage.set_margin_right(5) |
1813 | 134 | g_upimage.set_from_stock(Gtk.STOCK_GO_FORWARD,Gtk.IconSize.LARGE_TOOLBAR) | 130 | g_upimage.set_from_stock(Gtk.STOCK_GO_FORWARD, Gtk.IconSize.LARGE_TOOLBAR) |
1814 | 135 | 131 | ||
1815 | 136 | #temporarily we'll use an ugly name | 132 | #temporarily we'll use an ugly name |
1816 | 137 | n = len(i) | 133 | n = len(i) |
1817 | 138 | if n is 1: | 134 | if n is 1: |
1818 | @@ -141,32 +137,32 @@ | |||
1819 | 141 | name = self.libaccom.get_collection_name(i[0]) + " and " + self.libaccom.get_collection_name(i[1]) | 137 | name = self.libaccom.get_collection_name(i[0]) + " and " + self.libaccom.get_collection_name(i[1]) |
1820 | 142 | else: | 138 | else: |
1821 | 143 | name = "" | 139 | name = "" |
1824 | 144 | for k in range(0,n): | 140 | for k in range(0, n): |
1825 | 145 | if n-k > 2: | 141 | if n - k > 2: |
1826 | 146 | name = name + self.libaccom.get_collection_name(i[k]) + ", " | 142 | name = name + self.libaccom.get_collection_name(i[k]) + ", " |
1828 | 147 | elif n-k is 2: | 143 | elif n - k is 2: |
1829 | 148 | name = name + self.libaccom.get_collection_name(i[k]) + " and " | 144 | name = name + self.libaccom.get_collection_name(i[k]) + " and " |
1831 | 149 | elif n-k is 1: | 145 | elif n - k is 1: |
1832 | 150 | name = name + self.libaccom.get_collection_name(i[k]) | 146 | name = name + self.libaccom.get_collection_name(i[k]) |
1834 | 151 | 147 | ||
1835 | 152 | g_uplabel = Gtk.Label("<big><b>" + name + "</b></big>") | 148 | g_uplabel = Gtk.Label("<big><b>" + name + "</b></big>") |
1836 | 153 | g_uplabel.set_use_markup(True) | 149 | g_uplabel.set_use_markup(True) |
1837 | 154 | g_uplabel.set_margin_left(10) | 150 | g_uplabel.set_margin_left(10) |
1838 | 155 | #g_uplabel.set_halign(Gtk.Align.START) | 151 | #g_uplabel.set_halign(Gtk.Align.START) |
1840 | 156 | 152 | ||
1841 | 157 | g_sep = Gtk.HSeparator() | 153 | g_sep = Gtk.HSeparator() |
1844 | 158 | g_box.pack_start(g_sep,True,False,0) | 154 | g_box.pack_start(g_sep, True, False, 0) |
1845 | 159 | 155 | ||
1846 | 160 | for f in d: | 156 | for f in d: |
1847 | 161 | #for each information field in the group... | 157 | #for each information field in the group... |
1848 | 162 | extrainfo = extrainfo_dict[f] | 158 | extrainfo = extrainfo_dict[f] |
1849 | 163 | label = extrainfo['label'] | 159 | label = extrainfo['label'] |
1851 | 164 | label = label.replace("&","&") #pango would complain on that | 160 | label = label.replace("&", "&") # pango would complain on that |
1852 | 165 | description = extrainfo['description'] | 161 | description = extrainfo['description'] |
1854 | 166 | description = description.replace("&","&") #pango would complain on that | 162 | description = description.replace("&", "&") # pango would complain on that |
1855 | 167 | value = extrainfo['value'] | 163 | value = extrainfo['value'] |
1856 | 168 | example = extrainfo.get('example') | 164 | example = extrainfo.get('example') |
1858 | 169 | 165 | ||
1859 | 170 | g_entrybox = Gtk.HBox() | 166 | g_entrybox = Gtk.HBox() |
1860 | 171 | g_mainlabel = Gtk.Label(label) | 167 | g_mainlabel = Gtk.Label(label) |
1861 | 172 | g_mainlabel.set_justify(Gtk.Justification.RIGHT) | 168 | g_mainlabel.set_justify(Gtk.Justification.RIGHT) |
1862 | @@ -177,31 +173,31 @@ | |||
1863 | 177 | g_entry.set_text(value) | 173 | g_entry.set_text(value) |
1864 | 178 | g_desclabel = Gtk.Label("<small><small><b>" + description + "</b></small></small>") | 174 | g_desclabel = Gtk.Label("<small><small><b>" + description + "</b></small></small>") |
1865 | 179 | g_desclabel.set_use_markup(True) | 175 | g_desclabel.set_use_markup(True) |
1867 | 180 | g_desclabel.set_alignment(1,0) | 176 | g_desclabel.set_alignment(1, 0) |
1868 | 181 | 177 | ||
1869 | 182 | if example: | 178 | if example: |
1870 | 183 | g_example = Gtk.Label("<small><small><b>Example: " + example + "</b></small></small>") | 179 | g_example = Gtk.Label("<small><small><b>Example: " + example + "</b></small></small>") |
1871 | 184 | g_example.set_use_markup(True) | 180 | g_example.set_use_markup(True) |
1873 | 185 | g_example.set_alignment(1,0) | 181 | g_example.set_alignment(1, 0) |
1874 | 186 | g_example.set_margin_right(20) | 182 | g_example.set_margin_right(20) |
1876 | 187 | 183 | ||
1877 | 188 | g_entrybox.set_margin_right(20) | 184 | g_entrybox.set_margin_right(20) |
1878 | 189 | g_desclabel.set_margin_right(20) | 185 | g_desclabel.set_margin_right(20) |
1882 | 190 | 186 | ||
1883 | 191 | g_box.pack_start(g_entrybox,True,False,0) | 187 | g_box.pack_start(g_entrybox, True, False, 0) |
1884 | 192 | g_box.pack_start(g_desclabel,True,False,0) | 188 | g_box.pack_start(g_desclabel, True, False, 0) |
1885 | 193 | if example: | 189 | if example: |
1895 | 194 | g_box.pack_start(g_example,True,False,0) | 190 | g_box.pack_start(g_example, True, False, 0) |
1896 | 195 | g_entrybox.pack_end(g_entry,False,False,0) | 191 | g_entrybox.pack_end(g_entry, False, False, 0) |
1897 | 196 | g_entrybox.pack_end(g_mainlabel,False,False,0) | 192 | g_entrybox.pack_end(g_mainlabel, False, False, 0) |
1898 | 197 | 193 | ||
1899 | 198 | self.entries_map[f] = [g_entry,value] | 194 | self.entries_map[f] = [g_entry, value] |
1900 | 199 | 195 | ||
1901 | 200 | g_upbox.pack_start(g_upimage,False,False,0) | 196 | g_upbox.pack_start(g_upimage, False, False, 0) |
1902 | 201 | g_upbox.pack_start(g_uplabel,False,True,0) | 197 | g_upbox.pack_start(g_uplabel, False, True, 0) |
1903 | 202 | 198 | ||
1904 | 203 | self.auth_box.show_all() | 199 | self.auth_box.show_all() |
1906 | 204 | 200 | ||
1907 | 205 | else: | 201 | else: |
1908 | 206 | #no point in asking at all | 202 | #no point in asking at all |
1909 | 207 | label = Gtk.Label("<i>(no extra-information is required, most likely there is something wrong with your installtion)</i>") | 203 | label = Gtk.Label("<i>(no extra-information is required, most likely there is something wrong with your installtion)</i>") |
1910 | @@ -214,26 +210,25 @@ | |||
1911 | 214 | """Proxy function that simply calls the OK button when the user | 210 | """Proxy function that simply calls the OK button when the user |
1912 | 215 | has pressed Enter on a textbox.""" | 211 | has pressed Enter on a textbox.""" |
1913 | 216 | self.btn_ok.clicked() | 212 | self.btn_ok.clicked() |
1914 | 217 | |||
1915 | 218 | 213 | ||
1916 | 219 | def on_btn_ok_clicked(self, widget, data=None): | 214 | def on_btn_ok_clicked(self, widget, data=None): |
1917 | 220 | """The user has elected to save the changes. | 215 | """The user has elected to save the changes. |
1918 | 221 | Called before the dialog returns Gtk.ResponseType.OK from run(). | 216 | Called before the dialog returns Gtk.ResponseType.OK from run(). |
1921 | 222 | """ | 217 | """ |
1922 | 223 | 218 | ||
1923 | 224 | #saving the data should happen here. | 219 | #saving the data should happen here. |
1924 | 225 | anything_changed = False | 220 | anything_changed = False |
1925 | 226 | for f in self.entries_map: | 221 | for f in self.entries_map: |
1927 | 227 | entry = self.entries_map[f][0] | 222 | entry = self.entries_map[f][0] |
1928 | 228 | origvalue = self.entries_map[f][1] | 223 | origvalue = self.entries_map[f][1] |
1930 | 229 | newvalue = entry.get_text() | 224 | newvalue = entry.get_text() |
1931 | 230 | if newvalue == origvalue: | 225 | if newvalue == origvalue: |
1932 | 231 | pass | 226 | pass |
1933 | 232 | else: | 227 | else: |
1934 | 233 | #print "value " + f + " changed" | 228 | #print "value " + f + " changed" |
1935 | 234 | anything_changed = True | 229 | anything_changed = True |
1938 | 235 | self.libaccom.write_extra_information_file(f,newvalue) | 230 | self.libaccom.write_extra_information_file(f, newvalue) |
1939 | 236 | 231 | ||
1940 | 237 | if anything_changed: | 232 | if anything_changed: |
1941 | 238 | self.libaccom.run_scripts(True) | 233 | self.libaccom.run_scripts(True) |
1942 | 239 | 234 | ||
1943 | 240 | 235 | ||
1944 | === modified file 'accomplishments_viewer/PreferencesAccomplishmentsViewerDialog.py' | |||
1945 | --- accomplishments_viewer/PreferencesAccomplishmentsViewerDialog.py 2012-09-07 18:19:02 +0000 | |||
1946 | +++ accomplishments_viewer/PreferencesAccomplishmentsViewerDialog.py 2012-11-26 16:03:25 +0000 | |||
1947 | @@ -1,16 +1,16 @@ | |||
1948 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
1949 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
1950 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
1953 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
1954 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
1955 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
1960 | 7 | # | 7 | # |
1961 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
1962 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
1963 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1964 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
1967 | 12 | # | 12 | # |
1968 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
1969 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
1970 | 15 | ### END LICENSE | 15 | ### END LICENSE |
1971 | 16 | 16 | ||
1972 | @@ -20,27 +20,24 @@ | |||
1973 | 20 | # data/glib-2.0/schemas/net.launchpad.accomplishments-viewer.gschema.xml | 20 | # data/glib-2.0/schemas/net.launchpad.accomplishments-viewer.gschema.xml |
1974 | 21 | # See http://developer.gnome.org/gio/stable/GSettings.html for more info. | 21 | # See http://developer.gnome.org/gio/stable/GSettings.html for more info. |
1975 | 22 | 22 | ||
1979 | 23 | from gi.repository import Gio # pylint: disable=E0611 | 23 | import gettext |
1980 | 24 | 24 | import locale | |
1978 | 25 | import gettext, locale | ||
1981 | 26 | from locale import gettext as _ | 25 | from locale import gettext as _ |
1982 | 27 | from accomplishments.util.paths import locale_dir | 26 | from accomplishments.util.paths import locale_dir |
1983 | 28 | locale.bindtextdomain('accomplishments-viewer', locale_dir) | 27 | locale.bindtextdomain('accomplishments-viewer', locale_dir) |
1985 | 29 | gettext.bindtextdomain('accomplishments-viewer',locale_dir) | 28 | gettext.bindtextdomain('accomplishments-viewer', locale_dir) |
1986 | 30 | locale.textdomain('accomplishments-viewer') | 29 | locale.textdomain('accomplishments-viewer') |
1987 | 31 | 30 | ||
1988 | 32 | from accomplishments.daemon import dbusapi | ||
1989 | 33 | import os, xdg.BaseDirectory, ConfigParser | ||
1990 | 34 | |||
1991 | 35 | import logging | 31 | import logging |
1992 | 36 | logger = logging.getLogger('accomplishments_viewer') | 32 | logger = logging.getLogger('accomplishments_viewer') |
1993 | 37 | 33 | ||
1994 | 38 | from accomplishments_viewer_lib.PreferencesDialog import PreferencesDialog | 34 | from accomplishments_viewer_lib.PreferencesDialog import PreferencesDialog |
1995 | 39 | 35 | ||
1996 | 36 | |||
1997 | 40 | class PreferencesAccomplishmentsViewerDialog(PreferencesDialog): | 37 | class PreferencesAccomplishmentsViewerDialog(PreferencesDialog): |
1998 | 41 | __gtype_name__ = "PreferencesAccomplishmentsViewerDialog" | 38 | __gtype_name__ = "PreferencesAccomplishmentsViewerDialog" |
1999 | 42 | 39 | ||
2001 | 43 | def finish_initializing(self, builder): # pylint: disable=E1002 | 40 | def finish_initializing(self, builder): # pylint: disable=E1002 |
2002 | 44 | """Set up the preferences dialog""" | 41 | """Set up the preferences dialog""" |
2003 | 45 | super(PreferencesAccomplishmentsViewerDialog, self).finish_initializing(builder) | 42 | super(PreferencesAccomplishmentsViewerDialog, self).finish_initializing(builder) |
2004 | 46 | self.cb_daemonsessionstart = self.builder.get_object("cb_daemonsessionstart") | 43 | self.cb_daemonsessionstart = self.builder.get_object("cb_daemonsessionstart") |
2005 | @@ -49,9 +46,9 @@ | |||
2006 | 49 | self.pref_publish_label = self.builder.get_object("pref_publish_label") | 46 | self.pref_publish_label = self.builder.get_object("pref_publish_label") |
2007 | 50 | self.pref_publish_icon = self.builder.get_object("pref_publish_icon") | 47 | self.pref_publish_icon = self.builder.get_object("pref_publish_icon") |
2008 | 51 | self.publishedstatus = None | 48 | self.publishedstatus = None |
2010 | 52 | 49 | ||
2011 | 53 | #trophydir = self.libaccom.get_config_value("config", "trophypath") | 50 | #trophydir = self.libaccom.get_config_value("config", "trophypath") |
2013 | 54 | 51 | ||
2014 | 55 | # Bind each preference widget to gsettings | 52 | # Bind each preference widget to gsettings |
2015 | 56 | #settings = Gio.Settings("net.launchpad.accomplishments-viewer") | 53 | #settings = Gio.Settings("net.launchpad.accomplishments-viewer") |
2016 | 57 | #widget = self.builder.get_object('example_entry') | 54 | #widget = self.builder.get_object('example_entry') |
2017 | @@ -59,21 +56,21 @@ | |||
2018 | 59 | 56 | ||
2019 | 60 | # Code for other initialization actions should be added here. | 57 | # Code for other initialization actions should be added here. |
2020 | 61 | 58 | ||
2022 | 62 | def prepare(self,daemon_handle): | 59 | def prepare(self, daemon_handle): |
2023 | 63 | self.libaccom = daemon_handle | 60 | self.libaccom = daemon_handle |
2024 | 64 | self.populate_settings() | 61 | self.populate_settings() |
2026 | 65 | 62 | ||
2027 | 66 | self.publishedstatus = self.libaccom.get_published_status() | 63 | self.publishedstatus = self.libaccom.get_published_status() |
2029 | 67 | 64 | ||
2030 | 68 | if self.publishedstatus == 0: | 65 | if self.publishedstatus == 0: |
2031 | 69 | self.pref_publish.set_label(_("Publish...")) | 66 | self.pref_publish.set_label(_("Publish...")) |
2032 | 70 | else: | 67 | else: |
2033 | 71 | self.pref_publish.set_label(_("Stop Publishing")) | 68 | self.pref_publish.set_label(_("Stop Publishing")) |
2035 | 72 | 69 | ||
2036 | 73 | def populate_settings(self): | 70 | def populate_settings(self): |
2037 | 74 | self.cb_daemonsessionstart.handler_block_by_func(self.cb_daemonsessionstart_toggled) | 71 | self.cb_daemonsessionstart.handler_block_by_func(self.cb_daemonsessionstart_toggled) |
2038 | 75 | self.cb_hideu1bubbles.handler_block_by_func(self.cb_hideu1bubbles_toggled) | 72 | self.cb_hideu1bubbles.handler_block_by_func(self.cb_hideu1bubbles_toggled) |
2040 | 76 | 73 | ||
2041 | 77 | self.cb_daemonsessionstart.set_active(bool(self.libaccom.get_daemon_session_start())) | 74 | self.cb_daemonsessionstart.set_active(bool(self.libaccom.get_daemon_session_start())) |
2042 | 78 | print self.libaccom.get_daemon_session_start() | 75 | print self.libaccom.get_daemon_session_start() |
2043 | 79 | print type(self.libaccom.get_daemon_session_start()) | 76 | print type(self.libaccom.get_daemon_session_start()) |
2044 | @@ -81,13 +78,13 @@ | |||
2045 | 81 | 78 | ||
2046 | 82 | self.cb_daemonsessionstart.handler_unblock_by_func(self.cb_daemonsessionstart_toggled) | 79 | self.cb_daemonsessionstart.handler_unblock_by_func(self.cb_daemonsessionstart_toggled) |
2047 | 83 | self.cb_hideu1bubbles.handler_unblock_by_func(self.cb_hideu1bubbles_toggled) | 80 | self.cb_hideu1bubbles.handler_unblock_by_func(self.cb_hideu1bubbles_toggled) |
2049 | 84 | 81 | ||
2050 | 85 | def cb_daemonsessionstart_toggled(self, widget): | 82 | def cb_daemonsessionstart_toggled(self, widget): |
2051 | 86 | print widget.get_active() | 83 | print widget.get_active() |
2053 | 87 | self.libaccom.set_daemon_session_start( widget.get_active() ) | 84 | self.libaccom.set_daemon_session_start(widget.get_active()) |
2054 | 88 | 85 | ||
2055 | 89 | def cb_hideu1bubbles_toggled(self, widget): | 86 | def cb_hideu1bubbles_toggled(self, widget): |
2057 | 90 | self.libaccom.set_block_ubuntuone_notification_bubbles( widget.get_active() ) | 87 | self.libaccom.set_block_ubuntuone_notification_bubbles(widget.get_active()) |
2058 | 91 | 88 | ||
2059 | 92 | def on_pref_publish_clicked(self, widget): | 89 | def on_pref_publish_clicked(self, widget): |
2060 | 93 | if self.publishedstatus == 0: | 90 | if self.publishedstatus == 0: |
2061 | 94 | 91 | ||
2062 | === modified file 'accomplishments_viewer/__init__.py' | |||
2063 | --- accomplishments_viewer/__init__.py 2012-11-22 10:04:35 +0000 | |||
2064 | +++ accomplishments_viewer/__init__.py 2012-11-26 16:03:25 +0000 | |||
2065 | @@ -1,34 +1,36 @@ | |||
2066 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2067 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
2068 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2071 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
2072 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
2073 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
2078 | 7 | # | 7 | # |
2079 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
2080 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2081 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2082 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
2085 | 12 | # | 12 | # |
2086 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
2087 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2088 | 15 | ### END LICENSE | 15 | ### END LICENSE |
2089 | 16 | 16 | ||
2090 | 17 | import optparse | 17 | import optparse |
2091 | 18 | 18 | ||
2093 | 19 | import gettext, locale | 19 | import gettext |
2094 | 20 | import locale | ||
2095 | 20 | from locale import gettext as _ | 21 | from locale import gettext as _ |
2096 | 21 | from accomplishments.util.paths import locale_dir | 22 | from accomplishments.util.paths import locale_dir |
2097 | 22 | locale.bindtextdomain('accomplishments-viewer', locale_dir) | 23 | locale.bindtextdomain('accomplishments-viewer', locale_dir) |
2099 | 23 | gettext.bindtextdomain('accomplishments-viewer',locale_dir) | 24 | gettext.bindtextdomain('accomplishments-viewer', locale_dir) |
2100 | 24 | locale.textdomain('accomplishments-viewer') | 25 | locale.textdomain('accomplishments-viewer') |
2101 | 25 | 26 | ||
2103 | 26 | from gi.repository import Gtk, GObject # pylint: disable=E0611 | 27 | from gi.repository import Gtk, GObject # pylint: disable=E0611 |
2104 | 27 | 28 | ||
2105 | 28 | from accomplishments_viewer import AccomplishmentsViewerWindow | 29 | from accomplishments_viewer import AccomplishmentsViewerWindow |
2106 | 29 | 30 | ||
2107 | 30 | from accomplishments_viewer_lib import set_up_logging, get_version | 31 | from accomplishments_viewer_lib import set_up_logging, get_version |
2108 | 31 | 32 | ||
2109 | 33 | |||
2110 | 32 | def parse_options(): | 34 | def parse_options(): |
2111 | 33 | """Support for command line options""" | 35 | """Support for command line options""" |
2112 | 34 | parser = optparse.OptionParser(version="%%prog %s" % get_version()) | 36 | parser = optparse.OptionParser(version="%%prog %s" % get_version()) |
2113 | @@ -39,20 +41,21 @@ | |||
2114 | 39 | "-a", "--accomplishment", action="store", dest="id", | 41 | "-a", "--accomplishment", action="store", dest="id", |
2115 | 40 | help=_("Display information about the provided accomplishment ID (e.g. 'ubuntu-community/registered-on-launchpad')").decode('utf-8')) | 42 | help=_("Display information about the provided accomplishment ID (e.g. 'ubuntu-community/registered-on-launchpad')").decode('utf-8')) |
2116 | 41 | (options, args) = parser.parse_args() | 43 | (options, args) = parser.parse_args() |
2118 | 42 | 44 | ||
2119 | 43 | set_up_logging(options) | 45 | set_up_logging(options) |
2120 | 44 | return options | 46 | return options |
2121 | 45 | 47 | ||
2122 | 48 | |||
2123 | 46 | def main(): | 49 | def main(): |
2124 | 47 | 'constructor for your class instances' | 50 | 'constructor for your class instances' |
2125 | 48 | GObject.threads_init() | 51 | GObject.threads_init() |
2126 | 49 | options = parse_options() | 52 | options = parse_options() |
2127 | 50 | 53 | ||
2129 | 51 | # Run the application. | 54 | # Run the application. |
2130 | 52 | window = AccomplishmentsViewerWindow.AccomplishmentsViewerWindow() | 55 | window = AccomplishmentsViewerWindow.AccomplishmentsViewerWindow() |
2132 | 53 | 56 | ||
2133 | 54 | if options.id: | 57 | if options.id: |
2134 | 55 | window.optparse_accomplishment(options.id) | 58 | window.optparse_accomplishment(options.id) |
2136 | 56 | 59 | ||
2137 | 57 | window.show() | 60 | window.show() |
2138 | 58 | Gtk.main() | 61 | Gtk.main() |
2139 | 59 | 62 | ||
2140 | === modified file 'accomplishments_viewer_lib/AboutDialog.py' | |||
2141 | --- accomplishments_viewer_lib/AboutDialog.py 2012-09-07 18:19:02 +0000 | |||
2142 | +++ accomplishments_viewer_lib/AboutDialog.py 2012-11-26 16:03:25 +0000 | |||
2143 | @@ -1,32 +1,33 @@ | |||
2144 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2145 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
2146 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2149 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
2150 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
2151 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
2156 | 7 | # | 7 | # |
2157 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
2158 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2159 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2160 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
2163 | 12 | # | 12 | # |
2164 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
2165 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2166 | 15 | ### END LICENSE | 15 | ### END LICENSE |
2167 | 16 | 16 | ||
2168 | 17 | ### DO NOT EDIT THIS FILE ### | 17 | ### DO NOT EDIT THIS FILE ### |
2169 | 18 | 18 | ||
2171 | 19 | from gi.repository import Gtk # pylint: disable=E0611 | 19 | from gi.repository import Gtk # pylint: disable=E0611 |
2172 | 20 | 20 | ||
2173 | 21 | from . helpers import get_builder | 21 | from . helpers import get_builder |
2174 | 22 | 22 | ||
2175 | 23 | |||
2176 | 23 | class AboutDialog(Gtk.AboutDialog): | 24 | class AboutDialog(Gtk.AboutDialog): |
2177 | 24 | __gtype_name__ = "AboutDialog" | 25 | __gtype_name__ = "AboutDialog" |
2178 | 25 | 26 | ||
2179 | 26 | def __new__(cls): | 27 | def __new__(cls): |
2181 | 27 | """Special static method that's automatically called by Python when | 28 | """Special static method that's automatically called by Python when |
2182 | 28 | constructing a new instance of this class. | 29 | constructing a new instance of this class. |
2184 | 29 | 30 | ||
2185 | 30 | Returns a fully instantiated AboutDialog object. | 31 | Returns a fully instantiated AboutDialog object. |
2186 | 31 | """ | 32 | """ |
2187 | 32 | builder = get_builder('AboutAccomplishmentsViewerDialog') | 33 | builder = get_builder('AboutAccomplishmentsViewerDialog') |
2188 | @@ -41,10 +42,9 @@ | |||
2189 | 41 | and creating a AboutDialog object with it in order | 42 | and creating a AboutDialog object with it in order |
2190 | 42 | to finish initializing the start of the new AboutAccomplishmentsViewerDialog | 43 | to finish initializing the start of the new AboutAccomplishmentsViewerDialog |
2191 | 43 | instance. | 44 | instance. |
2193 | 44 | 45 | ||
2194 | 45 | Put your initialization code in here and leave __init__ undefined. | 46 | Put your initialization code in here and leave __init__ undefined. |
2195 | 46 | """ | 47 | """ |
2196 | 47 | # Get a reference to the builder and set up the signals. | 48 | # Get a reference to the builder and set up the signals. |
2197 | 48 | self.builder = builder | 49 | self.builder = builder |
2198 | 49 | self.ui = builder.get_ui(self) | 50 | self.ui = builder.get_ui(self) |
2199 | 50 | |||
2200 | 51 | 51 | ||
2201 | === modified file 'accomplishments_viewer_lib/Builder.py' | |||
2202 | --- accomplishments_viewer_lib/Builder.py 2012-09-07 18:19:02 +0000 | |||
2203 | +++ accomplishments_viewer_lib/Builder.py 2012-11-26 16:03:25 +0000 | |||
2204 | @@ -1,16 +1,16 @@ | |||
2205 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2206 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
2207 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2210 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
2211 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
2212 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
2217 | 7 | # | 7 | # |
2218 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
2219 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2220 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2221 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
2224 | 12 | # | 12 | # |
2225 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
2226 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2227 | 15 | ### END LICENSE | 15 | ### END LICENSE |
2228 | 16 | 16 | ||
2229 | @@ -18,7 +18,7 @@ | |||
2230 | 18 | 18 | ||
2231 | 19 | '''Enhances builder connections, provides object to access glade objects''' | 19 | '''Enhances builder connections, provides object to access glade objects''' |
2232 | 20 | 20 | ||
2234 | 21 | from gi.repository import GObject, Gtk # pylint: disable=E0611 | 21 | from gi.repository import GObject, Gtk # pylint: disable=E0611 |
2235 | 22 | 22 | ||
2236 | 23 | import inspect | 23 | import inspect |
2237 | 24 | import functools | 24 | import functools |
2238 | @@ -54,8 +54,7 @@ | |||
2239 | 54 | 54 | ||
2240 | 55 | # pylint: disable=R0201 | 55 | # pylint: disable=R0201 |
2241 | 56 | # this is a method so that a subclass of Builder can redefine it | 56 | # this is a method so that a subclass of Builder can redefine it |
2244 | 57 | def default_handler(self, | 57 | def default_handler(self, handler_name, filename, *args, **kwargs): |
2243 | 58 | handler_name, filename, *args, **kwargs): | ||
2245 | 59 | '''helps the apprentice guru | 58 | '''helps the apprentice guru |
2246 | 60 | 59 | ||
2247 | 61 | glade defined handlers that do not exist come here instead. | 60 | glade defined handlers that do not exist come here instead. |
2248 | @@ -108,7 +107,8 @@ | |||
2249 | 108 | ele_signals = tree.getiterator("signal") | 107 | ele_signals = tree.getiterator("signal") |
2250 | 109 | for ele_signal in ele_signals: | 108 | for ele_signal in ele_signals: |
2251 | 110 | self.glade_handler_dict.update( | 109 | self.glade_handler_dict.update( |
2253 | 111 | {ele_signal.attrib["handler"]: None}) | 110 | {ele_signal.attrib["handler"]: None} |
2254 | 111 | ) | ||
2255 | 112 | 112 | ||
2256 | 113 | def connect_signals(self, callback_obj): | 113 | def connect_signals(self, callback_obj): |
2257 | 114 | '''connect the handlers defined in glade | 114 | '''connect the handlers defined in glade |
2258 | @@ -129,8 +129,7 @@ | |||
2259 | 129 | connection_dict[item[0]] = handler | 129 | connection_dict[item[0]] = handler |
2260 | 130 | 130 | ||
2261 | 131 | # replace the run time warning | 131 | # replace the run time warning |
2264 | 132 | logger.warn("expected handler '%s' in %s", | 132 | logger.warn("expected handler '%s' in %s", item[0], filename) |
2263 | 133 | item[0], filename) | ||
2265 | 134 | 133 | ||
2266 | 135 | # connect glade define handlers | 134 | # connect glade define handlers |
2267 | 136 | Gtk.Builder.connect_signals(self, connection_dict) | 135 | Gtk.Builder.connect_signals(self, connection_dict) |
2268 | @@ -139,7 +138,7 @@ | |||
2269 | 139 | for connection in self.connections: | 138 | for connection in self.connections: |
2270 | 140 | widget_name, signal_name, handler_name = connection | 139 | widget_name, signal_name, handler_name = connection |
2271 | 141 | logger.debug("connect builder by design '%s', '%s', '%s'", | 140 | logger.debug("connect builder by design '%s', '%s', '%s'", |
2273 | 142 | widget_name, signal_name, handler_name) | 141 | widget_name, signal_name, handler_name) |
2274 | 143 | 142 | ||
2275 | 144 | def get_ui(self, callback_obj=None, by_name=True): | 143 | def get_ui(self, callback_obj=None, by_name=True): |
2276 | 145 | '''Creates the ui object with widgets as attributes | 144 | '''Creates the ui object with widgets as attributes |
2277 | @@ -175,7 +174,7 @@ | |||
2278 | 175 | cannot_message = """cannot bind ui.%s, name already exists | 174 | cannot_message = """cannot bind ui.%s, name already exists |
2279 | 176 | consider using a pythonic name instead of design name '%s'""" | 175 | consider using a pythonic name instead of design name '%s'""" |
2280 | 177 | consider_message = """consider using a pythonic name instead of design name '%s'""" | 176 | consider_message = """consider using a pythonic name instead of design name '%s'""" |
2282 | 178 | 177 | ||
2283 | 179 | for (widget_name, widget) in widget_dict.items(): | 178 | for (widget_name, widget) in widget_dict.items(): |
2284 | 180 | pyname = make_pyname(widget_name) | 179 | pyname = make_pyname(widget_name) |
2285 | 181 | if pyname != widget_name: | 180 | if pyname != widget_name: |
2286 | @@ -201,14 +200,14 @@ | |||
2287 | 201 | pyname = '' | 200 | pyname = '' |
2288 | 202 | for character in name: | 201 | for character in name: |
2289 | 203 | if (character.isalpha() or character == '_' or | 202 | if (character.isalpha() or character == '_' or |
2291 | 204 | (pyname and character.isdigit())): | 203 | (pyname and character.isdigit())): |
2292 | 205 | pyname += character | 204 | pyname += character |
2293 | 206 | else: | 205 | else: |
2294 | 207 | pyname += '_' | 206 | pyname += '_' |
2295 | 208 | return pyname | 207 | return pyname |
2296 | 209 | 208 | ||
2297 | 210 | 209 | ||
2299 | 211 | # Until bug https://bugzilla.gnome.org/show_bug.cgi?id=652127 is fixed, we | 210 | # Until bug https://bugzilla.gnome.org/show_bug.cgi?id=652127 is fixed, we |
2300 | 212 | # need to reimplement inspect.getmembers. GObject introspection doesn't | 211 | # need to reimplement inspect.getmembers. GObject introspection doesn't |
2301 | 213 | # play nice with it. | 212 | # play nice with it. |
2302 | 214 | def getmembers(obj, check): | 213 | def getmembers(obj, check): |
2303 | @@ -285,13 +284,13 @@ | |||
2304 | 285 | handler_names.append("on_%s" % sig) | 284 | handler_names.append("on_%s" % sig) |
2305 | 286 | 285 | ||
2306 | 287 | do_connect(item, sig, handler_names, | 286 | do_connect(item, sig, handler_names, |
2308 | 288 | callback_handler_dict, builder.connections) | 287 | callback_handler_dict, builder.connections) |
2309 | 289 | 288 | ||
2310 | 290 | log_unconnected_functions(callback_handler_dict, builder.connections) | 289 | log_unconnected_functions(callback_handler_dict, builder.connections) |
2311 | 291 | 290 | ||
2312 | 292 | 291 | ||
2313 | 293 | def do_connect(item, signal_name, handler_names, | 292 | def do_connect(item, signal_name, handler_names, |
2315 | 294 | callback_handler_dict, connections): | 293 | callback_handler_dict, connections): |
2316 | 295 | '''connect this signal to an unused handler''' | 294 | '''connect this signal to an unused handler''' |
2317 | 296 | widget_name, widget = item | 295 | widget_name, widget = item |
2318 | 297 | 296 | ||
2319 | @@ -304,7 +303,7 @@ | |||
2320 | 304 | connections.append(connection) | 303 | connections.append(connection) |
2321 | 305 | 304 | ||
2322 | 306 | logger.debug("connect builder by name '%s','%s', '%s'", | 305 | logger.debug("connect builder by name '%s','%s', '%s'", |
2324 | 307 | widget_name, signal_name, handler_name) | 306 | widget_name, signal_name, handler_name) |
2325 | 308 | 307 | ||
2326 | 309 | 308 | ||
2327 | 310 | def log_unconnected_functions(callback_handler_dict, connections): | 309 | def log_unconnected_functions(callback_handler_dict, connections): |
2328 | 311 | 310 | ||
2329 | === modified file 'accomplishments_viewer_lib/PreferencesDialog.py' | |||
2330 | --- accomplishments_viewer_lib/PreferencesDialog.py 2012-09-07 18:19:02 +0000 | |||
2331 | +++ accomplishments_viewer_lib/PreferencesDialog.py 2012-11-26 16:03:25 +0000 | |||
2332 | @@ -1,16 +1,16 @@ | |||
2333 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2334 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
2335 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2338 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
2339 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
2340 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
2345 | 7 | # | 7 | # |
2346 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
2347 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2348 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2349 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
2352 | 12 | # | 12 | # |
2353 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
2354 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2355 | 15 | ### END LICENSE | 15 | ### END LICENSE |
2356 | 16 | 16 | ||
2357 | @@ -19,19 +19,20 @@ | |||
2358 | 19 | """this dialog adjusts values in gsettings | 19 | """this dialog adjusts values in gsettings |
2359 | 20 | """ | 20 | """ |
2360 | 21 | 21 | ||
2362 | 22 | from gi.repository import Gtk # pylint: disable=E0611 | 22 | from gi.repository import Gtk # pylint: disable=E0611 |
2363 | 23 | import logging | 23 | import logging |
2364 | 24 | logger = logging.getLogger('accomplishments_viewer_lib') | 24 | logger = logging.getLogger('accomplishments_viewer_lib') |
2365 | 25 | 25 | ||
2366 | 26 | from . helpers import get_builder, show_uri, get_help_uri | 26 | from . helpers import get_builder, show_uri, get_help_uri |
2367 | 27 | 27 | ||
2368 | 28 | |||
2369 | 28 | class PreferencesDialog(Gtk.Dialog): | 29 | class PreferencesDialog(Gtk.Dialog): |
2370 | 29 | __gtype_name__ = "PreferencesDialog" | 30 | __gtype_name__ = "PreferencesDialog" |
2371 | 30 | 31 | ||
2372 | 31 | def __new__(cls): | 32 | def __new__(cls): |
2374 | 32 | """Special static method that's automatically called by Python when | 33 | """Special static method that's automatically called by Python when |
2375 | 33 | constructing a new instance of this class. | 34 | constructing a new instance of this class. |
2377 | 34 | 35 | ||
2378 | 35 | Returns a fully instantiated PreferencesDialog object. | 36 | Returns a fully instantiated PreferencesDialog object. |
2379 | 36 | """ | 37 | """ |
2380 | 37 | builder = get_builder('PreferencesAccomplishmentsViewerDialog') | 38 | builder = get_builder('PreferencesAccomplishmentsViewerDialog') |
2381 | @@ -46,7 +47,7 @@ | |||
2382 | 46 | and creating a PreferencesDialog object with it in order to | 47 | and creating a PreferencesDialog object with it in order to |
2383 | 47 | finish initializing the start of the new PerferencesAccomplishmentsViewerDialog | 48 | finish initializing the start of the new PerferencesAccomplishmentsViewerDialog |
2384 | 48 | instance. | 49 | instance. |
2386 | 49 | 50 | ||
2387 | 50 | Put your initialization code in here and leave __init__ undefined. | 51 | Put your initialization code in here and leave __init__ undefined. |
2388 | 51 | """ | 52 | """ |
2389 | 52 | 53 | ||
2390 | @@ -61,4 +62,3 @@ | |||
2391 | 61 | 62 | ||
2392 | 62 | def on_btn_help_clicked(self, widget, data=None): | 63 | def on_btn_help_clicked(self, widget, data=None): |
2393 | 63 | show_uri(self, "ghelp:%s" % get_help_uri('preferences')) | 64 | show_uri(self, "ghelp:%s" % get_help_uri('preferences')) |
2394 | 64 | |||
2395 | 65 | 65 | ||
2396 | === modified file 'accomplishments_viewer_lib/Window.py' | |||
2397 | --- accomplishments_viewer_lib/Window.py 2012-09-07 18:19:02 +0000 | |||
2398 | +++ accomplishments_viewer_lib/Window.py 2012-11-26 16:03:25 +0000 | |||
2399 | @@ -1,33 +1,34 @@ | |||
2400 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2401 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
2402 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2405 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
2406 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
2407 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
2412 | 7 | # | 7 | # |
2413 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
2414 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2415 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2416 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
2419 | 12 | # | 12 | # |
2420 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
2421 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2422 | 15 | ### END LICENSE | 15 | ### END LICENSE |
2423 | 16 | 16 | ||
2424 | 17 | ### DO NOT EDIT THIS FILE ### | 17 | ### DO NOT EDIT THIS FILE ### |
2425 | 18 | 18 | ||
2427 | 19 | from gi.repository import Gio, Gtk # pylint: disable=E0611 | 19 | from gi.repository import Gio, Gtk # pylint: disable=E0611 |
2428 | 20 | import logging | 20 | import logging |
2429 | 21 | logger = logging.getLogger('accomplishments_viewer_lib') | 21 | logger = logging.getLogger('accomplishments_viewer_lib') |
2430 | 22 | 22 | ||
2431 | 23 | from . helpers import get_builder, show_uri, get_help_uri | 23 | from . helpers import get_builder, show_uri, get_help_uri |
2432 | 24 | 24 | ||
2433 | 25 | |||
2434 | 25 | # This class is meant to be subclassed by AccomplishmentsViewerWindow. It provides | 26 | # This class is meant to be subclassed by AccomplishmentsViewerWindow. It provides |
2435 | 26 | # common functions and some boilerplate. | 27 | # common functions and some boilerplate. |
2436 | 27 | class Window(Gtk.Window): | 28 | class Window(Gtk.Window): |
2437 | 28 | __gtype_name__ = "Window" | 29 | __gtype_name__ = "Window" |
2438 | 29 | 30 | ||
2440 | 30 | # To construct a new instance of this method, the following notable | 31 | # To construct a new instance of this method, the following notable |
2441 | 31 | # methods are called in this order: | 32 | # methods are called in this order: |
2442 | 32 | # __new__(cls) | 33 | # __new__(cls) |
2443 | 33 | # __init__(self) | 34 | # __init__(self) |
2444 | @@ -36,11 +37,11 @@ | |||
2445 | 36 | # | 37 | # |
2446 | 37 | # For this reason, it's recommended you leave __init__ empty and put | 38 | # For this reason, it's recommended you leave __init__ empty and put |
2447 | 38 | # your initialization code in finish_initializing | 39 | # your initialization code in finish_initializing |
2449 | 39 | 40 | ||
2450 | 40 | def __new__(cls): | 41 | def __new__(cls): |
2452 | 41 | """Special static method that's automatically called by Python when | 42 | """Special static method that's automatically called by Python when |
2453 | 42 | constructing a new instance of this class. | 43 | constructing a new instance of this class. |
2455 | 43 | 44 | ||
2456 | 44 | Returns a fully instantiated BaseAccomplishmentsViewerWindow object. | 45 | Returns a fully instantiated BaseAccomplishmentsViewerWindow object. |
2457 | 45 | """ | 46 | """ |
2458 | 46 | builder = get_builder('AccomplishmentsViewerWindow') | 47 | builder = get_builder('AccomplishmentsViewerWindow') |
2459 | @@ -58,9 +59,9 @@ | |||
2460 | 58 | # Get a reference to the builder and set up the signals. | 59 | # Get a reference to the builder and set up the signals. |
2461 | 59 | self.builder = builder | 60 | self.builder = builder |
2462 | 60 | self.ui = builder.get_ui(self, True) | 61 | self.ui = builder.get_ui(self, True) |
2466 | 61 | self.PreferencesDialog = None # class | 62 | self.PreferencesDialog = None # class |
2467 | 62 | self.preferences_dialog = None # instance | 63 | self.preferences_dialog = None # instance |
2468 | 63 | self.AboutDialog = None # class | 64 | self.AboutDialog = None # class |
2469 | 64 | 65 | ||
2470 | 65 | self.settings = Gio.Settings("net.launchpad.accomplishments-viewer") | 66 | self.settings = Gio.Settings("net.launchpad.accomplishments-viewer") |
2471 | 66 | self.settings.connect('changed', self.on_preferences_changed) | 67 | self.settings.connect('changed', self.on_preferences_changed) |
2472 | @@ -84,7 +85,7 @@ | |||
2473 | 84 | def on_mnu_about_activate(self, widget, data=None): | 85 | def on_mnu_about_activate(self, widget, data=None): |
2474 | 85 | """Display the about box for accomplishments-viewer.""" | 86 | """Display the about box for accomplishments-viewer.""" |
2475 | 86 | if self.AboutDialog is not None: | 87 | if self.AboutDialog is not None: |
2477 | 87 | about = self.AboutDialog() # pylint: disable=E1102 | 88 | about = self.AboutDialog() # pylint: disable=E1102 |
2478 | 88 | response = about.run() | 89 | response = about.run() |
2479 | 89 | about.destroy() | 90 | about.destroy() |
2480 | 90 | 91 | ||
2481 | @@ -101,7 +102,7 @@ | |||
2482 | 101 | self.preferences_dialog.present() | 102 | self.preferences_dialog.present() |
2483 | 102 | elif self.PreferencesDialog is not None: | 103 | elif self.PreferencesDialog is not None: |
2484 | 103 | logger.debug('create new preferences_dialog') | 104 | logger.debug('create new preferences_dialog') |
2486 | 104 | self.preferences_dialog = self.PreferencesDialog() # pylint: disable=E1102 | 105 | self.preferences_dialog = self.PreferencesDialog() # pylint: disable=E1102 |
2487 | 105 | self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed) | 106 | self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed) |
2488 | 106 | self.preferences_dialog.show() | 107 | self.preferences_dialog.show() |
2489 | 107 | # destroy command moved into dialog to allow for a help button | 108 | # destroy command moved into dialog to allow for a help button |
2490 | @@ -120,7 +121,7 @@ | |||
2491 | 120 | 121 | ||
2492 | 121 | def on_preferences_dialog_destroyed(self, widget, data=None): | 122 | def on_preferences_dialog_destroyed(self, widget, data=None): |
2493 | 122 | '''only affects gui | 123 | '''only affects gui |
2495 | 123 | 124 | ||
2496 | 124 | logically there is no difference between the user closing, | 125 | logically there is no difference between the user closing, |
2497 | 125 | minimising or ignoring the preferences dialog''' | 126 | minimising or ignoring the preferences dialog''' |
2498 | 126 | logger.debug('on_preferences_dialog_destroyed') | 127 | logger.debug('on_preferences_dialog_destroyed') |
2499 | 127 | 128 | ||
2500 | === modified file 'accomplishments_viewer_lib/__init__.py' | |||
2501 | --- accomplishments_viewer_lib/__init__.py 2012-09-07 18:19:02 +0000 | |||
2502 | +++ accomplishments_viewer_lib/__init__.py 2012-11-26 16:03:25 +0000 | |||
2503 | @@ -1,16 +1,16 @@ | |||
2504 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2505 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
2506 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2509 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
2510 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
2511 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
2516 | 7 | # | 7 | # |
2517 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
2518 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2519 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2520 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
2523 | 12 | # | 12 | # |
2524 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
2525 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2526 | 15 | ### END LICENSE | 15 | ### END LICENSE |
2527 | 16 | 16 | ||
2528 | @@ -22,4 +22,3 @@ | |||
2529 | 22 | from . helpers import set_up_logging | 22 | from . helpers import set_up_logging |
2530 | 23 | from . Window import Window | 23 | from . Window import Window |
2531 | 24 | from . accomplishments_viewerconfig import get_version | 24 | from . accomplishments_viewerconfig import get_version |
2532 | 25 | |||
2533 | 26 | 25 | ||
2534 | === modified file 'accomplishments_viewer_lib/accomplishments_viewerconfig.py' | |||
2535 | --- accomplishments_viewer_lib/accomplishments_viewerconfig.py 2012-09-07 18:19:02 +0000 | |||
2536 | +++ accomplishments_viewer_lib/accomplishments_viewerconfig.py 2012-11-26 16:03:25 +0000 | |||
2537 | @@ -1,16 +1,16 @@ | |||
2538 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2539 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
2540 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2543 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
2544 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
2545 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
2550 | 7 | # | 7 | # |
2551 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
2552 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2553 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2554 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
2557 | 12 | # | 12 | # |
2558 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
2559 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2560 | 15 | ### END LICENSE | 15 | ### END LICENSE |
2561 | 16 | 16 | ||
2562 | @@ -20,7 +20,7 @@ | |||
2563 | 20 | 'project_path_not_found', | 20 | 'project_path_not_found', |
2564 | 21 | 'get_data_file', | 21 | 'get_data_file', |
2565 | 22 | 'get_data_path', | 22 | 'get_data_path', |
2567 | 23 | ] | 23 | ] |
2568 | 24 | 24 | ||
2569 | 25 | # Where your project will look for your data (for instance, images and ui | 25 | # Where your project will look for your data (for instance, images and ui |
2570 | 26 | # files). By default, this is ../data, relative your trunk layout | 26 | # files). By default, this is ../data, relative your trunk layout |
2571 | @@ -30,7 +30,6 @@ | |||
2572 | 30 | 30 | ||
2573 | 31 | import os | 31 | import os |
2574 | 32 | 32 | ||
2575 | 33 | from locale import gettext as _ | ||
2576 | 34 | 33 | ||
2577 | 35 | class project_path_not_found(Exception): | 34 | class project_path_not_found(Exception): |
2578 | 36 | """Raised when we can't find the project directory.""" | 35 | """Raised when we can't find the project directory.""" |
2579 | 37 | 36 | ||
2580 | === modified file 'accomplishments_viewer_lib/helpers.py' | |||
2581 | --- accomplishments_viewer_lib/helpers.py 2012-09-07 18:19:02 +0000 | |||
2582 | +++ accomplishments_viewer_lib/helpers.py 2012-11-26 16:03:25 +0000 | |||
2583 | @@ -1,16 +1,16 @@ | |||
2584 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2585 | 2 | ### BEGIN LICENSE | 2 | ### BEGIN LICENSE |
2586 | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 3 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2589 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # This program is free software: you can redistribute it and/or modify it |
2590 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # under the terms of the GNU General Public License version 3, as published |
2591 | 6 | # by the Free Software Foundation. | 6 | # by the Free Software Foundation. |
2596 | 7 | # | 7 | # |
2597 | 8 | # This program is distributed in the hope that it will be useful, but | 8 | # This program is distributed in the hope that it will be useful, but |
2598 | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 9 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2599 | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 10 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2600 | 11 | # PURPOSE. See the GNU General Public License for more details. | 11 | # PURPOSE. See the GNU General Public License for more details. |
2603 | 12 | # | 12 | # |
2604 | 13 | # You should have received a copy of the GNU General Public License along | 13 | # You should have received a copy of the GNU General Public License along |
2605 | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2606 | 15 | ### END LICENSE | 15 | ### END LICENSE |
2607 | 16 | 16 | ||
2608 | @@ -25,10 +25,11 @@ | |||
2609 | 25 | 25 | ||
2610 | 26 | from locale import gettext as _ | 26 | from locale import gettext as _ |
2611 | 27 | 27 | ||
2612 | 28 | |||
2613 | 28 | def get_builder(builder_file_name): | 29 | def get_builder(builder_file_name): |
2615 | 29 | """Return a fully-instantiated Gtk.Builder instance from specified ui | 30 | """Return a fully-instantiated Gtk.Builder instance from specified ui |
2616 | 30 | file | 31 | file |
2618 | 31 | 32 | ||
2619 | 32 | :param builder_file_name: The name of the builder file, without extension. | 33 | :param builder_file_name: The name of the builder file, without extension. |
2620 | 33 | Assumed to be in the 'ui' directory under the data path. | 34 | Assumed to be in the 'ui' directory under the data path. |
2621 | 34 | """ | 35 | """ |
2622 | @@ -49,12 +50,14 @@ | |||
2623 | 49 | if not os.path.exists(media_filename): | 50 | if not os.path.exists(media_filename): |
2624 | 50 | media_filename = None | 51 | media_filename = None |
2625 | 51 | 52 | ||
2627 | 52 | return "file:///"+media_filename | 53 | return "file:///" + media_filename |
2628 | 54 | |||
2629 | 53 | 55 | ||
2630 | 54 | class NullHandler(logging.Handler): | 56 | class NullHandler(logging.Handler): |
2631 | 55 | def emit(self, record): | 57 | def emit(self, record): |
2632 | 56 | pass | 58 | pass |
2633 | 57 | 59 | ||
2634 | 60 | |||
2635 | 58 | def set_up_logging(opts): | 61 | def set_up_logging(opts): |
2636 | 59 | # add a handler to prevent basicConfig | 62 | # add a handler to prevent basicConfig |
2637 | 60 | root = logging.getLogger() | 63 | root = logging.getLogger() |
2638 | @@ -80,6 +83,7 @@ | |||
2639 | 80 | if opts.verbose > 1: | 83 | if opts.verbose > 1: |
2640 | 81 | lib_logger.setLevel(logging.DEBUG) | 84 | lib_logger.setLevel(logging.DEBUG) |
2641 | 82 | 85 | ||
2642 | 86 | |||
2643 | 83 | def get_help_uri(page=None): | 87 | def get_help_uri(page=None): |
2644 | 84 | # help_uri from source tree - default language | 88 | # help_uri from source tree - default language |
2645 | 85 | here = os.path.dirname(__file__) | 89 | here = os.path.dirname(__file__) |
2646 | @@ -95,11 +99,13 @@ | |||
2647 | 95 | 99 | ||
2648 | 96 | return help_uri | 100 | return help_uri |
2649 | 97 | 101 | ||
2650 | 102 | |||
2651 | 98 | def show_uri(parent, link): | 103 | def show_uri(parent, link): |
2653 | 99 | from gi.repository import Gtk # pylint: disable=E0611 | 104 | from gi.repository import Gtk # pylint: disable=E0611 |
2654 | 100 | screen = parent.get_screen() | 105 | screen = parent.get_screen() |
2655 | 101 | Gtk.show_uri(screen, link, Gtk.get_current_event_time()) | 106 | Gtk.show_uri(screen, link, Gtk.get_current_event_time()) |
2656 | 102 | 107 | ||
2657 | 108 | |||
2658 | 103 | def alias(alternative_function_name): | 109 | def alias(alternative_function_name): |
2659 | 104 | '''see http://www.drdobbs.com/web-development/184406073#l9''' | 110 | '''see http://www.drdobbs.com/web-development/184406073#l9''' |
2660 | 105 | def decorator(function): | 111 | def decorator(function): |
2661 | 106 | 112 | ||
2662 | === modified file 'bin/accomplishments-viewer' | |||
2663 | --- bin/accomplishments-viewer 2012-09-07 18:19:02 +0000 | |||
2664 | +++ bin/accomplishments-viewer 2012-11-26 16:03:25 +0000 | |||
2665 | @@ -2,16 +2,16 @@ | |||
2666 | 2 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 2 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2667 | 3 | ### BEGIN LICENSE | 3 | ### BEGIN LICENSE |
2668 | 4 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 4 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2671 | 5 | # This program is free software: you can redistribute it and/or modify it | 5 | # This program is free software: you can redistribute it and/or modify it |
2672 | 6 | # under the terms of the GNU General Public License version 3, as published | 6 | # under the terms of the GNU General Public License version 3, as published |
2673 | 7 | # by the Free Software Foundation. | 7 | # by the Free Software Foundation. |
2678 | 8 | # | 8 | # |
2679 | 9 | # This program is distributed in the hope that it will be useful, but | 9 | # This program is distributed in the hope that it will be useful, but |
2680 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2681 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2682 | 12 | # PURPOSE. See the GNU General Public License for more details. | 12 | # PURPOSE. See the GNU General Public License for more details. |
2685 | 13 | # | 13 | # |
2686 | 14 | # You should have received a copy of the GNU General Public License along | 14 | # You should have received a copy of the GNU General Public License along |
2687 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2688 | 16 | ### END LICENSE | 16 | ### END LICENSE |
2689 | 17 | 17 | ||
2690 | @@ -30,18 +30,18 @@ | |||
2691 | 30 | python_path = [] | 30 | python_path = [] |
2692 | 31 | if os.path.abspath(__file__).startswith('/opt'): | 31 | if os.path.abspath(__file__).startswith('/opt'): |
2693 | 32 | locale.bindtextdomain('accomplishments-viewer', '/opt/extras.ubuntu.com/accomplishments-viewer/share/locale') | 32 | locale.bindtextdomain('accomplishments-viewer', '/opt/extras.ubuntu.com/accomplishments-viewer/share/locale') |
2695 | 33 | syspath = sys.path[:] # copy to avoid infinite loop in pending objects | 33 | syspath = sys.path[:] # copy to avoid infinite loop in pending objects |
2696 | 34 | for path in syspath: | 34 | for path in syspath: |
2697 | 35 | opt_path = path.replace('/usr', '/opt/extras.ubuntu.com/accomplishments-viewer') | 35 | opt_path = path.replace('/usr', '/opt/extras.ubuntu.com/accomplishments-viewer') |
2698 | 36 | python_path.insert(0, opt_path) | 36 | python_path.insert(0, opt_path) |
2699 | 37 | sys.path.insert(0, opt_path) | 37 | sys.path.insert(0, opt_path) |
2700 | 38 | os.putenv("XDG_DATA_DIRS", "%s:%s" % ("/opt/extras.ubuntu.com/accomplishments-viewer/share/", os.getenv("XDG_DATA_DIRS", "/usr/local/share/:/usr/share/"))) | 38 | os.putenv("XDG_DATA_DIRS", "%s:%s" % ("/opt/extras.ubuntu.com/accomplishments-viewer/share/", os.getenv("XDG_DATA_DIRS", "/usr/local/share/:/usr/share/"))) |
2701 | 39 | if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'accomplishments_viewer')) | 39 | if (os.path.exists(os.path.join(PROJECT_ROOT_DIRECTORY, 'accomplishments_viewer')) |
2703 | 40 | and PROJECT_ROOT_DIRECTORY not in sys.path): | 40 | and PROJECT_ROOT_DIRECTORY not in sys.path): |
2704 | 41 | python_path.insert(0, PROJECT_ROOT_DIRECTORY) | 41 | python_path.insert(0, PROJECT_ROOT_DIRECTORY) |
2705 | 42 | sys.path.insert(0, PROJECT_ROOT_DIRECTORY) | 42 | sys.path.insert(0, PROJECT_ROOT_DIRECTORY) |
2706 | 43 | if python_path: | 43 | if python_path: |
2708 | 44 | os.putenv('PYTHONPATH', "%s:%s" % (os.getenv('PYTHONPATH', ''), ':'.join(python_path))) # for subprocesses | 44 | os.putenv('PYTHONPATH', "%s:%s" % (os.getenv('PYTHONPATH', ''), ':'.join(python_path))) # for subprocesses |
2709 | 45 | 45 | ||
2710 | 46 | import accomplishments_viewer | 46 | import accomplishments_viewer |
2711 | 47 | accomplishments_viewer.main() | 47 | accomplishments_viewer.main() |
2712 | 48 | 48 | ||
2713 | === modified file 'tests/test_example.py' | |||
2714 | --- tests/test_example.py 2012-09-07 18:40:05 +0000 | |||
2715 | +++ tests/test_example.py 2012-11-26 16:03:25 +0000 | |||
2716 | @@ -2,16 +2,16 @@ | |||
2717 | 2 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 2 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2718 | 3 | ### BEGIN LICENSE | 3 | ### BEGIN LICENSE |
2719 | 4 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 4 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2722 | 5 | # This program is free software: you can redistribute it and/or modify it | 5 | # This program is free software: you can redistribute it and/or modify it |
2723 | 6 | # under the terms of the GNU General Public License version 3, as published | 6 | # under the terms of the GNU General Public License version 3, as published |
2724 | 7 | # by the Free Software Foundation. | 7 | # by the Free Software Foundation. |
2729 | 8 | # | 8 | # |
2730 | 9 | # This program is distributed in the hope that it will be useful, but | 9 | # This program is distributed in the hope that it will be useful, but |
2731 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2732 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2733 | 12 | # PURPOSE. See the GNU General Public License for more details. | 12 | # PURPOSE. See the GNU General Public License for more details. |
2736 | 13 | # | 13 | # |
2737 | 14 | # You should have received a copy of the GNU General Public License along | 14 | # You should have received a copy of the GNU General Public License along |
2738 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2739 | 16 | ### END LICENSE | 16 | ### END LICENSE |
2740 | 17 | 17 | ||
2741 | @@ -22,10 +22,13 @@ | |||
2742 | 22 | 22 | ||
2743 | 23 | from accomplishments_viewer import AboutAccomplishmentsViewerDialog | 23 | from accomplishments_viewer import AboutAccomplishmentsViewerDialog |
2744 | 24 | 24 | ||
2745 | 25 | |||
2746 | 25 | class TestExample(unittest.TestCase): | 26 | class TestExample(unittest.TestCase): |
2747 | 26 | def setUp(self): | 27 | def setUp(self): |
2748 | 27 | self.AboutAccomplishmentsViewerDialog_members = [ | 28 | self.AboutAccomplishmentsViewerDialog_members = [ |
2750 | 28 | 'AboutAccomplishmentsViewerDialog', 'AboutDialog', 'dbusapi', 'gettext', 'locale', 'locale_dir', 'logger', 'logging'] | 29 | 'AboutAccomplishmentsViewerDialog', 'AboutDialog', 'dbusapi', |
2751 | 30 | 'gettext', 'locale', 'locale_dir', 'logger', 'logging' | ||
2752 | 31 | ] | ||
2753 | 29 | 32 | ||
2754 | 30 | def test_AboutAccomplishmentsViewerDialog_members(self): | 33 | def test_AboutAccomplishmentsViewerDialog_members(self): |
2755 | 31 | all_members = dir(AboutAccomplishmentsViewerDialog) | 34 | all_members = dir(AboutAccomplishmentsViewerDialog) |
2756 | @@ -33,5 +36,5 @@ | |||
2757 | 33 | public_members.sort() | 36 | public_members.sort() |
2758 | 34 | self.assertEqual(self.AboutAccomplishmentsViewerDialog_members, public_members) | 37 | self.assertEqual(self.AboutAccomplishmentsViewerDialog_members, public_members) |
2759 | 35 | 38 | ||
2761 | 36 | if __name__ == '__main__': | 39 | if __name__ == '__main__': |
2762 | 37 | unittest.main() | 40 | unittest.main() |
2763 | 38 | 41 | ||
2764 | === modified file 'tests/test_lint.py' | |||
2765 | --- tests/test_lint.py 2012-09-07 18:19:02 +0000 | |||
2766 | +++ tests/test_lint.py 2012-11-26 16:03:25 +0000 | |||
2767 | @@ -2,16 +2,16 @@ | |||
2768 | 2 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 2 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
2769 | 3 | ### BEGIN LICENSE | 3 | ### BEGIN LICENSE |
2770 | 4 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> | 4 | # Copyright (C) 2012 Jono Bacon <jono@ubuntu.com> |
2773 | 5 | # This program is free software: you can redistribute it and/or modify it | 5 | # This program is free software: you can redistribute it and/or modify it |
2774 | 6 | # under the terms of the GNU General Public License version 3, as published | 6 | # under the terms of the GNU General Public License version 3, as published |
2775 | 7 | # by the Free Software Foundation. | 7 | # by the Free Software Foundation. |
2780 | 8 | # | 8 | # |
2781 | 9 | # This program is distributed in the hope that it will be useful, but | 9 | # This program is distributed in the hope that it will be useful, but |
2782 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of |
2783 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2784 | 12 | # PURPOSE. See the GNU General Public License for more details. | 12 | # PURPOSE. See the GNU General Public License for more details. |
2787 | 13 | # | 13 | # |
2788 | 14 | # You should have received a copy of the GNU General Public License along | 14 | # You should have received a copy of the GNU General Public License along |
2789 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
2790 | 16 | ### END LICENSE | 16 | ### END LICENSE |
2791 | 17 | 17 | ||
2792 | @@ -21,17 +21,17 @@ | |||
2793 | 21 | class TestPylint(unittest.TestCase): | 21 | class TestPylint(unittest.TestCase): |
2794 | 22 | def test_project_errors_only(self): | 22 | def test_project_errors_only(self): |
2795 | 23 | '''run pylint in error only mode | 23 | '''run pylint in error only mode |
2797 | 24 | 24 | ||
2798 | 25 | your code may well work even with pylint errors | 25 | your code may well work even with pylint errors |
2799 | 26 | but have some unusual code''' | 26 | but have some unusual code''' |
2800 | 27 | return_code = subprocess.call(["pylint", '-E', 'accomplishments_viewer']) | 27 | return_code = subprocess.call(["pylint", '-E', 'accomplishments_viewer']) |
2801 | 28 | # not needed because nosetests displays pylint console output | 28 | # not needed because nosetests displays pylint console output |
2802 | 29 | #self.assertEqual(return_code, 0) | 29 | #self.assertEqual(return_code, 0) |
2803 | 30 | 30 | ||
2805 | 31 | # un-comment the following for loads of diagnostics | 31 | # un-comment the following for loads of diagnostics |
2806 | 32 | #~ def test_project_full_report(self): | 32 | #~ def test_project_full_report(self): |
2807 | 33 | #~ '''Only for the brave | 33 | #~ '''Only for the brave |
2809 | 34 | #~ | 34 | #~ |
2810 | 35 | #~ you will have to make judgement calls about your code standards | 35 | #~ you will have to make judgement calls about your code standards |
2811 | 36 | #~ that differ from the norm''' | 36 | #~ that differ from the norm''' |
2812 | 37 | #~ return_code = subprocess.call(["pylint", 'accomplishments_viewer']) | 37 | #~ return_code = subprocess.call(["pylint", 'accomplishments_viewer']) |
Here's a diff with all whitespace changes removed:
http:// paste.ubuntu. com/1390196/