~jendrikseipp/pogo/github-mirror

« back to all changes in this revision

Viewing changes to pogo/gui/preferences.py

  • Committer: GitHub
  • Author(s): Jendrik Seipp
  • Date: 2017-07-16 15:22:48 UTC
  • mfrom: (695.1.4)
  • Revision ID: git-v1:08a9790f5259c0afc6beb390a10358e104e209c9
Merge pull request #42 from jendrikseipp/pep8

Fix code style (PEP8)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
 
32
32
(
33
 
    ROW_ENABLED,    # True if the module is currently enabled
34
 
    ROW_TEXT,       # Name and description of the module
35
 
    ROW_ICON,       # An icon indicating whether the module is configurable
36
 
    ROW_UNLOADABLE, # True if the module can be disabled
37
 
    ROW_INSTANCE,   # Instance of the module, if any
38
 
    ROW_MODINFO     # Information exported by a module
 
33
    ROW_ENABLED,     # True if the module is currently enabled
 
34
    ROW_TEXT,        # Name and description of the module
 
35
    ROW_ICON,        # An icon indicating whether the module is configurable
 
36
    ROW_UNLOADABLE,  # True if the module can be disabled
 
37
    ROW_INSTANCE,    # Instance of the module, if any
 
38
    ROW_MODINFO      # Information exported by a module
39
39
) = list(range(6))
40
40
 
41
41
 
99
99
 
100
100
class Preferences:
101
101
    """ Allow the user to load/unload/configure modules """
 
102
 
102
103
    def __init__(self):
103
104
        from gi.repository import GObject
104
105
 
108
109
 
109
110
        # List of modules
110
111
        toggleRdr = Gtk.CellRendererToggle()
111
 
        columns   = (
112
 
            ('',   [(toggleRdr, GObject.TYPE_BOOLEAN)],             ROW_ENABLED,    False, True),
113
 
            ('',   [(Gtk.CellRendererText(), GObject.TYPE_STRING)], ROW_TEXT,       True,  True),
114
 
            ('',   [(Gtk.CellRendererPixbuf(), GdkPixbuf.Pixbuf)],    ROW_ICON,       False, True),
115
 
            (None, [(None, GObject.TYPE_BOOLEAN)],                  ROW_UNLOADABLE, False, False),
116
 
            (None, [(None, GObject.TYPE_PYOBJECT)],                 ROW_INSTANCE,   False, False),
117
 
            (None, [(None, GObject.TYPE_PYOBJECT)],                 ROW_MODINFO,    False, False))
 
112
        columns = (
 
113
            ('', [(toggleRdr, GObject.TYPE_BOOLEAN)], ROW_ENABLED, False, True),
 
114
            ('', [(Gtk.CellRendererText(), GObject.TYPE_STRING)], ROW_TEXT, True, True),
 
115
            ('', [(Gtk.CellRendererPixbuf(), GdkPixbuf.Pixbuf)], ROW_ICON, False, True),
 
116
            (None, [(None, GObject.TYPE_BOOLEAN)], ROW_UNLOADABLE, False, False),
 
117
            (None, [(None, GObject.TYPE_PYOBJECT)], ROW_INSTANCE, False, False),
 
118
            (None, [(None, GObject.TYPE_PYOBJECT)], ROW_MODINFO, False, False))
118
119
 
119
120
        self.list = PreferencesListView(columns)
120
121
        self.list.set_headers_visible(False)
144
145
        """ Fill the list of modules """
145
146
        rows = []
146
147
        for (name, data) in modules.getModules():
147
 
            instance     = data[modules.MOD_INSTANCE]
148
 
            mandatory    = data[modules.MOD_INFO][modules.MODINFO_MANDATORY]
 
148
            instance = data[modules.MOD_INSTANCE]
 
149
            mandatory = data[modules.MOD_INFO][modules.MODINFO_MANDATORY]
149
150
            configurable = data[modules.MOD_INFO][modules.MODINFO_CONFIGURABLE]
150
151
 
151
152
            if configurable or not mandatory:
153
154
                    icon = icons.prefsBtnIcon()
154
155
                else:
155
156
                    icon = None
156
 
                text = '<b>%s</b>\n<small>%s</small>' % (tools.htmlEscape(_(name)), tools.htmlEscape(data[modules.MOD_INFO][modules.MODINFO_DESC]))
 
157
                text = '<b>%s</b>\n<small>%s</small>' % (
 
158
                    tools.htmlEscape(_(name)),
 
159
                    tools.htmlEscape(data[modules.MOD_INFO][modules.MODINFO_DESC]))
157
160
                rows.append((instance is not None, text, icon, not mandatory, instance, data[modules.MOD_INFO]))
158
161
 
159
162
        rows.sort(key=lambda row: row[ROW_TEXT])
174
177
 
175
178
    def onModuleToggled(self, renderer, path):
176
179
        """ A module has been enabled/disabled """
177
 
        row  = self.list.getRow(path)
 
180
        row = self.list.getRow(path)
178
181
        name = row[ROW_MODINFO][modules.MODINFO_NAME]
179
182
 
180
183
        if row[ROW_ENABLED]:
221
224
 
222
225
__instance = None
223
226
 
 
227
 
224
228
def get_instance():
225
229
    global __instance
226
230