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

Proposed by dobey
Status: Merged
Approved by: Vincenzo Di Somma
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
Rodrigo Moya (community) Approve
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.
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Looks good to me

review: Approve
Revision history for this message
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
=== modified file 'Makefile.am'
--- Makefile.am 2009-08-24 20:22:32 +0000
+++ Makefile.am 2009-09-28 14:55:20 +0000
@@ -19,6 +19,7 @@
19# Install our scripts and extra data here19# Install our scripts and extra data here
20bin_SCRIPTS = \20bin_SCRIPTS = \
21 bin/ubuntuone-client-applet \21 bin/ubuntuone-client-applet \
22 bin/ubuntuone-client-preferences \
22 bin/u1sdtool \23 bin/u1sdtool \
23 bin/u1sync24 bin/u1sync
2425
@@ -26,6 +27,7 @@
2627
27manfilesdir = $(mandir)/man128manfilesdir = $(mandir)/man1
28manfiles_DATA = \29manfiles_DATA = \
30 docs/man/ubuntuone-client-preferences.1 \
29 docs/man/ubuntuone-client-applet.1 \31 docs/man/ubuntuone-client-applet.1 \
30 docs/man/u1sdtool.1 \32 docs/man/u1sdtool.1 \
31 docs/man/u1sync.133 docs/man/u1sync.1
3234
=== modified file 'bin/ubuntuone-client-applet'
--- bin/ubuntuone-client-applet 2009-09-18 13:24:52 +0000
+++ bin/ubuntuone-client-applet 2009-09-28 14:55:20 +0000
@@ -53,6 +53,9 @@
5353
54_ = gettext.gettext54_ = gettext.gettext
5555
56APPLET_BUS_NAME = "com.ubuntuone.ClientApplet"
57APPLET_CONFIG_NAME = APPLET_BUS_NAME + ".Config"
58
56DBUS_IFACE_NAME = "com.ubuntuone.SyncDaemon"59DBUS_IFACE_NAME = "com.ubuntuone.SyncDaemon"
57DBUS_IFACE_SYNC_NAME = "com.ubuntuone.SyncDaemon.SyncDaemon"60DBUS_IFACE_SYNC_NAME = "com.ubuntuone.SyncDaemon.SyncDaemon"
58DBUS_IFACE_STATUS_NAME = "com.ubuntuone.SyncDaemon.Status"61DBUS_IFACE_STATUS_NAME = "com.ubuntuone.SyncDaemon.Status"
@@ -383,6 +386,20 @@
383386
384387
385388
389def do_config_open():
390 """Opens the preferences dialog."""
391 paths = os.environ["PATH"].split(":")
392 dirpath = os.path.join(os.getcwd(), "bin")
393 if os.path.isdir(dirpath):
394 paths.insert(0, dirpath)
395 os.environ["PATH"] = ":".join(paths)
396 try:
397 ret = subprocess.call(["ubuntuone-client-preferences"])
398 except OSError:
399 ret = -1
400 if ret != 0:
401 logger.error(_("Failed to open Ubuntu One preferences"))
402
386def do_xdg_open(path_or_url):403def do_xdg_open(path_or_url):
387 """Utility method to run xdg-open with path_or_url."""404 """Utility method to run xdg-open with path_or_url."""
388 ret = subprocess.call(["xdg-open", path_or_url])405 ret = subprocess.call(["xdg-open", path_or_url])
@@ -449,11 +466,12 @@
449 self.__total = 0466 self.__total = 0
450 self.__last_id = 0467 self.__last_id = 0
451468
452 # Config dialog!
453 self.__conf_dialog = AppletConfigDialog(self, self.__config)
454
455 self.__bus = dbus.SessionBus()469 self.__bus = dbus.SessionBus()
456470
471 # Our own DBus service, for the config to deal with
472 self.__service = AppletConfig(icon=self)
473
474 # DBus signal handling
457 self.__bus.add_signal_receiver(475 self.__bus.add_signal_receiver(
458 handler_function=self.__status_changed,476 handler_function=self.__status_changed,
459 signal_name="StatusChanged",477 signal_name="StatusChanged",
@@ -474,9 +492,15 @@
474492
475 gobject.idle_add(self.__get_root)493 gobject.idle_add(self.__get_root)
476494
477 def update_config(self):495 def set_visibility_config(self, visibility):
478 """Update internal reference to the config when it changes."""496 """Update the visibility configuration."""
479 self.__show_when = self.__config.getint("ubuntuone", "show_applet")497 self.__show_when = int(visibility)
498 self.__config.set("ubuntuone", "show_applet", str(self.__show_when))
499 self.update_visibility()
500
501 def set_connection_config(self, connect):
502 """Update the connection config."""
503 self.__config.set("ubuntuone", "connect", str(connect))
480504
481 def __update_transfer_status(self, done=False):505 def __update_transfer_status(self, done=False):
482 """Update the status display."""506 """Update the status display."""
@@ -852,9 +876,6 @@
852876
853 def __quit_applet(self, menuitem, data=None):877 def __quit_applet(self, menuitem, data=None):
854 """Quit the daemon and closes the applet."""878 """Quit the daemon and closes the applet."""
855 with open(CONF_FILE, "w+b") as f:
856 self.__config.write(f)
857
858 def quit_error(e):879 def quit_error(e):
859 """Just log and ignore."""880 """Just log and ignore."""
860 logger.error(_("Quit Error: %s") % e.get_dbus_message())881 logger.error(_("Quit Error: %s") % e.get_dbus_message())
@@ -929,7 +950,7 @@
929950
930 def __open_config(self, data=None):951 def __open_config(self, data=None):
931 """Opens the preferences dialog."""952 """Opens the preferences dialog."""
932 self.__conf_dialog.show()953 do_config_open()
933954
934 def __add_to_places(self):955 def __add_to_places(self):
935 """Add the managed directory to the .gtk-bookmarks file."""956 """Add the managed directory to the .gtk-bookmarks file."""
@@ -974,249 +995,40 @@
974 self.__status_changed({'name' : 'UNKNOWN_ERROR'})995 self.__status_changed({'name' : 'UNKNOWN_ERROR'})
975996
976997
977class AppletConfigDialog(gtk.Dialog):998class AppletConfig(dbus.service.Object):
978 """Preferences dialog."""999 """DBus Service object"""
9791000
980 def __init__(self, icon=None, config=None, *args, **kw):1001 def __init__(self, icon, *args, **kwargs):
981 """Initializes our custom StatusIcon based widget."""1002 """Initialize our magic."""
982 super(AppletConfigDialog, self).__init__(*args, **kw)1003 self.icon = icon
983 self.set_title(_("Ubuntu One Preferences"))1004 self.path = "/config"
984 self.set_has_separator(False)1005 self.bus = dbus.SessionBus()
985 self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)1006 bus_name = dbus.service.BusName(APPLET_BUS_NAME,
986 self.set_default_response(gtk.RESPONSE_CLOSE)1007 bus=self.bus)
987 self.set_icon_name("ubuntuone-client")1008 dbus.service.Object.__init__(self, bus_name=bus_name,
9881009 object_path=self.path)
989 self.connect("close", self.__handle_response, gtk.RESPONSE_CLOSE)1010
990 self.connect("response", self.__handle_response)1011 @dbus.service.method(APPLET_CONFIG_NAME,
9911012 in_signature='i', out_signature='')
992 self.__icon = icon1013 def set_visibility_config(self, visibility):
993 self.config = config1014 self.icon.set_visibility_config(visibility)
9941015
995 self.bw_enabled = False1016 @dbus.service.method(APPLET_CONFIG_NAME,
996 self.up_limit = 20971521017 in_signature='i', out_signature='')
997 self.dn_limit = 20971521018 def set_connection_config(self, connect):
9981019 self.icon.set_connection_config(connect)
999 self.__bus = dbus.SessionBus()1020
10001021
1001 try:
1002 client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
1003 iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
1004 iface.get_throttling_limits(
1005 reply_handler=self.__got_limits,
1006 error_handler=self.__throttle_error)
1007 iface.bandwidth_throttling_enabled(
1008 reply_handler=self.__got_enabled,
1009 error_handler=self.__throttle_error)
1010 except DBusException, e:
1011 self.__throttle_error(e)
1012
1013 # Timeout ID to avoid spamming DBus from spinbutton changes
1014 self.__update_id = 0
1015
1016 self.__construct()
1017
1018
1019 def __throttle_error(self, error):
1020 """Error getting throttling config."""
1021 logger.error(_("Error getting throttle config: %s") %
1022 error.get_dbus_message())
1023
1024 def __got_limits(self, limits):
1025 """Got the throttling limits."""
1026 self.up_limit = int(limits['upload'])
1027 self.dn_limit = int(limits['download'])
1028
1029 def __got_enabled(self, enabled):
1030 """Got the throttling enabled config."""
1031 self.bw_enabled = bool(enabled)
1032
1033 def __update_bw_settings(self):
1034 """Update the bandwidth throttling config in syncdaemon."""
1035 self.bw_enabled = self.limit_check.get_active()
1036 self.up_limit = self.up_spin.get_value_as_int() * 1024
1037 self.dn_limit = self.dn_spin.get_value_as_int() * 1024
1038
1039 try:
1040 client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
1041 iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
1042 iface.set_throttling_limits(self.dn_limit, self.up_limit,
1043 reply_handler=dbus_async,
1044 error_handler=self.__throttle_error)
1045 if self.bw_enabled:
1046 iface.enable_bandwidth_throttling(
1047 reply_handler=dbus_async,
1048 error_handler=self.__throttle_error)
1049 else:
1050 iface.disable_bandwidth_throttling(
1051 reply_handler=dbus_async,
1052 error_handler=self.__throttle_error)
1053 except DBusException, e:
1054 self.__throttle_error(e)
1055
1056 def __handle_response(self, dialog, response):
1057 """Handle the dialog's response."""
1058 self.hide()
1059 self.config.set("ubuntuone", "show_applet",
1060 self.show_menu.get_active())
1061 self.config.set("ubuntuone", "connect",
1062 self.conn_menu.get_active())
1063
1064 self.__update_bw_settings()
1065
1066 with open(CONF_FILE, "w+b") as f:
1067 self.config.write(f)
1068
1069 def __show_menu_changed(self, menu, data=None):
1070 """Update the config for showing the applet."""
1071 value = menu.get_active()
1072 self.config.set("ubuntuone", "show_applet", str(value))
1073 self.__icon.update_config()
1074 self.__icon.update_visibility()
1075
1076 def __conn_menu_changed(self, menu, data=None):
1077 """Update the config for showing the applet."""
1078 self.config.set("ubuntuone", "connect", str(menu.get_active()))
1079
1080 def __bw_limit_toggled(self, button, data=None):
1081 """Toggle the bw limit panel."""
1082 self.bw_enabled = self.limit_check.get_active()
1083 self.bw_table.set_sensitive(self.bw_enabled)
1084 try:
1085 client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
1086 iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
1087 iface.set_throttling_limits(self.dn_limit, self.up_limit,
1088 reply_handler=dbus_async,
1089 error_handler=self.__throttle_error)
1090 if self.bw_enabled:
1091 iface.enable_bandwidth_throttling(
1092 reply_handler=dbus_async,
1093 error_handler=self.__throttle_error)
1094 else:
1095 iface.disable_bandwidth_throttling(
1096 reply_handler=dbus_async,
1097 error_handler=self.__throttle_error)
1098 except DBusException, e:
1099 self.__throttle_error(e)
1100
1101 def __spinner_changed(self, button, data=None):
1102 """Remove timeout and add anew."""
1103 if self.__update_id != 0:
1104 gobject.source_remove(self.__update_id)
1105
1106 self.__update_id = gobject.timeout_add_seconds(
1107 1, self.__update_bw_settings)
1108
1109 def __construct(self):
1110 """Construct the dialog's layout."""
1111 area = self.get_content_area()
1112
1113 vbox = gtk.VBox(spacing=12)
1114 vbox.set_border_width(12)
1115 area.add(vbox)
1116 vbox.show()
1117
1118 # Put the first set of options in a table.
1119 table = gtk.Table(rows=2, columns=2)
1120 table.set_row_spacings(12)
1121 table.set_col_spacings(6)
1122 vbox.add(table)
1123 table.show()
1124
1125 label = gtk.Label(_("_Show icon:"))
1126 label.set_use_underline(True)
1127 label.set_alignment(0, 0.5)
1128 table.attach(label, 0, 1, 0, 1)
1129 label.show()
1130
1131 self.show_menu = gtk.combo_box_new_text()
1132 self.show_menu.connect("changed", self.__show_menu_changed)
1133 label.set_mnemonic_widget(self.show_menu)
1134 self.show_menu.append_text(_("Always"))
1135 self.show_menu.append_text(_("When updating"))
1136 self.show_menu.append_text(_("Never"))
1137 self.show_menu.set_active(self.config.getint("ubuntuone",
1138 "show_applet"))
1139 table.attach(self.show_menu, 1, 2, 0, 1)
1140 self.show_menu.show()
1141
1142 label = gtk.Label(_("Connect on start:"))
1143 label.set_use_underline(True)
1144 label.set_alignment(0, 0.5)
1145 table.attach(label, 0, 1, 1, 2)
1146 label.show()
1147
1148 self.conn_menu = gtk.combo_box_new_text()
1149 self.conn_menu.connect("changed", self.__conn_menu_changed)
1150 label.set_mnemonic_widget(self.conn_menu)
1151 self.conn_menu.append_text(_("Automatically"))
1152 self.conn_menu.append_text(_("Remember last"))
1153 self.conn_menu.append_text(_("Never"))
1154 self.conn_menu.set_active(self.config.getint("ubuntuone",
1155 "connect"))
1156 table.attach(self.conn_menu, 1, 2, 1, 2)
1157 self.conn_menu.show()
1158
1159 # Bandwidth limiting
1160 self.limit_check = gtk.CheckButton(_("_Limit Bandwidth Usage"))
1161 self.limit_check.connect("toggled", self.__bw_limit_toggled)
1162 vbox.add(self.limit_check)
1163 self.limit_check.show()
1164
1165 hbox = gtk.HBox(spacing=12)
1166 vbox.add(hbox)
1167 hbox.show()
1168
1169 label = gtk.Label()
1170 hbox.add(label)
1171 label.show()
1172
1173 # Now put the bw limit bits in a table too
1174 self.bw_table = gtk.Table(rows=2, columns=2)
1175 self.bw_table.set_row_spacings(6)
1176 self.bw_table.set_col_spacings(6)
1177 self.bw_table.set_sensitive(False)
1178 hbox.add(self.bw_table)
1179 self.bw_table.show()
1180
1181 # Upload speed
1182 label = gtk.Label(_("Maximum _upload speed (KB/s):"))
1183 label.set_use_underline(True)
1184 label.set_alignment(0, 0.5)
1185 self.bw_table.attach(label, 0, 1, 0, 1)
1186 label.show()
1187
1188 adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
1189 step_incr=64.0, page_incr=128.0)
1190 self.up_spin = gtk.SpinButton(adjustment)
1191 self.up_spin.connect("value-changed", self.__spinner_changed)
1192 label.set_mnemonic_widget(self.up_spin)
1193 self.bw_table.attach(self.up_spin, 1, 2, 0, 1)
1194 self.up_spin.show()
1195
1196 # Download speed
1197 label = gtk.Label(_("Maximum _download speed (KB/s):"))
1198 label.set_use_underline(True)
1199 label.set_alignment(0, 0.5)
1200 self.bw_table.attach(label, 0, 1, 1, 2)
1201 label.show()
1202 adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
1203 step_incr=64.0, page_incr=128.0)
1204 self.dn_spin = gtk.SpinButton(adjustment)
1205 self.dn_spin.connect("value-changed", self.__spinner_changed)
1206 label.set_mnemonic_widget(self.dn_spin)
1207 self.bw_table.attach(self.dn_spin, 1, 2, 1, 2)
1208 self.dn_spin.show()
1209
1210
1211if __name__ == "__main__":1022if __name__ == "__main__":
1212 gettext.bindtextdomain(clientdefs.GETTEXT_PACKAGE, clientdefs.LOCALEDIR)1023 gettext.bindtextdomain(clientdefs.GETTEXT_PACKAGE, clientdefs.LOCALEDIR)
1213 gettext.textdomain(clientdefs.GETTEXT_PACKAGE)1024 gettext.textdomain(clientdefs.GETTEXT_PACKAGE)
12141025
1215 # Register DBus service for making sure we run only one instance1026 # Register DBus service for making sure we run only one instance
1216 bus = dbus.SessionBus()1027 bus = dbus.SessionBus()
1217 if bus.request_name("com.ubuntuone.ClientApplet", dbus.bus.NAME_FLAG_DO_NOT_QUEUE) == dbus.bus.REQUEST_NAME_REPLY_EXISTS:1028 if bus.request_name(APPLET_BUS_NAME, dbus.bus.NAME_FLAG_DO_NOT_QUEUE) == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
1218 print _("Ubuntu One client applet already running, quitting")1029 print _("Ubuntu One client applet already running, quitting")
1219 sys.exit(-1)1030 do_config_open()
1031 sys.exit(0)
12201032
1221 gtk.rc_parse_string(RCSTYLE)1033 gtk.rc_parse_string(RCSTYLE)
12221034
12231035
=== added file 'bin/ubuntuone-client-preferences'
--- bin/ubuntuone-client-preferences 1970-01-01 00:00:00 +0000
+++ bin/ubuntuone-client-preferences 2009-09-28 14:55:20 +0000
@@ -0,0 +1,349 @@
1#!/usr/bin/python
2
3# ubuntuone-client-applet - Tray icon applet for managing Ubuntu One
4#
5# Author: Rodney Dawes <rodney.dawes@canonical.com>
6#
7# Copyright 2009 Canonical Ltd.
8#
9# This program is free software: you can redistribute it and/or modify it
10# under the terms of the GNU General Public License version 3, as published
11# by the Free Software Foundation.
12#
13# This program is distributed in the hope that it will be useful, but
14# WITHOUT ANY WARRANTY; without even the implied warranties of
15# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16# PURPOSE. See the GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License along
19# with this program. If not, see <http://www.gnu.org/licenses/>.
20
21from __future__ import with_statement
22
23import pygtk
24pygtk.require('2.0')
25import gobject
26import gtk
27import os
28import gettext
29from ubuntuone import clientdefs
30
31import dbus.service
32from ConfigParser import ConfigParser
33from dbus.exceptions import DBusException
34from dbus.mainloop.glib import DBusGMainLoop
35from xdg.BaseDirectory import xdg_config_home
36
37DBusGMainLoop(set_as_default=True)
38
39_ = gettext.gettext
40
41APPLET_IFACE_NAME = "com.ubuntuone.ClientApplet"
42APPLET_IFACE_CONFIG_NAME = APPLET_IFACE_NAME + ".Config"
43
44DBUS_IFACE_NAME = "com.ubuntuone.SyncDaemon"
45DBUS_IFACE_CONFIG_NAME = DBUS_IFACE_NAME + ".Config"
46
47# Why thank you GTK+ for enforcing style-set and breaking API
48RCSTYLE = """
49style 'dialogs' {
50 GtkDialog::action-area-border = 12
51 GtkDialog::button-spacing = 6
52 GtkDialog::content-area-border = 0
53}
54widget_class '*Dialog*' style 'dialogs'
55"""
56
57CONF_FILE = os.path.join(xdg_config_home, "ubuntuone", "ubuntuone-client.conf")
58
59def dbus_async(*args):
60 """Simple handler to make dbus do stuff async."""
61 pass
62
63
64class AppletConfigDialog(gtk.Dialog):
65 """Preferences dialog."""
66
67 def __init__(self, config=None, *args, **kw):
68 """Initializes our config dialog."""
69 super(AppletConfigDialog, self).__init__(*args, **kw)
70 self.set_title(_("Ubuntu One Preferences"))
71 self.set_has_separator(False)
72 self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
73 self.set_default_response(gtk.RESPONSE_CLOSE)
74 self.set_icon_name("ubuntuone-client")
75
76 self.connect("close", self.__handle_response, gtk.RESPONSE_CLOSE)
77 self.connect("response", self.__handle_response)
78
79 self.config = config
80
81 self.bw_enabled = False
82 self.up_limit = 2097152
83 self.dn_limit = 2097152
84
85 self.__bus = dbus.SessionBus()
86
87 try:
88 client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
89 iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
90 iface.get_throttling_limits(
91 reply_handler=self.__got_limits,
92 error_handler=self.__dbus_error)
93 iface.bandwidth_throttling_enabled(
94 reply_handler=self.__got_enabled,
95 error_handler=self.__dbus_error)
96 except DBusException, e:
97 self.__dbus_error(e)
98
99 # Timeout ID to avoid spamming DBus from spinbutton changes
100 self.__update_id = 0
101
102 self.load_config()
103
104 self.__construct()
105
106 def load_config(self):
107 """Load the configuration, and initilize if empty."""
108 self.config = ConfigParser()
109 self.config.read(CONF_FILE)
110
111 if not self.config.has_section("ubuntuone"):
112 self.config.add_section("ubuntuone")
113
114 if not self.config.has_option("ubuntuone", "show_applet"):
115 self.config.set("ubuntuone", "show_applet", "1")
116
117 if not self.config.has_option("ubuntuone", "connect"):
118 self.config.set("ubuntuone", "connect", "0")
119
120 if not self.config.has_option("ubuntuone", "connected"):
121 self.config.set("ubuntuone", "connected", "False")
122
123 if not os.path.exists(CONF_FILE):
124 self.save_config()
125
126 def save_config(self):
127 """Write the configuration back to a file."""
128 with open(CONF_FILE, "w+b") as f:
129 self.config.write(f)
130
131 def quit(self):
132 """Exit the main loop."""
133 gtk.main_quit()
134
135 def __dbus_error(self, error):
136 """Error getting throttling config."""
137 print repr(error)
138
139 def __got_limits(self, limits):
140 """Got the throttling limits."""
141 self.up_limit = int(limits['upload'])
142 self.dn_limit = int(limits['download'])
143
144 def __got_enabled(self, enabled):
145 """Got the throttling enabled config."""
146 self.bw_enabled = bool(enabled)
147
148 def __update_bw_settings(self):
149 """Update the bandwidth throttling config in syncdaemon."""
150 self.bw_enabled = self.limit_check.get_active()
151 self.up_limit = self.up_spin.get_value_as_int() * 1024
152 self.dn_limit = self.dn_spin.get_value_as_int() * 1024
153
154 try:
155 client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
156 iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
157 iface.set_throttling_limits(self.dn_limit, self.up_limit,
158 reply_handler=dbus_async,
159 error_handler=self.__dbus_error)
160 if self.bw_enabled:
161 iface.enable_bandwidth_throttling(
162 reply_handler=dbus_async,
163 error_handler=self.__dbus_error)
164 else:
165 iface.disable_bandwidth_throttling(
166 reply_handler=dbus_async,
167 error_handler=self.__dbus_error)
168 except DBusException, e:
169 self.__dbus_error(e)
170
171 def __handle_response(self, dialog, response):
172 """Handle the dialog's response."""
173 self.hide()
174 self.config.set("ubuntuone", "show_applet",
175 self.show_menu.get_active())
176 self.config.set("ubuntuone", "connect",
177 self.conn_menu.get_active())
178
179 self.__update_bw_settings()
180 self.save_config()
181 gtk.main_quit()
182
183 def __show_menu_changed(self, menu, data=None):
184 """Update the config for showing the applet."""
185 value = menu.get_active()
186 self.config.set("ubuntuone", "show_applet", str(value))
187 try:
188 client = self.__bus.get_object(APPLET_IFACE_NAME, "/config")
189 iface = dbus.Interface(client, APPLET_IFACE_CONFIG_NAME)
190 iface.set_visibility_config(value, reply_handler=dbus_async,
191 error_handler=self.__dbus_error)
192 except DBusException, e:
193 self.__dbus_error(e)
194
195 def __conn_menu_changed(self, menu, data=None):
196 """Update the config for showing the applet."""
197 value = menu.get_active()
198 self.config.set("ubuntuone", "connect", str(value))
199 try:
200 client = self.__bus.get_object(APPLET_IFACE_NAME, "/config")
201 iface = dbus.Interface(client, APPLET_IFACE_CONFIG_NAME)
202 iface.set_connection_config(value, reply_handler=dbus_async,
203 error_handler=self.__dbus_error)
204 except DBusException, e:
205 self.__dbus_error(e)
206
207 def __bw_limit_toggled(self, button, data=None):
208 """Toggle the bw limit panel."""
209 self.bw_enabled = self.limit_check.get_active()
210 self.bw_table.set_sensitive(self.bw_enabled)
211 try:
212 client = self.__bus.get_object(DBUS_IFACE_NAME, "/config")
213 iface = dbus.Interface(client, DBUS_IFACE_CONFIG_NAME)
214 iface.set_throttling_limits(self.dn_limit, self.up_limit,
215 reply_handler=dbus_async,
216 error_handler=self.__dbus_error)
217 if self.bw_enabled:
218 iface.enable_bandwidth_throttling(
219 reply_handler=dbus_async,
220 error_handler=self.__dbus_error)
221 else:
222 iface.disable_bandwidth_throttling(
223 reply_handler=dbus_async,
224 error_handler=self.__dbus_error)
225 except DBusException, e:
226 self.__dbus_error(e)
227
228 def __spinner_changed(self, button, data=None):
229 """Remove timeout and add anew."""
230 if self.__update_id != 0:
231 gobject.source_remove(self.__update_id)
232
233 self.__update_id = gobject.timeout_add_seconds(
234 1, self.__update_bw_settings)
235
236 def __construct(self):
237 """Construct the dialog's layout."""
238 area = self.get_content_area()
239
240 vbox = gtk.VBox(spacing=12)
241 vbox.set_border_width(12)
242 area.add(vbox)
243 vbox.show()
244
245 # Put the first set of options in a table.
246 table = gtk.Table(rows=2, columns=2)
247 table.set_row_spacings(12)
248 table.set_col_spacings(6)
249 vbox.add(table)
250 table.show()
251
252 label = gtk.Label(_("_Show icon:"))
253 label.set_use_underline(True)
254 label.set_alignment(0, 0.5)
255 table.attach(label, 0, 1, 0, 1)
256 label.show()
257
258 self.show_menu = gtk.combo_box_new_text()
259 self.show_menu.connect("changed", self.__show_menu_changed)
260 label.set_mnemonic_widget(self.show_menu)
261 self.show_menu.append_text(_("Always"))
262 self.show_menu.append_text(_("When updating"))
263 self.show_menu.append_text(_("Never"))
264 self.show_menu.set_active(self.config.getint("ubuntuone",
265 "show_applet"))
266 table.attach(self.show_menu, 1, 2, 0, 1)
267 self.show_menu.show()
268
269 label = gtk.Label(_("Connect on start:"))
270 label.set_use_underline(True)
271 label.set_alignment(0, 0.5)
272 table.attach(label, 0, 1, 1, 2)
273 label.show()
274
275 self.conn_menu = gtk.combo_box_new_text()
276 self.conn_menu.connect("changed", self.__conn_menu_changed)
277 label.set_mnemonic_widget(self.conn_menu)
278 self.conn_menu.append_text(_("Automatically"))
279 self.conn_menu.append_text(_("Remember last"))
280 self.conn_menu.append_text(_("Never"))
281 self.conn_menu.set_active(self.config.getint("ubuntuone",
282 "connect"))
283 table.attach(self.conn_menu, 1, 2, 1, 2)
284 self.conn_menu.show()
285
286 # Bandwidth limiting
287 self.limit_check = gtk.CheckButton(_("_Limit Bandwidth Usage"))
288 self.limit_check.connect("toggled", self.__bw_limit_toggled)
289 vbox.add(self.limit_check)
290 self.limit_check.show()
291
292 hbox = gtk.HBox(spacing=12)
293 vbox.add(hbox)
294 hbox.show()
295
296 label = gtk.Label()
297 hbox.add(label)
298 label.show()
299
300 # Now put the bw limit bits in a table too
301 self.bw_table = gtk.Table(rows=2, columns=2)
302 self.bw_table.set_row_spacings(6)
303 self.bw_table.set_col_spacings(6)
304 self.bw_table.set_sensitive(False)
305 hbox.add(self.bw_table)
306 self.bw_table.show()
307
308 # Upload speed
309 label = gtk.Label(_("Maximum _upload speed (KB/s):"))
310 label.set_use_underline(True)
311 label.set_alignment(0, 0.5)
312 self.bw_table.attach(label, 0, 1, 0, 1)
313 label.show()
314
315 adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
316 step_incr=64.0, page_incr=128.0)
317 self.up_spin = gtk.SpinButton(adjustment)
318 self.up_spin.connect("value-changed", self.__spinner_changed)
319 label.set_mnemonic_widget(self.up_spin)
320 self.bw_table.attach(self.up_spin, 1, 2, 0, 1)
321 self.up_spin.show()
322
323 # Download speed
324 label = gtk.Label(_("Maximum _download speed (KB/s):"))
325 label.set_use_underline(True)
326 label.set_alignment(0, 0.5)
327 self.bw_table.attach(label, 0, 1, 1, 2)
328 label.show()
329 adjustment = gtk.Adjustment(value=2048.0, lower=0.0, upper=4096.0,
330 step_incr=64.0, page_incr=128.0)
331 self.dn_spin = gtk.SpinButton(adjustment)
332 self.dn_spin.connect("value-changed", self.__spinner_changed)
333 label.set_mnemonic_widget(self.dn_spin)
334 self.bw_table.attach(self.dn_spin, 1, 2, 1, 2)
335 self.dn_spin.show()
336
337
338if __name__ == "__main__":
339 gettext.bindtextdomain(clientdefs.GETTEXT_PACKAGE, clientdefs.LOCALEDIR)
340 gettext.textdomain(clientdefs.GETTEXT_PACKAGE)
341
342 gtk.rc_parse_string(RCSTYLE)
343
344 try:
345 dialog = AppletConfigDialog()
346 dialog.show()
347 gtk.main()
348 except KeyboardInterrupt:
349 pass
0350
=== modified file 'data/Makefile.am'
--- data/Makefile.am 2009-08-12 19:28:32 +0000
+++ data/Makefile.am 2009-09-28 14:55:20 +0000
@@ -12,7 +12,8 @@
12oauth_DATA = oauth_registration.d/ubuntuone12oauth_DATA = oauth_registration.d/ubuntuone
1313
14desktopdir = $(datadir)/applications14desktopdir = $(datadir)/applications
15desktop_in_files = ubuntuone-client-applet.desktop.in15desktop_in_files = ubuntuone-client-applet.desktop.in \
16 ubuntuone-client-preferences.desktop.in
16desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)17desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
1718
18@INTLTOOL_DESKTOP_RULE@19@INTLTOOL_DESKTOP_RULE@
1920
=== added file 'data/ubuntuone-client-preferences.desktop.in'
--- data/ubuntuone-client-preferences.desktop.in 1970-01-01 00:00:00 +0000
+++ data/ubuntuone-client-preferences.desktop.in 2009-09-28 14:55:20 +0000
@@ -0,0 +1,9 @@
1[Desktop Entry]
2Name=Ubuntu One
3_Comment=Configure the Ubuntu One file sharing client
4Exec=ubuntuone-client-preferences
5Icon=ubuntuone-client
6Terminal=false
7Type=Application
8Categories=GTK;Settings;
9X-Ubuntu-Gettext-Domain=ubuntuone-client
010
=== added file 'docs/man/ubuntuone-client-preferences.1'
--- docs/man/ubuntuone-client-preferences.1 1970-01-01 00:00:00 +0000
+++ docs/man/ubuntuone-client-preferences.1 2009-09-28 14:55:20 +0000
@@ -0,0 +1,16 @@
1.TH UBUNTUONE-CLIENT-PREFERENCES 1
2
3.SH NAME
4ubuntuone-client-preferences \- A dialog for configuring Ubuntu One
5
6.SH SYNOPSYS
7.B ubutuone-client-preferences
8
9.SH DESCRIPTION
10This manual page briefly documents the
11.BR ubuntuone-client-preferences
12process, which provides a configuration dialog for configuring
13Ubuntu One file sharing.
14
15.SH AUTHOR
16This manual page was written by Rodney Dawes <rodney.dawes@canonical.com>
017
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2009-06-17 16:08:17 +0000
+++ po/POTFILES.in 2009-09-28 14:55:20 +0000
@@ -1,7 +1,9 @@
1bin/ubuntuone-client-applet1bin/ubuntuone-client-applet
2bin/ubuntuone-client-preferences
2data/emblem-ubuntuone-downloading.icon.in3data/emblem-ubuntuone-downloading.icon.in
3data/emblem-ubuntuone-unsynchronized.icon.in4data/emblem-ubuntuone-unsynchronized.icon.in
4data/emblem-ubuntuone-uploading.icon.in5data/emblem-ubuntuone-uploading.icon.in
5data/ubuntuone-client-applet.desktop.in6data/ubuntuone-client-applet.desktop.in
7data/ubuntuone-client-preferences.desktop.in
6nautilus/ubuntuone-nautilus.c8nautilus/ubuntuone-nautilus.c
79

Subscribers

People subscribed via source and target branches