21
22
# Invalid name "ubuntuone-control-panel-gtk", pylint: disable=C0103
25
import dbus.mainloop.glib
28
27
from optparse import OptionParser
30
from ubuntuone.controlpanel.gtk import DBUS_BUS_NAME, TRANSLATION_DOMAIN
29
from ubuntuone.controlpanel.gtk import TRANSLATION_DOMAIN
32
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
33
31
gettext.textdomain(TRANSLATION_DOMAIN)
35
32
# import the GUI after the translation domain has been set
36
from ubuntuone.controlpanel.gtk.gui import ControlPanelWindow
33
from ubuntuone.controlpanel.gtk.gui import main
39
36
def parser_options():
41
38
usage = "Usage: %prog [option]"
42
39
result = OptionParser(usage=usage)
43
40
result.add_option("", "--switch-to", dest="switch_to", type="string",
41
metavar="PANEL_NAME", default="",
45
42
help="Start the Ubuntu One Control Panel (GTK) in the "
46
43
"PANEL_NAME tab. Possible values are: "
47
44
"dashboard, volumes, devices, applications")
48
45
result.add_option("-a", "--alert", dest="alert", action="store_true",
49
help="Start the Ubuntu One Control Panel (GTK) alerting "
50
"the user to its presence.")
46
default=False, help="Start the Ubuntu One Control Panel "
47
"(GTK) alerting the user to its presence.")
54
51
if __name__ == "__main__":
55
bus = dbus.SessionBus()
56
name = bus.request_name(DBUS_BUS_NAME,
57
dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
58
if name == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
61
bus_name = dbus.service.BusName(DBUS_BUS_NAME, bus=dbus.SessionBus())
62
52
parser = parser_options()
63
53
(options, args) = parser.parse_args(sys.argv)
64
gui = ControlPanelWindow(
65
switch_to=options.switch_to, alert=options.alert)
54
main(switch_to=options.switch_to, alert=options.alert)