Merge lp:~dobey/ubuntuone-client/config-preferences into lp:ubuntuone-client

Proposed by dobey
Status: Merged
Approved by: Eric Casteleijn
Approved revision: 178
Merged at revision: not available
Proposed branch: lp:~dobey/ubuntuone-client/config-preferences
Merge into: lp:ubuntuone-client
Diff against target: None lines
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/config-preferences
Reviewer Review Type Date Requested Status
Eric Casteleijn (community) Approve
Tim Cole (community) Approve
Review via email: mp+10699@code.launchpad.net

Commit message

Add a dialog to configure some settings (need to hook up the settings)

To post a comment you must log in.
Revision history for this message
Tim Cole (tcole) wrote :

Wonder if there's a more theme-friendly way to get the layout you want...

review: Approve
Revision history for this message
dobey (dobey) wrote :

> Wonder if there's a more theme-friendly way to get the layout you want...

Changes in a theme should override the parse_string here. But we need to do a parse_string to get the correct spacing for the HIG, since set_border_width() is useless on widgets that have a border-width style property now.

Revision history for this message
Eric Casteleijn (thisfred) wrote :

Looks good, tests pass.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-client-applet'
2--- bin/ubuntuone-client-applet 2009-08-24 20:22:32 +0000
3+++ bin/ubuntuone-client-applet 2009-08-25 21:00:24 +0000
4@@ -62,6 +62,16 @@
5 OAUTH_CONSUMER = "ubuntuone"
6 BOOKMARK_NAME = "Ubuntu One"
7
8+# Why thank you GTK+ for enforcing style-set and breaking API
9+RCSTYLE = """
10+style 'dialogs' {
11+ GtkDialog::action-area-border = 12
12+ GtkDialog::button-spacing = 6
13+ GtkDialog::content-area-border = 0
14+}
15+widget_class '*Dialog*' style 'dialogs'
16+"""
17+
18
19 def dbus_async(*args):
20 """Simple handler to make dbus do stuff async."""
21@@ -160,6 +170,7 @@
22 area = dialog.get_content_area()
23
24 hbox = gtk.HBox(spacing=12)
25+ hbox.set_border_width(12)
26 area.pack_start(hbox)
27 hbox.show()
28
29@@ -340,6 +351,9 @@
30 self.__total = 0
31 self.__last_id = 0
32
33+ # Config dialog!
34+ self.__conf_dialog = AppletConfigDialog()
35+
36 self.__bus = dbus.SessionBus()
37
38 self.__bus.add_signal_receiver(
39@@ -655,6 +669,12 @@
40 self.__ritems["web"].connect("activate", self.__open_website)
41 self.__ritems["web"].show()
42
43+ self.__ritems["config"] = gtk.ImageMenuItem(
44+ stock_id=gtk.STOCK_PREFERENCES)
45+ rmenu.append(self.__ritems["config"])
46+ self.__ritems["config"].connect("activate", self.__open_config)
47+ self.__ritems["config"].show()
48+
49 sep = gtk.SeparatorMenuItem()
50 rmenu.append(sep)
51 sep.show()
52@@ -760,6 +780,11 @@
53 else:
54 do_xdg_open("https://ubuntuone.com/")
55
56+
57+ def __open_config(self, data=None):
58+ """Opens the preferences dialog."""
59+ self.__conf_dialog.show()
60+
61 def __add_to_places(self):
62 """Add the managed directory to the .gtk-bookmarks file."""
63 # migrate from the old places bookmark
64@@ -815,6 +840,125 @@
65 self.__status_changed({'name' : 'UNKNOWN_ERROR'})
66
67
68+class AppletConfigDialog(gtk.Dialog):
69+ """Preferences dialog."""
70+
71+ def __init__(self, config=None, *args, **kw):
72+ """Initializes our custom StatusIcon based widget."""
73+ super(AppletConfigDialog, self).__init__(*args, **kw)
74+ self.set_title(_("Ubuntu One Preferences"))
75+ self.set_has_separator(False)
76+ self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
77+ self.set_default_response(gtk.RESPONSE_CLOSE)
78+ self.set_icon_name("ubuntuone-client")
79+
80+ self.connect("close", self.__handle_response, gtk.RESPONSE_CLOSE)
81+ self.connect("response", self.__handle_response)
82+
83+ self.config = config
84+
85+ self.__construct()
86+
87+ def __handle_response(self, dialog, response):
88+ """Handle the dialog's response."""
89+ self.hide()
90+
91+ def __construct(self):
92+ """Construct the dialog's layout."""
93+ # XXX set the widgets to the values from config
94+ # XXX hook up the widgets to some actual settings
95+ area = self.get_content_area()
96+
97+ vbox = gtk.VBox(spacing=12)
98+ vbox.set_border_width(12)
99+ area.add(vbox)
100+ vbox.show()
101+
102+ # Put the first set of options in a table.
103+ table = gtk.Table(rows=2, columns=2)
104+ table.set_row_spacings(12)
105+ table.set_col_spacings(6)
106+ vbox.add(table)
107+ table.show()
108+
109+ label = gtk.Label(_("_Show icon:"))
110+ label.set_use_underline(True)
111+ label.set_alignment(0, 0.5)
112+ table.attach(label, 0, 1, 0, 1)
113+ label.show()
114+
115+ self.show_menu = gtk.combo_box_new_text()
116+ label.set_mnemonic_widget(self.show_menu)
117+ self.show_menu.append_text(_("Always"))
118+ self.show_menu.append_text(_("When updating"))
119+ self.show_menu.append_text(_("Never"))
120+ self.show_menu.set_active(1)
121+ table.attach(self.show_menu, 1, 2, 0, 1)
122+ self.show_menu.show()
123+
124+ label = gtk.Label(_("Connect on start:"))
125+ label.set_use_underline(True)
126+ label.set_alignment(0, 0.5)
127+ table.attach(label, 0, 1, 1, 2)
128+ label.show()
129+
130+ self.conn_menu = gtk.combo_box_new_text()
131+ label.set_mnemonic_widget(self.conn_menu)
132+ self.conn_menu.append_text(_("Automatically"))
133+ self.conn_menu.append_text(_("Remember last"))
134+ self.conn_menu.append_text(_("Never"))
135+ self.conn_menu.set_active(0)
136+ table.attach(self.conn_menu, 1, 2, 1, 2)
137+ self.conn_menu.show()
138+
139+ self.limit_check = gtk.CheckButton(_("_Limit Bandwidth Usage"))
140+ vbox.add(self.limit_check)
141+ self.limit_check.show()
142+
143+ hbox = gtk.HBox(spacing=12)
144+ vbox.add(hbox)
145+ hbox.show()
146+
147+ label = gtk.Label()
148+ hbox.add(label)
149+ label.show()
150+
151+ # Now put the bw limit bits in a table too
152+ self.bw_table = gtk.Table(rows=2, columns=2)
153+ self.bw_table.set_row_spacings(6)
154+ self.bw_table.set_col_spacings(6)
155+ self.bw_table.set_sensitive(False)
156+ hbox.add(self.bw_table)
157+ self.bw_table.show()
158+
159+ # Upload speed
160+ label = gtk.Label(_("Maximum _upload speed (KB/s):"))
161+ label.set_use_underline(True)
162+ label.set_alignment(0, 0.5)
163+ self.bw_table.attach(label, 0, 1, 0, 1)
164+ label.show()
165+
166+ adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
167+ step_incr=64.0, page_incr=128.0)
168+ self.up_spin = gtk.SpinButton(adjustment)
169+ label.set_mnemonic_widget(self.up_spin)
170+ self.bw_table.attach(self.up_spin, 1, 2, 0, 1)
171+ self.up_spin.show()
172+
173+ # Download speed
174+ label = gtk.Label(_("Maximum _download speed (KB/s):"))
175+ label.set_use_underline(True)
176+ label.set_alignment(0, 0.5)
177+ self.bw_table.attach(label, 0, 1, 1, 2)
178+ label.show()
179+ adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
180+ step_incr=64.0, page_incr=128.0)
181+ self.dn_spin = gtk.SpinButton(adjustment)
182+ label.set_mnemonic_widget(self.dn_spin)
183+ self.bw_table.attach(self.dn_spin, 1, 2, 1, 2)
184+ self.dn_spin.show()
185+
186+
187 if __name__ == "__main__":
188 gettext.bindtextdomain(clientdefs.GETTEXT_PACKAGE, clientdefs.LOCALEDIR)
189 gettext.textdomain(clientdefs.GETTEXT_PACKAGE)
190@@ -825,5 +969,7 @@
191 print _("Ubuntu One client applet already running, quitting")
192 sys.exit(-1)
193
194+ gtk.rc_parse_string(RCSTYLE)
195+
196 icon = AppletMain()
197 icon.main()

Subscribers

People subscribed via source and target branches