~dpm/qreator/snap

« back to all changes in this revision

Viewing changes to qreator_lib/Window.py

  • Committer: David Planella
  • Date: 2012-06-09 00:06:51 UTC
  • mfrom: (81.2.8 VCARD_support)
  • Revision ID: david.planella@ubuntu.com-20120609000651-ehe6bkiw3d724wc2
Merged VCARD QR code support from lp:stefan-schwarzburg/qreator/VCARD_support, with a bunch of UI changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
### END LICENSE
16
16
 
17
 
### DO NOT EDIT THIS FILE ###
18
 
 
19
 
from gi.repository import Gio, Gtk # pylint: disable=E0611
 
17
from gi.repository import Gtk  # pylint: disable=E0611
20
18
import logging
21
19
logger = logging.getLogger('qreator_lib')
22
20
 
23
 
from . helpers import get_builder, show_uri, get_help_uri
 
21
from . helpers import get_builder
24
22
 
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
64
62
 
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)
67
65
 
68
66
        # Optional application indicator support
69
67
        # Run 'quickly add indicator' to get started.
78
76
        except ImportError:
79
77
            pass
80
78
 
81
 
    def on_mnu_contents_activate(self, widget, data=None):
82
 
        show_uri(self, "ghelp:%s" % get_help_uri())
83
 
 
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()
89
 
            about.destroy()
90
 
 
91
 
    def on_mnu_preferences_activate(self, widget, data=None):
92
 
        """Display the preferences window for qreator."""
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
 
 
109
79
    def on_mnu_close_activate(self, widget, data=None):
110
80
        """Signal handler for closing the QreatorWindow."""
111
81
        self.destroy()
115
85
        # Clean up code for saving application state should be added here.
116
86
        Gtk.main_quit()
117
87
 
118
 
    def on_preferences_changed(self, settings, key, data=None):
119
 
        logger.debug('preference changed: %s = %s' % (key, str(settings.get_value(key))))
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