Merge lp:~dobey/ubuntuone-client/accessible-prefs into lp:ubuntuone-client

Proposed by dobey on 2009-09-28
Status: Merged
Approved by: Vincenzo Di Somma on 2009-09-28
Approved revision: 222
Merged at revision: not available
Proposed branch: lp:~dobey/ubuntuone-client/accessible-prefs
Merge into: lp:ubuntuone-client
Diff against target: 801 lines
7 files modified
Makefile.am (+2/-0)
bin/ubuntuone-client-applet (+58/-246)
bin/ubuntuone-client-preferences (+349/-0)
data/Makefile.am (+2/-1)
data/ubuntuone-client-preferences.desktop.in (+9/-0)
docs/man/ubuntuone-client-preferences.1 (+16/-0)
po/POTFILES.in (+2/-0)
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/accessible-prefs
Reviewer Review Type Date Requested Status
Vincenzo Di Somma (community) Approve on 2009-09-28
Rodrigo Moya (community) 2009-09-28 Approve on 2009-09-28
Review via email: mp+12524@code.launchpad.net

Commit message

Split the preferences dialog to a separate app
Add a launcher to System->Preferences for preferences app
Add man page for preferences app
Add DBus object class and methods to applet for getting preferences changes

To post a comment you must log in.
Rodrigo Moya (rodrigo-moya) wrote :

Looks good to me

