~mvo/ubuntu-sso-client/strawman-lp711413

« back to all changes in this revision

Viewing changes to ubuntu_sso/gtk/main.py

Merged trunk in up to revno 836.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
# Copyright 2012 Canonical Ltd.
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU General Public License version 3, as published
 
7
# by the Free Software Foundation.
 
8
#
 
9
# This program is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
12
# PURPOSE.  See the GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License along
 
15
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
"""Main module to open the GTK UI."""
 
18
 
 
19
import argparse
 
20
 
 
21
import gtk
 
22
 
 
23
from ubuntu_sso.gtk.gui import UbuntuSSOClientGUI
 
24
 
 
25
 
 
26
def parse_args():
 
27
    """Parse sys.argv options."""
 
28
    parser = argparse.ArgumentParser(description='Open the GTK SSO UI.')
 
29
    parser.add_argument('--app_name', required=True,
 
30
        help='the name of the application to retrieve credentials for')
 
31
    parser.add_argument('--ping_url', default='',
 
32
        help='a link to be used as the ping url (to notify about new tokens)')
 
33
    parser.add_argument('--tc_url', default='',
 
34
        help='a link to be used as Terms & Conditions url')
 
35
    parser.add_argument('--help_text', default='',
 
36
        help='extra text that will be shown below the headers')
 
37
    parser.add_argument('--window_id', type=int, default=0,
 
38
        help='the window id to be set transient for the SSO GTK dialogs')
 
39
    parser.add_argument('--login_only', action='store_true', default=False,
 
40
        help='whether the SSO GTK UI should only offer login or not')
 
41
 
 
42
    args = parser.parse_args()
 
43
    return args
 
44
 
 
45
 
 
46
def main(**kwargs):
 
47
    """Start the GTK mainloop and open the main window."""
 
48
    UbuntuSSOClientGUI(close_callback=gtk.main_quit, **kwargs)
 
49
    gtk.main()