Merge lp:~quickly-committers/quickly/gtk3-projects into lp:quickly

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
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Approve
Review via email: mp+81600@code.launchpad.net

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-distutils-extra in precise).

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

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 :)

review: Approve
Revision history for this message
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
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
=== modified file 'data/templates/ubuntu-application/create.py'
--- data/templates/ubuntu-application/create.py 2011-06-06 10:14:40 +0000
+++ data/templates/ubuntu-application/create.py 2011-11-08 16:10:57 +0000
@@ -107,10 +107,22 @@
107bzr_instance.wait()107bzr_instance.wait()
108bzr_instance = subprocess.Popen(["bzr", "commit", "-m", "Initial project creation with Quickly!"], stderr=subprocess.PIPE)108bzr_instance = subprocess.Popen(["bzr", "commit", "-m", "Initial project creation with Quickly!"], stderr=subprocess.PIPE)
109109
110# Compile schema if present
111schemapath = os.path.abspath("data/glib-2.0/schemas")
112if os.path.exists(schemapath):
113 subprocess.call(["glib-compile-schemas", schemapath])
114
115 env = os.environ.copy()
116 datadir = os.path.abspath("data")
117 if 'XDG_DATA_DIRS' in env:
118 env['XDG_DATA_DIRS'] = "%s:%s" % (datadir, env['XDG_DATA_DIRS'])
119 else:
120 env['XDG_DATA_DIRS'] = datadir
121
110# run the new application if X display122# run the new application if X display
111if templatetools.is_X_display() and os.path.isfile(exec_file):123if templatetools.is_X_display() and os.path.isfile(exec_file):
112 print _("Launching your newly created project!")124 print _("Launching your newly created project!")
113 subprocess.call(['./' + project_name], cwd='bin/')125 subprocess.call(['./' + project_name], cwd='bin/', env=env)
114126
115bzr_instance.wait()127bzr_instance.wait()
116128
117129
=== modified file 'data/templates/ubuntu-application/help/code/JottyWindow.py'
--- data/templates/ubuntu-application/help/code/JottyWindow.py 2011-04-04 13:55:18 +0000
+++ data/templates/ubuntu-application/help/code/JottyWindow.py 2011-11-08 16:10:57 +0000
@@ -7,7 +7,7 @@
7from gettext import gettext as _7from gettext import gettext as _
8gettext.textdomain('jotty')8gettext.textdomain('jotty')
99
10import gtk10from gi.repository import Gtk # pylint: disable=E0611
11import logging11import logging
12logger = logging.getLogger('jotty')12logger = logging.getLogger('jotty')
1313
1414
=== modified file 'data/templates/ubuntu-application/help/tutorial.xml'
--- data/templates/ubuntu-application/help/tutorial.xml 2011-09-26 13:02:43 +0000
+++ data/templates/ubuntu-application/help/tutorial.xml 2011-11-08 16:10:57 +0000
@@ -3,7 +3,7 @@
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" [
44
5 <!ENTITY appname "<application>Quickly</application>" >5 <!ENTITY appname "<application>Quickly</application>" >
6 <!ENTITY appversion "11.10" >6 <!ENTITY appversion "11.11" >
7] >7] >
88
9<book lang="en" id="index">9<book lang="en" id="index">
1010
=== added file 'data/templates/ubuntu-application/project_root/.bzrignore'
--- data/templates/ubuntu-application/project_root/.bzrignore 1970-01-01 00:00:00 +0000
+++ data/templates/ubuntu-application/project_root/.bzrignore 2011-11-08 16:10:57 +0000
@@ -0,0 +1,1 @@
1data/glib-2.0/schemas/gschemas.compiled
02
=== added directory 'data/templates/ubuntu-application/project_root/data/glib-2.0'
=== added directory 'data/templates/ubuntu-application/project_root/data/glib-2.0/schemas'
=== added file 'data/templates/ubuntu-application/project_root/data/glib-2.0/schemas/net.launchpad.project_name.gschema.xml'
--- data/templates/ubuntu-application/project_root/data/glib-2.0/schemas/net.launchpad.project_name.gschema.xml 1970-01-01 00:00:00 +0000
+++ data/templates/ubuntu-application/project_root/data/glib-2.0/schemas/net.launchpad.project_name.gschema.xml 2011-11-08 16:10:57 +0000
@@ -0,0 +1,10 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<schemalist gettext-domain="project_name">
3 <schema id="net.launchpad.project_name" path="/net/launchpad/project_name/">
4 <key name="example" type="s">
5 <default>''</default>
6 <summary>Sample setting</summary>
7 <description>Longer description of this sample setting. Talk about allowed values and what it does.</description>
8 </key>
9 </schema>
10</schemalist>
011
=== modified file 'data/templates/ubuntu-application/project_root/data/ui/Aboutcamel_case_nameDialog.ui'
--- data/templates/ubuntu-application/project_root/data/ui/Aboutcamel_case_nameDialog.ui 2010-12-20 15:44:44 +0000
+++ data/templates/ubuntu-application/project_root/data/ui/Aboutcamel_case_nameDialog.ui 2011-11-08 16:10:57 +0000
@@ -1,39 +1,37 @@
1<?xml version="1.0"?>1<?xml version="1.0" encoding="UTF-8"?>
2<interface>2<interface>
3 <requires lib="gtk+" version="2.16"/>
4 <!-- interface-requires about_python_name_dialog 1.0 -->3 <!-- interface-requires about_python_name_dialog 1.0 -->
5 <!-- interface-naming-policy project-wide -->4 <!-- interface-requires gtk+ 3.0 -->
6 <object class="Aboutcamel_case_nameDialog" id="about_python_name_dialog">5 <object class="Aboutcamel_case_nameDialog" id="about_python_name_dialog">
6 <property name="can_focus">False</property>
7 <property name="border_width">5</property>7 <property name="border_width">5</property>
8 <property name="icon">../media/project_name.svg</property>8 <property name="icon">../media/project_name.svg</property>
9 <property name="type_hint">normal</property>9 <property name="type_hint">normal</property>
10 <property name="has_separator">False</property>
11 <property name="program_name">sentence_name</property>10 <property name="program_name">sentence_name</property>
12 <property name="version"></property>
13 <property name="copyright"></property>
14 <property name="website"></property>
15 <property name="license"></property>
16 <property name="authors"></property>11 <property name="authors"></property>
17 <property name="logo">../media/project_name.svg</property>12 <property name="logo">../media/project_name.svg</property>
18 <child internal-child="vbox">13 <child internal-child="vbox">
19 <object class="GtkVBox" id="dialog-vbox1">14 <object class="GtkBox" id="dialog-vbox1">
20 <property name="visible">True</property>15 <property name="visible">True</property>
16 <property name="can_focus">False</property>
21 <property name="orientation">vertical</property>17 <property name="orientation">vertical</property>
22 <property name="spacing">2</property>18 <property name="spacing">2</property>
23 <child>
24 <placeholder/>
25 </child>
26 <child internal-child="action_area">19 <child internal-child="action_area">
27 <object class="GtkHButtonBox" id="dialog-action_area1">20 <object class="GtkButtonBox" id="dialog-action_area1">
28 <property name="visible">True</property>21 <property name="visible">True</property>
22 <property name="can_focus">False</property>
29 <property name="layout_style">end</property>23 <property name="layout_style">end</property>
30 </object>24 </object>
31 <packing>25 <packing>
32 <property name="expand">False</property>26 <property name="expand">False</property>
27 <property name="fill">True</property>
33 <property name="pack_type">end</property>28 <property name="pack_type">end</property>
34 <property name="position">0</property>29 <property name="position">0</property>
35 </packing>30 </packing>
36 </child>31 </child>
32 <child>
33 <placeholder/>
34 </child>
37 </object>35 </object>
38 </child>36 </child>
39 </object>37 </object>
4038
=== modified file 'data/templates/ubuntu-application/project_root/data/ui/Preferencescamel_case_nameDialog.ui'
--- data/templates/ubuntu-application/project_root/data/ui/Preferencescamel_case_nameDialog.ui 2010-12-20 15:44:44 +0000
+++ data/templates/ubuntu-application/project_root/data/ui/Preferencescamel_case_nameDialog.ui 2011-11-08 16:10:57 +0000
@@ -1,88 +1,107 @@
1<?xml version="1.0" encoding="UTF-8"?>1<?xml version="1.0" encoding="UTF-8"?>
2<interface>2<interface>
3 <requires lib="gtk+" version="2.16"/>3 <!-- interface-requires gtk+ 3.0 -->
4 <!-- interface-requires preferences_python_name_dialog 1.0 -->4 <!-- interface-requires preferences_python_name_dialog 1.0 -->
5 <!-- interface-naming-policy project-wide -->
6 <object class="Preferencescamel_case_nameDialog" id="preferences_python_name_dialog">5 <object class="Preferencescamel_case_nameDialog" id="preferences_python_name_dialog">
7 <property name="border_width">5</property>6 <property name="can_focus">False</property>
8 <property name="title" translatable="yes">sentence_name Preferences</property>7 <property name="title" translatable="yes">sentence_name Preferences</property>
9 <property name="icon">../media/project_name.svg</property>8 <property name="icon">../media/project_name.svg</property>
10 <property name="type_hint">normal</property>9 <property name="type_hint">normal</property>
11 <child internal-child="vbox">10 <child internal-child="vbox">
12 <object class="GtkVBox" id="dialog-vbox1">11 <object class="GtkBox" id="dialog-vbox1">
13 <property name="visible">True</property>12 <property name="visible">True</property>
14 <property name="spacing">2</property>13 <property name="can_focus">False</property>
14 <property name="orientation">vertical</property>
15 <property name="spacing">12</property>
16 <child internal-child="action_area">
17 <object class="GtkButtonBox" id="dialog-action_area1">
18 <property name="visible">True</property>
19 <property name="can_focus">False</property>
20 <property name="layout_style">end</property>
21 <child>
22 <object class="GtkButton" id="btn_help">
23 <property name="label">gtk-help</property>
24 <property name="visible">True</property>
25 <property name="can_focus">True</property>
26 <property name="receives_default">True</property>
27 <property name="use_action_appearance">False</property>
28 <property name="use_stock">True</property>
29 </object>
30 <packing>
31 <property name="expand">False</property>
32 <property name="fill">False</property>
33 <property name="position">0</property>
34 <property name="secondary">True</property>
35 </packing>
36 </child>
37 <child>
38 <object class="GtkButton" id="btn_close">
39 <property name="label">gtk-close</property>
40 <property name="visible">True</property>
41 <property name="can_focus">True</property>
42 <property name="receives_default">True</property>
43 <property name="use_action_appearance">False</property>
44 <property name="use_stock">True</property>
45 </object>
46 <packing>
47 <property name="expand">False</property>
48 <property name="fill">False</property>
49 <property name="position">1</property>
50 </packing>
51 </child>
52 </object>
53 <packing>
54 <property name="expand">False</property>
55 <property name="fill">True</property>
56 <property name="pack_type">end</property>
57 <property name="position">0</property>
58 </packing>
59 </child>
15 <child>60 <child>
16 <object class="GtkTable" id="table1">61 <object class="GtkGrid" id="table1">
17 <property name="visible">True</property>62 <property name="visible">True</property>
63 <property name="can_focus">False</property>
64 <property name="row_spacing">6</property>
65 <property name="column_spacing">6</property>
66 <property name="n_rows">1</property>
18 <property name="n_columns">2</property>67 <property name="n_columns">2</property>
19 <property name="column_spacing">6</property>
20 <property name="row_spacing">6</property>
21 <child>68 <child>
22 <object class="GtkEntry" id="example_entry">69 <object class="GtkEntry" id="example_entry">
23 <property name="visible">True</property>70 <property name="visible">True</property>
24 <property name="can_focus">True</property>71 <property name="can_focus">True</property>
72 <property name="hexpand">True</property>
25 <property name="invisible_char">•</property>73 <property name="invisible_char">•</property>
26 </object>74 </object>
27 <packing>75 <packing>
28 <property name="left_attach">1</property>76 <property name="left_attach">1</property>
29 <property name="right_attach">2</property>77 <property name="top_attach">0</property>
78 <property name="width">1</property>
79 <property name="height">1</property>
30 </packing>80 </packing>
31 </child>81 </child>
32 <child>82 <child>
33 <object class="GtkLabel" id="example_entry_label">83 <object class="GtkLabel" id="example_entry_label">
34 <property name="visible">True</property>84 <property name="visible">True</property>
85 <property name="can_focus">False</property>
35 <property name="xalign">0</property>86 <property name="xalign">0</property>
36 <property name="label" translatable="yes">_Example entry:</property>87 <property name="label" translatable="yes">_Example entry:</property>
37 <property name="use_underline">True</property>88 <property name="use_underline">True</property>
38 <property name="mnemonic_widget">example_entry</property>89 <property name="mnemonic_widget">example_entry</property>
39 </object>90 </object>
91 <packing>
92 <property name="left_attach">0</property>
93 <property name="top_attach">0</property>
94 <property name="width">1</property>
95 <property name="height">1</property>
96 </packing>
40 </child>97 </child>
41 </object>98 </object>
42 <packing>99 <packing>
100 <property name="expand">False</property>
101 <property name="fill">True</property>
43 <property name="position">1</property>102 <property name="position">1</property>
44 </packing>103 </packing>
45 </child>104 </child>
46 <child internal-child="action_area">
47 <object class="GtkHButtonBox" id="dialog-action_area1">
48 <property name="visible">True</property>
49 <property name="layout_style">end</property>
50 <child>
51 <object class="GtkButton" id="btn_help">
52 <property name="label">gtk-help</property>
53 <property name="visible">True</property>
54 <property name="can_focus">True</property>
55 <property name="receives_default">True</property>
56 <property name="use_stock">True</property>
57 </object>
58 <packing>
59 <property name="expand">False</property>
60 <property name="fill">False</property>
61 <property name="position">0</property>
62 <property name="secondary">True</property>
63 </packing>
64 </child>
65 <child>
66 <object class="GtkButton" id="btn_close">
67 <property name="label">gtk-close</property>
68 <property name="visible">True</property>
69 <property name="can_focus">True</property>
70 <property name="receives_default">True</property>
71 <property name="use_stock">True</property>
72 </object>
73 <packing>
74 <property name="expand">False</property>
75 <property name="fill">False</property>
76 <property name="position">1</property>
77 </packing>
78 </child>
79 </object>
80 <packing>
81 <property name="expand">False</property>
82 <property name="pack_type">end</property>
83 <property name="position">0</property>
84 </packing>
85 </child>
86 </object>105 </object>
87 </child>106 </child>
88 <action-widgets>107 <action-widgets>
89108
=== modified file 'data/templates/ubuntu-application/project_root/data/ui/camel_case_nameWindow.ui'
--- data/templates/ubuntu-application/project_root/data/ui/camel_case_nameWindow.ui 2011-04-01 21:02:04 +0000
+++ data/templates/ubuntu-application/project_root/data/ui/camel_case_nameWindow.ui 2011-11-08 16:10:57 +0000
@@ -1,8 +1,7 @@
1<?xml version="1.0" encoding="UTF-8"?>1<?xml version="1.0" encoding="UTF-8"?>
2<interface>2<interface>
3 <requires lib="gtk+" version="2.16"/>3 <!-- interface-requires gtk+ 3.0 -->
4 <!-- interface-requires python_name_window 1.0 -->4 <!-- interface-requires python_name_window 1.0 -->
5 <!-- interface-naming-policy project-wide -->
6 <!-- interface-local-resource-path ../media -->5 <!-- interface-local-resource-path ../media -->
7 <object class="GtkImage" id="image2">6 <object class="GtkImage" id="image2">
8 <property name="visible">True</property>7 <property name="visible">True</property>
98
=== modified file 'data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py'
--- data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py 2011-04-04 14:28:36 +0000
+++ data/templates/ubuntu-application/project_root/python/Preferencescamel_case_nameDialog.py 2011-11-08 16:10:57 +0000
@@ -5,27 +5,11 @@
55
6# This is your preferences dialog.6# This is your preferences dialog.
7#7#
8# Define your preferences dictionary in the __init__.main() function.8# Define your preferences in
9# The widget names in the PreferencesTestProjectDialog.ui9# data/glib-2.0/schemas/net.launchpad.project_name.gschema.xml
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.
11#11
12# Each preference also need to be defined in the 'widget_methods' map below12from gi.repository import Gio # pylint: disable=E0611
13# to show up in the dialog itself. Provide three bits of information:
14# 1) The first entry is the method on the widget that grabs a value from the
15# widget.
16# 2) The second entry is the method on the widget that sets the widgets value
17# from a stored preference.
18# 3) The third entry is a signal the widget will send when the contents have
19# been changed by the user. The preferences dictionary is always up to
20# date and will signal the rest of the application about these changes.
21# The values will be saved to desktopcouch when the application closes.
22#
23# TODO: replace widget_methods with your own values
24
25
26widget_methods = {
27 'example_entry': ['get_text', 'set_text', 'changed'],
28}
2913
30import gettext14import gettext
31from gettext import gettext as _15from gettext import gettext as _
@@ -43,9 +27,9 @@
43 """Set up the preferences dialog"""27 """Set up the preferences dialog"""
44 super(Preferencescamel_case_nameDialog, self).finish_initializing(builder)28 super(Preferencescamel_case_nameDialog, self).finish_initializing(builder)
4529
46 # populate the dialog from the preferences dictionary30 # Bind each preference widget to gsettings
47 # using the methods from widget_methods31 settings = Gio.Settings("net.launchpad.project_name")
48 self.widget_methods = widget_methods32 widget = self.builder.get_object('example_entry')
49 self.set_widgets_from_preferences() # pylint: disable=E110133 settings.bind("example", widget, "text", Gio.SettingsBindFlags.DEFAULT)
5034
51 # Code for other initialization actions should be added here.35 # Code for other initialization actions should be added here.
5236
=== modified file 'data/templates/ubuntu-application/project_root/python/__init__.py'
--- data/templates/ubuntu-application/project_root/python/__init__.py 2011-03-31 15:19:55 +0000
+++ data/templates/ubuntu-application/project_root/python/__init__.py 2011-11-08 16:10:57 +0000
@@ -9,11 +9,11 @@
9from gettext import gettext as _9from gettext import gettext as _
10gettext.textdomain('project_name')10gettext.textdomain('project_name')
1111
12import gtk12from gi.repository import Gtk # pylint: disable=E0611
1313
14from python_name import camel_case_nameWindow14from python_name import camel_case_nameWindow
1515
16from python_name_lib import set_up_logging, preferences, get_version16from python_name_lib import set_up_logging, get_version
1717
18def parse_options():18def parse_options():
19 """Support for command line options"""19 """Support for command line options"""
@@ -29,20 +29,7 @@
29 'constructor for your class instances'29 'constructor for your class instances'
30 parse_options()30 parse_options()
3131
32 # preferences
33 # set some values for our first session
34 # TODO: replace defaults with your own values
35 default_preferences = {
36 'example_entry': 'I remember stuff',
37 }
38 preferences.update(default_preferences)
39 # user's stored preferences are used for 2nd and subsequent sessions
40 preferences.db_connect()
41 preferences.load()
42
43 # Run the application. 32 # Run the application.
44 window = camel_case_nameWindow.camel_case_nameWindow()33 window = camel_case_nameWindow.camel_case_nameWindow()
45 window.show()34 window.show()
46 gtk.main()35 Gtk.main()
47
48 preferences.save()
4936
=== modified file 'data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py'
--- data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py 2011-04-04 14:28:36 +0000
+++ data/templates/ubuntu-application/project_root/python/camel_case_nameWindow.py 2011-11-08 16:10:57 +0000
@@ -7,7 +7,7 @@
7from gettext import gettext as _7from gettext import gettext as _
8gettext.textdomain('project_name')8gettext.textdomain('project_name')
99
10import gtk10from gi.repository import Gtk # pylint: disable=E0611
11import logging11import logging
12logger = logging.getLogger('python_name')12logger = logging.getLogger('python_name')
1313
1414
=== modified file 'data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py'
--- data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py 2011-03-31 17:05:41 +0000
+++ data/templates/ubuntu-application/project_root/python_lib/AboutDialog.py 2011-11-08 16:10:57 +0000
@@ -3,11 +3,11 @@
3# This file is in the public domain3# This file is in the public domain
4### END LICENSE4### END LICENSE
55
6import gtk6from gi.repository import Gtk # pylint: disable=E0611
77
8from . helpers import get_builder8from . helpers import get_builder
99
10class AboutDialog(gtk.AboutDialog):10class AboutDialog(Gtk.AboutDialog):
11 __gtype_name__ = "AboutDialog"11 __gtype_name__ = "AboutDialog"
1212
13 def __new__(cls):13 def __new__(cls):
1414
=== modified file 'data/templates/ubuntu-application/project_root/python_lib/Builder.py'
--- data/templates/ubuntu-application/project_root/python_lib/Builder.py 2011-09-06 07:47:36 +0000
+++ data/templates/ubuntu-application/project_root/python_lib/Builder.py 2011-11-08 16:10:57 +0000
@@ -5,9 +5,8 @@
55
6'''Enhances builder connections, provides object to access glade objects'''6'''Enhances builder connections, provides object to access glade objects'''
77
8import gobject # pylint: disable=E06118from gi.repository import GObject, Gtk # pylint: disable=E0611
99
10import gtk
11import inspect10import inspect
12import functools11import functools
13import logging12import logging
@@ -23,8 +22,8 @@
2322
2423
25# pylint: disable=R090424# pylint: disable=R0904
26# the many public methods is a feature of gtk.Builder25# the many public methods is a feature of Gtk.Builder
27class Builder(gtk.Builder):26class Builder(Gtk.Builder):
28 ''' extra features27 ''' extra features
29 connects glade defined handler to default_handler if necessary28 connects glade defined handler to default_handler if necessary
30 auto connects widget to handler with matching name or alias29 auto connects widget to handler with matching name or alias
@@ -34,7 +33,7 @@
34 '''33 '''
3534
36 def __init__(self):35 def __init__(self):
37 gtk.Builder.__init__(self)36 Gtk.Builder.__init__(self)
38 self.widgets = {}37 self.widgets = {}
39 self.glade_handler_dict = {}38 self.glade_handler_dict = {}
40 self.connections = []39 self.connections = []
@@ -50,7 +49,7 @@
50 An apprentice guru might wonder which signal does what he wants,49 An apprentice guru might wonder which signal does what he wants,
51 now he can define any likely candidates in glade and notice which50 now he can define any likely candidates in glade and notice which
52 ones get triggered when he plays with the project.51 ones get triggered when he plays with the project.
53 this method does not appear in gtk.Builder'''52 this method does not appear in Gtk.Builder'''
54 logger.debug('''tried to call non-existent function:%s()53 logger.debug('''tried to call non-existent function:%s()
55 expected in %s54 expected in %s
56 args:%s55 args:%s
@@ -60,12 +59,12 @@
60 def get_name(self, widget):59 def get_name(self, widget):
61 ''' allows a handler to get the name (id) of a widget60 ''' allows a handler to get the name (id) of a widget
6261
63 this method does not appear in gtk.Builder'''62 this method does not appear in Gtk.Builder'''
64 return self._reverse_widget_dict.get(widget)63 return self._reverse_widget_dict.get(widget)
6564
66 def add_from_file(self, filename):65 def add_from_file(self, filename):
67 '''parses xml file and stores wanted details'''66 '''parses xml file and stores wanted details'''
68 gtk.Builder.add_from_file(self, filename)67 Gtk.Builder.add_from_file(self, filename)
6968
70 # extract data for the extra interfaces69 # extract data for the extra interfaces
71 tree = ElementTree()70 tree = ElementTree()
@@ -121,7 +120,7 @@
121 item[0], filename)120 item[0], filename)
122121
123 # connect glade define handlers122 # connect glade define handlers
124 gtk.Builder.connect_signals(self, connection_dict)123 Gtk.Builder.connect_signals(self, connection_dict)
125124
126 # let's tell the user how we applied the glade design125 # let's tell the user how we applied the glade design
127 for connection in self.connections:126 for connection in self.connections:
@@ -133,7 +132,7 @@
133 '''Creates the ui object with widgets as attributes132 '''Creates the ui object with widgets as attributes
134133
135 connects signals by 2 methods134 connects signals by 2 methods
136 this method does not appear in gtk.Builder'''135 this method does not appear in Gtk.Builder'''
137136
138 result = UiFactory(self.widgets)137 result = UiFactory(self.widgets)
139138
@@ -196,9 +195,25 @@
196 return pyname195 return pyname
197196
198197
198# Until bug https://bugzilla.gnome.org/show_bug.cgi?id=652127 is fixed, we
199# need to reimplement inspect.getmembers. GObject introspection doesn't
200# play nice with it.
201def getmembers(obj, check):
202 members = []
203 for k in dir(obj):
204 try:
205 attr = getattr(obj, k)
206 except:
207 continue
208 if check(attr):
209 members.append((k, attr))
210 members.sort()
211 return members
212
213
199def dict_from_callback_obj(callback_obj):214def dict_from_callback_obj(callback_obj):
200 '''a dictionary interface to callback_obj'''215 '''a dictionary interface to callback_obj'''
201 methods = inspect.getmembers(callback_obj, inspect.ismethod)216 methods = getmembers(callback_obj, inspect.ismethod)
202217
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')]
204219
@@ -238,11 +253,11 @@
238 try:253 try:
239 widget_type = type(widget)254 widget_type = type(widget)
240 while widget_type:255 while widget_type:
241 signal_ids.extend(gobject.signal_list_ids(widget_type))256 signal_ids.extend(GObject.signal_list_ids(widget_type))
242 widget_type = gobject.type_parent(widget_type)257 widget_type = GObject.type_parent(widget_type)
243 except RuntimeError: # pylint wants a specific error258 except RuntimeError: # pylint wants a specific error
244 pass259 pass
245 signal_names = [gobject.signal_name(sid) for sid in signal_ids]260 signal_names = [GObject.signal_name(sid) for sid in signal_ids]
246261
247 # Now, automatically find any the user didn't specify in glade262 # Now, automatically find any the user didn't specify in glade
248 for sig in signal_names:263 for sig in signal_names:
249264
=== modified file 'data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py'
--- data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py 2011-03-31 17:05:41 +0000
+++ data/templates/ubuntu-application/project_root/python_lib/PreferencesDialog.py 2011-11-08 16:10:57 +0000
@@ -3,23 +3,16 @@
3# This file is in the public domain3# This file is in the public domain
4### END LICENSE4### END LICENSE
55
6"""this dialog adjusts values in the preferences dictionary6"""this dialog adjusts values in gsettings
7
8requirements:
9in module preferences: defaults[key] has a value
10self.builder.get_object(key) is a suitable widget to adjust value
11widget_methods[key] provides method names for the widget
12each widget calls set_preference(...) when it has adjusted value
13"""7"""
148
15import gtk9from gi.repository import Gtk # pylint: disable=E0611
16import logging10import logging
17logger = logging.getLogger('python_name_lib')11logger = logging.getLogger('python_name_lib')
1812
19from . helpers import get_builder, show_uri, get_help_uri13from . helpers import get_builder, show_uri, get_help_uri
20from . preferences import preferences
2114
22class PreferencesDialog(gtk.Dialog):15class PreferencesDialog(Gtk.Dialog):
23 __gtype_name__ = "PreferencesDialog"16 __gtype_name__ = "PreferencesDialog"
2417
25 def __new__(cls):18 def __new__(cls):
@@ -49,80 +42,6 @@
49 self.ui = builder.get_ui(self, True)42 self.ui = builder.get_ui(self, True)
5043
51 # code for other initialization actions should be added here44 # code for other initialization actions should be added here
52 self.widget_methods = []
53
54 def set_widgets_from_preferences(self):
55 ''' these widgets show values in the preferences dictionary '''
56 for key in preferences.keys():
57 self.set_widget_from_preference(key)
58
59 def set_widget_from_preference(self, key):
60 '''set widget value from item in preferences'''
61
62 value = preferences.get(key)
63 widget = self.builder.get_object(key)
64 if widget is None:
65 # this preference is not adjustable by this dialog
66 # for example: window and dialog geometries
67 logger.debug('no widget for preference: %s' % key)
68 return
69
70 logger.debug('set_widget_from_preference: %s' % key)
71 try:
72 write_method_name = self.widget_methods[key][1]
73 except KeyError:
74 logger.warn('%s not in widget_methods' % key)
75 return
76
77 try:
78 method = getattr(widget, write_method_name)
79 except AttributeError:
80 logger.warn("""'%s' does not have a '%s' method.
81Please edit 'widget_methods' in %s"""
82 % (key, write_method_name, self.__gtype_name__))
83 return
84
85 try:
86 widget.connect(self.widget_methods[key][2], self.set_preference)
87 except TypeError:
88 logger.warn("""'%s' unknown signal name '%s'
89Please edit 'widget_methods' in %s"""
90 % (key, self.widget_methods[key][2], self.__gtype_name__))
91
92 method(value)
93
94 def get_key_for_widget(self, widget):
95 key = None
96 for key_try in preferences.keys():
97 obj = self.builder.get_object(key_try)
98 if obj == widget:
99 key = key_try
100 return key
101
102 def set_preference(self, widget, data=None):
103 '''set a preference from a widget'''
104 key = self.get_key_for_widget(widget)
105 if key is None:
106 logger.warn('''This widget will not write to a preference.
107The preference must already exist so add this widget's name
108to default_preferences in your main function''')
109 return
110
111 # set_widget_from_preference is called first
112 # so no KeyError test is needed here
113 read_method_name = self.widget_methods[key][0]
114
115 try:
116 read_method = getattr(widget, read_method_name)
117 except AttributeError:
118 logger.warn("""'%s' does not have a '%s' method.
119Please edit 'widget_methods' in %s"""
120 % (key, read_method_name, self.__gtype_name__))
121 return
122
123 value=read_method()
124 logger.debug('set_preference: %s = %s' % (key, str(value)))
125 preferences[key] = value
12645
127 def on_btn_close_clicked(self, widget, data=None):46 def on_btn_close_clicked(self, widget, data=None):
128 self.destroy()47 self.destroy()
12948
=== modified file 'data/templates/ubuntu-application/project_root/python_lib/Window.py'
--- data/templates/ubuntu-application/project_root/python_lib/Window.py 2011-04-04 14:28:36 +0000
+++ data/templates/ubuntu-application/project_root/python_lib/Window.py 2011-11-08 16:10:57 +0000
@@ -3,16 +3,15 @@
3# This file is in the public domain3# This file is in the public domain
4### END LICENSE4### END LICENSE
55
6import gtk6from gi.repository import Gio, Gtk # pylint: disable=E0611
7import logging7import logging
8logger = logging.getLogger('python_name_lib')8logger = logging.getLogger('python_name_lib')
99
10from . helpers import get_builder, show_uri, get_help_uri10from . helpers import get_builder, show_uri, get_help_uri
11from . preferences import preferences
1211
13# This class is meant to be subclassed by camel_case_nameWindow. It provides12# This class is meant to be subclassed by camel_case_nameWindow. It provides
14# common functions and some boilerplate.13# common functions and some boilerplate.
15class Window(gtk.Window):14class Window(Gtk.Window):
16 __gtype_name__ = "Window"15 __gtype_name__ = "Window"
1716
18 # To construct a new instance of this method, the following notable 17 # To construct a new instance of this method, the following notable
@@ -50,14 +49,15 @@
50 self.preferences_dialog = None # instance49 self.preferences_dialog = None # instance
51 self.AboutDialog = None # class50 self.AboutDialog = None # class
5251
53 preferences.connect('changed', self.on_preferences_changed)52 self.settings = Gio.Settings("net.launchpad.project_name")
53 self.settings.connect('changed', self.on_preferences_changed)
5454
55 # Optional Launchpad integration55 # Optional Launchpad integration
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.
57 # See https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding57 # See https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding
58 # for more information about Launchpad integration.58 # for more information about Launchpad integration.
59 try:59 try:
60 import LaunchpadIntegration60 from gi.repository import LaunchpadIntegration # pylint: disable=E0611
61 LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)61 LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
62 LaunchpadIntegration.set_sourcepackagename('project_name')62 LaunchpadIntegration.set_sourcepackagename('project_name')
63 except ImportError:63 except ImportError:
@@ -111,12 +111,10 @@
111 def on_destroy(self, widget, data=None):111 def on_destroy(self, widget, data=None):
112 """Called when the camel_case_nameWindow is closed."""112 """Called when the camel_case_nameWindow is closed."""
113 # Clean up code for saving application state should be added here.113 # Clean up code for saving application state should be added here.
114 gtk.main_quit()114 Gtk.main_quit()
115115
116 def on_preferences_changed(self, widget, data=None):116 def on_preferences_changed(self, settings, key, data=None):
117 logger.debug('main window received preferences changed')117 logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key))))
118 for key in data:
119 logger.debug('preference changed: %s = %s' % (key, preferences[key]))
120118
121 def on_preferences_dialog_destroyed(self, widget, data=None):119 def on_preferences_dialog_destroyed(self, widget, data=None):
122 '''only affects gui120 '''only affects gui
123121
=== modified file 'data/templates/ubuntu-application/project_root/python_lib/__init__.py'
--- data/templates/ubuntu-application/project_root/python_lib/__init__.py 2011-03-31 17:05:41 +0000
+++ data/templates/ubuntu-application/project_root/python_lib/__init__.py 2011-11-08 16:10:57 +0000
@@ -7,7 +7,6 @@
77
8while keeping its api constant'''8while keeping its api constant'''
9from . helpers import set_up_logging9from . helpers import set_up_logging
10from . preferences import preferences
11from . Window import Window10from . Window import Window
12from . python_nameconfig import get_version11from . python_nameconfig import get_version
1312
1413
=== modified file 'data/templates/ubuntu-application/project_root/python_lib/helpers.py'
--- data/templates/ubuntu-application/project_root/python_lib/helpers.py 2011-03-31 17:05:41 +0000
+++ data/templates/ubuntu-application/project_root/python_lib/helpers.py 2011-11-08 16:10:57 +0000
@@ -7,8 +7,6 @@
7import logging7import logging
8import os8import os
99
10import gtk
11
12from . python_nameconfig import get_data_file10from . python_nameconfig import get_data_file
13from . Builder import Builder11from . Builder import Builder
1412
@@ -17,7 +15,7 @@
17gettext.textdomain('project_name')15gettext.textdomain('project_name')
1816
19def get_builder(builder_file_name):17def get_builder(builder_file_name):
20 """Return a fully-instantiated gtk.Builder instance from specified ui 18 """Return a fully-instantiated Gtk.Builder instance from specified ui
21 file19 file
22 20
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.
@@ -87,8 +85,9 @@
87 return help_uri85 return help_uri
8886
89def show_uri(parent, link):87def show_uri(parent, link):
88 from gi.repository import Gtk # pylint: disable=E0611
90 screen = parent.get_screen()89 screen = parent.get_screen()
91 gtk.show_uri(screen, link, gtk.get_current_event_time())90 Gtk.show_uri(screen, link, Gtk.get_current_event_time())
9291
93def alias(alternative_function_name):92def alias(alternative_function_name):
94 '''see http://www.drdobbs.com/web-development/184406073#l9'''93 '''see http://www.drdobbs.com/web-development/184406073#l9'''
9594
=== removed file 'data/templates/ubuntu-application/project_root/python_lib/preferences.py'
--- data/templates/ubuntu-application/project_root/python_lib/preferences.py 2011-03-31 15:19:55 +0000
+++ data/templates/ubuntu-application/project_root/python_lib/preferences.py 1970-01-01 00:00:00 +0000
@@ -1,100 +0,0 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2### BEGIN LICENSE
3# This file is in the public domain
4### END LICENSE
5
6"""Provides a shared preferences dictionary"""
7
8from desktopcouch.records.server import CouchDatabase
9from desktopcouch.records.record import Record
10import gtk
11import gobject
12
13class User_dict(dict):
14 ''' a dictionary with extra methods:
15
16 persistence: load, save and db_connect
17 gobject signals: connect and emit.
18
19 Don't use this directly. Please use the preferences instance.'''
20
21 def __init__(self, *args, **kwds):
22 dict.__init__(self, *args, **kwds)
23 # Set up couchdb.
24 self._db_name = "project_name"
25 self._key = None
26 self._database = None
27
28 self._record_type = (
29 "http://wiki.ubuntu.com/Quickly/RecordTypes/camel_case_name/"
30 "Preferences")
31
32 class Publisher(gtk.Invisible): # pylint: disable=R0904
33 '''set up signals in a separate class
34
35 gtk.Invisible has 230 public methods'''
36 __gsignals__ = {'changed' : (gobject.SIGNAL_RUN_LAST,
37 gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
38 'loaded' : (gobject.SIGNAL_RUN_LAST,
39 gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))}
40
41 publisher = Publisher()
42 self.emit = publisher.emit
43 self.connect = publisher.connect
44
45 def db_connect(self):
46 '''connect to couchdb
47
48 create if necessary'''
49 # logging.basicConfig will be called now
50 self._database = CouchDatabase(self._db_name, create=True)
51
52 def save(self):
53 'save to couchdb'
54 self._database.update_fields(self._key, self)
55
56
57 def load(self):
58 'load from couchdb'
59 self.update({"record_type": self._record_type})
60
61 results = self._database.get_records(
62 record_type=self._record_type, create_view=True)
63
64 if len(results.rows) == 0:
65 # No preferences have ever been saved
66 # save them before returning.
67 self._key = self._database.put_record(Record(self))
68 else:
69 self.update(results.rows[0].value)
70 del self['_rev']
71 self._key = results.rows[0].value["_id"]
72 self.emit('loaded', None)
73
74 def update(self, *args, **kwds):
75 ''' interface for dictionary
76
77 send changed signal when appropriate '''
78
79 # parse args
80 new_data = {}
81 new_data.update(*args, **kwds)
82
83 changed_keys = []
84 for key in new_data.keys():
85 if new_data.get(key) != dict.get(self, key):
86 changed_keys.append(key)
87 dict.update(self, new_data)
88 if changed_keys:
89 self.emit('changed', tuple(changed_keys))
90
91 def __setitem__(self, key, value):
92 ''' interface for dictionary
93
94 send changed signal when appropriate '''
95 if value != dict.get(self, key):
96 dict.__setitem__(self, key, value)
97 self.emit('changed', (key,))
98
99preferences = User_dict()
100
1010
=== modified file 'data/templates/ubuntu-application/project_root/tests/test_example.py'
--- data/templates/ubuntu-application/project_root/tests/test_example.py 2011-03-02 22:59:32 +0000
+++ data/templates/ubuntu-application/project_root/tests/test_example.py 2011-11-08 16:10:57 +0000
@@ -14,7 +14,7 @@
14class TestExample(unittest.TestCase):14class TestExample(unittest.TestCase):
15 def setUp(self):15 def setUp(self):
16 self.Aboutcamel_case_nameDialog_members = [16 self.Aboutcamel_case_nameDialog_members = [
17 'Aboutcamel_case_nameDialog', 'get_builder', 'gettext', 'gtk']17 'Aboutcamel_case_nameDialog', 'get_builder', 'gettext', 'Gtk']
1818
19 def test_Aboutcamel_case_nameDialog_members(self):19 def test_Aboutcamel_case_nameDialog_members(self):
20 all_members = dir(Aboutcamel_case_nameDialog)20 all_members = dir(Aboutcamel_case_nameDialog)
2121
=== modified file 'data/templates/ubuntu-application/run.py'
--- data/templates/ubuntu-application/run.py 2011-07-22 10:47:34 +0000
+++ data/templates/ubuntu-application/run.py 2011-11-08 16:10:57 +0000
@@ -50,6 +50,18 @@
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")
51 sys.exit(1)51 sys.exit(1)
5252
53# Compile schema if present
54schemapath = os.path.abspath("data/glib-2.0/schemas")
55if os.path.exists(schemapath):
56 subprocess.call(["glib-compile-schemas", schemapath])
57
58 env = os.environ.copy()
59 datadir = os.path.abspath("data")
60 if 'XDG_DATA_DIRS' in env:
61 env['XDG_DATA_DIRS'] = "%s:%s" % (datadir, env['XDG_DATA_DIRS'])
62 else:
63 env['XDG_DATA_DIRS'] = datadir
64
53project_bin = 'bin/' + configurationhandler.project_config['project']65project_bin = 'bin/' + configurationhandler.project_config['project']
54command_line = [project_bin]66command_line = [project_bin]
55command_line.extend([arg for arg in sys.argv[1:] if arg != "--"])67command_line.extend([arg for arg in sys.argv[1:] if arg != "--"])
@@ -58,7 +70,7 @@
58st = os.stat(project_bin)70st = os.stat(project_bin)
59mode = st[stat.ST_MODE]71mode = st[stat.ST_MODE]
60if mode & stat.S_IEXEC:72if mode & stat.S_IEXEC:
61 subprocess.call(command_line)73 subprocess.call(command_line, env=env)
62else:74else:
63 print _("Can't execute %s") % project_bin75 print _("Can't execute %s") % project_bin
64 sys.exit(1)76 sys.exit(1)
6577
=== modified file 'data/templates/ubuntu-application/store/data/ui/dialog_camel_case_nameDialog.ui'
--- data/templates/ubuntu-application/store/data/ui/dialog_camel_case_nameDialog.ui 2010-12-20 15:44:44 +0000
+++ data/templates/ubuntu-application/store/data/ui/dialog_camel_case_nameDialog.ui 2011-11-08 16:10:57 +0000
@@ -1,24 +1,22 @@
1<?xml version="1.0"?>1<?xml version="1.0" encoding="UTF-8"?>
2<interface>2<interface>
3 <requires lib="gtk+" version="2.16"/>3 <!-- interface-requires gtk+ 3.0 -->
4 <!-- interface-requires dialog_python_name_dialog 1.0 -->4 <!-- interface-requires dialog_python_name_dialog 1.0 -->
5 <!-- interface-naming-policy project-wide -->
6 <object class="dialog_camel_case_nameDialog" id="dialog_python_name_dialog">5 <object class="dialog_camel_case_nameDialog" id="dialog_python_name_dialog">
6 <property name="can_focus">False</property>
7 <property name="border_width">5</property>7 <property name="border_width">5</property>
8 <property name="icon">../media/project_name.svg</property>8 <property name="icon">../media/project_name.svg</property>
9 <property name="type_hint">normal</property>9 <property name="type_hint">normal</property>
10 <property name="has_separator">False</property>
11 <child internal-child="vbox">10 <child internal-child="vbox">
12 <object class="GtkVBox" id="dialog-vbox1">11 <object class="GtkBox" id="dialog-vbox1">
13 <property name="visible">True</property>12 <property name="visible">True</property>
13 <property name="can_focus">False</property>
14 <property name="orientation">vertical</property>14 <property name="orientation">vertical</property>
15 <property name="spacing">2</property>15 <property name="spacing">2</property>
16 <child>
17 <placeholder/>
18 </child>
19 <child internal-child="action_area">16 <child internal-child="action_area">
20 <object class="GtkHButtonBox" id="dialog-action_area1">17 <object class="GtkButtonBox" id="dialog-action_area1">
21 <property name="visible">True</property>18 <property name="visible">True</property>
19 <property name="can_focus">False</property>
22 <property name="layout_style">end</property>20 <property name="layout_style">end</property>
23 <child>21 <child>
24 <object class="GtkButton" id="btn_cancel">22 <object class="GtkButton" id="btn_cancel">
@@ -26,6 +24,7 @@
26 <property name="visible">True</property>24 <property name="visible">True</property>
27 <property name="can_focus">True</property>25 <property name="can_focus">True</property>
28 <property name="receives_default">True</property>26 <property name="receives_default">True</property>
27 <property name="use_action_appearance">False</property>
29 <property name="use_stock">True</property>28 <property name="use_stock">True</property>
30 </object>29 </object>
31 <packing>30 <packing>
@@ -40,6 +39,7 @@
40 <property name="visible">True</property>39 <property name="visible">True</property>
41 <property name="can_focus">True</property>40 <property name="can_focus">True</property>
42 <property name="receives_default">True</property>41 <property name="receives_default">True</property>
42 <property name="use_action_appearance">False</property>
43 <property name="use_stock">True</property>43 <property name="use_stock">True</property>
44 </object>44 </object>
45 <packing>45 <packing>
@@ -51,10 +51,14 @@
51 </object>51 </object>
52 <packing>52 <packing>
53 <property name="expand">False</property>53 <property name="expand">False</property>
54 <property name="fill">True</property>
54 <property name="pack_type">end</property>55 <property name="pack_type">end</property>
55 <property name="position">0</property>56 <property name="position">0</property>
56 </packing>57 </packing>
57 </child>58 </child>
59 <child>
60 <placeholder/>
61 </child>
58 </object>62 </object>
59 </child>63 </child>
60 <action-widgets>64 <action-widgets>
6165
=== modified file 'data/templates/ubuntu-application/store/data/ui/dialog_python_name_dialog.xml'
--- data/templates/ubuntu-application/store/data/ui/dialog_python_name_dialog.xml 2010-03-03 08:07:21 +0000
+++ data/templates/ubuntu-application/store/data/ui/dialog_python_name_dialog.xml 2011-11-08 16:10:57 +0000
@@ -1,4 +1,4 @@
1<glade-catalog name="dialog_name_dialog" domain="glade-3" 1<glade-catalog name="dialog_python_name_dialog" domain="glade-3"
2 depends="gtk+" version="1.0">2 depends="gtk+" version="1.0">
3 <glade-widget-classes>3 <glade-widget-classes>
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"
55
=== modified file 'data/templates/ubuntu-application/store/dialog.py'
--- data/templates/ubuntu-application/store/dialog.py 2011-07-22 10:47:34 +0000
+++ data/templates/ubuntu-application/store/dialog.py 2011-11-08 16:10:57 +0000
@@ -31,7 +31,7 @@
31help_text= _("""Here, dialog-name is one or more words separated with dash31help_text= _("""Here, dialog-name is one or more words separated with dash
3232
33For instance 'quickly add dialog dialog-name' will create:33For instance 'quickly add dialog dialog-name' will create:
341. A subclass of gtk.Dialog called DialogNameDialog in the module341. A subclass of Gtk.Dialog called DialogNameDialog in the module
35 DialogNameDialog.py35 DialogNameDialog.py
362. A glade file called DialogNameDialog.ui in the ui directory362. A glade file called DialogNameDialog.ui in the ui directory
373. A catalog file called dialog_name_dialog.xml also in the ui directory373. A catalog file called dialog_name_dialog.xml also in the ui directory
3838
=== modified file 'data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py'
--- data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py 2011-04-01 21:03:53 +0000
+++ data/templates/ubuntu-application/store/python/dialog_camel_case_nameDialog.py 2011-11-08 16:10:57 +0000
@@ -3,7 +3,7 @@
3# This file is in the public domain3# This file is in the public domain
4### END LICENSE4### END LICENSE
55
6import gtk6from gi.repository import Gtk # pylint: disable=E0611
77
8from python_name_lib.helpers import get_builder8from python_name_lib.helpers import get_builder
99
@@ -11,7 +11,7 @@
11from gettext import gettext as _11from gettext import gettext as _
12gettext.textdomain('project_name')12gettext.textdomain('project_name')
1313
14class dialog_camel_case_nameDialog(gtk.Dialog):14class dialog_camel_case_nameDialog(Gtk.Dialog):
15 __gtype_name__ = "dialog_camel_case_nameDialog"15 __gtype_name__ = "dialog_camel_case_nameDialog"
1616
17 def __new__(cls):17 def __new__(cls):
@@ -40,14 +40,14 @@
40 def on_btn_ok_clicked(self, widget, data=None):40 def on_btn_ok_clicked(self, widget, data=None):
41 """The user has elected to save the changes.41 """The user has elected to save the changes.
4242
43 Called before the dialog returns gtk.RESONSE_OK from run().43 Called before the dialog returns Gtk.ResponseType.OK from run().
44 """44 """
45 pass45 pass
4646
47 def on_btn_cancel_clicked(self, widget, data=None):47 def on_btn_cancel_clicked(self, widget, data=None):
48 """The user has elected cancel changes.48 """The user has elected cancel changes.
4949
50 Called before the dialog returns gtk.RESPONSE_CANCEL for run()50 Called before the dialog returns Gtk.ResponseType.CANCEL for run()
51 """51 """
52 pass52 pass
5353
@@ -55,4 +55,4 @@
55if __name__ == "__main__":55if __name__ == "__main__":
56 dialog = dialog_camel_case_nameDialog()56 dialog = dialog_camel_case_nameDialog()
57 dialog.show()57 dialog.show()
58 gtk.main()58 Gtk.main()
5959
=== modified file 'data/templates/ubuntu-application/store/python/indicator.py'
--- data/templates/ubuntu-application/store/python/indicator.py 2011-07-29 18:57:04 +0000
+++ data/templates/ubuntu-application/store/python/indicator.py 2011-11-08 16:10:57 +0000
@@ -6,7 +6,8 @@
66
7"""Code to add AppIndicator."""7"""Code to add AppIndicator."""
88
9import gtk9from gi.repository import Gtk # pylint: disable=E0611
10from gi.repository import AppIndicator3 # pylint: disable=E0611
1011
11from python_name_lib.helpers import get_media_file12from python_name_lib.helpers import get_media_file
1213
@@ -14,12 +15,10 @@
14from gettext import gettext as _15from gettext import gettext as _
15gettext.textdomain('project_name')16gettext.textdomain('project_name')
1617
17import appindicator
18
19class Indicator:18class Indicator:
20 def __init__(self, window):19 def __init__(self, window):
21 self.indicator = appindicator.Indicator('project_name','',appindicator.CATEGORY_APPLICATION_STATUS)20 self.indicator = AppIndicator3.Indicator('project_name', '', AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
22 self.indicator.set_status(appindicator.STATUS_ACTIVE)21 self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
2322
24 icon_uri = get_media_file("project_name.svg")23 icon_uri = get_media_file("project_name.svg")
25 icon_path = icon_uri.replace("file:///", '')24 icon_path = icon_uri.replace("file:///", '')
@@ -28,18 +27,18 @@
28 #Uncomment and choose an icon for attention state. 27 #Uncomment and choose an icon for attention state.
29 #self.indicator.set_attention_icon("ICON-NAME")28 #self.indicator.set_attention_icon("ICON-NAME")
30 29
31 self.menu = gtk.Menu()30 self.menu = Gtk.Menu()
3231
33 # Add items to Menu and connect signals.32 # Add items to Menu and connect signals.
34 33
35 #Adding preferences button 34 #Adding preferences button
36 #window represents the main Window object of your app35 #window represents the main Window object of your app
37 self.preferences = gtk.MenuItem("Preferences")36 self.preferences = Gtk.MenuItem("Preferences")
38 self.preferences.connect("activate",window.on_mnu_preferences_activate)37 self.preferences.connect("activate",window.on_mnu_preferences_activate)
39 self.preferences.show()38 self.preferences.show()
40 self.menu.append(self.preferences)39 self.menu.append(self.preferences)
4140
42 self.quit = gtk.MenuItem("Quit")41 self.quit = Gtk.MenuItem("Quit")
43 self.quit.connect("activate",window.on_mnu_close_activate)42 self.quit.connect("activate",window.on_mnu_close_activate)
44 self.quit.show()43 self.quit.show()
45 self.menu.append(self.quit)44 self.menu.append(self.quit)
4645
=== modified file 'data/templates/ubuntu-application/test/apport/apport.sh'
--- data/templates/ubuntu-application/test/apport/apport.sh 2011-11-08 00:50:34 +0000
+++ data/templates/ubuntu-application/test/apport/apport.sh 2011-11-08 16:10:57 +0000
@@ -12,6 +12,7 @@
12cd test-project12cd test-project
1313
14grep LaunchpadIntegration. test_project_lib/Window.py14grep LaunchpadIntegration. test_project_lib/Window.py
15# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
15# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)16# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
16# LaunchpadIntegration.set_sourcepackagename('test-project')17# LaunchpadIntegration.set_sourcepackagename('test-project')
1718
@@ -25,6 +26,7 @@
25# Creating new apport hooks26# Creating new apport hooks
2627
27grep LaunchpadIntegration. test_project_lib/Window.py28grep LaunchpadIntegration. test_project_lib/Window.py
29# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
28# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)30# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
29# LaunchpadIntegration.set_sourcepackagename('test-project')31# LaunchpadIntegration.set_sourcepackagename('test-project')
3032
@@ -54,6 +56,7 @@
54# Updating project name references in existing apport crashdb configuration56# Updating project name references in existing apport crashdb configuration
5557
56grep LaunchpadIntegration. test_project_lib/Window.py58grep LaunchpadIntegration. test_project_lib/Window.py
59# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
57# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)60# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
58# LaunchpadIntegration.set_sourcepackagename('test-project')61# LaunchpadIntegration.set_sourcepackagename('test-project')
5962
@@ -119,6 +122,7 @@
119# Updating project name references in existing apport crashdb configuration122# Updating project name references in existing apport crashdb configuration
120123
121grep LaunchpadIntegration. test_project_lib/Window.py124grep LaunchpadIntegration. test_project_lib/Window.py
125# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
122# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)126# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
123# LaunchpadIntegration.set_sourcepackagename('test-project')127# LaunchpadIntegration.set_sourcepackagename('test-project')
124128
@@ -149,6 +153,7 @@
149# Creating new apport hooks153# Creating new apport hooks
150154
151grep LaunchpadIntegration. test_project_lib/Window.py155grep LaunchpadIntegration. test_project_lib/Window.py
156# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
152# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)157# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
153# LaunchpadIntegration.set_sourcepackagename('test-project')158# LaunchpadIntegration.set_sourcepackagename('test-project')
154159
@@ -188,6 +193,7 @@
188# Updating project name references in existing apport crashdb configuration193# Updating project name references in existing apport crashdb configuration
189194
190grep LaunchpadIntegration. test_project_lib/Window.py195grep LaunchpadIntegration. test_project_lib/Window.py
196# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
191# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)197# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
192# LaunchpadIntegration.set_sourcepackagename('test-project')198# LaunchpadIntegration.set_sourcepackagename('test-project')
193199
@@ -283,7 +289,7 @@
283# modified etc/apport/crashdb.conf.d/test-project-crashdb.conf289# modified etc/apport/crashdb.conf.d/test-project-crashdb.conf
284# Committed revision 4.290# Committed revision 4.
285291
286quickly upgrade 0.3 0.4292quickly upgrade 0.3
287293
288bzr status294bzr status
289295
@@ -309,11 +315,12 @@
309315
310bzr status316bzr status
311317
312quickly upgrade 0.3 0.4318quickly upgrade 0.3
313# Creating new apport crashdb configuration319# Creating new apport crashdb configuration
314# Creating new apport hooks320# Creating new apport hooks
315321
316grep LaunchpadIntegration. test_project_lib/Window.py322grep LaunchpadIntegration. test_project_lib/Window.py
323# from gi.repository import LaunchpadIntegration # pylint: disable=E0611
317# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)324# LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
318# LaunchpadIntegration.set_sourcepackagename('test-project')325# LaunchpadIntegration.set_sourcepackagename('test-project')
319326
@@ -359,7 +366,7 @@
359366
360grep helpMenu test_project_lib/Window.py367grep helpMenu test_project_lib/Window.py
361368
362quickly upgrade 0.3 0.4369quickly upgrade 0.3
363# Adding launchpad integration to existing application370# Adding launchpad integration to existing application
364# Creating new apport crashdb configuration371# Creating new apport crashdb configuration
365# Creating new apport hooks372# Creating new apport hooks
@@ -388,7 +395,7 @@
388# modified test_project_lib/Window.py395# modified test_project_lib/Window.py
389# Committed revision 6.396# Committed revision 6.
390397
391quickly upgrade 0.3 0.4398quickly upgrade 0.3
392# Creating new apport crashdb configuration399# Creating new apport crashdb configuration
393# Creating new apport hooks400# Creating new apport hooks
394401
@@ -409,4 +416,4 @@
409416
410grep helpMenu test_project_lib/Window.py417grep helpMenu test_project_lib/Window.py
411418
412quickly upgrade 0.3 0.4419quickly upgrade 0.3
413420
=== modified file 'data/templates/ubuntu-application/test/builder/builder.py'
--- data/templates/ubuntu-application/test/builder/builder.py 2011-06-08 13:48:05 +0000
+++ data/templates/ubuntu-application/test/builder/builder.py 2011-11-08 16:10:57 +0000
@@ -4,7 +4,7 @@
4import unittest4import unittest
5import sys5import sys
6import os6import os
7import gtk7from gi.repository import Gtk # pylint: disable=E0611
8import inspect8import inspect
9import logging9import logging
10import glob10import glob
@@ -85,7 +85,7 @@
85 'wind?o-w two', 'wind_o_w_two', 'window'] # sorted list85 'wind?o-w two', 'wind_o_w_two', 'window'] # sorted list
8686
87 def test_interface(self):87 def test_interface(self):
88 builder = dir(gtk.Builder)88 builder = dir(Gtk.Builder)
89 89
90 # sanity test90 # sanity test
91 self.assertTrue('add_from_file' in builder)91 self.assertTrue('add_from_file' in builder)
9292
=== modified file 'data/templates/ubuntu-application/test/configure.sh'
--- data/templates/ubuntu-application/test/configure.sh 2010-10-15 20:26:19 +0000
+++ data/templates/ubuntu-application/test/configure.sh 2011-11-08 16:10:57 +0000
@@ -17,7 +17,6 @@
17# #url='https://launchpad.net/test-project',17# #url='https://launchpad.net/test-project',
1818
19grep website data/ui/AboutTestProjectDialog.ui19grep website data/ui/AboutTestProjectDialog.ui
20# <property name="website"></property>
2120
22grep lp_id .quickly21grep lp_id .quickly
2322
@@ -33,7 +32,7 @@
33grep url= setup.py32grep url= setup.py
34# url='https://launchpad.net/gpoweroff',33# url='https://launchpad.net/gpoweroff',
3534
36grep website data/ui/AboutTestProjectDialog.ui35grep website data/ui/AboutTestProjectDialog.ui | sed 's|</property>.*|</property>|'
37# <property name="website">https://launchpad.net/gpoweroff</property>36# <property name="website">https://launchpad.net/gpoweroff</property>
3837
39(echo hudson-notifier > tmp)38(echo hudson-notifier > tmp)
@@ -49,7 +48,7 @@
49grep url= setup.py48grep url= setup.py
50# url='https://launchpad.net/hudson-notifier',49# url='https://launchpad.net/hudson-notifier',
5150
52grep website data/ui/AboutTestProjectDialog.ui51grep website data/ui/AboutTestProjectDialog.ui | sed 's|</property>.*|</property>|'
53# <property name="website">https://launchpad.net/hudson-notifier</property>52# <property name="website">https://launchpad.net/hudson-notifier</property>
5453
55## Test configure bzr54## Test configure bzr
5655
=== modified file 'data/templates/ubuntu-application/test/filelist.sh'
--- data/templates/ubuntu-application/test/filelist.sh 2011-03-31 15:19:55 +0000
+++ data/templates/ubuntu-application/test/filelist.sh 2011-11-08 16:10:57 +0000
@@ -13,12 +13,16 @@
1313
14bzr status14bzr status
1515
16bzr ls -R16bzr ls -RV
17# .bzrignore
17# .quickly18# .quickly
18# AUTHORS19# AUTHORS
19# bin/20# bin/
20# bin/test-project21# bin/test-project
21# data/22# data/
23# data/glib-2.0/
24# data/glib-2.0/schemas/
25# data/glib-2.0/schemas/net.launchpad.test-project.gschema.xml
22# data/media/26# data/media/
23# data/media/background.png27# data/media/background.png
24# data/media/test-project.svg28# data/media/test-project.svg
@@ -50,7 +54,6 @@
50# test_project_lib/Window.py54# test_project_lib/Window.py
51# test_project_lib/__init__.py55# test_project_lib/__init__.py
52# test_project_lib/helpers.py56# test_project_lib/helpers.py
53# test_project_lib/preferences.py
54# test_project_lib/test_projectconfig.py57# test_project_lib/test_projectconfig.py
55# tests/58# tests/
56# tests/test_example.py59# tests/test_example.py
5760
=== modified file 'data/templates/ubuntu-application/test/metadata.sh'
--- data/templates/ubuntu-application/test/metadata.sh 2011-11-08 00:50:34 +0000
+++ data/templates/ubuntu-application/test/metadata.sh 2011-11-08 16:10:57 +0000
@@ -38,10 +38,8 @@
38# XB-Icon: test-project.svg38# XB-Icon: test-project.svg
39# Depends: ${misc:Depends},39# Depends: ${misc:Depends},
40# ${python:Depends},40# ${python:Depends},
41# python-gobject-2,41# gir1.2-glib-2.0,
42# python-launchpad-integration,42# gir1.2-launchpad-integration-3.0,
43# python-gtk2,
44# python-desktopcouch-records,
45# yelp43# yelp
46# Description: UNKNOWN44# Description: UNKNOWN
47# UNKNOWN45# UNKNOWN
4846
=== removed file 'data/templates/ubuntu-application/test/preferences.py'
--- data/templates/ubuntu-application/test/preferences.py 2011-03-31 17:38:31 +0000
+++ data/templates/ubuntu-application/test/preferences.py 1970-01-01 00:00:00 +0000
@@ -1,151 +0,0 @@
1import unittest
2import os
3import sys
4import glob
5
6proj_root = os.path.abspath(os.path.join(os.path.dirname(__file__),"..","project_root"))
7sys.path.insert(0, proj_root)
8import logging
9logging.debug(sys.path[0])
10
11from python_lib.preferences import User_dict, preferences
12
13# Clean up after ourselves
14for f in glob.glob(os.path.join(proj_root, 'python_lib', '*.pyc')):
15 os.remove(f)
16
17class TestUser_dict(unittest.TestCase):
18
19 def test_interface(self):
20 foo = User_dict()
21 # provides gobject signals
22 self.assertTrue(callable(foo.emit))
23 self.assertTrue(callable(foo.connect))
24
25 # provides load and save
26 self.assertTrue(callable(foo.load))
27 self.assertTrue(callable(foo.save))
28
29 def test_update_from_dict(self):
30 foo = User_dict()
31 bar = {'pluto':2}
32 foo.update(bar)
33 self.assertEqual(foo.get('pluto'), 2)
34
35 def test_update_from_pairs(self):
36 a = User_dict([['position', 'Public Relations'], ['name', 'Jayne Cobb']])
37 b = {'name': 'Jayne Cobb', 'position': 'Public Relations'}
38 self.assertEqual(a, b)
39
40 def test_serialisation(self):
41 # used in couchdb for instance
42 import json
43 a = User_dict([['position', 'Public Relations'], ['name', 'Jayne Cobb']])
44 b = {'name': 'Jayne Cobb', 'position': 'Public Relations'}
45 c = json.loads(json.dumps(a))
46 self.assertEqual(a, c)
47
48 def test__setitem__(self):
49 foo = User_dict()
50 foo[2] = 3
51 self.assertEqual(foo.get(2), 3)
52
53 def test__delitem__(self):
54 foo = User_dict()
55 foo[2] = 3
56 self.assertEqual(foo.get(2), 3)
57 del foo[2]
58 self.assertEqual(foo.get(2, 'default'), 'default')
59
60 def test__getitem__(self):
61 foo = User_dict()
62 foo[2] = 3
63 self.assertEqual(foo[2], 3)
64
65class TestSignals(unittest.TestCase):
66
67 def setUp(self):
68 self.foo = User_dict()
69 self.messages = []
70 self.foo.connect('changed', self.callback)
71
72 def callback(self, *args):
73 self.messages.append(args)
74
75 def test_update_with_additions(self):
76 bar = {'foobar': 7}
77 self.foo.update({'foobar': 7})
78 self.assertEqual(self.messages[0][1], ('foobar',))
79 self.foo.update({'fooey': 2})
80 self.assertEqual(self.messages[1][1], ('fooey',))
81 self.assertEqual(len(self.messages), 2)
82
83 def test_update_with_changes(self):
84 bar = {'foobar': 7}
85 self.foo.update({'foobar': 7})
86 self.assertEqual(self.messages[0][1], ('foobar',))
87 self.foo.update({'foobar': 8})
88 self.assertEqual(self.messages[1][1], ('foobar',))
89 self.assertEqual(len(self.messages), 2)
90
91 def test_update_without_changes(self):
92 bar = {'foobar': 7}
93 self.foo.update({'foobar': 7})
94 self.assertEqual(self.messages[0][1], ('foobar',))
95 self.foo.update({'foobar': 7})
96 self.assertEqual(len(self.messages), 1)
97
98 def test_update_with_several_items(self):
99 data = {'pluto': 7, 'mickey': 8, 'minnie': 9}
100 self.foo.update(data)
101 self.assertEqual(self.messages[0][1], ('mickey', 'minnie', 'pluto'))
102 self.assertEqual(len(self.messages), 1)
103 data = {'mickey': 1, 'minnie': 2}
104 self.foo.update(data)
105 self.assertEqual(self.messages[1][1], ('mickey', 'minnie'))
106 self.assertEqual(len(self.messages), 2)
107
108 def test__setitem__with_additions(self):
109 self.foo['too'] = 3
110 self.assertEqual(self.messages[0][1], ('too',))
111
112 def test__setitem__with_changes(self):
113 self.foo['too'] = 3
114 self.assertEqual(self.messages[0][1], ('too',))
115 self.assertEqual(len(self.messages), 1)
116 self.foo['too'] = 4
117 self.assertEqual(len(self.messages), 2)
118
119 def test__setitem__without_changes(self):
120 self.foo['too'] = 3
121 self.assertEqual(self.messages[0][1], ('too',))
122 self.assertEqual(len(self.messages), 1)
123 self.foo['too'] = 3
124 self.assertEqual(len(self.messages), 1)
125
126class TestPreferences(unittest.TestCase):
127 ''' this one we really need '''
128
129 def setUp(self):
130 self.messages = []
131 preferences.connect('changed', self.callback)
132
133 def callback(self, *args):
134 self.messages.append(args)
135
136 def test_update(self):
137 preferences.update({'foobar': 7})
138 self.assertEqual(self.messages[0][1], ('foobar',))
139 self.assertEqual(len(self.messages), 1)
140 # preferences persist so we need to clean our changes
141 del preferences['foobar']
142
143 def test__setitem__(self):
144 preferences['too'] = 3
145 self.assertEqual(self.messages[0][1], ('too',))
146 self.assertEqual(len(self.messages), 1)
147 # preferences persist so we need to clean our changes
148 del preferences['too']
149
150if __name__ == '__main__':
151 unittest.main()
1520
=== modified file 'data/templates/ubuntu-application/upgrade.py'
--- data/templates/ubuntu-application/upgrade.py 2011-10-03 18:05:30 +0000
+++ data/templates/ubuntu-application/upgrade.py 2011-11-08 16:10:57 +0000
@@ -34,6 +34,8 @@
34# get project version and template version if no argument given34# get project version and template version if no argument given
35if len(sys.argv) < 3:35if len(sys.argv) < 3:
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")
37 if len(sys.argv) == 2: # we have been given project but not template version
38 project_version = sys.argv[1]
37else:39else:
38 project_version = sys.argv[1]40 project_version = sys.argv[1]
39 template_version = sys.argv[2]41 template_version = sys.argv[2]
@@ -201,8 +203,8 @@
201 except templatetools.CantUpdateFile, e:203 except templatetools.CantUpdateFile, e:
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)
203205
204### 11.09 update206### 11.09 update (but only through 11.10; later versions don't want this change)
205if project_version < '11.09':207if project_version < '11.09' and template_version <= '11.10':
206 filename = './%s_lib/Builder.py' % python_name208 filename = './%s_lib/Builder.py' % python_name
207 try:209 try:
208 with open(filename) as fileobj:210 with open(filename) as fileobj:
209211
=== removed file 'data/templates/ubuntu-flash-game/internal/apportutils.py'
--- data/templates/ubuntu-flash-game/internal/apportutils.py 2011-06-06 10:14:40 +0000
+++ data/templates/ubuntu-flash-game/internal/apportutils.py 1970-01-01 00:00:00 +0000
@@ -1,143 +0,0 @@
1import os
2import shutil
3import subprocess
4
5from gettext import gettext as _
6
7import quickly
8import quicklyutils
9
10from lxml import etree
11
12LPI_import_block = """
13# optional Launchpad integration
14# this shouldn't crash if not found as it is simply used for bug reporting
15try:
16 import LaunchpadIntegration
17 launchpad_available = True
18except:
19 launchpad_available = False
20
21"""
22
23LPI_init_menu_block = """
24 global launchpad_available
25 if launchpad_available:
26 # see https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding for more information
27 # about LaunchpadIntegration
28 helpmenu = self.builder.get_object('%(help_menu)s')
29 if helpmenu:
30 LaunchpadIntegration.set_sourcepackagename('%(project_name)s')
31 LaunchpadIntegration.add_items(helpmenu, 0, False, True)
32 else:
33 launchpad_available = False"""
34
35def update_apport(project_name, old_lp_project, new_lp_project):
36 if not new_lp_project:
37 return
38 # crashdb file doesn't support spaces or dashes in the crash db name
39 safe_project_name = project_name.replace(" ", "_").replace("-","_")
40 crashdb_file = "%s-crashdb.conf"%project_name
41 hook_file = "source_%s.py"%project_name
42
43
44 pathname = quickly.templatetools.get_template_path_from_project()
45 template_pr_path = os.path.join(os.path.abspath(pathname), "store",
46 "apport")
47 relative_crashdb_dir = os.path.join("etc", "apport", "crashdb.conf.d")
48 relative_apport_dir = "apport"
49
50 existing_crashdb = os.path.join(relative_crashdb_dir, crashdb_file)
51 existing_hook = os.path.join(relative_apport_dir, hook_file)
52
53 template_crashdb_dir = os.path.join(template_pr_path, relative_crashdb_dir)
54 template_hook_dir = os.path.join(template_pr_path, relative_apport_dir)
55
56 # if the project name has changed, or any of the files are missing, then
57 # attempt to set up the apport configuration and hooks
58 if not old_lp_project == new_lp_project \
59 or not os.path.isfile(existing_crashdb) \
60 or not os.path.isfile(existing_hook):
61
62 subst_existing = ((old_lp_project, new_lp_project),)
63 subst_new = ( ("safe_project_name", safe_project_name),
64 ("project_name", project_name),
65 ("lp_project", new_lp_project))
66
67 if os.path.isfile(existing_crashdb):
68 print _("Updating project name references in existing apport crashdb configuration")
69 templatetools.file_from_template(relative_crashdb_dir, crashdb_file, relative_crashdb_dir, subst_existing)
70 elif os.path.isdir(template_crashdb_dir):
71 print _("Creating new apport crashdb configuration")
72 if not os.path.isdir(relative_crashdb_dir):
73 os.makedirs(relative_crashdb_dir)
74 templatetools.file_from_template(template_crashdb_dir, "project_name-crashdb.conf", relative_crashdb_dir, subst_new)
75
76 if not os.path.isfile(existing_hook) and os.path.isdir(template_hook_dir):
77 print _("Creating new apport hooks")
78 if not os.path.isdir(relative_apport_dir):
79 os.makedirs(relative_apport_dir)
80 templatetools.file_from_template(template_hook_dir, "source_project_name.py", relative_apport_dir, subst_new)
81
82def insert_lpi_if_required(project_name):
83 existing_bin_filename = os.path.join("bin",project_name)
84 camel_case_project_name = quickly.templatetools.get_camel_case_name(project_name)
85 existing_ui_filename = os.path.join("data","ui", "%sWindow.ui"%camel_case_project_name)
86
87 if os.path.isfile(existing_bin_filename) and os.path.isfile(existing_ui_filename):
88 tree = etree.parse(existing_ui_filename)
89 help_menu = find_about_menu(tree)
90
91 if help_menu:
92 existing_bin_file = file(existing_bin_filename, "r")
93 existing_lines = existing_bin_file.readlines()
94 existing_bin_file.close()
95 new_lines = detect_or_insert_lpi(existing_lines, project_name, help_menu)
96 if new_lines:
97 print _("Adding launchpad integration to existing application")
98 ftarget_file_name_out = file(existing_bin_file.name + '.new', 'w')
99 ftarget_file_name_out.writelines(new_lines)
100 ftarget_file_name_out.close()
101 quickly.templatetools.apply_file_rights(existing_bin_file.name, ftarget_file_name_out.name)
102 os.rename(ftarget_file_name_out.name, existing_bin_file.name)
103 return True
104 return False
105
106def detect_or_insert_lpi(existing_lines, project_name, help_menu):
107 integration_present = False
108 import_insert_line = None
109 init_insert_line = None
110 current_line = 0
111 for line in existing_lines:
112 if "import LaunchpadIntegration" in line \
113 or "if launchpad_available:" in line:
114 integration_present = True
115 break
116 if not import_insert_line and "import gtk" in line:
117 import_insert_line = current_line
118 if not init_insert_line and "self.builder.connect_signals(self)" in line:
119 init_insert_line = current_line
120 current_line += 1
121
122 if not integration_present \
123 and import_insert_line \
124 and init_insert_line \
125 and import_insert_line < init_insert_line:
126 init_menu_block = LPI_init_menu_block%{"project_name":project_name, "help_menu":help_menu}
127 existing_lines = existing_lines[:import_insert_line+1] + \
128 ["%s\n"%l for l in LPI_import_block.splitlines()] + \
129 existing_lines[import_insert_line+1:init_insert_line+1] + \
130 ["%s\n"%l for l in init_menu_block.splitlines()] + \
131 existing_lines[init_insert_line+1:]
132 return existing_lines
133 else:
134 return None
135
136
137def find_about_menu(tree):
138 """Finds the current help menu in the passed xml document by looking for the gtk-about element"""
139 help_item = tree.xpath('//property[@name="label" and .="gtk-about"]/../../../@id')
140 if len(help_item) == 1: # only one element matching this should be found
141 return help_item[0]
142 else:
143 return None
1440
=== modified file 'data/templates/ubuntu-flash-game/project_root/bin/project_name'
--- data/templates/ubuntu-flash-game/project_root/bin/project_name 2011-01-03 16:05:40 +0000
+++ data/templates/ubuntu-flash-game/project_root/bin/project_name 2011-11-08 16:10:57 +0000
@@ -18,7 +18,7 @@
18###########################################################################18###########################################################################
1919
2020
21import webkit, gtk, gio21from gi.repository import WebKit, Gtk, Gio
22import json, os22import json, os
2323
24# Where your project will look for your data (for instance, images and ui24# Where your project will look for your data (for instance, images and ui
@@ -55,17 +55,18 @@
5555
5656
57if __name__ == "__main__":57if __name__ == "__main__":
58 w = gtk.Window()58 w = Gtk.Window()
59 v = webkit.WebView()59 v = WebKit.WebView()
60 w.add(v)60 w.add(v)
61 w.show_all() # have to have this before set_size_request61 w.show_all() # have to have this before set_size_request
62 w.connect("destroy", lambda q: gtk.main_quit())62 w.connect("destroy", lambda q: Gtk.main_quit())
63 w.set_title(GAME_NAME)63 w.set_title(GAME_NAME)
64 htmlfp = gio.File(get_data_file('index.html'))64 htmlfp = Gio.file_new_for_path(get_data_file('index.html'))
65 uri = htmlfp.get_uri()65 uri = htmlfp.get_uri()
66 html, _, _ = htmlfp.load_contents()66 _, html, _ = htmlfp.load_contents(None)
67 print html, "hello", uri
67 v.load_html_string(html, uri)68 v.load_html_string(html, uri)
68 w.set_size_request(*WINDOW_SIZE)69 w.set_size_request(*WINDOW_SIZE)
69 v.queue_resize() # force a reallocation, https://bugs.webkit.org/show_bug.cgi?id=4774270 v.queue_resize() # force a reallocation, https://bugs.webkit.org/show_bug.cgi?id=47742
70 gtk.main()71 Gtk.main()
7172
7273
=== modified file 'quickly/quicklyconfig.py'
--- quickly/quicklyconfig.py 2011-09-26 13:02:43 +0000
+++ quickly/quicklyconfig.py 2011-11-08 16:10:57 +0000
@@ -20,7 +20,7 @@
20# you're warned :)20# you're warned :)
2121
22# quickly version used for project format compatibility22# quickly version used for project format compatibility
23__version__ = '11.10'23__version__ = '11.11'
2424
25# where quickly will head for quickly data (for instance, templates)25# where quickly will head for quickly data (for instance, templates)
26# by default, this is ../data, relative to trunk layout26# by default, this is ../data, relative to trunk layout
2727
=== modified file 'quickly/test/pylint.sh'
--- quickly/test/pylint.sh 2010-12-04 17:28:41 +0000
+++ quickly/test/pylint.sh 2011-11-08 16:10:57 +0000
@@ -2,4 +2,4 @@
22
3if ! which pylint >/dev/null; then echo 'Please install pylint'; fi3if ! which pylint >/dev/null; then echo 'Please install pylint'; fi
44
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)
66
=== modified file 'setup.py'
--- setup.py 2011-09-26 13:02:43 +0000
+++ setup.py 2011-11-08 16:10:57 +0000
@@ -18,7 +18,7 @@
1818
1919
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)
21VERSION = '11.10'21VERSION = '11.11'
2222
23import glob23import glob
24import os24import os
2525
=== modified file 'ubuntudevbar.py'
--- ubuntudevbar.py 2010-12-02 16:03:30 +0000
+++ ubuntudevbar.py 2011-11-08 16:10:57 +0000
@@ -1,10 +1,7 @@
1#!/usr/bin/python1#!/usr/bin/python
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 -*-
33
4import nautilus4from gi.repository import GLib, GdkPixbuf, Gtk, Nautilus, Vte # pylint: disable=E0611
5import pygtk
6import gtk
7import vte
85
9try:6try:
10 from quickly import api as quicklyapi7 from quickly import api as quicklyapi
@@ -16,7 +13,7 @@
16command_order = ('create', 'edit', 'design', 'save', 'package', 'share', 'release', 'tutorial')13command_order = ('create', 'edit', 'design', 'save', 'package', 'share', 'release', 'tutorial')
17command_without_output = ('edit', 'design', 'save', 'tutorial')14command_without_output = ('edit', 'design', 'save', 'tutorial')
1815
19class DevBar(nautilus.LocationWidgetProvider):16class DevBar(Nautilus.LocationWidgetProvider):
20 pass17 pass
21 def __init__(self):18 def __init__(self):
22 self.bars = {}19 self.bars = {}
@@ -73,12 +70,12 @@
73 return bar70 return bar
7471
7572
76class UbuntuDevBar(gtk.HBox):73class UbuntuDevBar(Gtk.HBox):
77 '''Container to all buttons in nautilus.'''74 '''Container to all buttons in nautilus.'''
7875
79 def __init__(self, *args, **kwargs):76 def __init__(self, *args, **kwargs):
80 '''create a Ubuntu Dev Bar'''77 '''create a Ubuntu Dev Bar'''
81 super(UbuntuDevBar, self).__init__(*args, **kwargs)78 Gtk.HBox.__init__(*args, **kwargs)
82 self._logo = None79 self._logo = None
83 self._image = None80 self._image = None
84 self._subtitle = None81 self._subtitle = None
@@ -87,16 +84,16 @@
8784
88 def add_image(self, image_name, subtitle=None):85 def add_image(self, image_name, subtitle=None):
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."""
90 self._logo = gtk.VBox(homogeneous=False, spacing=0)87 self._logo = Gtk.VBox(homogeneous=False, spacing=0)
91 self._image = gtk.Image()88 self._image = Gtk.Image()
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)
93 pixbuf = gtk.gdk.pixbuf_new_from_file(image_name)90 pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_name)
94 if pixbuf:91 if pixbuf:
95 scaled_pixbuf = pixbuf.scale_simple(48, 48, gtk.gdk.INTERP_BILINEAR)92 scaled_pixbuf = pixbuf.scale_simple(48, 48, GdkPixbuf.InterpType.BILINEAR)
96 self._image.set_from_pixbuf(scaled_pixbuf)93 self._image.set_from_pixbuf(scaled_pixbuf)
97 self._image.show()94 self._image.show()
98 if subtitle:95 if subtitle:
99 self._subtitle = gtk.Label(subtitle)96 self._subtitle = Gtk.Label(subtitle)
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)
101 self._subtitle.show()98 self._subtitle.show()
102 self.pack_start(self._logo, expand=False, fill=False, padding=0)99 self.pack_start(self._logo, expand=False, fill=False, padding=0)
@@ -104,17 +101,17 @@
104101
105 def add_button(self, signal, label, command_line, path, icon=None):102 def add_button(self, signal, label, command_line, path, icon=None):
106 """Adds a new new button to the bar widget."""103 """Adds a new new button to the bar widget."""
107 button = gtk.Button()104 button = Gtk.Button()
108 button.connect("clicked", signal, command_line, path)105 button.connect("clicked", signal, command_line, path)
109 button.set_label(label)106 button.set_label(label)
110 if icon:107 if icon:
111 image = gtk.Image()108 image = Gtk.Image()
112 image.set_from_file(icon)109 image.set_from_file(icon)
113 settings = button.get_settings()110 settings = button.get_settings()
114 settings.set_property("gtk-button-images", True)111 settings.set_property("gtk-button-images", True)
115 button.set_image(image)112 button.set_image(image)
116 button.show()113 button.show()
117 vbox = gtk.VBox(homogeneous=False, spacing=0)114 vbox = Gtk.VBox(homogeneous=False, spacing=0)
118 vbox.pack_start(button, expand=True, fill=False, padding=0)115 vbox.pack_start(button, expand=True, fill=False, padding=0)
119 vbox.show()116 vbox.show()
120 self._buttons.append(button)117 self._buttons.append(button)
@@ -123,21 +120,21 @@
123 def add_button_with_selection(self, signal, label, selection, command_line,120 def add_button_with_selection(self, signal, label, selection, command_line,
124 path, icon=None):121 path, icon=None):
125 """Adds a new button with a multiple selection widget"""122 """Adds a new button with a multiple selection widget"""
126 combobox = gtk.combo_box_new_text()123 combobox = Gtk.ComboBoxText()
127 for item in selection:124 for item in selection:
128 combobox.append_text(item)125 combobox.append_text(item)
129 combobox.show()126 combobox.show()
130 button = gtk.Button()127 button = Gtk.Button()
131 button.set_label(label)128 button.set_label(label)
132 button.connect("clicked", signal, command_line, path, combobox)129 button.connect("clicked", signal, command_line, path, combobox)
133 if icon:130 if icon:
134 image = gtk.Image()131 image = Gtk.Image()
135 image.set_from_file(icon)132 image.set_from_file(icon)
136 settings = button.get_settings()133 settings = button.get_settings()
137 settings.set_property("gtk-button-images", True)134 settings.set_property("gtk-button-images", True)
138 button.set_image(image)135 button.set_image(image)
139 button.show()136 button.show()
140 vbox = gtk.VBox(homogeneous=False, spacing=0)137 vbox = Gtk.VBox(homogeneous=False, spacing=0)
141 vbox.pack_start(combobox, expand=True, fill=False, padding=0)138 vbox.pack_start(combobox, expand=True, fill=False, padding=0)
142 vbox.pack_start(button, expand=True, fill=False, padding=0)139 vbox.pack_start(button, expand=True, fill=False, padding=0)
143 self._buttons_with_selection.append((combobox,button))140 self._buttons_with_selection.append((combobox,button))
@@ -158,13 +155,14 @@
158 except IndexError:155 except IndexError:
159 pass156 pass
160 command = self.add_additional_actions(command)157 command = self.add_additional_actions(command)
161 v = vte.Terminal()158 v = Vte.Terminal()
162 v.fork_command(command[0], argv=command, directory=argscommand[1])159 v.fork_command_full(Vte.PtyFlags.DEFAULT, argscommand[1], command,
163 window = gtk.Window()160 None, GLib.SpawnFlags.SEARCH_PATH, None, None)
161 window = Gtk.Window()
164 window.add(v)162 window.add(v)
165 if command[1] not in command_without_output:163 if command[1] not in command_without_output:
166 window.show_all()164 window.show_all()
167 gtk.main()165 Gtk.main()
168166
169 def add_additional_actions(self, command):167 def add_additional_actions(self, command):
170 """Some commands needs additional args, filter them here"""168 """Some commands needs additional args, filter them here"""
@@ -172,7 +170,7 @@
172 # TODO: Add missing prompts module170 # TODO: Add missing prompts module
173 #if command[1] == "create":171 #if command[1] == "create":
174 # response, val = prompts.string("Project Name","Please enter a project name")172 # response, val = prompts.string("Project Name","Please enter a project name")
175 # if response == gtk.RESPONSE_OK:173 # if response == Gtk.ResponseType.OK:
176 # command.append(val)174 # command.append(val)
177175
178 return command176 return command

Subscribers

People subscribed via source and target branches