~thomas-deruyter-3/qreator/qreator

« back to all changes in this revision

Viewing changes to qreator_lib/Window.py

  • Committer: David Planella
  • Date: 2012-05-17 08:12:32 UTC
  • Revision ID: david.planella@ubuntu.com-20120517081232-uq92gvxfji2v68gi
First working version ready for release

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# This file is in the public domain
4
4
### END LICENSE
5
5
 
6
 
from gi.repository import Gio, Gtk # pylint: disable=E0611
 
6
from gi.repository import Gtk  # pylint: disable=E0611
7
7
import logging
8
8
logger = logging.getLogger('qreator_lib')
9
9
 
10
 
from . helpers import get_builder, show_uri, get_help_uri
 
10
from . helpers import get_builder
11
11
 
12
12
# This class is meant to be subclassed by QreatorWindow.  It provides
13
13
# common functions and some boilerplate.
52
52
        ##self.settings = Gio.Settings("net.launchpad.qreator")
53
53
        ##self.settings.connect('changed', self.on_preferences_changed)
54
54
 
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
 
        try:
60
 
            from gi.repository import LaunchpadIntegration # pylint: disable=E0611
61
 
            LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
62
 
            LaunchpadIntegration.set_sourcepackagename('qreator')
63
 
        except ImportError:
64
 
            pass
65
 
 
66
55
        # Optional application indicator support
67
56
        # Run 'quickly add indicator' to get started.
68
57
        # More information:
76
65
        except ImportError:
77
66
            pass
78
67
 
79
 
    def on_mnu_contents_activate(self, widget, data=None):
80
 
        show_uri(self, "ghelp:%s" % get_help_uri())
81
 
 
82
 
    def on_mnu_about_activate(self, widget, data=None):
83
 
        """Display the about box for qreator."""
84
 
        if self.AboutDialog is not None:
85
 
            about = self.AboutDialog() # pylint: disable=E1102
86
 
            response = about.run()
87
 
            about.destroy()
88
 
 
89
 
    def on_mnu_preferences_activate(self, widget, data=None):
90
 
        """Display the preferences window for qreator."""
91
 
 
92
 
        """ From the PyGTK Reference manual
93
 
           Say for example the preferences dialog is currently open,
94
 
           and the user chooses Preferences from the menu a second time;
95
 
           use the present() method to move the already-open dialog
96
 
           where the user can see it."""
97
 
        if self.preferences_dialog is not None:
98
 
            logger.debug('show existing preferences_dialog')
99
 
            self.preferences_dialog.present()
100
 
        elif self.PreferencesDialog is not None:
101
 
            logger.debug('create new preferences_dialog')
102
 
            self.preferences_dialog = self.PreferencesDialog() # pylint: disable=E1102
103
 
            self.preferences_dialog.connect('destroy', self.on_preferences_dialog_destroyed)
104
 
            self.preferences_dialog.show()
105
 
        # destroy command moved into dialog to allow for a help button
106
 
 
107
68
    def on_mnu_close_activate(self, widget, data=None):
108
69
        """Signal handler for closing the QreatorWindow."""
109
70
        self.destroy()
113
74
        # Clean up code for saving application state should be added here.
114
75
        Gtk.main_quit()
115
76
 
116
 
    def on_preferences_changed(self, settings, key, data=None):
117
 
        logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key))))
118
 
 
119
 
    def on_preferences_dialog_destroyed(self, widget, data=None):
120
 
        '''only affects gui
121
 
        
122
 
        logically there is no difference between the user closing,
123
 
        minimising or ignoring the preferences dialog'''
124
 
        logger.debug('on_preferences_dialog_destroyed')
125
 
        # to determine whether to create or present preferences_dialog
126
 
        self.preferences_dialog = None
127