3
3
# This file is in the public domain
6
from gi.repository import Gio, Gtk # pylint: disable=E0611
6
from gi.repository import Gtk # pylint: disable=E0611
8
8
logger = logging.getLogger('qreator_lib')
10
from . helpers import get_builder, show_uri, get_help_uri
10
from . helpers import get_builder
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)
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.
60
from gi.repository import LaunchpadIntegration # pylint: disable=E0611
61
LaunchpadIntegration.add_items(self.ui.helpMenu, 1, True, True)
62
LaunchpadIntegration.set_sourcepackagename('qreator')
66
55
# Optional application indicator support
67
56
# Run 'quickly add indicator' to get started.
68
57
# More information:
76
65
except ImportError:
79
def on_mnu_contents_activate(self, widget, data=None):
80
show_uri(self, "ghelp:%s" % get_help_uri())
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()
89
def on_mnu_preferences_activate(self, widget, data=None):
90
"""Display the preferences window for qreator."""
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
107
68
def on_mnu_close_activate(self, widget, data=None):
108
69
"""Signal handler for closing the QreatorWindow."""
113
74
# Clean up code for saving application state should be added here.
116
def on_preferences_changed(self, settings, key, data=None):
117
logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key))))
119
def on_preferences_dialog_destroyed(self, widget, data=None):
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