14
14
# with this program. If not, see <http://www.gnu.org/licenses/>.
17
### DO NOT EDIT THIS FILE ###
19
from gi.repository import Gio, Gtk # pylint: disable=E0611
17
from gi.repository import Gtk # pylint: disable=E0611
21
19
logger = logging.getLogger('qreator_lib')
23
from . helpers import get_builder, show_uri, get_help_uri
21
from . helpers import get_builder
25
23
# This class is meant to be subclassed by QreatorWindow. It provides
26
24
# common functions and some boilerplate.
62
60
self.preferences_dialog = None # instance
63
61
self.AboutDialog = None # class
65
self.settings = Gio.Settings("net.launchpad.qreator")
66
self.settings.connect('changed', self.on_preferences_changed)
63
##self.settings = Gio.Settings("net.launchpad.qreator")
64
##self.settings.connect('changed', self.on_preferences_changed)
68
66
# Optional application indicator support
69
67
# Run 'quickly add indicator' to get started.
78
76
except ImportError:
81
def on_mnu_contents_activate(self, widget, data=None):
82
show_uri(self, "ghelp:%s" % get_help_uri())
84
def on_mnu_about_activate(self, widget, data=None):
85
"""Display the about box for qreator."""
86
if self.AboutDialog is not None:
87
about = self.AboutDialog() # pylint: disable=E1102
88
response = about.run()
91
def on_mnu_preferences_activate(self, widget, data=None):
92
"""Display the preferences window for qreator."""
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
109
79
def on_mnu_close_activate(self, widget, data=None):
110
80
"""Signal handler for closing the QreatorWindow."""
115
85
# Clean up code for saving application state should be added here.
118
def on_preferences_changed(self, settings, key, data=None):
119
logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key))))
121
def on_preferences_dialog_destroyed(self, widget, data=None):
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