Merge lp:~quickly-committers/quickly/gtk3-projects into lp:quickly
- gtk3-projects
- Merge into trunk
Proposed by
Michael Terry
Status: | Merged |
---|---|
Merged at revision: | 645 |
Proposed branch: | lp:~quickly-committers/quickly/gtk3-projects |
Merge into: | lp:quickly |
Diff against target: |
1834 lines (+265/-696) 38 files modified
data/templates/ubuntu-application/create.py (+13/-1) data/templates/ubuntu-application/help/code/JottyWindow.py (+1/-1) data/templates/ubuntu-application/help/tutorial.xml (+1/-1) data/templates/ubuntu-application/project_root/.bzrignore (+1/-0) data/templates/ubuntu-application/project_root/data/glib-2.0/schemas/net.launchpad.project_name.gschema.xml (+10/-0) data/templates/ubuntu-application/project_root/data/ui/Aboutcamel_case_nameDialog.ui (+11/-13) data/templates/ubuntu-application/project_root/data/ui/Preferencescamel_case_nameDialog.ui (+68/-49) data/templates/ubuntu-application/project_root/data/ui/camel_case_nameWindow.ui (+1/-2) data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py (+9/-25) data/templates/ubuntu-application/project_root/python/__init__.py (+3/-16) data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py (+1/-1) data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py (+2/-2) data/templates/ubuntu-application/project_root/python_lib/Builder.py (+29/-14) data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py (+3/-84) data/templates/ubuntu-application/project_root/python_lib/Window.py (+8/-10) data/templates/ubuntu-application/project_root/python_lib/__init__.py (+0/-1) data/templates/ubuntu-application/project_root/python_lib/helpers.py (+3/-4) data/templates/ubuntu-application/project_root/python_lib/preferences.py (+0/-100) data/templates/ubuntu-application/project_root/tests/test_example.py (+1/-1) data/templates/ubuntu-application/run.py (+13/-1) data/templates/ubuntu-application/store/data/ui/dialog_camel_case_nameDialog.ui (+13/-9) data/templates/ubuntu-application/store/data/ui/dialog_python_name_dialog.xml (+1/-1) data/templates/ubuntu-application/store/dialog.py (+1/-1) data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py (+5/-5) data/templates/ubuntu-application/store/python/indicator.py (+7/-8) data/templates/ubuntu-application/test/apport/apport.sh (+12/-5) data/templates/ubuntu-application/test/builder/builder.py (+2/-2) data/templates/ubuntu-application/test/configure.sh (+2/-3) data/templates/ubuntu-application/test/filelist.sh (+5/-2) data/templates/ubuntu-application/test/metadata.sh (+2/-4) data/templates/ubuntu-application/test/preferences.py (+0/-151) data/templates/ubuntu-application/upgrade.py (+4/-2) data/templates/ubuntu-flash-game/internal/apportutils.py (+0/-143) data/templates/ubuntu-flash-game/project_root/bin/project_name (+8/-7) quickly/quicklyconfig.py (+1/-1) quickly/test/pylint.sh (+1/-1) setup.py (+1/-1) ubuntudevbar.py (+22/-24) |
To merge this branch: | bzr merge lp:~quickly-committers/quickly/gtk3-projects |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Didier Roche-Tolomelli | Approve | ||
Review via email:
|
Commit message
Description of the change
Woo! Gtk3/PyGI/GSettings all wrapped into one branch (because they can't be done separately).
Lots of changes. I dropped desktopcouch for gsettings (as discussed in mailing list). Rest of changes are pretty expected.
Tests all pass now (with latest python-
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Terry (mterry) wrote : | # |
I missed your review comment! I was sitting here thinking, "Man, didrocks is taking forever with gtk3... What?! He's on holiday!? Son of a..." Then I checked and you had approved! :)
The "quickly upgrade 0.3" changes were just a spot of cleanup because the "0.4" argument was not actually doing anything. Merged it after double confirming that tests pass.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
See, don't be so mean ;)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/templates/ubuntu-application/create.py' | |||
2 | --- data/templates/ubuntu-application/create.py 2011-06-06 10:14:40 +0000 | |||
3 | +++ data/templates/ubuntu-application/create.py 2011-11-08 16:10:57 +0000 | |||
4 | @@ -107,10 +107,22 @@ | |||
5 | 107 | bzr_instance.wait() | 107 | bzr_instance.wait() |
6 | 108 | bzr_instance = subprocess.Popen(["bzr", "commit", "-m", "Initial project creation with Quickly!"], stderr=subprocess.PIPE) | 108 | bzr_instance = subprocess.Popen(["bzr", "commit", "-m", "Initial project creation with Quickly!"], stderr=subprocess.PIPE) |
7 | 109 | 109 | ||
8 | 110 | # Compile schema if present | ||
9 | 111 | schemapath = os.path.abspath("data/glib-2.0/schemas") | ||
10 | 112 | if os.path.exists(schemapath): | ||
11 | 113 | subprocess.call(["glib-compile-schemas", schemapath]) | ||
12 | 114 | |||
13 | 115 | env = os.environ.copy() | ||
14 | 116 | datadir = os.path.abspath("data") | ||
15 | 117 | if 'XDG_DATA_DIRS' in env: | ||
16 | 118 | env['XDG_DATA_DIRS'] = "%s:%s" % (datadir, env['XDG_DATA_DIRS']) | ||
17 | 119 | else: | ||
18 | 120 | env['XDG_DATA_DIRS'] = datadir | ||
19 | 121 | |||
20 | 110 | # run the new application if X display | 122 | # run the new application if X display |
21 | 111 | if templatetools.is_X_display() and os.path.isfile(exec_file): | 123 | if templatetools.is_X_display() and os.path.isfile(exec_file): |
22 | 112 | print _("Launching your newly created project!") | 124 | print _("Launching your newly created project!") |
24 | 113 | subprocess.call(['./' + project_name], cwd='bin/') | 125 | subprocess.call(['./' + project_name], cwd='bin/', env=env) |
25 | 114 | 126 | ||
26 | 115 | bzr_instance.wait() | 127 | bzr_instance.wait() |
27 | 116 | 128 | ||
28 | 117 | 129 | ||
29 | === modified file 'data/templates/ubuntu-application/help/code/JottyWindow.py' | |||
30 | --- data/templates/ubuntu-application/help/code/JottyWindow.py 2011-04-04 13:55:18 +0000 | |||
31 | +++ data/templates/ubuntu-application/help/code/JottyWindow.py 2011-11-08 16:10:57 +0000 | |||
32 | @@ -7,7 +7,7 @@ | |||
33 | 7 | from gettext import gettext as _ | 7 | from gettext import gettext as _ |
34 | 8 | gettext.textdomain('jotty') | 8 | gettext.textdomain('jotty') |
35 | 9 | 9 | ||
37 | 10 | import gtk | 10 | from gi.repository import Gtk # pylint: disable=E0611 |
38 | 11 | import logging | 11 | import logging |
39 | 12 | logger = logging.getLogger('jotty') | 12 | logger = logging.getLogger('jotty') |
40 | 13 | 13 | ||
41 | 14 | 14 | ||
42 | === modified file 'data/templates/ubuntu-application/help/tutorial.xml' | |||
43 | --- data/templates/ubuntu-application/help/tutorial.xml 2011-09-26 13:02:43 +0000 | |||
44 | +++ data/templates/ubuntu-application/help/tutorial.xml 2011-11-08 16:10:57 +0000 | |||
45 | @@ -3,7 +3,7 @@ | |||
46 | 3 | "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ | 3 | "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ |
47 | 4 | 4 | ||
48 | 5 | <!ENTITY appname "<application>Quickly</application>" > | 5 | <!ENTITY appname "<application>Quickly</application>" > |
50 | 6 | <!ENTITY appversion "11.10" > | 6 | <!ENTITY appversion "11.11" > |
51 | 7 | ] > | 7 | ] > |
52 | 8 | 8 | ||
53 | 9 | <book lang="en" id="index"> | 9 | <book lang="en" id="index"> |
54 | 10 | 10 | ||
55 | === added file 'data/templates/ubuntu-application/project_root/.bzrignore' | |||
56 | --- data/templates/ubuntu-application/project_root/.bzrignore 1970-01-01 00:00:00 +0000 | |||
57 | +++ data/templates/ubuntu-application/project_root/.bzrignore 2011-11-08 16:10:57 +0000 | |||
58 | @@ -0,0 +1,1 @@ | |||
59 | 1 | data/glib-2.0/schemas/gschemas.compiled | ||
60 | 0 | 2 | ||
61 | === added directory 'data/templates/ubuntu-application/project_root/data/glib-2.0' | |||
62 | === added directory 'data/templates/ubuntu-application/project_root/data/glib-2.0/schemas' | |||
63 | === added file 'data/templates/ubuntu-application/project_root/data/glib-2.0/schemas/net.launchpad.project_name.gschema.xml' | |||
64 | --- data/templates/ubuntu-application/project_root/data/glib-2.0/schemas/net.launchpad.project_name.gschema.xml 1970-01-01 00:00:00 +0000 | |||
65 | +++ data/templates/ubuntu-application/project_root/data/glib-2.0/schemas/net.launchpad.project_name.gschema.xml 2011-11-08 16:10:57 +0000 | |||
66 | @@ -0,0 +1,10 @@ | |||
67 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
68 | 2 | <schemalist gettext-domain="project_name"> | ||
69 | 3 | <schema id="net.launchpad.project_name" path="/net/launchpad/project_name/"> | ||
70 | 4 | <key name="example" type="s"> | ||
71 | 5 | <default>''</default> | ||
72 | 6 | <summary>Sample setting</summary> | ||
73 | 7 | <description>Longer description of this sample setting. Talk about allowed values and what it does.</description> | ||
74 | 8 | </key> | ||
75 | 9 | </schema> | ||
76 | 10 | </schemalist> | ||
77 | 0 | 11 | ||
78 | === modified file 'data/templates/ubuntu-application/project_root/data/ui/Aboutcamel_case_nameDialog.ui' | |||
79 | --- data/templates/ubuntu-application/project_root/data/ui/Aboutcamel_case_nameDialog.ui 2010-12-20 15:44:44 +0000 | |||
80 | +++ data/templates/ubuntu-application/project_root/data/ui/Aboutcamel_case_nameDialog.ui 2011-11-08 16:10:57 +0000 | |||
81 | @@ -1,39 +1,37 @@ | |||
83 | 1 | <?xml version="1.0"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
84 | 2 | <interface> | 2 | <interface> |
85 | 3 | <requires lib="gtk+" version="2.16"/> | ||
86 | 4 | <!-- interface-requires about_python_name_dialog 1.0 --> | 3 | <!-- interface-requires about_python_name_dialog 1.0 --> |
88 | 5 | <!-- interface-naming-policy project-wide --> | 4 | <!-- interface-requires gtk+ 3.0 --> |
89 | 6 | <object class="Aboutcamel_case_nameDialog" id="about_python_name_dialog"> | 5 | <object class="Aboutcamel_case_nameDialog" id="about_python_name_dialog"> |
90 | 6 | <property name="can_focus">False</property> | ||
91 | 7 | <property name="border_width">5</property> | 7 | <property name="border_width">5</property> |
92 | 8 | <property name="icon">../media/project_name.svg</property> | 8 | <property name="icon">../media/project_name.svg</property> |
93 | 9 | <property name="type_hint">normal</property> | 9 | <property name="type_hint">normal</property> |
94 | 10 | <property name="has_separator">False</property> | ||
95 | 11 | <property name="program_name">sentence_name</property> | 10 | <property name="program_name">sentence_name</property> |
96 | 12 | <property name="version"></property> | ||
97 | 13 | <property name="copyright"></property> | ||
98 | 14 | <property name="website"></property> | ||
99 | 15 | <property name="license"></property> | ||
100 | 16 | <property name="authors"></property> | 11 | <property name="authors"></property> |
101 | 17 | <property name="logo">../media/project_name.svg</property> | 12 | <property name="logo">../media/project_name.svg</property> |
102 | 18 | <child internal-child="vbox"> | 13 | <child internal-child="vbox"> |
104 | 19 | <object class="GtkVBox" id="dialog-vbox1"> | 14 | <object class="GtkBox" id="dialog-vbox1"> |
105 | 20 | <property name="visible">True</property> | 15 | <property name="visible">True</property> |
106 | 16 | <property name="can_focus">False</property> | ||
107 | 21 | <property name="orientation">vertical</property> | 17 | <property name="orientation">vertical</property> |
108 | 22 | <property name="spacing">2</property> | 18 | <property name="spacing">2</property> |
109 | 23 | <child> | ||
110 | 24 | <placeholder/> | ||
111 | 25 | </child> | ||
112 | 26 | <child internal-child="action_area"> | 19 | <child internal-child="action_area"> |
114 | 27 | <object class="GtkHButtonBox" id="dialog-action_area1"> | 20 | <object class="GtkButtonBox" id="dialog-action_area1"> |
115 | 28 | <property name="visible">True</property> | 21 | <property name="visible">True</property> |
116 | 22 | <property name="can_focus">False</property> | ||
117 | 29 | <property name="layout_style">end</property> | 23 | <property name="layout_style">end</property> |
118 | 30 | </object> | 24 | </object> |
119 | 31 | <packing> | 25 | <packing> |
120 | 32 | <property name="expand">False</property> | 26 | <property name="expand">False</property> |
121 | 27 | <property name="fill">True</property> | ||
122 | 33 | <property name="pack_type">end</property> | 28 | <property name="pack_type">end</property> |
123 | 34 | <property name="position">0</property> | 29 | <property name="position">0</property> |
124 | 35 | </packing> | 30 | </packing> |
125 | 36 | </child> | 31 | </child> |
126 | 32 | <child> | ||
127 | 33 | <placeholder/> | ||
128 | 34 | </child> | ||
129 | 37 | </object> | 35 | </object> |
130 | 38 | </child> | 36 | </child> |
131 | 39 | </object> | 37 | </object> |
132 | 40 | 38 | ||
133 | === modified file 'data/templates/ubuntu-application/project_root/data/ui/Preferencescamel_case_nameDialog.ui' | |||
134 | --- data/templates/ubuntu-application/project_root/data/ui/Preferencescamel_case_nameDialog.ui 2010-12-20 15:44:44 +0000 | |||
135 | +++ data/templates/ubuntu-application/project_root/data/ui/Preferencescamel_case_nameDialog.ui 2011-11-08 16:10:57 +0000 | |||
136 | @@ -1,88 +1,107 @@ | |||
137 | 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
138 | 2 | <interface> | 2 | <interface> |
140 | 3 | <requires lib="gtk+" version="2.16"/> | 3 | <!-- interface-requires gtk+ 3.0 --> |
141 | 4 | <!-- interface-requires preferences_python_name_dialog 1.0 --> | 4 | <!-- interface-requires preferences_python_name_dialog 1.0 --> |
142 | 5 | <!-- interface-naming-policy project-wide --> | ||
143 | 6 | <object class="Preferencescamel_case_nameDialog" id="preferences_python_name_dialog"> | 5 | <object class="Preferencescamel_case_nameDialog" id="preferences_python_name_dialog"> |
145 | 7 | <property name="border_width">5</property> | 6 | <property name="can_focus">False</property> |
146 | 8 | <property name="title" translatable="yes">sentence_name Preferences</property> | 7 | <property name="title" translatable="yes">sentence_name Preferences</property> |
147 | 9 | <property name="icon">../media/project_name.svg</property> | 8 | <property name="icon">../media/project_name.svg</property> |
148 | 10 | <property name="type_hint">normal</property> | 9 | <property name="type_hint">normal</property> |
149 | 11 | <child internal-child="vbox"> | 10 | <child internal-child="vbox"> |
151 | 12 | <object class="GtkVBox" id="dialog-vbox1"> | 11 | <object class="GtkBox" id="dialog-vbox1"> |
152 | 13 | <property name="visible">True</property> | 12 | <property name="visible">True</property> |
154 | 14 | <property name="spacing">2</property> | 13 | <property name="can_focus">False</property> |
155 | 14 | <property name="orientation">vertical</property> | ||
156 | 15 | <property name="spacing">12</property> | ||
157 | 16 | <child internal-child="action_area"> | ||
158 | 17 | <object class="GtkButtonBox" id="dialog-action_area1"> | ||
159 | 18 | <property name="visible">True</property> | ||
160 | 19 | <property name="can_focus">False</property> | ||
161 | 20 | <property name="layout_style">end</property> | ||
162 | 21 | <child> | ||
163 | 22 | <object class="GtkButton" id="btn_help"> | ||
164 | 23 | <property name="label">gtk-help</property> | ||
165 | 24 | <property name="visible">True</property> | ||
166 | 25 | <property name="can_focus">True</property> | ||
167 | 26 | <property name="receives_default">True</property> | ||
168 | 27 | <property name="use_action_appearance">False</property> | ||
169 | 28 | <property name="use_stock">True</property> | ||
170 | 29 | </object> | ||
171 | 30 | <packing> | ||
172 | 31 | <property name="expand">False</property> | ||
173 | 32 | <property name="fill">False</property> | ||
174 | 33 | <property name="position">0</property> | ||
175 | 34 | <property name="secondary">True</property> | ||
176 | 35 | </packing> | ||
177 | 36 | </child> | ||
178 | 37 | <child> | ||
179 | 38 | <object class="GtkButton" id="btn_close"> | ||
180 | 39 | <property name="label">gtk-close</property> | ||
181 | 40 | <property name="visible">True</property> | ||
182 | 41 | <property name="can_focus">True</property> | ||
183 | 42 | <property name="receives_default">True</property> | ||
184 | 43 | <property name="use_action_appearance">False</property> | ||
185 | 44 | <property name="use_stock">True</property> | ||
186 | 45 | </object> | ||
187 | 46 | <packing> | ||
188 | 47 | <property name="expand">False</property> | ||
189 | 48 | <property name="fill">False</property> | ||
190 | 49 | <property name="position">1</property> | ||
191 | 50 | </packing> | ||
192 | 51 | </child> | ||
193 | 52 | </object> | ||
194 | 53 | <packing> | ||
195 | 54 | <property name="expand">False</property> | ||
196 | 55 | <property name="fill">True</property> | ||
197 | 56 | <property name="pack_type">end</property> | ||
198 | 57 | <property name="position">0</property> | ||
199 | 58 | </packing> | ||
200 | 59 | </child> | ||
201 | 15 | <child> | 60 | <child> |
203 | 16 | <object class="GtkTable" id="table1"> | 61 | <object class="GtkGrid" id="table1"> |
204 | 17 | <property name="visible">True</property> | 62 | <property name="visible">True</property> |
205 | 63 | <property name="can_focus">False</property> | ||
206 | 64 | <property name="row_spacing">6</property> | ||
207 | 65 | <property name="column_spacing">6</property> | ||
208 | 66 | <property name="n_rows">1</property> | ||
209 | 18 | <property name="n_columns">2</property> | 67 | <property name="n_columns">2</property> |
210 | 19 | <property name="column_spacing">6</property> | ||
211 | 20 | <property name="row_spacing">6</property> | ||
212 | 21 | <child> | 68 | <child> |
213 | 22 | <object class="GtkEntry" id="example_entry"> | 69 | <object class="GtkEntry" id="example_entry"> |
214 | 23 | <property name="visible">True</property> | 70 | <property name="visible">True</property> |
215 | 24 | <property name="can_focus">True</property> | 71 | <property name="can_focus">True</property> |
216 | 72 | <property name="hexpand">True</property> | ||
217 | 25 | <property name="invisible_char">•</property> | 73 | <property name="invisible_char">•</property> |
218 | 26 | </object> | 74 | </object> |
219 | 27 | <packing> | 75 | <packing> |
220 | 28 | <property name="left_attach">1</property> | 76 | <property name="left_attach">1</property> |
222 | 29 | <property name="right_attach">2</property> | 77 | <property name="top_attach">0</property> |
223 | 78 | <property name="width">1</property> | ||
224 | 79 | <property name="height">1</property> | ||
225 | 30 | </packing> | 80 | </packing> |
226 | 31 | </child> | 81 | </child> |
227 | 32 | <child> | 82 | <child> |
228 | 33 | <object class="GtkLabel" id="example_entry_label"> | 83 | <object class="GtkLabel" id="example_entry_label"> |
229 | 34 | <property name="visible">True</property> | 84 | <property name="visible">True</property> |
230 | 85 | <property name="can_focus">False</property> | ||
231 | 35 | <property name="xalign">0</property> | 86 | <property name="xalign">0</property> |
232 | 36 | <property name="label" translatable="yes">_Example entry:</property> | 87 | <property name="label" translatable="yes">_Example entry:</property> |
233 | 37 | <property name="use_underline">True</property> | 88 | <property name="use_underline">True</property> |
234 | 38 | <property name="mnemonic_widget">example_entry</property> | 89 | <property name="mnemonic_widget">example_entry</property> |
235 | 39 | </object> | 90 | </object> |
236 | 91 | <packing> | ||
237 | 92 | <property name="left_attach">0</property> | ||
238 | 93 | <property name="top_attach">0</property> | ||
239 | 94 | <property name="width">1</property> | ||
240 | 95 | <property name="height">1</property> | ||
241 | 96 | </packing> | ||
242 | 40 | </child> | 97 | </child> |
243 | 41 | </object> | 98 | </object> |
244 | 42 | <packing> | 99 | <packing> |
245 | 100 | <property name="expand">False</property> | ||
246 | 101 | <property name="fill">True</property> | ||
247 | 43 | <property name="position">1</property> | 102 | <property name="position">1</property> |
248 | 44 | </packing> | 103 | </packing> |
249 | 45 | </child> | 104 | </child> |
250 | 46 | <child internal-child="action_area"> | ||
251 | 47 | <object class="GtkHButtonBox" id="dialog-action_area1"> | ||
252 | 48 | <property name="visible">True</property> | ||
253 | 49 | <property name="layout_style">end</property> | ||
254 | 50 | <child> | ||
255 | 51 | <object class="GtkButton" id="btn_help"> | ||
256 | 52 | <property name="label">gtk-help</property> | ||
257 | 53 | <property name="visible">True</property> | ||
258 | 54 | <property name="can_focus">True</property> | ||
259 | 55 | <property name="receives_default">True</property> | ||
260 | 56 | <property name="use_stock">True</property> | ||
261 | 57 | </object> | ||
262 | 58 | <packing> | ||
263 | 59 | <property name="expand">False</property> | ||
264 | 60 | <property name="fill">False</property> | ||
265 | 61 | <property name="position">0</property> | ||
266 | 62 | <property name="secondary">True</property> | ||
267 | 63 | </packing> | ||
268 | 64 | </child> | ||
269 | 65 | <child> | ||
270 | 66 | <object class="GtkButton" id="btn_close"> | ||
271 | 67 | <property name="label">gtk-close</property> | ||
272 | 68 | <property name="visible">True</property> | ||
273 | 69 | <property name="can_focus">True</property> | ||
274 | 70 | <property name="receives_default">True</property> | ||
275 | 71 | <property name="use_stock">True</property> | ||
276 | 72 | </object> | ||
277 | 73 | <packing> | ||
278 | 74 | <property name="expand">False</property> | ||
279 | 75 | <property name="fill">False</property> | ||
280 | 76 | <property name="position">1</property> | ||
281 | 77 | </packing> | ||
282 | 78 | </child> | ||
283 | 79 | </object> | ||
284 | 80 | <packing> | ||
285 | 81 | <property name="expand">False</property> | ||
286 | 82 | <property name="pack_type">end</property> | ||
287 | 83 | <property name="position">0</property> | ||
288 | 84 | </packing> | ||
289 | 85 | </child> | ||
290 | 86 | </object> | 105 | </object> |
291 | 87 | </child> | 106 | </child> |
292 | 88 | <action-widgets> | 107 | <action-widgets> |
293 | 89 | 108 | ||
294 | === modified file 'data/templates/ubuntu-application/project_root/data/ui/camel_case_nameWindow.ui' | |||
295 | --- data/templates/ubuntu-application/project_root/data/ui/camel_case_nameWindow.ui 2011-04-01 21:02:04 +0000 | |||
296 | +++ data/templates/ubuntu-application/project_root/data/ui/camel_case_nameWindow.ui 2011-11-08 16:10:57 +0000 | |||
297 | @@ -1,8 +1,7 @@ | |||
298 | 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
299 | 2 | <interface> | 2 | <interface> |
301 | 3 | <requires lib="gtk+" version="2.16"/> | 3 | <!-- interface-requires gtk+ 3.0 --> |
302 | 4 | <!-- interface-requires python_name_window 1.0 --> | 4 | <!-- interface-requires python_name_window 1.0 --> |
303 | 5 | <!-- interface-naming-policy project-wide --> | ||
304 | 6 | <!-- interface-local-resource-path ../media --> | 5 | <!-- interface-local-resource-path ../media --> |
305 | 7 | <object class="GtkImage" id="image2"> | 6 | <object class="GtkImage" id="image2"> |
306 | 8 | <property name="visible">True</property> | 7 | <property name="visible">True</property> |
307 | 9 | 8 | ||
308 | === modified file 'data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py' | |||
309 | --- data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py 2011-04-04 14:28:36 +0000 | |||
310 | +++ data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py 2011-11-08 16:10:57 +0000 | |||
311 | @@ -5,27 +5,11 @@ | |||
312 | 5 | 5 | ||
313 | 6 | # This is your preferences dialog. | 6 | # This is your preferences dialog. |
314 | 7 | # | 7 | # |
336 | 8 | # Define your preferences dictionary in the __init__.main() function. | 8 | # Define your preferences in |
337 | 9 | # The widget names in the PreferencesTestProjectDialog.ui | 9 | # data/glib-2.0/schemas/net.launchpad.project_name.gschema.xml |
338 | 10 | # file need to correspond to the keys in the preferences dictionary. | 10 | # See http://developer.gnome.org/gio/stable/GSettings.html for more info. |
339 | 11 | # | 11 | |
340 | 12 | # Each preference also need to be defined in the 'widget_methods' map below | 12 | from gi.repository import Gio # pylint: disable=E0611 |
320 | 13 | # to show up in the dialog itself. Provide three bits of information: | ||
321 | 14 | # 1) The first entry is the method on the widget that grabs a value from the | ||
322 | 15 | # widget. | ||
323 | 16 | # 2) The second entry is the method on the widget that sets the widgets value | ||
324 | 17 | # from a stored preference. | ||
325 | 18 | # 3) The third entry is a signal the widget will send when the contents have | ||
326 | 19 | # been changed by the user. The preferences dictionary is always up to | ||
327 | 20 | # date and will signal the rest of the application about these changes. | ||
328 | 21 | # The values will be saved to desktopcouch when the application closes. | ||
329 | 22 | # | ||
330 | 23 | # TODO: replace widget_methods with your own values | ||
331 | 24 | |||
332 | 25 | |||
333 | 26 | widget_methods = { | ||
334 | 27 | 'example_entry': ['get_text', 'set_text', 'changed'], | ||
335 | 28 | } | ||
341 | 29 | 13 | ||
342 | 30 | import gettext | 14 | import gettext |
343 | 31 | from gettext import gettext as _ | 15 | from gettext import gettext as _ |
344 | @@ -43,9 +27,9 @@ | |||
345 | 43 | """Set up the preferences dialog""" | 27 | """Set up the preferences dialog""" |
346 | 44 | super(Preferencescamel_case_nameDialog, self).finish_initializing(builder) | 28 | super(Preferencescamel_case_nameDialog, self).finish_initializing(builder) |
347 | 45 | 29 | ||
352 | 46 | # populate the dialog from the preferences dictionary | 30 | # Bind each preference widget to gsettings |
353 | 47 | # using the methods from widget_methods | 31 | settings = Gio.Settings("net.launchpad.project_name") |
354 | 48 | self.widget_methods = widget_methods | 32 | widget = self.builder.get_object('example_entry') |
355 | 49 | self.set_widgets_from_preferences() # pylint: disable=E1101 | 33 | settings.bind("example", widget, "text", Gio.SettingsBindFlags.DEFAULT) |
356 | 50 | 34 | ||
357 | 51 | # Code for other initialization actions should be added here. | 35 | # Code for other initialization actions should be added here. |
358 | 52 | 36 | ||
359 | === modified file 'data/templates/ubuntu-application/project_root/python/__init__.py' | |||
360 | --- data/templates/ubuntu-application/project_root/python/__init__.py 2011-03-31 15:19:55 +0000 | |||
361 | +++ data/templates/ubuntu-application/project_root/python/__init__.py 2011-11-08 16:10:57 +0000 | |||
362 | @@ -9,11 +9,11 @@ | |||
363 | 9 | from gettext import gettext as _ | 9 | from gettext import gettext as _ |
364 | 10 | gettext.textdomain('project_name') | 10 | gettext.textdomain('project_name') |
365 | 11 | 11 | ||
367 | 12 | import gtk | 12 | from gi.repository import Gtk # pylint: disable=E0611 |
368 | 13 | 13 | ||
369 | 14 | from python_name import camel_case_nameWindow | 14 | from python_name import camel_case_nameWindow |
370 | 15 | 15 | ||
372 | 16 | from python_name_lib import set_up_logging, preferences, get_version | 16 | from python_name_lib import set_up_logging, get_version |
373 | 17 | 17 | ||
374 | 18 | def parse_options(): | 18 | def parse_options(): |
375 | 19 | """Support for command line options""" | 19 | """Support for command line options""" |
376 | @@ -29,20 +29,7 @@ | |||
377 | 29 | 'constructor for your class instances' | 29 | 'constructor for your class instances' |
378 | 30 | parse_options() | 30 | parse_options() |
379 | 31 | 31 | ||
380 | 32 | # preferences | ||
381 | 33 | # set some values for our first session | ||
382 | 34 | # TODO: replace defaults with your own values | ||
383 | 35 | default_preferences = { | ||
384 | 36 | 'example_entry': 'I remember stuff', | ||
385 | 37 | } | ||
386 | 38 | preferences.update(default_preferences) | ||
387 | 39 | # user's stored preferences are used for 2nd and subsequent sessions | ||
388 | 40 | preferences.db_connect() | ||
389 | 41 | preferences.load() | ||
390 | 42 | |||
391 | 43 | # Run the application. | 32 | # Run the application. |
392 | 44 | window = camel_case_nameWindow.camel_case_nameWindow() | 33 | window = camel_case_nameWindow.camel_case_nameWindow() |
393 | 45 | window.show() | 34 | window.show() |
397 | 46 | gtk.main() | 35 | Gtk.main() |
395 | 47 | |||
396 | 48 | preferences.save() | ||
398 | 49 | 36 | ||
399 | === modified file 'data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py' | |||
400 | --- data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py 2011-04-04 14:28:36 +0000 | |||
401 | +++ data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py 2011-11-08 16:10:57 +0000 | |||
402 | @@ -7,7 +7,7 @@ | |||
403 | 7 | from gettext import gettext as _ | 7 | from gettext import gettext as _ |
404 | 8 | gettext.textdomain('project_name') | 8 | gettext.textdomain('project_name') |
405 | 9 | 9 | ||
407 | 10 | import gtk | 10 | from gi.repository import Gtk # pylint: disable=E0611 |
408 | 11 | import logging | 11 | import logging |
409 | 12 | logger = logging.getLogger('python_name') | 12 | logger = logging.getLogger('python_name') |
410 | 13 | 13 | ||
411 | 14 | 14 | ||
412 | === modified file 'data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py' | |||
413 | --- data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py 2011-03-31 17:05:41 +0000 | |||
414 | +++ data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py 2011-11-08 16:10:57 +0000 | |||
415 | @@ -3,11 +3,11 @@ | |||
416 | 3 | # This file is in the public domain | 3 | # This file is in the public domain |
417 | 4 | ### END LICENSE | 4 | ### END LICENSE |
418 | 5 | 5 | ||
420 | 6 | import gtk | 6 | from gi.repository import Gtk # pylint: disable=E0611 |
421 | 7 | 7 | ||
422 | 8 | from . helpers import get_builder | 8 | from . helpers import get_builder |
423 | 9 | 9 | ||
425 | 10 | class AboutDialog(gtk.AboutDialog): | 10 | class AboutDialog(Gtk.AboutDialog): |
426 | 11 | __gtype_name__ = "AboutDialog" | 11 | __gtype_name__ = "AboutDialog" |
427 | 12 | 12 | ||
428 | 13 | def __new__(cls): | 13 | def __new__(cls): |
429 | 14 | 14 | ||
430 | === modified file 'data/templates/ubuntu-application/project_root/python_lib/Builder.py' | |||
431 | --- data/templates/ubuntu-application/project_root/python_lib/Builder.py 2011-09-06 07:47:36 +0000 | |||
432 | +++ data/templates/ubuntu-application/project_root/python_lib/Builder.py 2011-11-08 16:10:57 +0000 | |||
433 | @@ -5,9 +5,8 @@ | |||
434 | 5 | 5 | ||
435 | 6 | '''Enhances builder connections, provides object to access glade objects''' | 6 | '''Enhances builder connections, provides object to access glade objects''' |
436 | 7 | 7 | ||
438 | 8 | import gobject # pylint: disable=E0611 | 8 | from gi.repository import GObject, Gtk # pylint: disable=E0611 |
439 | 9 | 9 | ||
440 | 10 | import gtk | ||
441 | 11 | import inspect | 10 | import inspect |
442 | 12 | import functools | 11 | import functools |
443 | 13 | import logging | 12 | import logging |
444 | @@ -23,8 +22,8 @@ | |||
445 | 23 | 22 | ||
446 | 24 | 23 | ||
447 | 25 | # pylint: disable=R0904 | 24 | # pylint: disable=R0904 |
450 | 26 | # the many public methods is a feature of gtk.Builder | 25 | # the many public methods is a feature of Gtk.Builder |
451 | 27 | class Builder(gtk.Builder): | 26 | class Builder(Gtk.Builder): |
452 | 28 | ''' extra features | 27 | ''' extra features |
453 | 29 | connects glade defined handler to default_handler if necessary | 28 | connects glade defined handler to default_handler if necessary |
454 | 30 | auto connects widget to handler with matching name or alias | 29 | auto connects widget to handler with matching name or alias |
455 | @@ -34,7 +33,7 @@ | |||
456 | 34 | ''' | 33 | ''' |
457 | 35 | 34 | ||
458 | 36 | def __init__(self): | 35 | def __init__(self): |
460 | 37 | gtk.Builder.__init__(self) | 36 | Gtk.Builder.__init__(self) |
461 | 38 | self.widgets = {} | 37 | self.widgets = {} |
462 | 39 | self.glade_handler_dict = {} | 38 | self.glade_handler_dict = {} |
463 | 40 | self.connections = [] | 39 | self.connections = [] |
464 | @@ -50,7 +49,7 @@ | |||
465 | 50 | An apprentice guru might wonder which signal does what he wants, | 49 | An apprentice guru might wonder which signal does what he wants, |
466 | 51 | now he can define any likely candidates in glade and notice which | 50 | now he can define any likely candidates in glade and notice which |
467 | 52 | ones get triggered when he plays with the project. | 51 | ones get triggered when he plays with the project. |
469 | 53 | this method does not appear in gtk.Builder''' | 52 | this method does not appear in Gtk.Builder''' |
470 | 54 | logger.debug('''tried to call non-existent function:%s() | 53 | logger.debug('''tried to call non-existent function:%s() |
471 | 55 | expected in %s | 54 | expected in %s |
472 | 56 | args:%s | 55 | args:%s |
473 | @@ -60,12 +59,12 @@ | |||
474 | 60 | def get_name(self, widget): | 59 | def get_name(self, widget): |
475 | 61 | ''' allows a handler to get the name (id) of a widget | 60 | ''' allows a handler to get the name (id) of a widget |
476 | 62 | 61 | ||
478 | 63 | this method does not appear in gtk.Builder''' | 62 | this method does not appear in Gtk.Builder''' |
479 | 64 | return self._reverse_widget_dict.get(widget) | 63 | return self._reverse_widget_dict.get(widget) |
480 | 65 | 64 | ||
481 | 66 | def add_from_file(self, filename): | 65 | def add_from_file(self, filename): |
482 | 67 | '''parses xml file and stores wanted details''' | 66 | '''parses xml file and stores wanted details''' |
484 | 68 | gtk.Builder.add_from_file(self, filename) | 67 | Gtk.Builder.add_from_file(self, filename) |
485 | 69 | 68 | ||
486 | 70 | # extract data for the extra interfaces | 69 | # extract data for the extra interfaces |
487 | 71 | tree = ElementTree() | 70 | tree = ElementTree() |
488 | @@ -121,7 +120,7 @@ | |||
489 | 121 | item[0], filename) | 120 | item[0], filename) |
490 | 122 | 121 | ||
491 | 123 | # connect glade define handlers | 122 | # connect glade define handlers |
493 | 124 | gtk.Builder.connect_signals(self, connection_dict) | 123 | Gtk.Builder.connect_signals(self, connection_dict) |
494 | 125 | 124 | ||
495 | 126 | # let's tell the user how we applied the glade design | 125 | # let's tell the user how we applied the glade design |
496 | 127 | for connection in self.connections: | 126 | for connection in self.connections: |
497 | @@ -133,7 +132,7 @@ | |||
498 | 133 | '''Creates the ui object with widgets as attributes | 132 | '''Creates the ui object with widgets as attributes |
499 | 134 | 133 | ||
500 | 135 | connects signals by 2 methods | 134 | connects signals by 2 methods |
502 | 136 | this method does not appear in gtk.Builder''' | 135 | this method does not appear in Gtk.Builder''' |
503 | 137 | 136 | ||
504 | 138 | result = UiFactory(self.widgets) | 137 | result = UiFactory(self.widgets) |
505 | 139 | 138 | ||
506 | @@ -196,9 +195,25 @@ | |||
507 | 196 | return pyname | 195 | return pyname |
508 | 197 | 196 | ||
509 | 198 | 197 | ||
510 | 198 | # Until bug https://bugzilla.gnome.org/show_bug.cgi?id=652127 is fixed, we | ||
511 | 199 | # need to reimplement inspect.getmembers. GObject introspection doesn't | ||
512 | 200 | # play nice with it. | ||
513 | 201 | def getmembers(obj, check): | ||
514 | 202 | members = [] | ||
515 | 203 | for k in dir(obj): | ||
516 | 204 | try: | ||
517 | 205 | attr = getattr(obj, k) | ||
518 | 206 | except: | ||
519 | 207 | continue | ||
520 | 208 | if check(attr): | ||
521 | 209 | members.append((k, attr)) | ||
522 | 210 | members.sort() | ||
523 | 211 | return members | ||
524 | 212 | |||
525 | 213 | |||
526 | 199 | def dict_from_callback_obj(callback_obj): | 214 | def dict_from_callback_obj(callback_obj): |
527 | 200 | '''a dictionary interface to callback_obj''' | 215 | '''a dictionary interface to callback_obj''' |
529 | 201 | methods = inspect.getmembers(callback_obj, inspect.ismethod) | 216 | methods = getmembers(callback_obj, inspect.ismethod) |
530 | 202 | 217 | ||
531 | 203 | aliased_methods = [x[1] for x in methods if hasattr(x[1], 'aliases')] | 218 | aliased_methods = [x[1] for x in methods if hasattr(x[1], 'aliases')] |
532 | 204 | 219 | ||
533 | @@ -238,11 +253,11 @@ | |||
534 | 238 | try: | 253 | try: |
535 | 239 | widget_type = type(widget) | 254 | widget_type = type(widget) |
536 | 240 | while widget_type: | 255 | while widget_type: |
539 | 241 | signal_ids.extend(gobject.signal_list_ids(widget_type)) | 256 | signal_ids.extend(GObject.signal_list_ids(widget_type)) |
540 | 242 | widget_type = gobject.type_parent(widget_type) | 257 | widget_type = GObject.type_parent(widget_type) |
541 | 243 | except RuntimeError: # pylint wants a specific error | 258 | except RuntimeError: # pylint wants a specific error |
542 | 244 | pass | 259 | pass |
544 | 245 | signal_names = [gobject.signal_name(sid) for sid in signal_ids] | 260 | signal_names = [GObject.signal_name(sid) for sid in signal_ids] |
545 | 246 | 261 | ||
546 | 247 | # Now, automatically find any the user didn't specify in glade | 262 | # Now, automatically find any the user didn't specify in glade |
547 | 248 | for sig in signal_names: | 263 | for sig in signal_names: |
548 | 249 | 264 | ||
549 | === modified file 'data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py' | |||
550 | --- data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py 2011-03-31 17:05:41 +0000 | |||
551 | +++ data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py 2011-11-08 16:10:57 +0000 | |||
552 | @@ -3,23 +3,16 @@ | |||
553 | 3 | # This file is in the public domain | 3 | # This file is in the public domain |
554 | 4 | ### END LICENSE | 4 | ### END LICENSE |
555 | 5 | 5 | ||
563 | 6 | """this dialog adjusts values in the preferences dictionary | 6 | """this dialog adjusts values in gsettings |
557 | 7 | |||
558 | 8 | requirements: | ||
559 | 9 | in module preferences: defaults[key] has a value | ||
560 | 10 | self.builder.get_object(key) is a suitable widget to adjust value | ||
561 | 11 | widget_methods[key] provides method names for the widget | ||
562 | 12 | each widget calls set_preference(...) when it has adjusted value | ||
564 | 13 | """ | 7 | """ |
565 | 14 | 8 | ||
567 | 15 | import gtk | 9 | from gi.repository import Gtk # pylint: disable=E0611 |
568 | 16 | import logging | 10 | import logging |
569 | 17 | logger = logging.getLogger('python_name_lib') | 11 | logger = logging.getLogger('python_name_lib') |
570 | 18 | 12 | ||
571 | 19 | from . helpers import get_builder, show_uri, get_help_uri | 13 | from . helpers import get_builder, show_uri, get_help_uri |
572 | 20 | from . preferences import preferences | ||
573 | 21 | 14 | ||
575 | 22 | class PreferencesDialog(gtk.Dialog): | 15 | class PreferencesDialog(Gtk.Dialog): |
576 | 23 | __gtype_name__ = "PreferencesDialog" | 16 | __gtype_name__ = "PreferencesDialog" |
577 | 24 | 17 | ||
578 | 25 | def __new__(cls): | 18 | def __new__(cls): |
579 | @@ -49,80 +42,6 @@ | |||
580 | 49 | self.ui = builder.get_ui(self, True) | 42 | self.ui = builder.get_ui(self, True) |
581 | 50 | 43 | ||
582 | 51 | # code for other initialization actions should be added here | 44 | # code for other initialization actions should be added here |
583 | 52 | self.widget_methods = [] | ||
584 | 53 | |||
585 | 54 | def set_widgets_from_preferences(self): | ||
586 | 55 | ''' these widgets show values in the preferences dictionary ''' | ||
587 | 56 | for key in preferences.keys(): | ||
588 | 57 | self.set_widget_from_preference(key) | ||
589 | 58 | |||
590 | 59 | def set_widget_from_preference(self, key): | ||
591 | 60 | '''set widget value from item in preferences''' | ||
592 | 61 | |||
593 | 62 | value = preferences.get(key) | ||
594 | 63 | widget = self.builder.get_object(key) | ||
595 | 64 | if widget is None: | ||
596 | 65 | # this preference is not adjustable by this dialog | ||
597 | 66 | # for example: window and dialog geometries | ||
598 | 67 | logger.debug('no widget for preference: %s' % key) | ||
599 | 68 | return | ||
600 | 69 | |||
601 | 70 | logger.debug('set_widget_from_preference: %s' % key) | ||
602 | 71 | try: | ||
603 | 72 | write_method_name = self.widget_methods[key][1] | ||
604 | 73 | except KeyError: | ||
605 | 74 | logger.warn('%s not in widget_methods' % key) | ||
606 | 75 | return | ||
607 | 76 | |||
608 | 77 | try: | ||
609 | 78 | method = getattr(widget, write_method_name) | ||
610 | 79 | except AttributeError: | ||
611 | 80 | logger.warn("""'%s' does not have a '%s' method. | ||
612 | 81 | Please edit 'widget_methods' in %s""" | ||
613 | 82 | % (key, write_method_name, self.__gtype_name__)) | ||
614 | 83 | return | ||
615 | 84 | |||
616 | 85 | try: | ||
617 | 86 | widget.connect(self.widget_methods[key][2], self.set_preference) | ||
618 | 87 | except TypeError: | ||
619 | 88 | logger.warn("""'%s' unknown signal name '%s' | ||
620 | 89 | Please edit 'widget_methods' in %s""" | ||
621 | 90 | % (key, self.widget_methods[key][2], self.__gtype_name__)) | ||
622 | 91 | |||
623 | 92 | method(value) | ||
624 | 93 | |||
625 | 94 | def get_key_for_widget(self, widget): | ||
626 | 95 | key = None | ||
627 | 96 | for key_try in preferences.keys(): | ||
628 | 97 | obj = self.builder.get_object(key_try) | ||
629 | 98 | if obj == widget: | ||
630 | 99 | key = key_try | ||
631 | 100 | return key | ||
632 | 101 | |||
633 | 102 | def set_preference(self, widget, data=None): | ||
634 | 103 | '''set a preference from a widget''' | ||
635 | 104 | key = self.get_key_for_widget(widget) | ||
636 | 105 | if key is None: | ||
637 | 106 | logger.warn('''This widget will not write to a preference. | ||
638 | 107 | The preference must already exist so add this widget's name | ||
639 | 108 | to default_preferences in your main function''') | ||
640 | 109 | return | ||
641 | 110 | |||
642 | 111 | # set_widget_from_preference is called first | ||
643 | 112 | # so no KeyError test is needed here | ||
644 | 113 | read_method_name = self.widget_methods[key][0] | ||
645 | 114 | |||
646 | 115 | try: | ||
647 | 116 | read_method = getattr(widget, read_method_name) | ||
648 | 117 | except AttributeError: | ||
649 | 118 | logger.warn("""'%s' does not have a '%s' method. | ||
650 | 119 | Please edit 'widget_methods' in %s""" | ||
651 | 120 | % (key, read_method_name, self.__gtype_name__)) | ||
652 | 121 | return | ||
653 | 122 | |||
654 | 123 | value=read_method() | ||
655 | 124 | logger.debug('set_preference: %s = %s' % (key, str(value))) | ||
656 | 125 | preferences[key] = value | ||
657 | 126 | 45 | ||
658 | 127 | def on_btn_close_clicked(self, widget, data=None): | 46 | def on_btn_close_clicked(self, widget, data=None): |
659 | 128 | self.destroy() | 47 | self.destroy() |
660 | 129 | 48 | ||
661 | === modified file 'data/templates/ubuntu-application/project_root/python_lib/Window.py' | |||
662 | --- data/templates/ubuntu-application/project_root/python_lib/Window.py 2011-04-04 14:28:36 +0000 | |||
663 | +++ data/templates/ubuntu-application/project_root/python_lib/Window.py 2011-11-08 16:10:57 +0000 | |||
664 | @@ -3,16 +3,15 @@ | |||
665 | 3 | # This file is in the public domain | 3 | # This file is in the public domain |
666 | 4 | ### END LICENSE | 4 | ### END LICENSE |
667 | 5 | 5 | ||
669 | 6 | import gtk | 6 | from gi.repository import Gio, Gtk # pylint: disable=E0611 |
670 | 7 | import logging | 7 | import logging |
671 | 8 | logger = logging.getLogger('python_name_lib') | 8 | logger = logging.getLogger('python_name_lib') |
672 | 9 | 9 | ||
673 | 10 | from . helpers import get_builder, show_uri, get_help_uri | 10 | from . helpers import get_builder, show_uri, get_help_uri |
674 | 11 | from . preferences import preferences | ||
675 | 12 | 11 | ||
676 | 13 | # This class is meant to be subclassed by camel_case_nameWindow. It provides | 12 | # This class is meant to be subclassed by camel_case_nameWindow. It provides |
677 | 14 | # common functions and some boilerplate. | 13 | # common functions and some boilerplate. |
679 | 15 | class Window(gtk.Window): | 14 | class Window(Gtk.Window): |
680 | 16 | __gtype_name__ = "Window" | 15 | __gtype_name__ = "Window" |
681 | 17 | 16 | ||
682 | 18 | # To construct a new instance of this method, the following notable | 17 | # To construct a new instance of this method, the following notable |
683 | @@ -50,14 +49,15 @@ | |||
684 | 50 | self.preferences_dialog = None # instance | 49 | self.preferences_dialog = None # instance |
685 | 51 | self.AboutDialog = None # class | 50 | self.AboutDialog = None # class |
686 | 52 | 51 | ||
688 | 53 | preferences.connect('changed', self.on_preferences_changed) | 52 | self.settings = Gio.Settings("net.launchpad.project_name") |
689 | 53 | self.settings.connect('changed', self.on_preferences_changed) | ||
690 | 54 | 54 | ||
691 | 55 | # Optional Launchpad integration | 55 | # Optional Launchpad integration |
692 | 56 | # This shouldn't crash if not found as it is simply used for bug reporting. | 56 | # This shouldn't crash if not found as it is simply used for bug reporting. |
693 | 57 | # See https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding | 57 | # See https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding |
694 | 58 | # for more information about Launchpad integration. | 58 | # for more information about Launchpad integration. |
695 | 59 | try: | 59 | try: |
697 | 60 | import LaunchpadIntegration | 60 | from gi.repository import LaunchpadIntegration # pylint: disable=E0611 |
698 | 61 | LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) | 61 | LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) |
699 | 62 | LaunchpadIntegration.set_sourcepackagename('project_name') | 62 | LaunchpadIntegration.set_sourcepackagename('project_name') |
700 | 63 | except ImportError: | 63 | except ImportError: |
701 | @@ -111,12 +111,10 @@ | |||
702 | 111 | def on_destroy(self, widget, data=None): | 111 | def on_destroy(self, widget, data=None): |
703 | 112 | """Called when the camel_case_nameWindow is closed.""" | 112 | """Called when the camel_case_nameWindow is closed.""" |
704 | 113 | # Clean up code for saving application state should be added here. | 113 | # Clean up code for saving application state should be added here. |
706 | 114 | gtk.main_quit() | 114 | Gtk.main_quit() |
707 | 115 | 115 | ||
712 | 116 | def on_preferences_changed(self, widget, data=None): | 116 | def on_preferences_changed(self, settings, key, data=None): |
713 | 117 | logger.debug('main window received preferences changed') | 117 | logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key)))) |
710 | 118 | for key in data: | ||
711 | 119 | logger.debug('preference changed: %s = %s' % (key, preferences[key])) | ||
714 | 120 | 118 | ||
715 | 121 | def on_preferences_dialog_destroyed(self, widget, data=None): | 119 | def on_preferences_dialog_destroyed(self, widget, data=None): |
716 | 122 | '''only affects gui | 120 | '''only affects gui |
717 | 123 | 121 | ||
718 | === modified file 'data/templates/ubuntu-application/project_root/python_lib/__init__.py' | |||
719 | --- data/templates/ubuntu-application/project_root/python_lib/__init__.py 2011-03-31 17:05:41 +0000 | |||
720 | +++ data/templates/ubuntu-application/project_root/python_lib/__init__.py 2011-11-08 16:10:57 +0000 | |||
721 | @@ -7,7 +7,6 @@ | |||
722 | 7 | 7 | ||
723 | 8 | while keeping its api constant''' | 8 | while keeping its api constant''' |
724 | 9 | from . helpers import set_up_logging | 9 | from . helpers import set_up_logging |
725 | 10 | from . preferences import preferences | ||
726 | 11 | from . Window import Window | 10 | from . Window import Window |
727 | 12 | from . python_nameconfig import get_version | 11 | from . python_nameconfig import get_version |
728 | 13 | 12 | ||
729 | 14 | 13 | ||
730 | === modified file 'data/templates/ubuntu-application/project_root/python_lib/helpers.py' | |||
731 | --- data/templates/ubuntu-application/project_root/python_lib/helpers.py 2011-03-31 17:05:41 +0000 | |||
732 | +++ data/templates/ubuntu-application/project_root/python_lib/helpers.py 2011-11-08 16:10:57 +0000 | |||
733 | @@ -7,8 +7,6 @@ | |||
734 | 7 | import logging | 7 | import logging |
735 | 8 | import os | 8 | import os |
736 | 9 | 9 | ||
737 | 10 | import gtk | ||
738 | 11 | |||
739 | 12 | from . python_nameconfig import get_data_file | 10 | from . python_nameconfig import get_data_file |
740 | 13 | from . Builder import Builder | 11 | from . Builder import Builder |
741 | 14 | 12 | ||
742 | @@ -17,7 +15,7 @@ | |||
743 | 17 | gettext.textdomain('project_name') | 15 | gettext.textdomain('project_name') |
744 | 18 | 16 | ||
745 | 19 | def get_builder(builder_file_name): | 17 | def get_builder(builder_file_name): |
747 | 20 | """Return a fully-instantiated gtk.Builder instance from specified ui | 18 | """Return a fully-instantiated Gtk.Builder instance from specified ui |
748 | 21 | file | 19 | file |
749 | 22 | 20 | ||
750 | 23 | :param builder_file_name: The name of the builder file, without extension. | 21 | :param builder_file_name: The name of the builder file, without extension. |
751 | @@ -87,8 +85,9 @@ | |||
752 | 87 | return help_uri | 85 | return help_uri |
753 | 88 | 86 | ||
754 | 89 | def show_uri(parent, link): | 87 | def show_uri(parent, link): |
755 | 88 | from gi.repository import Gtk # pylint: disable=E0611 | ||
756 | 90 | screen = parent.get_screen() | 89 | screen = parent.get_screen() |
758 | 91 | gtk.show_uri(screen, link, gtk.get_current_event_time()) | 90 | Gtk.show_uri(screen, link, Gtk.get_current_event_time()) |
759 | 92 | 91 | ||
760 | 93 | def alias(alternative_function_name): | 92 | def alias(alternative_function_name): |
761 | 94 | '''see http://www.drdobbs.com/web-development/184406073#l9''' | 93 | '''see http://www.drdobbs.com/web-development/184406073#l9''' |
762 | 95 | 94 | ||
763 | === removed file 'data/templates/ubuntu-application/project_root/python_lib/preferences.py' | |||
764 | --- data/templates/ubuntu-application/project_root/python_lib/preferences.py 2011-03-31 15:19:55 +0000 | |||
765 | +++ data/templates/ubuntu-application/project_root/python_lib/preferences.py 1970-01-01 00:00:00 +0000 | |||
766 | @@ -1,100 +0,0 @@ | |||
767 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
768 | 2 | ### BEGIN LICENSE | ||
769 | 3 | # This file is in the public domain | ||
770 | 4 | ### END LICENSE | ||
771 | 5 | |||
772 | 6 | """Provides a shared preferences dictionary""" | ||
773 | 7 | |||
774 | 8 | from desktopcouch.records.server import CouchDatabase | ||
775 | 9 | from desktopcouch.records.record import Record | ||
776 | 10 | import gtk | ||
777 | 11 | import gobject | ||
778 | 12 | |||
779 | 13 | class User_dict(dict): | ||
780 | 14 | ''' a dictionary with extra methods: | ||
781 | 15 | |||
782 | 16 | persistence: load, save and db_connect | ||
783 | 17 | gobject signals: connect and emit. | ||
784 | 18 | |||
785 | 19 | Don't use this directly. Please use the preferences instance.''' | ||
786 | 20 | |||
787 | 21 | def __init__(self, *args, **kwds): | ||
788 | 22 | dict.__init__(self, *args, **kwds) | ||
789 | 23 | # Set up couchdb. | ||
790 | 24 | self._db_name = "project_name" | ||
791 | 25 | self._key = None | ||
792 | 26 | self._database = None | ||
793 | 27 | |||
794 | 28 | self._record_type = ( | ||
795 | 29 | "http://wiki.ubuntu.com/Quickly/RecordTypes/camel_case_name/" | ||
796 | 30 | "Preferences") | ||
797 | 31 | |||
798 | 32 | class Publisher(gtk.Invisible): # pylint: disable=R0904 | ||
799 | 33 | '''set up signals in a separate class | ||
800 | 34 | |||
801 | 35 | gtk.Invisible has 230 public methods''' | ||
802 | 36 | __gsignals__ = {'changed' : (gobject.SIGNAL_RUN_LAST, | ||
803 | 37 | gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)), | ||
804 | 38 | 'loaded' : (gobject.SIGNAL_RUN_LAST, | ||
805 | 39 | gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))} | ||
806 | 40 | |||
807 | 41 | publisher = Publisher() | ||
808 | 42 | self.emit = publisher.emit | ||
809 | 43 | self.connect = publisher.connect | ||
810 | 44 | |||
811 | 45 | def db_connect(self): | ||
812 | 46 | '''connect to couchdb | ||
813 | 47 | |||
814 | 48 | create if necessary''' | ||
815 | 49 | # logging.basicConfig will be called now | ||
816 | 50 | self._database = CouchDatabase(self._db_name, create=True) | ||
817 | 51 | |||
818 | 52 | def save(self): | ||
819 | 53 | 'save to couchdb' | ||
820 | 54 | self._database.update_fields(self._key, self) | ||
821 | 55 | |||
822 | 56 | |||
823 | 57 | def load(self): | ||
824 | 58 | 'load from couchdb' | ||
825 | 59 | self.update({"record_type": self._record_type}) | ||
826 | 60 | |||
827 | 61 | results = self._database.get_records( | ||
828 | 62 | record_type=self._record_type, create_view=True) | ||
829 | 63 | |||
830 | 64 | if len(results.rows) == 0: | ||
831 | 65 | # No preferences have ever been saved | ||
832 | 66 | # save them before returning. | ||
833 | 67 | self._key = self._database.put_record(Record(self)) | ||
834 | 68 | else: | ||
835 | 69 | self.update(results.rows[0].value) | ||
836 | 70 | del self['_rev'] | ||
837 | 71 | self._key = results.rows[0].value["_id"] | ||
838 | 72 | self.emit('loaded', None) | ||
839 | 73 | |||
840 | 74 | def update(self, *args, **kwds): | ||
841 | 75 | ''' interface for dictionary | ||
842 | 76 | |||
843 | 77 | send changed signal when appropriate ''' | ||
844 | 78 | |||
845 | 79 | # parse args | ||
846 | 80 | new_data = {} | ||
847 | 81 | new_data.update(*args, **kwds) | ||
848 | 82 | |||
849 | 83 | changed_keys = [] | ||
850 | 84 | for key in new_data.keys(): | ||
851 | 85 | if new_data.get(key) != dict.get(self, key): | ||
852 | 86 | changed_keys.append(key) | ||
853 | 87 | dict.update(self, new_data) | ||
854 | 88 | if changed_keys: | ||
855 | 89 | self.emit('changed', tuple(changed_keys)) | ||
856 | 90 | |||
857 | 91 | def __setitem__(self, key, value): | ||
858 | 92 | ''' interface for dictionary | ||
859 | 93 | |||
860 | 94 | send changed signal when appropriate ''' | ||
861 | 95 | if value != dict.get(self, key): | ||
862 | 96 | dict.__setitem__(self, key, value) | ||
863 | 97 | self.emit('changed', (key,)) | ||
864 | 98 | |||
865 | 99 | preferences = User_dict() | ||
866 | 100 | |||
867 | 101 | 0 | ||
868 | === modified file 'data/templates/ubuntu-application/project_root/tests/test_example.py' | |||
869 | --- data/templates/ubuntu-application/project_root/tests/test_example.py 2011-03-02 22:59:32 +0000 | |||
870 | +++ data/templates/ubuntu-application/project_root/tests/test_example.py 2011-11-08 16:10:57 +0000 | |||
871 | @@ -14,7 +14,7 @@ | |||
872 | 14 | class TestExample(unittest.TestCase): | 14 | class TestExample(unittest.TestCase): |
873 | 15 | def setUp(self): | 15 | def setUp(self): |
874 | 16 | self.Aboutcamel_case_nameDialog_members = [ | 16 | self.Aboutcamel_case_nameDialog_members = [ |
876 | 17 | 'Aboutcamel_case_nameDialog', 'get_builder', 'gettext', 'gtk'] | 17 | 'Aboutcamel_case_nameDialog', 'get_builder', 'gettext', 'Gtk'] |
877 | 18 | 18 | ||
878 | 19 | def test_Aboutcamel_case_nameDialog_members(self): | 19 | def test_Aboutcamel_case_nameDialog_members(self): |
879 | 20 | all_members = dir(Aboutcamel_case_nameDialog) | 20 | all_members = dir(Aboutcamel_case_nameDialog) |
880 | 21 | 21 | ||
881 | === modified file 'data/templates/ubuntu-application/run.py' | |||
882 | --- data/templates/ubuntu-application/run.py 2011-07-22 10:47:34 +0000 | |||
883 | +++ data/templates/ubuntu-application/run.py 2011-11-08 16:10:57 +0000 | |||
884 | @@ -50,6 +50,18 @@ | |||
885 | 50 | print _("Can't access to X server, so can't run gtk application") | 50 | print _("Can't access to X server, so can't run gtk application") |
886 | 51 | sys.exit(1) | 51 | sys.exit(1) |
887 | 52 | 52 | ||
888 | 53 | # Compile schema if present | ||
889 | 54 | schemapath = os.path.abspath("data/glib-2.0/schemas") | ||
890 | 55 | if os.path.exists(schemapath): | ||
891 | 56 | subprocess.call(["glib-compile-schemas", schemapath]) | ||
892 | 57 | |||
893 | 58 | env = os.environ.copy() | ||
894 | 59 | datadir = os.path.abspath("data") | ||
895 | 60 | if 'XDG_DATA_DIRS' in env: | ||
896 | 61 | env['XDG_DATA_DIRS'] = "%s:%s" % (datadir, env['XDG_DATA_DIRS']) | ||
897 | 62 | else: | ||
898 | 63 | env['XDG_DATA_DIRS'] = datadir | ||
899 | 64 | |||
900 | 53 | project_bin = 'bin/' + configurationhandler.project_config['project'] | 65 | project_bin = 'bin/' + configurationhandler.project_config['project'] |
901 | 54 | command_line = [project_bin] | 66 | command_line = [project_bin] |
902 | 55 | command_line.extend([arg for arg in sys.argv[1:] if arg != "--"]) | 67 | command_line.extend([arg for arg in sys.argv[1:] if arg != "--"]) |
903 | @@ -58,7 +70,7 @@ | |||
904 | 58 | st = os.stat(project_bin) | 70 | st = os.stat(project_bin) |
905 | 59 | mode = st[stat.ST_MODE] | 71 | mode = st[stat.ST_MODE] |
906 | 60 | if mode & stat.S_IEXEC: | 72 | if mode & stat.S_IEXEC: |
908 | 61 | subprocess.call(command_line) | 73 | subprocess.call(command_line, env=env) |
909 | 62 | else: | 74 | else: |
910 | 63 | print _("Can't execute %s") % project_bin | 75 | print _("Can't execute %s") % project_bin |
911 | 64 | sys.exit(1) | 76 | sys.exit(1) |
912 | 65 | 77 | ||
913 | === modified file 'data/templates/ubuntu-application/store/data/ui/dialog_camel_case_nameDialog.ui' | |||
914 | --- data/templates/ubuntu-application/store/data/ui/dialog_camel_case_nameDialog.ui 2010-12-20 15:44:44 +0000 | |||
915 | +++ data/templates/ubuntu-application/store/data/ui/dialog_camel_case_nameDialog.ui 2011-11-08 16:10:57 +0000 | |||
916 | @@ -1,24 +1,22 @@ | |||
918 | 1 | <?xml version="1.0"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
919 | 2 | <interface> | 2 | <interface> |
921 | 3 | <requires lib="gtk+" version="2.16"/> | 3 | <!-- interface-requires gtk+ 3.0 --> |
922 | 4 | <!-- interface-requires dialog_python_name_dialog 1.0 --> | 4 | <!-- interface-requires dialog_python_name_dialog 1.0 --> |
923 | 5 | <!-- interface-naming-policy project-wide --> | ||
924 | 6 | <object class="dialog_camel_case_nameDialog" id="dialog_python_name_dialog"> | 5 | <object class="dialog_camel_case_nameDialog" id="dialog_python_name_dialog"> |
925 | 6 | <property name="can_focus">False</property> | ||
926 | 7 | <property name="border_width">5</property> | 7 | <property name="border_width">5</property> |
927 | 8 | <property name="icon">../media/project_name.svg</property> | 8 | <property name="icon">../media/project_name.svg</property> |
928 | 9 | <property name="type_hint">normal</property> | 9 | <property name="type_hint">normal</property> |
929 | 10 | <property name="has_separator">False</property> | ||
930 | 11 | <child internal-child="vbox"> | 10 | <child internal-child="vbox"> |
932 | 12 | <object class="GtkVBox" id="dialog-vbox1"> | 11 | <object class="GtkBox" id="dialog-vbox1"> |
933 | 13 | <property name="visible">True</property> | 12 | <property name="visible">True</property> |
934 | 13 | <property name="can_focus">False</property> | ||
935 | 14 | <property name="orientation">vertical</property> | 14 | <property name="orientation">vertical</property> |
936 | 15 | <property name="spacing">2</property> | 15 | <property name="spacing">2</property> |
937 | 16 | <child> | ||
938 | 17 | <placeholder/> | ||
939 | 18 | </child> | ||
940 | 19 | <child internal-child="action_area"> | 16 | <child internal-child="action_area"> |
942 | 20 | <object class="GtkHButtonBox" id="dialog-action_area1"> | 17 | <object class="GtkButtonBox" id="dialog-action_area1"> |
943 | 21 | <property name="visible">True</property> | 18 | <property name="visible">True</property> |
944 | 19 | <property name="can_focus">False</property> | ||
945 | 22 | <property name="layout_style">end</property> | 20 | <property name="layout_style">end</property> |
946 | 23 | <child> | 21 | <child> |
947 | 24 | <object class="GtkButton" id="btn_cancel"> | 22 | <object class="GtkButton" id="btn_cancel"> |
948 | @@ -26,6 +24,7 @@ | |||
949 | 26 | <property name="visible">True</property> | 24 | <property name="visible">True</property> |
950 | 27 | <property name="can_focus">True</property> | 25 | <property name="can_focus">True</property> |
951 | 28 | <property name="receives_default">True</property> | 26 | <property name="receives_default">True</property> |
952 | 27 | <property name="use_action_appearance">False</property> | ||
953 | 29 | <property name="use_stock">True</property> | 28 | <property name="use_stock">True</property> |
954 | 30 | </object> | 29 | </object> |
955 | 31 | <packing> | 30 | <packing> |
956 | @@ -40,6 +39,7 @@ | |||
957 | 40 | <property name="visible">True</property> | 39 | <property name="visible">True</property> |
958 | 41 | <property name="can_focus">True</property> | 40 | <property name="can_focus">True</property> |
959 | 42 | <property name="receives_default">True</property> | 41 | <property name="receives_default">True</property> |
960 | 42 | <property name="use_action_appearance">False</property> | ||
961 | 43 | <property name="use_stock">True</property> | 43 | <property name="use_stock">True</property> |
962 | 44 | </object> | 44 | </object> |
963 | 45 | <packing> | 45 | <packing> |
964 | @@ -51,10 +51,14 @@ | |||
965 | 51 | </object> | 51 | </object> |
966 | 52 | <packing> | 52 | <packing> |
967 | 53 | <property name="expand">False</property> | 53 | <property name="expand">False</property> |
968 | 54 | <property name="fill">True</property> | ||
969 | 54 | <property name="pack_type">end</property> | 55 | <property name="pack_type">end</property> |
970 | 55 | <property name="position">0</property> | 56 | <property name="position">0</property> |
971 | 56 | </packing> | 57 | </packing> |
972 | 57 | </child> | 58 | </child> |
973 | 59 | <child> | ||
974 | 60 | <placeholder/> | ||
975 | 61 | </child> | ||
976 | 58 | </object> | 62 | </object> |
977 | 59 | </child> | 63 | </child> |
978 | 60 | <action-widgets> | 64 | <action-widgets> |
979 | 61 | 65 | ||
980 | === modified file 'data/templates/ubuntu-application/store/data/ui/dialog_python_name_dialog.xml' | |||
981 | --- data/templates/ubuntu-application/store/data/ui/dialog_python_name_dialog.xml 2010-03-03 08:07:21 +0000 | |||
982 | +++ data/templates/ubuntu-application/store/data/ui/dialog_python_name_dialog.xml 2011-11-08 16:10:57 +0000 | |||
983 | @@ -1,4 +1,4 @@ | |||
985 | 1 | <glade-catalog name="dialog_name_dialog" domain="glade-3" | 1 | <glade-catalog name="dialog_python_name_dialog" domain="glade-3" |
986 | 2 | depends="gtk+" version="1.0"> | 2 | depends="gtk+" version="1.0"> |
987 | 3 | <glade-widget-classes> | 3 | <glade-widget-classes> |
988 | 4 | <glade-widget-class title="dialog_sentence_name Dialog" name="dialog_camel_case_nameDialog" | 4 | <glade-widget-class title="dialog_sentence_name Dialog" name="dialog_camel_case_nameDialog" |
989 | 5 | 5 | ||
990 | === modified file 'data/templates/ubuntu-application/store/dialog.py' | |||
991 | --- data/templates/ubuntu-application/store/dialog.py 2011-07-22 10:47:34 +0000 | |||
992 | +++ data/templates/ubuntu-application/store/dialog.py 2011-11-08 16:10:57 +0000 | |||
993 | @@ -31,7 +31,7 @@ | |||
994 | 31 | help_text= _("""Here, dialog-name is one or more words separated with dash | 31 | help_text= _("""Here, dialog-name is one or more words separated with dash |
995 | 32 | 32 | ||
996 | 33 | For instance 'quickly add dialog dialog-name' will create: | 33 | For instance 'quickly add dialog dialog-name' will create: |
998 | 34 | 1. A subclass of gtk.Dialog called DialogNameDialog in the module | 34 | 1. A subclass of Gtk.Dialog called DialogNameDialog in the module |
999 | 35 | DialogNameDialog.py | 35 | DialogNameDialog.py |
1000 | 36 | 2. A glade file called DialogNameDialog.ui in the ui directory | 36 | 2. A glade file called DialogNameDialog.ui in the ui directory |
1001 | 37 | 3. A catalog file called dialog_name_dialog.xml also in the ui directory | 37 | 3. A catalog file called dialog_name_dialog.xml also in the ui directory |
1002 | 38 | 38 | ||
1003 | === modified file 'data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py' | |||
1004 | --- data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py 2011-04-01 21:03:53 +0000 | |||
1005 | +++ data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py 2011-11-08 16:10:57 +0000 | |||
1006 | @@ -3,7 +3,7 @@ | |||
1007 | 3 | # This file is in the public domain | 3 | # This file is in the public domain |
1008 | 4 | ### END LICENSE | 4 | ### END LICENSE |
1009 | 5 | 5 | ||
1011 | 6 | import gtk | 6 | from gi.repository import Gtk # pylint: disable=E0611 |
1012 | 7 | 7 | ||
1013 | 8 | from python_name_lib.helpers import get_builder | 8 | from python_name_lib.helpers import get_builder |
1014 | 9 | 9 | ||
1015 | @@ -11,7 +11,7 @@ | |||
1016 | 11 | from gettext import gettext as _ | 11 | from gettext import gettext as _ |
1017 | 12 | gettext.textdomain('project_name') | 12 | gettext.textdomain('project_name') |
1018 | 13 | 13 | ||
1020 | 14 | class dialog_camel_case_nameDialog(gtk.Dialog): | 14 | class dialog_camel_case_nameDialog(Gtk.Dialog): |
1021 | 15 | __gtype_name__ = "dialog_camel_case_nameDialog" | 15 | __gtype_name__ = "dialog_camel_case_nameDialog" |
1022 | 16 | 16 | ||
1023 | 17 | def __new__(cls): | 17 | def __new__(cls): |
1024 | @@ -40,14 +40,14 @@ | |||
1025 | 40 | def on_btn_ok_clicked(self, widget, data=None): | 40 | def on_btn_ok_clicked(self, widget, data=None): |
1026 | 41 | """The user has elected to save the changes. | 41 | """The user has elected to save the changes. |
1027 | 42 | 42 | ||
1029 | 43 | Called before the dialog returns gtk.RESONSE_OK from run(). | 43 | Called before the dialog returns Gtk.ResponseType.OK from run(). |
1030 | 44 | """ | 44 | """ |
1031 | 45 | pass | 45 | pass |
1032 | 46 | 46 | ||
1033 | 47 | def on_btn_cancel_clicked(self, widget, data=None): | 47 | def on_btn_cancel_clicked(self, widget, data=None): |
1034 | 48 | """The user has elected cancel changes. | 48 | """The user has elected cancel changes. |
1035 | 49 | 49 | ||
1037 | 50 | Called before the dialog returns gtk.RESPONSE_CANCEL for run() | 50 | Called before the dialog returns Gtk.ResponseType.CANCEL for run() |
1038 | 51 | """ | 51 | """ |
1039 | 52 | pass | 52 | pass |
1040 | 53 | 53 | ||
1041 | @@ -55,4 +55,4 @@ | |||
1042 | 55 | if __name__ == "__main__": | 55 | if __name__ == "__main__": |
1043 | 56 | dialog = dialog_camel_case_nameDialog() | 56 | dialog = dialog_camel_case_nameDialog() |
1044 | 57 | dialog.show() | 57 | dialog.show() |
1046 | 58 | gtk.main() | 58 | Gtk.main() |
1047 | 59 | 59 | ||
1048 | === modified file 'data/templates/ubuntu-application/store/python/indicator.py' | |||
1049 | --- data/templates/ubuntu-application/store/python/indicator.py 2011-07-29 18:57:04 +0000 | |||
1050 | +++ data/templates/ubuntu-application/store/python/indicator.py 2011-11-08 16:10:57 +0000 | |||
1051 | @@ -6,7 +6,8 @@ | |||
1052 | 6 | 6 | ||
1053 | 7 | """Code to add AppIndicator.""" | 7 | """Code to add AppIndicator.""" |
1054 | 8 | 8 | ||
1056 | 9 | import gtk | 9 | from gi.repository import Gtk # pylint: disable=E0611 |
1057 | 10 | from gi.repository import AppIndicator3 # pylint: disable=E0611 | ||
1058 | 10 | 11 | ||
1059 | 11 | from python_name_lib.helpers import get_media_file | 12 | from python_name_lib.helpers import get_media_file |
1060 | 12 | 13 | ||
1061 | @@ -14,12 +15,10 @@ | |||
1062 | 14 | from gettext import gettext as _ | 15 | from gettext import gettext as _ |
1063 | 15 | gettext.textdomain('project_name') | 16 | gettext.textdomain('project_name') |
1064 | 16 | 17 | ||
1065 | 17 | import appindicator | ||
1066 | 18 | |||
1067 | 19 | class Indicator: | 18 | class Indicator: |
1068 | 20 | def __init__(self, window): | 19 | def __init__(self, window): |
1071 | 21 | self.indicator = appindicator.Indicator('project_name','',appindicator.CATEGORY_APPLICATION_STATUS) | 20 | self.indicator = AppIndicator3.Indicator('project_name', '', AppIndicator3.IndicatorCategory.APPLICATION_STATUS) |
1072 | 22 | self.indicator.set_status(appindicator.STATUS_ACTIVE) | 21 | self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) |
1073 | 23 | 22 | ||
1074 | 24 | icon_uri = get_media_file("project_name.svg") | 23 | icon_uri = get_media_file("project_name.svg") |
1075 | 25 | icon_path = icon_uri.replace("file:///", '') | 24 | icon_path = icon_uri.replace("file:///", '') |
1076 | @@ -28,18 +27,18 @@ | |||
1077 | 28 | #Uncomment and choose an icon for attention state. | 27 | #Uncomment and choose an icon for attention state. |
1078 | 29 | #self.indicator.set_attention_icon("ICON-NAME") | 28 | #self.indicator.set_attention_icon("ICON-NAME") |
1079 | 30 | 29 | ||
1081 | 31 | self.menu = gtk.Menu() | 30 | self.menu = Gtk.Menu() |
1082 | 32 | 31 | ||
1083 | 33 | # Add items to Menu and connect signals. | 32 | # Add items to Menu and connect signals. |
1084 | 34 | 33 | ||
1085 | 35 | #Adding preferences button | 34 | #Adding preferences button |
1086 | 36 | #window represents the main Window object of your app | 35 | #window represents the main Window object of your app |
1088 | 37 | self.preferences = gtk.MenuItem("Preferences") | 36 | self.preferences = Gtk.MenuItem("Preferences") |
1089 | 38 | self.preferences.connect("activate",window.on_mnu_preferences_activate) | 37 | self.preferences.connect("activate",window.on_mnu_preferences_activate) |
1090 | 39 | self.preferences.show() | 38 | self.preferences.show() |
1091 | 40 | self.menu.append(self.preferences) | 39 | self.menu.append(self.preferences) |
1092 | 41 | 40 | ||
1094 | 42 | self.quit = gtk.MenuItem("Quit") | 41 | self.quit = Gtk.MenuItem("Quit") |
1095 | 43 | self.quit.connect("activate",window.on_mnu_close_activate) | 42 | self.quit.connect("activate",window.on_mnu_close_activate) |
1096 | 44 | self.quit.show() | 43 | self.quit.show() |
1097 | 45 | self.menu.append(self.quit) | 44 | self.menu.append(self.quit) |
1098 | 46 | 45 | ||
1099 | === modified file 'data/templates/ubuntu-application/test/apport/apport.sh' | |||
1100 | --- data/templates/ubuntu-application/test/apport/apport.sh 2011-11-08 00:50:34 +0000 | |||
1101 | +++ data/templates/ubuntu-application/test/apport/apport.sh 2011-11-08 16:10:57 +0000 | |||
1102 | @@ -12,6 +12,7 @@ | |||
1103 | 12 | cd test-project | 12 | cd test-project |
1104 | 13 | 13 | ||
1105 | 14 | grep LaunchpadIntegration. test_project_lib/Window.py | 14 | grep LaunchpadIntegration. test_project_lib/Window.py |
1106 | 15 | # from gi.repository import LaunchpadIntegration # pylint: disable=E0611 | ||
1107 | 15 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) | 16 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) |
1108 | 16 | # LaunchpadIntegration.set_sourcepackagename('test-project') | 17 | # LaunchpadIntegration.set_sourcepackagename('test-project') |
1109 | 17 | 18 | ||
1110 | @@ -25,6 +26,7 @@ | |||
1111 | 25 | # Creating new apport hooks | 26 | # Creating new apport hooks |
1112 | 26 | 27 | ||
1113 | 27 | grep LaunchpadIntegration. test_project_lib/Window.py | 28 | grep LaunchpadIntegration. test_project_lib/Window.py |
1114 | 29 | # from gi.repository import LaunchpadIntegration # pylint: disable=E0611 | ||
1115 | 28 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) | 30 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) |
1116 | 29 | # LaunchpadIntegration.set_sourcepackagename('test-project') | 31 | # LaunchpadIntegration.set_sourcepackagename('test-project') |
1117 | 30 | 32 | ||
1118 | @@ -54,6 +56,7 @@ | |||
1119 | 54 | # Updating project name references in existing apport crashdb configuration | 56 | # Updating project name references in existing apport crashdb configuration |
1120 | 55 | 57 | ||
1121 | 56 | grep LaunchpadIntegration. test_project_lib/Window.py | 58 | grep LaunchpadIntegration. test_project_lib/Window.py |
1122 | 59 | # from gi.repository import LaunchpadIntegration # pylint: disable=E0611 | ||
1123 | 57 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) | 60 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) |
1124 | 58 | # LaunchpadIntegration.set_sourcepackagename('test-project') | 61 | # LaunchpadIntegration.set_sourcepackagename('test-project') |
1125 | 59 | 62 | ||
1126 | @@ -119,6 +122,7 @@ | |||
1127 | 119 | # Updating project name references in existing apport crashdb configuration | 122 | # Updating project name references in existing apport crashdb configuration |
1128 | 120 | 123 | ||
1129 | 121 | grep LaunchpadIntegration. test_project_lib/Window.py | 124 | grep LaunchpadIntegration. test_project_lib/Window.py |
1130 | 125 | # from gi.repository import LaunchpadIntegration # pylint: disable=E0611 | ||
1131 | 122 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) | 126 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) |
1132 | 123 | # LaunchpadIntegration.set_sourcepackagename('test-project') | 127 | # LaunchpadIntegration.set_sourcepackagename('test-project') |
1133 | 124 | 128 | ||
1134 | @@ -149,6 +153,7 @@ | |||
1135 | 149 | # Creating new apport hooks | 153 | # Creating new apport hooks |
1136 | 150 | 154 | ||
1137 | 151 | grep LaunchpadIntegration. test_project_lib/Window.py | 155 | grep LaunchpadIntegration. test_project_lib/Window.py |
1138 | 156 | # from gi.repository import LaunchpadIntegration # pylint: disable=E0611 | ||
1139 | 152 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) | 157 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) |
1140 | 153 | # LaunchpadIntegration.set_sourcepackagename('test-project') | 158 | # LaunchpadIntegration.set_sourcepackagename('test-project') |
1141 | 154 | 159 | ||
1142 | @@ -188,6 +193,7 @@ | |||
1143 | 188 | # Updating project name references in existing apport crashdb configuration | 193 | # Updating project name references in existing apport crashdb configuration |
1144 | 189 | 194 | ||
1145 | 190 | grep LaunchpadIntegration. test_project_lib/Window.py | 195 | grep LaunchpadIntegration. test_project_lib/Window.py |
1146 | 196 | # from gi.repository import LaunchpadIntegration # pylint: disable=E0611 | ||
1147 | 191 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) | 197 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) |
1148 | 192 | # LaunchpadIntegration.set_sourcepackagename('test-project') | 198 | # LaunchpadIntegration.set_sourcepackagename('test-project') |
1149 | 193 | 199 | ||
1150 | @@ -283,7 +289,7 @@ | |||
1151 | 283 | # modified etc/apport/crashdb.conf.d/test-project-crashdb.conf | 289 | # modified etc/apport/crashdb.conf.d/test-project-crashdb.conf |
1152 | 284 | # Committed revision 4. | 290 | # Committed revision 4. |
1153 | 285 | 291 | ||
1155 | 286 | quickly upgrade 0.3 0.4 | 292 | quickly upgrade 0.3 |
1156 | 287 | 293 | ||
1157 | 288 | bzr status | 294 | bzr status |
1158 | 289 | 295 | ||
1159 | @@ -309,11 +315,12 @@ | |||
1160 | 309 | 315 | ||
1161 | 310 | bzr status | 316 | bzr status |
1162 | 311 | 317 | ||
1164 | 312 | quickly upgrade 0.3 0.4 | 318 | quickly upgrade 0.3 |
1165 | 313 | # Creating new apport crashdb configuration | 319 | # Creating new apport crashdb configuration |
1166 | 314 | # Creating new apport hooks | 320 | # Creating new apport hooks |
1167 | 315 | 321 | ||
1168 | 316 | grep LaunchpadIntegration. test_project_lib/Window.py | 322 | grep LaunchpadIntegration. test_project_lib/Window.py |
1169 | 323 | # from gi.repository import LaunchpadIntegration # pylint: disable=E0611 | ||
1170 | 317 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) | 324 | # LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True) |
1171 | 318 | # LaunchpadIntegration.set_sourcepackagename('test-project') | 325 | # LaunchpadIntegration.set_sourcepackagename('test-project') |
1172 | 319 | 326 | ||
1173 | @@ -359,7 +366,7 @@ | |||
1174 | 359 | 366 | ||
1175 | 360 | grep helpMenu test_project_lib/Window.py | 367 | grep helpMenu test_project_lib/Window.py |
1176 | 361 | 368 | ||
1178 | 362 | quickly upgrade 0.3 0.4 | 369 | quickly upgrade 0.3 |
1179 | 363 | # Adding launchpad integration to existing application | 370 | # Adding launchpad integration to existing application |
1180 | 364 | # Creating new apport crashdb configuration | 371 | # Creating new apport crashdb configuration |
1181 | 365 | # Creating new apport hooks | 372 | # Creating new apport hooks |
1182 | @@ -388,7 +395,7 @@ | |||
1183 | 388 | # modified test_project_lib/Window.py | 395 | # modified test_project_lib/Window.py |
1184 | 389 | # Committed revision 6. | 396 | # Committed revision 6. |
1185 | 390 | 397 | ||
1187 | 391 | quickly upgrade 0.3 0.4 | 398 | quickly upgrade 0.3 |
1188 | 392 | # Creating new apport crashdb configuration | 399 | # Creating new apport crashdb configuration |
1189 | 393 | # Creating new apport hooks | 400 | # Creating new apport hooks |
1190 | 394 | 401 | ||
1191 | @@ -409,4 +416,4 @@ | |||
1192 | 409 | 416 | ||
1193 | 410 | grep helpMenu test_project_lib/Window.py | 417 | grep helpMenu test_project_lib/Window.py |
1194 | 411 | 418 | ||
1196 | 412 | quickly upgrade 0.3 0.4 | 419 | quickly upgrade 0.3 |
1197 | 413 | 420 | ||
1198 | === modified file 'data/templates/ubuntu-application/test/builder/builder.py' | |||
1199 | --- data/templates/ubuntu-application/test/builder/builder.py 2011-06-08 13:48:05 +0000 | |||
1200 | +++ data/templates/ubuntu-application/test/builder/builder.py 2011-11-08 16:10:57 +0000 | |||
1201 | @@ -4,7 +4,7 @@ | |||
1202 | 4 | import unittest | 4 | import unittest |
1203 | 5 | import sys | 5 | import sys |
1204 | 6 | import os | 6 | import os |
1206 | 7 | import gtk | 7 | from gi.repository import Gtk # pylint: disable=E0611 |
1207 | 8 | import inspect | 8 | import inspect |
1208 | 9 | import logging | 9 | import logging |
1209 | 10 | import glob | 10 | import glob |
1210 | @@ -85,7 +85,7 @@ | |||
1211 | 85 | 'wind?o-w two', 'wind_o_w_two', 'window'] # sorted list | 85 | 'wind?o-w two', 'wind_o_w_two', 'window'] # sorted list |
1212 | 86 | 86 | ||
1213 | 87 | def test_interface(self): | 87 | def test_interface(self): |
1215 | 88 | builder = dir(gtk.Builder) | 88 | builder = dir(Gtk.Builder) |
1216 | 89 | 89 | ||
1217 | 90 | # sanity test | 90 | # sanity test |
1218 | 91 | self.assertTrue('add_from_file' in builder) | 91 | self.assertTrue('add_from_file' in builder) |
1219 | 92 | 92 | ||
1220 | === modified file 'data/templates/ubuntu-application/test/configure.sh' | |||
1221 | --- data/templates/ubuntu-application/test/configure.sh 2010-10-15 20:26:19 +0000 | |||
1222 | +++ data/templates/ubuntu-application/test/configure.sh 2011-11-08 16:10:57 +0000 | |||
1223 | @@ -17,7 +17,6 @@ | |||
1224 | 17 | # #url='https://launchpad.net/test-project', | 17 | # #url='https://launchpad.net/test-project', |
1225 | 18 | 18 | ||
1226 | 19 | grep website data/ui/AboutTestProjectDialog.ui | 19 | grep website data/ui/AboutTestProjectDialog.ui |
1227 | 20 | # <property name="website"></property> | ||
1228 | 21 | 20 | ||
1229 | 22 | grep lp_id .quickly | 21 | grep lp_id .quickly |
1230 | 23 | 22 | ||
1231 | @@ -33,7 +32,7 @@ | |||
1232 | 33 | grep url= setup.py | 32 | grep url= setup.py |
1233 | 34 | # url='https://launchpad.net/gpoweroff', | 33 | # url='https://launchpad.net/gpoweroff', |
1234 | 35 | 34 | ||
1236 | 36 | grep website data/ui/AboutTestProjectDialog.ui | 35 | grep website data/ui/AboutTestProjectDialog.ui | sed 's|</property>.*|</property>|' |
1237 | 37 | # <property name="website">https://launchpad.net/gpoweroff</property> | 36 | # <property name="website">https://launchpad.net/gpoweroff</property> |
1238 | 38 | 37 | ||
1239 | 39 | (echo hudson-notifier > tmp) | 38 | (echo hudson-notifier > tmp) |
1240 | @@ -49,7 +48,7 @@ | |||
1241 | 49 | grep url= setup.py | 48 | grep url= setup.py |
1242 | 50 | # url='https://launchpad.net/hudson-notifier', | 49 | # url='https://launchpad.net/hudson-notifier', |
1243 | 51 | 50 | ||
1245 | 52 | grep website data/ui/AboutTestProjectDialog.ui | 51 | grep website data/ui/AboutTestProjectDialog.ui | sed 's|</property>.*|</property>|' |
1246 | 53 | # <property name="website">https://launchpad.net/hudson-notifier</property> | 52 | # <property name="website">https://launchpad.net/hudson-notifier</property> |
1247 | 54 | 53 | ||
1248 | 55 | ## Test configure bzr | 54 | ## Test configure bzr |
1249 | 56 | 55 | ||
1250 | === modified file 'data/templates/ubuntu-application/test/filelist.sh' | |||
1251 | --- data/templates/ubuntu-application/test/filelist.sh 2011-03-31 15:19:55 +0000 | |||
1252 | +++ data/templates/ubuntu-application/test/filelist.sh 2011-11-08 16:10:57 +0000 | |||
1253 | @@ -13,12 +13,16 @@ | |||
1254 | 13 | 13 | ||
1255 | 14 | bzr status | 14 | bzr status |
1256 | 15 | 15 | ||
1258 | 16 | bzr ls -R | 16 | bzr ls -RV |
1259 | 17 | # .bzrignore | ||
1260 | 17 | # .quickly | 18 | # .quickly |
1261 | 18 | # AUTHORS | 19 | # AUTHORS |
1262 | 19 | # bin/ | 20 | # bin/ |
1263 | 20 | # bin/test-project | 21 | # bin/test-project |
1264 | 21 | # data/ | 22 | # data/ |
1265 | 23 | # data/glib-2.0/ | ||
1266 | 24 | # data/glib-2.0/schemas/ | ||
1267 | 25 | # data/glib-2.0/schemas/net.launchpad.test-project.gschema.xml | ||
1268 | 22 | # data/media/ | 26 | # data/media/ |
1269 | 23 | # data/media/background.png | 27 | # data/media/background.png |
1270 | 24 | # data/media/test-project.svg | 28 | # data/media/test-project.svg |
1271 | @@ -50,7 +54,6 @@ | |||
1272 | 50 | # test_project_lib/Window.py | 54 | # test_project_lib/Window.py |
1273 | 51 | # test_project_lib/__init__.py | 55 | # test_project_lib/__init__.py |
1274 | 52 | # test_project_lib/helpers.py | 56 | # test_project_lib/helpers.py |
1275 | 53 | # test_project_lib/preferences.py | ||
1276 | 54 | # test_project_lib/test_projectconfig.py | 57 | # test_project_lib/test_projectconfig.py |
1277 | 55 | # tests/ | 58 | # tests/ |
1278 | 56 | # tests/test_example.py | 59 | # tests/test_example.py |
1279 | 57 | 60 | ||
1280 | === modified file 'data/templates/ubuntu-application/test/metadata.sh' | |||
1281 | --- data/templates/ubuntu-application/test/metadata.sh 2011-11-08 00:50:34 +0000 | |||
1282 | +++ data/templates/ubuntu-application/test/metadata.sh 2011-11-08 16:10:57 +0000 | |||
1283 | @@ -38,10 +38,8 @@ | |||
1284 | 38 | # XB-Icon: test-project.svg | 38 | # XB-Icon: test-project.svg |
1285 | 39 | # Depends: ${misc:Depends}, | 39 | # Depends: ${misc:Depends}, |
1286 | 40 | # ${python:Depends}, | 40 | # ${python:Depends}, |
1291 | 41 | # python-gobject-2, | 41 | # gir1.2-glib-2.0, |
1292 | 42 | # python-launchpad-integration, | 42 | # gir1.2-launchpad-integration-3.0, |
1289 | 43 | # python-gtk2, | ||
1290 | 44 | # python-desktopcouch-records, | ||
1293 | 45 | # yelp | 43 | # yelp |
1294 | 46 | # Description: UNKNOWN | 44 | # Description: UNKNOWN |
1295 | 47 | # UNKNOWN | 45 | # UNKNOWN |
1296 | 48 | 46 | ||
1297 | === removed file 'data/templates/ubuntu-application/test/preferences.py' | |||
1298 | --- data/templates/ubuntu-application/test/preferences.py 2011-03-31 17:38:31 +0000 | |||
1299 | +++ data/templates/ubuntu-application/test/preferences.py 1970-01-01 00:00:00 +0000 | |||
1300 | @@ -1,151 +0,0 @@ | |||
1301 | 1 | import unittest | ||
1302 | 2 | import os | ||
1303 | 3 | import sys | ||
1304 | 4 | import glob | ||
1305 | 5 | |||
1306 | 6 | proj_root = os.path.abspath(os.path.join(os.path.dirname(__file__),"..","project_root")) | ||
1307 | 7 | sys.path.insert(0, proj_root) | ||
1308 | 8 | import logging | ||
1309 | 9 | logging.debug(sys.path[0]) | ||
1310 | 10 | |||
1311 | 11 | from python_lib.preferences import User_dict, preferences | ||
1312 | 12 | |||
1313 | 13 | # Clean up after ourselves | ||
1314 | 14 | for f in glob.glob(os.path.join(proj_root, 'python_lib', '*.pyc')): | ||
1315 | 15 | os.remove(f) | ||
1316 | 16 | |||
1317 | 17 | class TestUser_dict(unittest.TestCase): | ||
1318 | 18 | |||
1319 | 19 | def test_interface(self): | ||
1320 | 20 | foo = User_dict() | ||
1321 | 21 | # provides gobject signals | ||
1322 | 22 | self.assertTrue(callable(foo.emit)) | ||
1323 | 23 | self.assertTrue(callable(foo.connect)) | ||
1324 | 24 | |||
1325 | 25 | # provides load and save | ||
1326 | 26 | self.assertTrue(callable(foo.load)) | ||
1327 | 27 | self.assertTrue(callable(foo.save)) | ||
1328 | 28 | |||
1329 | 29 | def test_update_from_dict(self): | ||
1330 | 30 | foo = User_dict() | ||
1331 | 31 | bar = {'pluto':2} | ||
1332 | 32 | foo.update(bar) | ||
1333 | 33 | self.assertEqual(foo.get('pluto'), 2) | ||
1334 | 34 | |||
1335 | 35 | def test_update_from_pairs(self): | ||
1336 | 36 | a = User_dict([['position', 'Public Relations'], ['name', 'Jayne Cobb']]) | ||
1337 | 37 | b = {'name': 'Jayne Cobb', 'position': 'Public Relations'} | ||
1338 | 38 | self.assertEqual(a, b) | ||
1339 | 39 | |||
1340 | 40 | def test_serialisation(self): | ||
1341 | 41 | # used in couchdb for instance | ||
1342 | 42 | import json | ||
1343 | 43 | a = User_dict([['position', 'Public Relations'], ['name', 'Jayne Cobb']]) | ||
1344 | 44 | b = {'name': 'Jayne Cobb', 'position': 'Public Relations'} | ||
1345 | 45 | c = json.loads(json.dumps(a)) | ||
1346 | 46 | self.assertEqual(a, c) | ||
1347 | 47 | |||
1348 | 48 | def test__setitem__(self): | ||
1349 | 49 | foo = User_dict() | ||
1350 | 50 | foo[2] = 3 | ||
1351 | 51 | self.assertEqual(foo.get(2), 3) | ||
1352 | 52 | |||
1353 | 53 | def test__delitem__(self): | ||
1354 | 54 | foo = User_dict() | ||
1355 | 55 | foo[2] = 3 | ||
1356 | 56 | self.assertEqual(foo.get(2), 3) | ||
1357 | 57 | del foo[2] | ||
1358 | 58 | self.assertEqual(foo.get(2, 'default'), 'default') | ||
1359 | 59 | |||
1360 | 60 | def test__getitem__(self): | ||
1361 | 61 | foo = User_dict() | ||
1362 | 62 | foo[2] = 3 | ||
1363 | 63 | self.assertEqual(foo[2], 3) | ||
1364 | 64 | |||
1365 | 65 | class TestSignals(unittest.TestCase): | ||
1366 | 66 | |||
1367 | 67 | def setUp(self): | ||
1368 | 68 | self.foo = User_dict() | ||
1369 | 69 | self.messages = [] | ||
1370 | 70 | self.foo.connect('changed', self.callback) | ||
1371 | 71 | |||
1372 | 72 | def callback(self, *args): | ||
1373 | 73 | self.messages.append(args) | ||
1374 | 74 | |||
1375 | 75 | def test_update_with_additions(self): | ||
1376 | 76 | bar = {'foobar': 7} | ||
1377 | 77 | self.foo.update({'foobar': 7}) | ||
1378 | 78 | self.assertEqual(self.messages[0][1], ('foobar',)) | ||
1379 | 79 | self.foo.update({'fooey': 2}) | ||
1380 | 80 | self.assertEqual(self.messages[1][1], ('fooey',)) | ||
1381 | 81 | self.assertEqual(len(self.messages), 2) | ||
1382 | 82 | |||
1383 | 83 | def test_update_with_changes(self): | ||
1384 | 84 | bar = {'foobar': 7} | ||
1385 | 85 | self.foo.update({'foobar': 7}) | ||
1386 | 86 | self.assertEqual(self.messages[0][1], ('foobar',)) | ||
1387 | 87 | self.foo.update({'foobar': 8}) | ||
1388 | 88 | self.assertEqual(self.messages[1][1], ('foobar',)) | ||
1389 | 89 | self.assertEqual(len(self.messages), 2) | ||
1390 | 90 | |||
1391 | 91 | def test_update_without_changes(self): | ||
1392 | 92 | bar = {'foobar': 7} | ||
1393 | 93 | self.foo.update({'foobar': 7}) | ||
1394 | 94 | self.assertEqual(self.messages[0][1], ('foobar',)) | ||
1395 | 95 | self.foo.update({'foobar': 7}) | ||
1396 | 96 | self.assertEqual(len(self.messages), 1) | ||
1397 | 97 | |||
1398 | 98 | def test_update_with_several_items(self): | ||
1399 | 99 | data = {'pluto': 7, 'mickey': 8, 'minnie': 9} | ||
1400 | 100 | self.foo.update(data) | ||
1401 | 101 | self.assertEqual(self.messages[0][1], ('mickey', 'minnie', 'pluto')) | ||
1402 | 102 | self.assertEqual(len(self.messages), 1) | ||
1403 | 103 | data = {'mickey': 1, 'minnie': 2} | ||
1404 | 104 | self.foo.update(data) | ||
1405 | 105 | self.assertEqual(self.messages[1][1], ('mickey', 'minnie')) | ||
1406 | 106 | self.assertEqual(len(self.messages), 2) | ||
1407 | 107 | |||
1408 | 108 | def test__setitem__with_additions(self): | ||
1409 | 109 | self.foo['too'] = 3 | ||
1410 | 110 | self.assertEqual(self.messages[0][1], ('too',)) | ||
1411 | 111 | |||
1412 | 112 | def test__setitem__with_changes(self): | ||
1413 | 113 | self.foo['too'] = 3 | ||
1414 | 114 | self.assertEqual(self.messages[0][1], ('too',)) | ||
1415 | 115 | self.assertEqual(len(self.messages), 1) | ||
1416 | 116 | self.foo['too'] = 4 | ||
1417 | 117 | self.assertEqual(len(self.messages), 2) | ||
1418 | 118 | |||
1419 | 119 | def test__setitem__without_changes(self): | ||
1420 | 120 | self.foo['too'] = 3 | ||
1421 | 121 | self.assertEqual(self.messages[0][1], ('too',)) | ||
1422 | 122 | self.assertEqual(len(self.messages), 1) | ||
1423 | 123 | self.foo['too'] = 3 | ||
1424 | 124 | self.assertEqual(len(self.messages), 1) | ||
1425 | 125 | |||
1426 | 126 | class TestPreferences(unittest.TestCase): | ||
1427 | 127 | ''' this one we really need ''' | ||
1428 | 128 | |||
1429 | 129 | def setUp(self): | ||
1430 | 130 | self.messages = [] | ||
1431 | 131 | preferences.connect('changed', self.callback) | ||
1432 | 132 | |||
1433 | 133 | def callback(self, *args): | ||
1434 | 134 | self.messages.append(args) | ||
1435 | 135 | |||
1436 | 136 | def test_update(self): | ||
1437 | 137 | preferences.update({'foobar': 7}) | ||
1438 | 138 | self.assertEqual(self.messages[0][1], ('foobar',)) | ||
1439 | 139 | self.assertEqual(len(self.messages), 1) | ||
1440 | 140 | # preferences persist so we need to clean our changes | ||
1441 | 141 | del preferences['foobar'] | ||
1442 | 142 | |||
1443 | 143 | def test__setitem__(self): | ||
1444 | 144 | preferences['too'] = 3 | ||
1445 | 145 | self.assertEqual(self.messages[0][1], ('too',)) | ||
1446 | 146 | self.assertEqual(len(self.messages), 1) | ||
1447 | 147 | # preferences persist so we need to clean our changes | ||
1448 | 148 | del preferences['too'] | ||
1449 | 149 | |||
1450 | 150 | if __name__ == '__main__': | ||
1451 | 151 | unittest.main() | ||
1452 | 152 | 0 | ||
1453 | === modified file 'data/templates/ubuntu-application/upgrade.py' | |||
1454 | --- data/templates/ubuntu-application/upgrade.py 2011-10-03 18:05:30 +0000 | |||
1455 | +++ data/templates/ubuntu-application/upgrade.py 2011-11-08 16:10:57 +0000 | |||
1456 | @@ -34,6 +34,8 @@ | |||
1457 | 34 | # get project version and template version if no argument given | 34 | # get project version and template version if no argument given |
1458 | 35 | if len(sys.argv) < 3: | 35 | if len(sys.argv) < 3: |
1459 | 36 | (project_version, template_version) = templatetools.get_project_and_template_versions("ubuntu-application") | 36 | (project_version, template_version) = templatetools.get_project_and_template_versions("ubuntu-application") |
1460 | 37 | if len(sys.argv) == 2: # we have been given project but not template version | ||
1461 | 38 | project_version = sys.argv[1] | ||
1462 | 37 | else: | 39 | else: |
1463 | 38 | project_version = sys.argv[1] | 40 | project_version = sys.argv[1] |
1464 | 39 | template_version = sys.argv[2] | 41 | template_version = sys.argv[2] |
1465 | @@ -201,8 +203,8 @@ | |||
1466 | 201 | except templatetools.CantUpdateFile, e: | 203 | except templatetools.CantUpdateFile, e: |
1467 | 202 | print _("WARNING: can't update your project to support /opt. This doesn't matter if you don't plan to submit your project to the application review board. Cause is: %s" % e) | 204 | print _("WARNING: can't update your project to support /opt. This doesn't matter if you don't plan to submit your project to the application review board. Cause is: %s" % e) |
1468 | 203 | 205 | ||
1471 | 204 | ### 11.09 update | 206 | ### 11.09 update (but only through 11.10; later versions don't want this change) |
1472 | 205 | if project_version < '11.09': | 207 | if project_version < '11.09' and template_version <= '11.10': |
1473 | 206 | filename = './%s_lib/Builder.py' % python_name | 208 | filename = './%s_lib/Builder.py' % python_name |
1474 | 207 | try: | 209 | try: |
1475 | 208 | with open(filename) as fileobj: | 210 | with open(filename) as fileobj: |
1476 | 209 | 211 | ||
1477 | === removed file 'data/templates/ubuntu-flash-game/internal/apportutils.py' | |||
1478 | --- data/templates/ubuntu-flash-game/internal/apportutils.py 2011-06-06 10:14:40 +0000 | |||
1479 | +++ data/templates/ubuntu-flash-game/internal/apportutils.py 1970-01-01 00:00:00 +0000 | |||
1480 | @@ -1,143 +0,0 @@ | |||
1481 | 1 | import os | ||
1482 | 2 | import shutil | ||
1483 | 3 | import subprocess | ||
1484 | 4 | |||
1485 | 5 | from gettext import gettext as _ | ||
1486 | 6 | |||
1487 | 7 | import quickly | ||
1488 | 8 | import quicklyutils | ||
1489 | 9 | |||
1490 | 10 | from lxml import etree | ||
1491 | 11 | |||
1492 | 12 | LPI_import_block = """ | ||
1493 | 13 | # optional Launchpad integration | ||
1494 | 14 | # this shouldn't crash if not found as it is simply used for bug reporting | ||
1495 | 15 | try: | ||
1496 | 16 | import LaunchpadIntegration | ||
1497 | 17 | launchpad_available = True | ||
1498 | 18 | except: | ||
1499 | 19 | launchpad_available = False | ||
1500 | 20 | |||
1501 | 21 | """ | ||
1502 | 22 | |||
1503 | 23 | LPI_init_menu_block = """ | ||
1504 | 24 | global launchpad_available | ||
1505 | 25 | if launchpad_available: | ||
1506 | 26 | # see https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding for more information | ||
1507 | 27 | # about LaunchpadIntegration | ||
1508 | 28 | helpmenu = self.builder.get_object('%(help_menu)s') | ||
1509 | 29 | if helpmenu: | ||
1510 | 30 | LaunchpadIntegration.set_sourcepackagename('%(project_name)s') | ||
1511 | 31 | LaunchpadIntegration.add_items(helpmenu, 0, False, True) | ||
1512 | 32 | else: | ||
1513 | 33 | launchpad_available = False""" | ||
1514 | 34 | |||
1515 | 35 | def update_apport(project_name, old_lp_project, new_lp_project): | ||
1516 | 36 | if not new_lp_project: | ||
1517 | 37 | return | ||
1518 | 38 | # crashdb file doesn't support spaces or dashes in the crash db name | ||
1519 | 39 | safe_project_name = project_name.replace(" ", "_").replace("-","_") | ||
1520 | 40 | crashdb_file = "%s-crashdb.conf"%project_name | ||
1521 | 41 | hook_file = "source_%s.py"%project_name | ||
1522 | 42 | |||
1523 | 43 | |||
1524 | 44 | pathname = quickly.templatetools.get_template_path_from_project() | ||
1525 | 45 | template_pr_path = os.path.join(os.path.abspath(pathname), "store", | ||
1526 | 46 | "apport") | ||
1527 | 47 | relative_crashdb_dir = os.path.join("etc", "apport", "crashdb.conf.d") | ||
1528 | 48 | relative_apport_dir = "apport" | ||
1529 | 49 | |||
1530 | 50 | existing_crashdb = os.path.join(relative_crashdb_dir, crashdb_file) | ||
1531 | 51 | existing_hook = os.path.join(relative_apport_dir, hook_file) | ||
1532 | 52 | |||
1533 | 53 | template_crashdb_dir = os.path.join(template_pr_path, relative_crashdb_dir) | ||
1534 | 54 | template_hook_dir = os.path.join(template_pr_path, relative_apport_dir) | ||
1535 | 55 | |||
1536 | 56 | # if the project name has changed, or any of the files are missing, then | ||
1537 | 57 | # attempt to set up the apport configuration and hooks | ||
1538 | 58 | if not old_lp_project == new_lp_project \ | ||
1539 | 59 | or not os.path.isfile(existing_crashdb) \ | ||
1540 | 60 | or not os.path.isfile(existing_hook): | ||
1541 | 61 | |||
1542 | 62 | subst_existing = ((old_lp_project, new_lp_project),) | ||
1543 | 63 | subst_new = ( ("safe_project_name", safe_project_name), | ||
1544 | 64 | ("project_name", project_name), | ||
1545 | 65 | ("lp_project", new_lp_project)) | ||
1546 | 66 | |||
1547 | 67 | if os.path.isfile(existing_crashdb): | ||
1548 | 68 | print _("Updating project name references in existing apport crashdb configuration") | ||
1549 | 69 | templatetools.file_from_template(relative_crashdb_dir, crashdb_file, relative_crashdb_dir, subst_existing) | ||
1550 | 70 | elif os.path.isdir(template_crashdb_dir): | ||
1551 | 71 | print _("Creating new apport crashdb configuration") | ||
1552 | 72 | if not os.path.isdir(relative_crashdb_dir): | ||
1553 | 73 | os.makedirs(relative_crashdb_dir) | ||
1554 | 74 | templatetools.file_from_template(template_crashdb_dir, "project_name-crashdb.conf", relative_crashdb_dir, subst_new) | ||
1555 | 75 | |||
1556 | 76 | if not os.path.isfile(existing_hook) and os.path.isdir(template_hook_dir): | ||
1557 | 77 | print _("Creating new apport hooks") | ||
1558 | 78 | if not os.path.isdir(relative_apport_dir): | ||
1559 | 79 | os.makedirs(relative_apport_dir) | ||
1560 | 80 | templatetools.file_from_template(template_hook_dir, "source_project_name.py", relative_apport_dir, subst_new) | ||
1561 | 81 | |||
1562 | 82 | def insert_lpi_if_required(project_name): | ||
1563 | 83 | existing_bin_filename = os.path.join("bin",project_name) | ||
1564 | 84 | camel_case_project_name = quickly.templatetools.get_camel_case_name(project_name) | ||
1565 | 85 | existing_ui_filename = os.path.join("data","ui", "%sWindow.ui"%camel_case_project_name) | ||
1566 | 86 | |||
1567 | 87 | if os.path.isfile(existing_bin_filename) and os.path.isfile(existing_ui_filename): | ||
1568 | 88 | tree = etree.parse(existing_ui_filename) | ||
1569 | 89 | help_menu = find_about_menu(tree) | ||
1570 | 90 | |||
1571 | 91 | if help_menu: | ||
1572 | 92 | existing_bin_file = file(existing_bin_filename, "r") | ||
1573 | 93 | existing_lines = existing_bin_file.readlines() | ||
1574 | 94 | existing_bin_file.close() | ||
1575 | 95 | new_lines = detect_or_insert_lpi(existing_lines, project_name, help_menu) | ||
1576 | 96 | if new_lines: | ||
1577 | 97 | print _("Adding launchpad integration to existing application") | ||
1578 | 98 | ftarget_file_name_out = file(existing_bin_file.name + '.new', 'w') | ||
1579 | 99 | ftarget_file_name_out.writelines(new_lines) | ||
1580 | 100 | ftarget_file_name_out.close() | ||
1581 | 101 | quickly.templatetools.apply_file_rights(existing_bin_file.name, ftarget_file_name_out.name) | ||
1582 | 102 | os.rename(ftarget_file_name_out.name, existing_bin_file.name) | ||
1583 | 103 | return True | ||
1584 | 104 | return False | ||
1585 | 105 | |||
1586 | 106 | def detect_or_insert_lpi(existing_lines, project_name, help_menu): | ||
1587 | 107 | integration_present = False | ||
1588 | 108 | import_insert_line = None | ||
1589 | 109 | init_insert_line = None | ||
1590 | 110 | current_line = 0 | ||
1591 | 111 | for line in existing_lines: | ||
1592 | 112 | if "import LaunchpadIntegration" in line \ | ||
1593 | 113 | or "if launchpad_available:" in line: | ||
1594 | 114 | integration_present = True | ||
1595 | 115 | break | ||
1596 | 116 | if not import_insert_line and "import gtk" in line: | ||
1597 | 117 | import_insert_line = current_line | ||
1598 | 118 | if not init_insert_line and "self.builder.connect_signals(self)" in line: | ||
1599 | 119 | init_insert_line = current_line | ||
1600 | 120 | current_line += 1 | ||
1601 | 121 | |||
1602 | 122 | if not integration_present \ | ||
1603 | 123 | and import_insert_line \ | ||
1604 | 124 | and init_insert_line \ | ||
1605 | 125 | and import_insert_line < init_insert_line: | ||
1606 | 126 | init_menu_block = LPI_init_menu_block%{"project_name":project_name, "help_menu":help_menu} | ||
1607 | 127 | existing_lines = existing_lines[:import_insert_line+1] + \ | ||
1608 | 128 | ["%s\n"%l for l in LPI_import_block.splitlines()] + \ | ||
1609 | 129 | existing_lines[import_insert_line+1:init_insert_line+1] + \ | ||
1610 | 130 | ["%s\n"%l for l in init_menu_block.splitlines()] + \ | ||
1611 | 131 | existing_lines[init_insert_line+1:] | ||
1612 | 132 | return existing_lines | ||
1613 | 133 | else: | ||
1614 | 134 | return None | ||
1615 | 135 | |||
1616 | 136 | |||
1617 | 137 | def find_about_menu(tree): | ||
1618 | 138 | """Finds the current help menu in the passed xml document by looking for the gtk-about element""" | ||
1619 | 139 | help_item = tree.xpath('//property[@name="label" and .="gtk-about"]/../../../@id') | ||
1620 | 140 | if len(help_item) == 1: # only one element matching this should be found | ||
1621 | 141 | return help_item[0] | ||
1622 | 142 | else: | ||
1623 | 143 | return None | ||
1624 | 144 | 0 | ||
1625 | === modified file 'data/templates/ubuntu-flash-game/project_root/bin/project_name' | |||
1626 | --- data/templates/ubuntu-flash-game/project_root/bin/project_name 2011-01-03 16:05:40 +0000 | |||
1627 | +++ data/templates/ubuntu-flash-game/project_root/bin/project_name 2011-11-08 16:10:57 +0000 | |||
1628 | @@ -18,7 +18,7 @@ | |||
1629 | 18 | ########################################################################### | 18 | ########################################################################### |
1630 | 19 | 19 | ||
1631 | 20 | 20 | ||
1633 | 21 | import webkit, gtk, gio | 21 | from gi.repository import WebKit, Gtk, Gio |
1634 | 22 | import json, os | 22 | import json, os |
1635 | 23 | 23 | ||
1636 | 24 | # Where your project will look for your data (for instance, images and ui | 24 | # Where your project will look for your data (for instance, images and ui |
1637 | @@ -55,17 +55,18 @@ | |||
1638 | 55 | 55 | ||
1639 | 56 | 56 | ||
1640 | 57 | if __name__ == "__main__": | 57 | if __name__ == "__main__": |
1643 | 58 | w = gtk.Window() | 58 | w = Gtk.Window() |
1644 | 59 | v = webkit.WebView() | 59 | v = WebKit.WebView() |
1645 | 60 | w.add(v) | 60 | w.add(v) |
1646 | 61 | w.show_all() # have to have this before set_size_request | 61 | w.show_all() # have to have this before set_size_request |
1648 | 62 | w.connect("destroy", lambda q: gtk.main_quit()) | 62 | w.connect("destroy", lambda q: Gtk.main_quit()) |
1649 | 63 | w.set_title(GAME_NAME) | 63 | w.set_title(GAME_NAME) |
1651 | 64 | htmlfp = gio.File(get_data_file('index.html')) | 64 | htmlfp = Gio.file_new_for_path(get_data_file('index.html')) |
1652 | 65 | uri = htmlfp.get_uri() | 65 | uri = htmlfp.get_uri() |
1654 | 66 | html, _, _ = htmlfp.load_contents() | 66 | _, html, _ = htmlfp.load_contents(None) |
1655 | 67 | print html, "hello", uri | ||
1656 | 67 | v.load_html_string(html, uri) | 68 | v.load_html_string(html, uri) |
1657 | 68 | w.set_size_request(*WINDOW_SIZE) | 69 | w.set_size_request(*WINDOW_SIZE) |
1658 | 69 | v.queue_resize() # force a reallocation, https://bugs.webkit.org/show_bug.cgi?id=47742 | 70 | v.queue_resize() # force a reallocation, https://bugs.webkit.org/show_bug.cgi?id=47742 |
1660 | 70 | gtk.main() | 71 | Gtk.main() |
1661 | 71 | 72 | ||
1662 | 72 | 73 | ||
1663 | === modified file 'quickly/quicklyconfig.py' | |||
1664 | --- quickly/quicklyconfig.py 2011-09-26 13:02:43 +0000 | |||
1665 | +++ quickly/quicklyconfig.py 2011-11-08 16:10:57 +0000 | |||
1666 | @@ -20,7 +20,7 @@ | |||
1667 | 20 | # you're warned :) | 20 | # you're warned :) |
1668 | 21 | 21 | ||
1669 | 22 | # quickly version used for project format compatibility | 22 | # quickly version used for project format compatibility |
1671 | 23 | __version__ = '11.10' | 23 | __version__ = '11.11' |
1672 | 24 | 24 | ||
1673 | 25 | # where quickly will head for quickly data (for instance, templates) | 25 | # where quickly will head for quickly data (for instance, templates) |
1674 | 26 | # by default, this is ../data, relative to trunk layout | 26 | # by default, this is ../data, relative to trunk layout |
1675 | 27 | 27 | ||
1676 | === modified file 'quickly/test/pylint.sh' | |||
1677 | --- quickly/test/pylint.sh 2010-12-04 17:28:41 +0000 | |||
1678 | +++ quickly/test/pylint.sh 2011-11-08 16:10:57 +0000 | |||
1679 | @@ -2,4 +2,4 @@ | |||
1680 | 2 | 2 | ||
1681 | 3 | if ! which pylint >/dev/null; then echo 'Please install pylint'; fi | 3 | if ! which pylint >/dev/null; then echo 'Please install pylint'; fi |
1682 | 4 | 4 | ||
1684 | 5 | (pylint -E --output-format=parseable --include-ids=y --ignored-classes=Credentials,Launchpad $(find "$ORIGINAL_DIR" -name '*.py' | grep -v "^$ORIGINAL_DIR/debian" | grep -v "^$ORIGINAL_DIR/build") 2>/dev/null) | 5 | (pylint -E --output-format=parseable --include-ids=y --disable=E1101 --ignored-classes=Credentials,Launchpad $(find "$ORIGINAL_DIR" -name '*.py' | grep -v "^$ORIGINAL_DIR/debian" | grep -v "^$ORIGINAL_DIR/build") 2>/dev/null) |
1685 | 6 | 6 | ||
1686 | === modified file 'setup.py' | |||
1687 | --- setup.py 2011-09-26 13:02:43 +0000 | |||
1688 | +++ setup.py 2011-11-08 16:10:57 +0000 | |||
1689 | @@ -18,7 +18,7 @@ | |||
1690 | 18 | 18 | ||
1691 | 19 | 19 | ||
1692 | 20 | # UPDATE VERSION WHEN NEEDED (it updates all versions needed to be updated) | 20 | # UPDATE VERSION WHEN NEEDED (it updates all versions needed to be updated) |
1694 | 21 | VERSION = '11.10' | 21 | VERSION = '11.11' |
1695 | 22 | 22 | ||
1696 | 23 | import glob | 23 | import glob |
1697 | 24 | import os | 24 | import os |
1698 | 25 | 25 | ||
1699 | === modified file 'ubuntudevbar.py' | |||
1700 | --- ubuntudevbar.py 2010-12-02 16:03:30 +0000 | |||
1701 | +++ ubuntudevbar.py 2011-11-08 16:10:57 +0000 | |||
1702 | @@ -1,10 +1,7 @@ | |||
1703 | 1 | #!/usr/bin/python | 1 | #!/usr/bin/python |
1704 | 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 -*- |
1705 | 3 | 3 | ||
1710 | 4 | import nautilus | 4 | from gi.repository import GLib, GdkPixbuf, Gtk, Nautilus, Vte # pylint: disable=E0611 |
1707 | 5 | import pygtk | ||
1708 | 6 | import gtk | ||
1709 | 7 | import vte | ||
1711 | 8 | 5 | ||
1712 | 9 | try: | 6 | try: |
1713 | 10 | from quickly import api as quicklyapi | 7 | from quickly import api as quicklyapi |
1714 | @@ -16,7 +13,7 @@ | |||
1715 | 16 | command_order = ('create', 'edit', 'design', 'save', 'package', 'share', 'release', 'tutorial') | 13 | command_order = ('create', 'edit', 'design', 'save', 'package', 'share', 'release', 'tutorial') |
1716 | 17 | command_without_output = ('edit', 'design', 'save', 'tutorial') | 14 | command_without_output = ('edit', 'design', 'save', 'tutorial') |
1717 | 18 | 15 | ||
1719 | 19 | class DevBar(nautilus.LocationWidgetProvider): | 16 | class DevBar(Nautilus.LocationWidgetProvider): |
1720 | 20 | pass | 17 | pass |
1721 | 21 | def __init__(self): | 18 | def __init__(self): |
1722 | 22 | self.bars = {} | 19 | self.bars = {} |
1723 | @@ -73,12 +70,12 @@ | |||
1724 | 73 | return bar | 70 | return bar |
1725 | 74 | 71 | ||
1726 | 75 | 72 | ||
1728 | 76 | class UbuntuDevBar(gtk.HBox): | 73 | class UbuntuDevBar(Gtk.HBox): |
1729 | 77 | '''Container to all buttons in nautilus.''' | 74 | '''Container to all buttons in nautilus.''' |
1730 | 78 | 75 | ||
1731 | 79 | def __init__(self, *args, **kwargs): | 76 | def __init__(self, *args, **kwargs): |
1732 | 80 | '''create a Ubuntu Dev Bar''' | 77 | '''create a Ubuntu Dev Bar''' |
1734 | 81 | super(UbuntuDevBar, self).__init__(*args, **kwargs) | 78 | Gtk.HBox.__init__(*args, **kwargs) |
1735 | 82 | self._logo = None | 79 | self._logo = None |
1736 | 83 | self._image = None | 80 | self._image = None |
1737 | 84 | self._subtitle = None | 81 | self._subtitle = None |
1738 | @@ -87,16 +84,16 @@ | |||
1739 | 87 | 84 | ||
1740 | 88 | def add_image(self, image_name, subtitle=None): | 85 | def add_image(self, image_name, subtitle=None): |
1741 | 89 | """Add an image to the bar and a subtitle below if one.""" | 86 | """Add an image to the bar and a subtitle below if one.""" |
1744 | 90 | self._logo = gtk.VBox(homogeneous=False, spacing=0) | 87 | self._logo = Gtk.VBox(homogeneous=False, spacing=0) |
1745 | 91 | self._image = gtk.Image() | 88 | self._image = Gtk.Image() |
1746 | 92 | self._logo.pack_start(self._image, expand=True, fill=True, padding=0) | 89 | self._logo.pack_start(self._image, expand=True, fill=True, padding=0) |
1748 | 93 | pixbuf = gtk.gdk.pixbuf_new_from_file(image_name) | 90 | pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_name) |
1749 | 94 | if pixbuf: | 91 | if pixbuf: |
1751 | 95 | scaled_pixbuf = pixbuf.scale_simple(48, 48, gtk.gdk.INTERP_BILINEAR) | 92 | scaled_pixbuf = pixbuf.scale_simple(48, 48, GdkPixbuf.InterpType.BILINEAR) |
1752 | 96 | self._image.set_from_pixbuf(scaled_pixbuf) | 93 | self._image.set_from_pixbuf(scaled_pixbuf) |
1753 | 97 | self._image.show() | 94 | self._image.show() |
1754 | 98 | if subtitle: | 95 | if subtitle: |
1756 | 99 | self._subtitle = gtk.Label(subtitle) | 96 | self._subtitle = Gtk.Label(subtitle) |
1757 | 100 | self._logo.pack_start(self._subtitle, expand=True, fill=True, padding=0) | 97 | self._logo.pack_start(self._subtitle, expand=True, fill=True, padding=0) |
1758 | 101 | self._subtitle.show() | 98 | self._subtitle.show() |
1759 | 102 | self.pack_start(self._logo, expand=False, fill=False, padding=0) | 99 | self.pack_start(self._logo, expand=False, fill=False, padding=0) |
1760 | @@ -104,17 +101,17 @@ | |||
1761 | 104 | 101 | ||
1762 | 105 | def add_button(self, signal, label, command_line, path, icon=None): | 102 | def add_button(self, signal, label, command_line, path, icon=None): |
1763 | 106 | """Adds a new new button to the bar widget.""" | 103 | """Adds a new new button to the bar widget.""" |
1765 | 107 | button = gtk.Button() | 104 | button = Gtk.Button() |
1766 | 108 | button.connect("clicked", signal, command_line, path) | 105 | button.connect("clicked", signal, command_line, path) |
1767 | 109 | button.set_label(label) | 106 | button.set_label(label) |
1768 | 110 | if icon: | 107 | if icon: |
1770 | 111 | image = gtk.Image() | 108 | image = Gtk.Image() |
1771 | 112 | image.set_from_file(icon) | 109 | image.set_from_file(icon) |
1772 | 113 | settings = button.get_settings() | 110 | settings = button.get_settings() |
1773 | 114 | settings.set_property("gtk-button-images", True) | 111 | settings.set_property("gtk-button-images", True) |
1774 | 115 | button.set_image(image) | 112 | button.set_image(image) |
1775 | 116 | button.show() | 113 | button.show() |
1777 | 117 | vbox = gtk.VBox(homogeneous=False, spacing=0) | 114 | vbox = Gtk.VBox(homogeneous=False, spacing=0) |
1778 | 118 | vbox.pack_start(button, expand=True, fill=False, padding=0) | 115 | vbox.pack_start(button, expand=True, fill=False, padding=0) |
1779 | 119 | vbox.show() | 116 | vbox.show() |
1780 | 120 | self._buttons.append(button) | 117 | self._buttons.append(button) |
1781 | @@ -123,21 +120,21 @@ | |||
1782 | 123 | def add_button_with_selection(self, signal, label, selection, command_line, | 120 | def add_button_with_selection(self, signal, label, selection, command_line, |
1783 | 124 | path, icon=None): | 121 | path, icon=None): |
1784 | 125 | """Adds a new button with a multiple selection widget""" | 122 | """Adds a new button with a multiple selection widget""" |
1786 | 126 | combobox = gtk.combo_box_new_text() | 123 | combobox = Gtk.ComboBoxText() |
1787 | 127 | for item in selection: | 124 | for item in selection: |
1788 | 128 | combobox.append_text(item) | 125 | combobox.append_text(item) |
1789 | 129 | combobox.show() | 126 | combobox.show() |
1791 | 130 | button = gtk.Button() | 127 | button = Gtk.Button() |
1792 | 131 | button.set_label(label) | 128 | button.set_label(label) |
1793 | 132 | button.connect("clicked", signal, command_line, path, combobox) | 129 | button.connect("clicked", signal, command_line, path, combobox) |
1794 | 133 | if icon: | 130 | if icon: |
1796 | 134 | image = gtk.Image() | 131 | image = Gtk.Image() |
1797 | 135 | image.set_from_file(icon) | 132 | image.set_from_file(icon) |
1798 | 136 | settings = button.get_settings() | 133 | settings = button.get_settings() |
1799 | 137 | settings.set_property("gtk-button-images", True) | 134 | settings.set_property("gtk-button-images", True) |
1800 | 138 | button.set_image(image) | 135 | button.set_image(image) |
1801 | 139 | button.show() | 136 | button.show() |
1803 | 140 | vbox = gtk.VBox(homogeneous=False, spacing=0) | 137 | vbox = Gtk.VBox(homogeneous=False, spacing=0) |
1804 | 141 | vbox.pack_start(combobox, expand=True, fill=False, padding=0) | 138 | vbox.pack_start(combobox, expand=True, fill=False, padding=0) |
1805 | 142 | vbox.pack_start(button, expand=True, fill=False, padding=0) | 139 | vbox.pack_start(button, expand=True, fill=False, padding=0) |
1806 | 143 | self._buttons_with_selection.append((combobox,button)) | 140 | self._buttons_with_selection.append((combobox,button)) |
1807 | @@ -158,13 +155,14 @@ | |||
1808 | 158 | except IndexError: | 155 | except IndexError: |
1809 | 159 | pass | 156 | pass |
1810 | 160 | command = self.add_additional_actions(command) | 157 | command = self.add_additional_actions(command) |
1814 | 161 | v = vte.Terminal() | 158 | v = Vte.Terminal() |
1815 | 162 | v.fork_command(command[0], argv=command, directory=argscommand[1]) | 159 | v.fork_command_full(Vte.PtyFlags.DEFAULT, argscommand[1], command, |
1816 | 163 | window = gtk.Window() | 160 | None, GLib.SpawnFlags.SEARCH_PATH, None, None) |
1817 | 161 | window = Gtk.Window() | ||
1818 | 164 | window.add(v) | 162 | window.add(v) |
1819 | 165 | if command[1] not in command_without_output: | 163 | if command[1] not in command_without_output: |
1820 | 166 | window.show_all() | 164 | window.show_all() |
1822 | 167 | gtk.main() | 165 | Gtk.main() |
1823 | 168 | 166 | ||
1824 | 169 | def add_additional_actions(self, command): | 167 | def add_additional_actions(self, command): |
1825 | 170 | """Some commands needs additional args, filter them here""" | 168 | """Some commands needs additional args, filter them here""" |
1826 | @@ -172,7 +170,7 @@ | |||
1827 | 172 | # TODO: Add missing prompts module | 170 | # TODO: Add missing prompts module |
1828 | 173 | #if command[1] == "create": | 171 | #if command[1] == "create": |
1829 | 174 | # response, val = prompts.string("Project Name","Please enter a project name") | 172 | # response, val = prompts.string("Project Name","Please enter a project name") |
1831 | 175 | # if response == gtk.RESPONSE_OK: | 173 | # if response == Gtk.ResponseType.OK: |
1832 | 176 | # command.append(val) | 174 | # command.append(val) |
1833 | 177 | 175 | ||
1834 | 178 | return command | 176 | return command |
Excellent work Michael! It's even frustrating that I have nothing to say about it as your much as your work there rocks!
Just a small questions though, in the test apport file:
1154 -quickly upgrade 0.3 0.4
1155 +quickly upgrade 0.3
at multiple time, do you need that and why?
However, I get a lot of error in the testsuite here. Seems to be more a setup issue than anything and not really have the time to run it. So if you confirm that all the tests are passing, please, feel free to merge :)