review: Approve
Vincenzo Di Somma (vds) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2009-08-24 20:22:32 +0000
3+++ Makefile.am 2009-09-28 14:55:20 +0000
4@@ -19,6 +19,7 @@
5 # Install our scripts and extra data here
6 bin_SCRIPTS = \
7 bin/ubuntuone-client-applet \
8+ bin/ubuntuone-client-preferences \
9 bin/u1sdtool \
10 bin/u1sync
11
12@@ -26,6 +27,7 @@
13
14 manfilesdir = $(mandir)/man1
15 manfiles_DATA = \
16+ docs/man/ubuntuone-client-preferences.1 \
17 docs/man/ubuntuone-client-applet.1 \
18 docs/man/u1sdtool.1 \
19 docs/man/u1sync.1
20
21=== modified file 'bin/ubuntuone-client-applet'
22--- bin/ubuntuone-client-applet 2009-09-18 13:24:52 +0000
23+++ bin/ubuntuone-client-applet 2009-09-28 14:55:20 +0000
24@@ -53,6 +53,9 @@
25
26 _ = gettext.gettext
27
28+APPLET_BUS_NAME = "com.ubuntuone.ClientApplet"
29+APPLET_CONFIG_NAME = APPLET_BUS_NAME + ".Config"
30+
31 DBUS_IFACE_NAME = "com.ubuntuone.SyncDaemon"
32 DBUS_IFACE_SYNC_NAME = "com.ubuntuone.SyncDaemon.SyncDaemon"
33 DBUS_IFACE_STATUS_NAME = "com.ubuntuone.SyncDaemon.Status"
34@@ -383,6 +386,20 @@
35
36
37
38+def do_config_open():
39+ """Opens the preferences dialog."""
40+ paths = os.environ["PATH"].split(":")
41+ dirpath = os.path.join(os.getcwd(), "bin")
42+ if os.path.isdir(dirpath):
43+ paths.insert(0, dirpath)
44+ os.environ["PATH"] = ":".join(paths)
45+ try:
46+ ret = subprocess.call(["ubuntuone-client-preferences"])
47+ except OSError:
48+ ret = -1
49+ if ret != 0:
50+ logger.error(_("Failed to open Ubuntu One preferences"))
51+
52 def do_xdg_open(path_or_url):
53 """Utility method to run xdg-open with path_or_url."""
54 ret = subprocess.call(["xdg-open", path_or_url])
55@@ -449,11 +466,12 @@
56 self.__total = 0
57 self.__last_id = 0
58
59- # Config dialog!
60- self.__conf_dialog = AppletConfigDialog(self, self.__config)
61-
62 self.__bus = dbus.SessionBus()
63
64+ # Our own DBus service, for the config to deal with
65+ self.__service = AppletConfig(icon=self)
66+
67+ # DBus signal handling
68 self.__bus.add_signal_receiver(
69 handler_function=self.__status_changed,
70 signal_name="StatusChanged",
71@@ -474,9 +492,15 @@
72
73 gobject.idle_add(self.__get_root)
74
75- def update_config(self):
76- """Update internal reference to the config when it changes."""
77- self.__show_when = self.__config.getint("ubuntuone", "show_applet")
78+ def set_visibility_config(self, visibility):
79+ """Update the visibility configuration."""
80+ self.__show_when = int(visibility)
81+ self.__config.set("ubuntuone", "show_applet", str(self.__show_when))
82+ self.update_visibility()
83+
84+ def set_connection_config(self, connect):
85+ """Update the connection config."""
86+ self.__config.set("ubuntuone", "connect", str(connect))
87
88 def __update_transfer_status(self, done=False):
89 """Update the status display."""
90@@ -852,9 +876,6 @@
91
92 def __quit_applet(self, menuitem, data=None):
93 """Quit the daemon and closes the applet."""
94- with open(CONF_FILE, "w+b") as f:
95- self.__config.write(f)
96-
97 def quit_error(e):
98 """Just log and ignore."""
99 logger.error(_("Quit Error: %s") % e.get_dbus_message())
100@@ -929,7 +950,7 @@
101
102 def __open_config(self, data=None):
103 """Opens the preferences dialog."""
104- self.__conf_dialog.show()
105+ do_config_open()
106
107 def __add_to_places(self):
108 """Add the managed directory to the .gtk-bookmarks file."""
109@@ -974,249 +995,40 @@
110 self.__status_changed({'name' : 'UNKNOWN_ERROR'})
111
112
113-class AppletConfigDialog(gtk.Dialog):
114- """Preferences dialog."""
115-
116- def __init__(self, icon=None, config=None, *args, **kw):
117- """Initializes our custom StatusIcon based widget."""
118- super(AppletConfigDialog, self).__init__(*args, **kw)
119- self.set_title(_("Ubuntu One Preferences"))
120- self.set_has_separator(False)
121- self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
122- self.set_default_response(gtk.RESPONSE_CLOSE)
123- self.set_icon_name("ubuntuone-client")
124-
125- self.connect("close", self.__handle_response, gtk.RESPONSE_CLOSE)
126- self.connect("response", self.__handle_response)
127-
128- self.__icon = icon
129- self.config = config
130-
131- self.bw_enabled = False
132- self.up_limit = 2097152
133- self.dn_limit = 2097152
134-
135- self.__bus = dbus.SessionBus()
136-
137- try:
138- client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
139- iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
140- iface.get_throttling_limits(
141- reply_handler=self.__got_limits,
142- error_handler=self.__throttle_error)
143- iface.bandwidth_throttling_enabled(
144- reply_handler=self.__got_enabled,
145- error_handler=self.__throttle_error)
146- except DBusException, e:
147- self.__throttle_error(e)
148-
149- # Timeout ID to avoid spamming DBus from spinbutton changes
150- self.__update_id = 0
151-
152- self.__construct()
153-
154-
155- def __throttle_error(self, error):
156- """Error getting throttling config."""
157- logger.error(_("Error getting throttle config: %s") %
158- error.get_dbus_message())
159-
160- def __got_limits(self, limits):
161- """Got the throttling limits."""
162- self.up_limit = int(limits['upload'])
163- self.dn_limit = int(limits['download'])
164-
165- def __got_enabled(self, enabled):
166- """Got the throttling enabled config."""
167- self.bw_enabled = bool(enabled)
168-
169- def __update_bw_settings(self):
170- """Update the bandwidth throttling config in syncdaemon."""
171- self.bw_enabled = self.limit_check.get_active()
172- self.up_limit = self.up_spin.get_value_as_int() * 1024
173- self.dn_limit = self.dn_spin.get_value_as_int() * 1024
174-
175- try:
176- client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
177- iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
178- iface.set_throttling_limits(self.dn_limit, self.up_limit,
179- reply_handler=dbus_async,
180- error_handler=self.__throttle_error)
181- if self.bw_enabled:
182- iface.enable_bandwidth_throttling(
183- reply_handler=dbus_async,
184- error_handler=self.__throttle_error)
185- else:
186- iface.disable_bandwidth_throttling(
187- reply_handler=dbus_async,
188- error_handler=self.__throttle_error)
189- except DBusException, e:
190- self.__throttle_error(e)
191-
192- def __handle_response(self, dialog, response):
193- """Handle the dialog's response."""
194- self.hide()
195- self.config.set("ubuntuone", "show_applet",
196- self.show_menu.get_active())
197- self.config.set("ubuntuone", "connect",
198- self.conn_menu.get_active())
199-
200- self.__update_bw_settings()
201-
202- with open(CONF_FILE, "w+b") as f:
203- self.config.write(f)
204-
205- def __show_menu_changed(self, menu, data=None):
206- """Update the config for showing the applet."""
207- value = menu.get_active()
208- self.config.set("ubuntuone", "show_applet", str(value))
209- self.__icon.update_config()
210- self.__icon.update_visibility()
211-
212- def __conn_menu_changed(self, menu, data=None):
213- """Update the config for showing the applet."""
214- self.config.set("ubuntuone", "connect", str(menu.get_active()))
215-
216- def __bw_limit_toggled(self, button, data=None):
217- """Toggle the bw limit panel."""
218- self.bw_enabled = self.limit_check.get_active()
219- self.bw_table.set_sensitive(self.bw_enabled)
220- try:
221- client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
222- iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
223- iface.set_throttling_limits(self.dn_limit, self.up_limit,
224- reply_handler=dbus_async,
225- error_handler=self.__throttle_error)
226- if self.bw_enabled:
227- iface.enable_bandwidth_throttling(
228- reply_handler=dbus_async,
229- error_handler=self.__throttle_error)
230- else:
231- iface.disable_bandwidth_throttling(
232- reply_handler=dbus_async,
233- error_handler=self.__throttle_error)
234- except DBusException, e:
235- self.__throttle_error(e)
236-
237- def __spinner_changed(self, button, data=None):
238- """Remove timeout and add anew."""
239- if self.__update_id != 0:
240- gobject.source_remove(self.__update_id)
241-
242- self.__update_id = gobject.timeout_add_seconds(
243- 1, self.__update_bw_settings)
244-
245- def __construct(self):
246- """Construct the dialog's layout."""
247- area = self.get_content_area()
248-
249- vbox = gtk.VBox(spacing=12)
250- vbox.set_border_width(12)
251- area.add(vbox)
252- vbox.show()
253-
254- # Put the first set of options in a table.
255- table = gtk.Table(rows=2, columns=2)
256- table.set_row_spacings(12)
257- table.set_col_spacings(6)
258- vbox.add(table)
259- table.show()
260-
261- label = gtk.Label(_("_Show icon:"))
262- label.set_use_underline(True)
263- label.set_alignment(0, 0.5)
264- table.attach(label, 0, 1, 0, 1)
265- label.show()
266-
267- self.show_menu = gtk.combo_box_new_text()
268- self.show_menu.connect("changed", self.__show_menu_changed)
269- label.set_mnemonic_widget(self.show_menu)
270- self.show_menu.append_text(_("Always"))
271- self.show_menu.append_text(_("When updating"))
272- self.show_menu.append_text(_("Never"))
273- self.show_menu.set_active(self.config.getint("ubuntuone",
274- "show_applet"))
275- table.attach(self.show_menu, 1, 2, 0, 1)
276- self.show_menu.show()
277-
278- label = gtk.Label(_("Connect on start:"))
279- label.set_use_underline(True)
280- label.set_alignment(0, 0.5)
281- table.attach(label, 0, 1, 1, 2)
282- label.show()
283-
284- self.conn_menu = gtk.combo_box_new_text()
285- self.conn_menu.connect("changed", self.__conn_menu_changed)
286- label.set_mnemonic_widget(self.conn_menu)
287- self.conn_menu.append_text(_("Automatically"))
288- self.conn_menu.append_text(_("Remember last"))
289- self.conn_menu.append_text(_("Never"))
290- self.conn_menu.set_active(self.config.getint("ubuntuone",
291- "connect"))
292- table.attach(self.conn_menu, 1, 2, 1, 2)
293- self.conn_menu.show()
294-
295- # Bandwidth limiting
296- self.limit_check = gtk.CheckButton(_("_Limit Bandwidth Usage"))
297- self.limit_check.connect("toggled", self.__bw_limit_toggled)
298- vbox.add(self.limit_check)
299- self.limit_check.show()
300-
301- hbox = gtk.HBox(spacing=12)
302- vbox.add(hbox)
303- hbox.show()
304-
305- label = gtk.Label()
306- hbox.add(label)
307- label.show()
308-
309- # Now put the bw limit bits in a table too
310- self.bw_table = gtk.Table(rows=2, columns=2)
311- self.bw_table.set_row_spacings(6)
312- self.bw_table.set_col_spacings(6)
313- self.bw_table.set_sensitive(False)
314- hbox.add(self.bw_table)
315- self.bw_table.show()
316-
317- # Upload speed
318- label = gtk.Label(_("Maximum _upload speed (KB/s):"))
319- label.set_use_underline(True)
320- label.set_alignment(0, 0.5)
321- self.bw_table.attach(label, 0, 1, 0, 1)
322- label.show()
323-
324- adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
325- step_incr=64.0, page_incr=128.0)
326- self.up_spin = gtk.SpinButton(adjustment)
327- self.up_spin.connect("value-changed", self.__spinner_changed)
328- label.set_mnemonic_widget(self.up_spin)
329- self.bw_table.attach(self.up_spin, 1, 2, 0, 1)
330- self.up_spin.show()
331-
332- # Download speed
333- label = gtk.Label(_("Maximum _download speed (KB/s):"))
334- label.set_use_underline(True)
335- label.set_alignment(0, 0.5)
336- self.bw_table.attach(label, 0, 1, 1, 2)
337- label.show()
338- adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
339- step_incr=64.0, page_incr=128.0)
340- self.dn_spin = gtk.SpinButton(adjustment)
341- self.dn_spin.connect("value-changed", self.__spinner_changed)
342- label.set_mnemonic_widget(self.dn_spin)
343- self.bw_table.attach(self.dn_spin, 1, 2, 1, 2)
344- self.dn_spin.show()
345-
346-
347+class AppletConfig(dbus.service.Object):
348+ """DBus Service object"""
349+
350+ def __init__(self, icon, *args, **kwargs):
351+ """Initialize our magic."""
352+ self.icon = icon
353+ self.path = "/config"
354+ self.bus = dbus.SessionBus()
355+ bus_name = dbus.service.BusName(APPLET_BUS_NAME,
356+ bus=self.bus)
357+ dbus.service.Object.__init__(self, bus_name=bus_name,
358+ object_path=self.path)
359+
360+ @dbus.service.method(APPLET_CONFIG_NAME,
361+ in_signature='i', out_signature='')
362+ def set_visibility_config(self, visibility):
363+ self.icon.set_visibility_config(visibility)
364+
365+ @dbus.service.method(APPLET_CONFIG_NAME,
366+ in_signature='i', out_signature='')
367+ def set_connection_config(self, connect):
368+ self.icon.set_connection_config(connect)
369+
370+
371 if __name__ == "__main__":
372 gettext.bindtextdomain(clientdefs.GETTEXT_PACKAGE, clientdefs.LOCALEDIR)
373 gettext.textdomain(clientdefs.GETTEXT_PACKAGE)
374
375 # Register DBus service for making sure we run only one instance
376 bus = dbus.SessionBus()
377- if bus.request_name("com.ubuntuone.ClientApplet", dbus.bus.NAME_FLAG_DO_NOT_QUEUE) == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
378+ if bus.request_name(APPLET_BUS_NAME, dbus.bus.NAME_FLAG_DO_NOT_QUEUE) == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
379 print _("Ubuntu One client applet already running, quitting")
380- sys.exit(-1)
381+ do_config_open()
382+ sys.exit(0)
383
384 gtk.rc_parse_string(RCSTYLE)
385
386
387=== added file 'bin/ubuntuone-client-preferences'
388--- bin/ubuntuone-client-preferences 1970-01-01 00:00:00 +0000
389+++ bin/ubuntuone-client-preferences 2009-09-28 14:55:20 +0000
390@@ -0,0 +1,349 @@
391+#!/usr/bin/python
392+
393+# ubuntuone-client-applet - Tray icon applet for managing Ubuntu One
394+#
395+# Author: Rodney Dawes <rodney.dawes@canonical.com>
396+#
397+# Copyright 2009 Canonical Ltd.
398+#
399+# This program is free software: you can redistribute it and/or modify it
400+# under the terms of the GNU General Public License version 3, as published
401+# by the Free Software Foundation.
402+#
403+# This program is distributed in the hope that it will be useful, but
404+# WITHOUT ANY WARRANTY; without even the implied warranties of
405+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
406+# PURPOSE. See the GNU General Public License for more details.
407+#
408+# You should have received a copy of the GNU General Public License along
409+# with this program. If not, see <http://www.gnu.org/licenses/>.
410+
411+from __future__ import with_statement
412+
413+import pygtk
414+pygtk.require('2.0')
415+import gobject
416+import gtk
417+import os
418+import gettext
419+from ubuntuone import clientdefs
420+
421+import dbus.service
422+from ConfigParser import ConfigParser
423+from dbus.exceptions import DBusException
424+from dbus.mainloop.glib import DBusGMainLoop
425+from xdg.BaseDirectory import xdg_config_home
426+
427+DBusGMainLoop(set_as_default=True)
428+
429+_ = gettext.gettext
430+
431+APPLET_IFACE_NAME = "com.ubuntuone.ClientApplet"
432+APPLET_IFACE_CONFIG_NAME = APPLET_IFACE_NAME + ".Config"
433+
434+DBUS_IFACE_NAME = "com.ubuntuone.SyncDaemon"
435+DBUS_IFACE_CONFIG_NAME = DBUS_IFACE_NAME + ".Config"
436+
437+# Why thank you GTK+ for enforcing style-set and breaking API
438+RCSTYLE = """
439+style 'dialogs' {
440+ GtkDialog::action-area-border = 12
441+ GtkDialog::button-spacing = 6
442+ GtkDialog::content-area-border = 0
443+}
444+widget_class '*Dialog*' style 'dialogs'
445+"""
446+
447+CONF_FILE = os.path.join(xdg_config_home, "ubuntuone", "ubuntuone-client.conf")
448+
449+def dbus_async(*args):
450+ """Simple handler to make dbus do stuff async."""
451+ pass
452+
453+
454+class AppletConfigDialog(gtk.Dialog):
455+ """Preferences dialog."""
456+
457+ def __init__(self, config=None, *args, **kw):
458+ """Initializes our config dialog."""
459+ super(AppletConfigDialog, self).__init__(*args, **kw)
460+ self.set_title(_("Ubuntu One Preferences"))
461+ self.set_has_separator(False)
462+ self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
463+ self.set_default_response(gtk.RESPONSE_CLOSE)
464+ self.set_icon_name("ubuntuone-client")
465+
466+ self.connect("close", self.__handle_response, gtk.RESPONSE_CLOSE)
467+ self.connect("response", self.__handle_response)
468+
469+ self.config = config
470+
471+ self.bw_enabled = False
472+ self.up_limit = 2097152
473+ self.dn_limit = 2097152
474+
475+ self.__bus = dbus.SessionBus()
476+
477+ try:
478+ client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
479+ iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
480+ iface.get_throttling_limits(
481+ reply_handler=self.__got_limits,
482+ error_handler=self.__dbus_error)
483+ iface.bandwidth_throttling_enabled(
484+ reply_handler=self.__got_enabled,
485+ error_handler=self.__dbus_error)
486+ except DBusException, e:
487+ self.__dbus_error(e)
488+
489+ # Timeout ID to avoid spamming DBus from spinbutton changes
490+ self.__update_id = 0
491+
492+ self.load_config()
493+
494+ self.__construct()
495+
496+ def load_config(self):
497+ """Load the configuration, and initilize if empty."""
498+ self.config = ConfigParser()
499+ self.config.read(CONF_FILE)
500+
501+ if not self.config.has_section("ubuntuone"):
502+ self.config.add_section("ubuntuone")
503+
504+ if not self.config.has_option("ubuntuone", "show_applet"):
505+ self.config.set("ubuntuone", "show_applet", "1")
506+
507+ if not self.config.has_option("ubuntuone", "connect"):
508+ self.config.set("ubuntuone", "connect", "0")
509+
510+ if not self.config.has_option("ubuntuone", "connected"):
511+ self.config.set("ubuntuone", "connected", "False")
512+
513+ if not os.path.exists(CONF_FILE):
514+ self.save_config()
515+
516+ def save_config(self):
517+ """Write the configuration back to a file."""
518+ with open(CONF_FILE, "w+b") as f:
519+ self.config.write(f)
520+
521+ def quit(self):
522+ """Exit the main loop."""
523+ gtk.main_quit()
524+
525+ def __dbus_error(self, error):
526+ """Error getting throttling config."""
527+ print repr(error)
528+
529+ def __got_limits(self, limits):
530+ """Got the throttling limits."""
531+ self.up_limit = int(limits['upload'])
532+ self.dn_limit = int(limits['download'])
533+
534+ def __got_enabled(self, enabled):
535+ """Got the throttling enabled config."""
536+ self.bw_enabled = bool(enabled)
537+
538+ def __update_bw_settings(self):
539+ """Update the bandwidth throttling config in syncdaemon."""
540+ self.bw_enabled = self.limit_check.get_active()
541+ self.up_limit = self.up_spin.get_value_as_int() * 1024
542+ self.dn_limit = self.dn_spin.get_value_as_int() * 1024
543+
544+ try:
545+ client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
546+ iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
547+ iface.set_throttling_limits(self.dn_limit, self.up_limit,
548+ reply_handler=dbus_async,
549+ error_handler=self.__dbus_error)
550+ if self.bw_enabled:
551+ iface.enable_bandwidth_throttling(
552+ reply_handler=dbus_async,
553+ error_handler=self.__dbus_error)
554+ else:
555+ iface.disable_bandwidth_throttling(
556+ reply_handler=dbus_async,
557+ error_handler=self.__dbus_error)
558+ except DBusException, e:
559+ self.__dbus_error(e)
560+
561+ def __handle_response(self, dialog, response):
562+ """Handle the dialog's response."""
563+ self.hide()
564+ self.config.set("ubuntuone", "show_applet",
565+ self.show_menu.get_active())
566+ self.config.set("ubuntuone", "connect",
567+ self.conn_menu.get_active())
568+
569+ self.__update_bw_settings()
570+ self.save_config()
571+ gtk.main_quit()
572+
573+ def __show_menu_changed(self, menu, data=None):
574+ """Update the config for showing the applet."""
575+ value = menu.get_active()
576+ self.config.set("ubuntuone", "show_applet", str(value))
577+ try:
578+ client = self.__bus.get_object(APPLET_IFACE_NAME, "/config")
579+ iface = dbus.Interface(client, APPLET_IFACE_CONFIG_NAME)
580+ iface.set_visibility_config(value, reply_handler=dbus_async,
581+ error_handler=self.__dbus_error)
582+ except DBusException, e:
583+ self.__dbus_error(e)
584+
585+ def __conn_menu_changed(self, menu, data=None):
586+ """Update the config for showing the applet."""
587+ value = menu.get_active()
588+ self.config.set("ubuntuone", "connect", str(value))
589+ try:
590+ client = self.__bus.get_object(APPLET_IFACE_NAME, "/config")
591+ iface = dbus.Interface(client, APPLET_IFACE_CONFIG_NAME)
592+ iface.set_connection_config(value, reply_handler=dbus_async,
593+ error_handler=self.__dbus_error)
594+ except DBusException, e:
595+ self.__dbus_error(e)
596+
597+ def __bw_limit_toggled(self, button, data=None):
598+ """Toggle the bw limit panel."""
599+ self.bw_enabled = self.limit_check.get_active()
600+ self.bw_table.set_sensitive(self.bw_enabled)
601+ try:
602+ client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
603+ iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
604+ iface.set_throttling_limits(self.dn_limit, self.up_limit,
605+ reply_handler=dbus_async,
606+ error_handler=self.__dbus_error)
607+ if self.bw_enabled:
608+ iface.enable_bandwidth_throttling(
609+ reply_handler=dbus_async,
610+ error_handler=self.__dbus_error)
611+ else:
612+ iface.disable_bandwidth_throttling(
613+ reply_handler=dbus_async,
614+ error_handler=self.__dbus_error)
615+ except DBusException, e:
616+ self.__dbus_error(e)
617+
618+ def __spinner_changed(self, button, data=None):
619+ """Remove timeout and add anew."""
620+ if self.__update_id != 0:
621+ gobject.source_remove(self.__update_id)
622+
623+ self.__update_id = gobject.timeout_add_seconds(
624+ 1, self.__update_bw_settings)
625+
626+ def __construct(self):
627+ """Construct the dialog's layout."""
628+ area = self.get_content_area()
629+
630+ vbox = gtk.VBox(spacing=12)
631+ vbox.set_border_width(12)
632+ area.add(vbox)
633+ vbox.show()
634+
635+ # Put the first set of options in a table.
636+ table = gtk.Table(rows=2, columns=2)
637+ table.set_row_spacings(12)
638+ table.set_col_spacings(6)
639+ vbox.add(table)
640+ table.show()
641+
642+ label = gtk.Label(_("_Show icon:"))
643+ label.set_use_underline(True)
644+ label.set_alignment(0, 0.5)
645+ table.attach(label, 0, 1, 0, 1)
646+ label.show()
647+
648+ self.show_menu = gtk.combo_box_new_text()
649+ self.show_menu.connect("changed", self.__show_menu_changed)
650+ label.set_mnemonic_widget(self.show_menu)
651+ self.show_menu.append_text(_("Always"))
652+ self.show_menu.append_text(_("When updating"))
653+ self.show_menu.append_text(_("Never"))
654+ self.show_menu.set_active(self.config.getint("ubuntuone",
655+ "show_applet"))
656+ table.attach(self.show_menu, 1, 2, 0, 1)
657+ self.show_menu.show()
658+
659+ label = gtk.Label(_("Connect on start:"))
660+ label.set_use_underline(True)
661+ label.set_alignment(0, 0.5)
662+ table.attach(label, 0, 1, 1, 2)
663+ label.show()
664+
665+ self.conn_menu = gtk.combo_box_new_text()
666+ self.conn_menu.connect("changed", self.__conn_menu_changed)
667+ label.set_mnemonic_widget(self.conn_menu)
668+ self.conn_menu.append_text(_("Automatically"))
669+ self.conn_menu.append_text(_("Remember last"))
670+ self.conn_menu.append_text(_("Never"))
671+ self.conn_menu.set_active(self.config.getint("ubuntuone",
672+ "connect"))
673+ table.attach(self.conn_menu, 1, 2, 1, 2)
674+ self.conn_menu.show()
675+
676+ # Bandwidth limiting
677+ self.limit_check = gtk.CheckButton(_("_Limit Bandwidth Usage"))
678+ self.limit_check.connect("toggled", self.__bw_limit_toggled)
679+ vbox.add(self.limit_check)
680+ self.limit_check.show()
681+
682+ hbox = gtk.HBox(spacing=12)
683+ vbox.add(hbox)
684+ hbox.show()
685+
686+ label = gtk.Label()
687+ hbox.add(label)
688+ label.show()
689+
690+ # Now put the bw limit bits in a table too
691+ self.bw_table = gtk.Table(rows=2, columns=2)
692+ self.bw_table.set_row_spacings(6)
693+ self.bw_table.set_col_spacings(6)
694+ self.bw_table.set_sensitive(False)
695+ hbox.add(self.bw_table)
696+ self.bw_table.show()
697+
698+ # Upload speed
699+ label = gtk.Label(_("Maximum _upload speed (KB/s):"))
700+ label.set_use_underline(True)
701+ label.set_alignment(0, 0.5)
702+ self.bw_table.attach(label, 0, 1, 0, 1)
703+ label.show()
704+
705+ adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
706+ step_incr=64.0, page_incr=128.0)
707+ self.up_spin = gtk.SpinButton(adjustment)
708+ self.up_spin.connect("value-changed", self.__spinner_changed)
709+ label.set_mnemonic_widget(self.up_spin)
710+ self.bw_table.attach(self.up_spin, 1, 2, 0, 1)
711+ self.up_spin.show()
712+
713+ # Download speed
714+ label = gtk.Label(_("Maximum _download speed (KB/s):"))
715+ label.set_use_underline(True)
716+ label.set_alignment(0, 0.5)
717+ self.bw_table.attach(label, 0, 1, 1, 2)
718+ label.show()
719+ adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
720+ step_incr=64.0, page_incr=128.0)
721+ self.dn_spin = gtk.SpinButton(adjustment)
722+ self.dn_spin.connect("value-changed", self.__spinner_changed)
723+ label.set_mnemonic_widget(self.dn_spin)
724+ self.bw_table.attach(self.dn_spin, 1, 2, 1, 2)
725+ self.dn_spin.show()
726+
727+
728+if __name__ == "__main__":
729+ gettext.bindtextdomain(clientdefs.GETTEXT_PACKAGE, clientdefs.LOCALEDIR)
730+ gettext.textdomain(clientdefs.GETTEXT_PACKAGE)
731+
732+ gtk.rc_parse_string(RCSTYLE)
733+
734+ try:
735+ dialog = AppletConfigDialog()
736+ dialog.show()
737+ gtk.main()
738+ except KeyboardInterrupt:
739+ pass
740
741=== modified file 'data/Makefile.am'
742--- data/Makefile.am 2009-08-12 19:28:32 +0000
743+++ data/Makefile.am 2009-09-28 14:55:20 +0000
744@@ -12,7 +12,8 @@
745 oauth_DATA = oauth_registration.d/ubuntuone
746
747 desktopdir = $(datadir)/applications
748-desktop_in_files = ubuntuone-client-applet.desktop.in
749+desktop_in_files = ubuntuone-client-applet.desktop.in \
750+ ubuntuone-client-preferences.desktop.in
751 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
752
753 @INTLTOOL_DESKTOP_RULE@
754
755=== added file 'data/ubuntuone-client-preferences.desktop.in'
756--- data/ubuntuone-client-preferences.desktop.in 1970-01-01 00:00:00 +0000
757+++ data/ubuntuone-client-preferences.desktop.in 2009-09-28 14:55:20 +0000
758@@ -0,0 +1,9 @@
759+[Desktop Entry]
760+Name=Ubuntu One
761+_Comment=Configure the Ubuntu One file sharing client
762+Exec=ubuntuone-client-preferences
763+Icon=ubuntuone-client
764+Terminal=false
765+Type=Application
766+Categories=GTK;Settings;
767+X-Ubuntu-Gettext-Domain=ubuntuone-client
768
769=== added file 'docs/man/ubuntuone-client-preferences.1'
770--- docs/man/ubuntuone-client-preferences.1 1970-01-01 00:00:00 +0000
771+++ docs/man/ubuntuone-client-preferences.1 2009-09-28 14:55:20 +0000
772@@ -0,0 +1,16 @@
773+.TH UBUNTUONE-CLIENT-PREFERENCES 1
774+
775+.SH NAME
776+ubuntuone-client-preferences \- A dialog for configuring Ubuntu One
777+
778+.SH SYNOPSYS
779+.B ubutuone-client-preferences
780+
781+.SH DESCRIPTION
782+This manual page briefly documents the
783+.BR ubuntuone-client-preferences
784+process, which provides a configuration dialog for configuring
785+Ubuntu One file sharing.
786+
787+.SH AUTHOR
788+This manual page was written by Rodney Dawes <rodney.dawes@canonical.com>
789
790=== modified file 'po/POTFILES.in'
791--- po/POTFILES.in 2009-06-17 16:08:17 +0000
792+++ po/POTFILES.in 2009-09-28 14:55:20 +0000
793@@ -1,7 +1,9 @@
794 bin/ubuntuone-client-applet
795+bin/ubuntuone-client-preferences
796 data/emblem-ubuntuone-downloading.icon.in
797 data/emblem-ubuntuone-unsynchronized.icon.in
798 data/emblem-ubuntuone-uploading.icon.in
799 data/ubuntuone-client-applet.desktop.in
800+data/ubuntuone-client-preferences.desktop.in
801 nautilus/ubuntuone-nautilus.c
802

Subscribers

People subscribed via source and target branches