~jonobacon/ubuntu-accomplishments-viewer/quickly-upgrade

« back to all changes in this revision

Viewing changes to accomplishments_viewer_lib/Window.py

  • Committer: Jono Bacon
  • Date: 2012-08-29 21:42:19 UTC
  • Revision ID: jono@ubuntu.com-20120829214219-eay3qu28uozfpkt9
 * Quickly upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
2
### BEGIN LICENSE
3
 
# This file is in the public domain
 
3
# Copyright (C) 2012 Jono Bacon <jono@ubuntu.com>
 
4
# This program is free software: you can redistribute it and/or modify it 
 
5
# under the terms of the GNU General Public License version 3, as published 
 
6
# by the Free Software Foundation.
 
7
 
8
# This program is distributed in the hope that it will be useful, but 
 
9
# WITHOUT ANY WARRANTY; without even the implied warranties of 
 
10
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
 
11
# PURPOSE.  See the GNU General Public License for more details.
 
12
 
13
# You should have received a copy of the GNU General Public License along 
 
14
# with this program.  If not, see <http://www.gnu.org/licenses/>.
4
15
### END LICENSE
5
16
 
 
17
### DO NOT EDIT THIS FILE ###
 
18
 
6
19
from gi.repository import Gio, Gtk # pylint: disable=E0611
7
20
import logging
8
21
logger = logging.getLogger('accomplishments_viewer_lib')
52
65
        self.settings = Gio.Settings("net.launchpad.accomplishments-viewer")
53
66
        self.settings.connect('changed', self.on_preferences_changed)
54
67
 
55
 
        # Optional Launchpad integration
56
 
        # This shouldn't crash if not found as it is simply used for bug reporting.
57
 
        # See https://wiki.ubuntu.com/UbuntuDevelopment/Internationalisation/Coding
58
 
        # for more information about Launchpad integration.
59
 
        # XXX: This is temporarily disabled, as there is no such package
60
 
        # in ubuntu repositories. We may want to re-enable it one day.
61
 
        """
62
 
        try:
63
 
            from gi.repository import LaunchpadIntegration # pylint: disable=E0611
64
 
            LaunchpadIntegration.add_items(self.ui.helpMenu, 2, True, True)
65
 
            LaunchpadIntegration.set_sourcepackagename('accomplishments-viewer')
66
 
        except ImportError:
67
 
            pass
68
 
        """
69
 
 
70
68
        # Optional application indicator support
71
69
        # Run 'quickly add indicator' to get started.
72
70
        # More information:
90
88
            response = about.run()
91
89
            about.destroy()
92
90
 
 
91
    def on_mnu_preferences_activate(self, widget, data=None):
 
92
        """Display the preferences window for accomplishments-viewer."""
 
93
 
 
94
        """ From the PyGTK Reference manual
 
95
           Say for example the preferences dialog is currently open,
 
96
           and the user chooses Preferences from the menu a second time;
 
97
           use the present() method to move the already-open dialog
 
98
           where the user can see it."""
 
99
        if self.preferences_dialog is not None:
 
100
            logger.debug('show existing preferences_dialog')
 
101
            self.preferences_dialog.present()
 
102
        elif self.PreferencesDialog is not None:
 
103
            logger.debug('create new preferences_dialog')
 
104
            self.preferences_dialog = self.PreferencesDialog() # pylint: disable=E1102
 
105
            self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed)
 
106
            self.preferences_dialog.show()
 
107
        # destroy command moved into dialog to allow for a help button
 
108
 
93
109
    def on_mnu_close_activate(self, widget, data=None):
94
110
        """Signal handler for closing the AccomplishmentsViewerWindow."""
95
111
        self.destroy()
102
118
    def on_preferences_changed(self, settings, key, data=None):
103
119
        logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key))))
104
120
 
 
121
    def on_preferences_dialog_destroyed(self, widget, data=None):
 
122
        '''only affects gui
 
123
        
 
124
        logically there is no difference between the user closing,
 
125
        minimising or ignoring the preferences dialog'''
 
126
        logger.debug('on_preferences_dialog_destroyed')
 
127
        # to determine whether to create or present preferences_dialog
 
128
        self.preferences_dialog = None
 
129