~ralsina/ubuntuone-control-panel/fix-scroll

« back to all changes in this revision

Viewing changes to ubuntuone/control_panel/gui.py

  • Committer: natalia.bidart at canonical
  • Date: 2010-09-15 21:43:48 UTC
  • Revision ID: natalia.bidart@canonical.com-20100915214348-qd7vpoj85z0jhx0m
Initial directory structure for new project.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
# Authors: Natalia B Bidart <natalia.bidart@canonical.com>
 
4
#
 
5
# Copyright 2010 Canonical Ltd.
 
6
#
 
7
# This program is free software: you can redistribute it and/or modify it
 
8
# under the terms of the GNU General Public License version 3, as published
 
9
# by the Free Software Foundation.
 
10
#
 
11
# This program is distributed in the hope that it will be useful, but
 
12
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
13
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
14
# PURPOSE.  See the GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License along
 
17
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
"""The user interface for the control panel for Ubuntu One."""
 
20
 
 
21
import gtk
 
22
 
 
23
from ubuntuone.logger import logging
 
24
from ubuntuone.control_panel import utils
 
25
 
 
26
logger = logging.getLogger('ubuntuone.control_panel')
 
27
 
 
28
 
 
29
class ControlPanelUI(object):
 
30
    """The main interface for the Ubuntu One control panel."""
 
31
 
 
32
    def __init__(self):
 
33
        self.builder = gtk.Builder()
 
34
        self.builder.add_from_file(utils.get_data_file('main.ui'))
 
35
        self.builder.connect_signals(self.builder)
 
36
 
 
37
        # untested directly
 
38
        for obj in self.builder.get_objects():
 
39
            name = getattr(obj, 'name', None)
 
40
            if name is None and isinstance(obj, gtk.Buildable):
 
41
                # work around bug lp:507739
 
42
                name = gtk.Buildable.get_name(obj)
 
43
            if name is None:
 
44
                logging.warn("%s has no name (??)", obj)
 
45
            else:
 
46
                setattr(self, name, obj)
 
47
 
 
48
    def main(self):
 
49
        """Run the main loop of the widget toolkit."""
 
50
        logger.debug('Starting GTK main loop.')
 
51
        gtk.main()