36
36
_ = gettext.gettext
38
38
class MainWin(gtk.Window):
39
def __init__(self, Context):
40
gtk.Window.__init__(self)
41
self.ShowingPlugin = None
42
self.Context = Context
43
self.connect("destroy", self.Quit)
44
self.set_default_size(960, 580)
45
self.set_title(_("CompizConfig Settings Manager"))
47
self.set_icon (gtk.gdk.pixbuf_new_from_file(IconDir+"/apps/ccsm.svg"))
54
self.MainBox = gtk.HBox()
55
self.add(self.MainBox)
56
self.LeftPane = gtk.Alignment()
57
self.LeftPane.set_size_request(230, 520)
58
self.RightPane = gtk.Alignment()
59
self.RightPane.set_border_width(5)
60
self.RightPane.props.yscale = 1
61
self.RightPane.props.xscale = 1
62
self.RightPane.props.xalign = 0
63
self.RightPane.props.yalign = 0
64
self.LeftPane.props.yscale = 1
65
self.LeftPane.props.xscale = 1
66
self.LeftPane.props.xalign = 0
67
self.LeftPane.props.yalign = 0
68
self.MainBox.pack_start(self.LeftPane, False, False)
69
self.MainBox.pack_start(self.RightPane, True, True)
71
self.PluginImages = {}
74
for pluginName, plugin in self.Context.Plugins.items():
75
self.PluginImages[pluginName] = Image(plugin.Name, ImagePlugin)
77
for category in sorted(self.Context.Categories, self.CatSortCompare):
78
self.Categories[category] = []
79
for pluginName, plugin in self.Context.Plugins.items():
80
if plugin.Category == category:
81
self.Categories[category].append(plugin)
83
self.BlockEnablePlugin = 0
84
self.ResetMainWidgets()
89
def ResetMainWidgets(self):
90
pluginsVPort = gtk.Viewport()
91
leftChild = gtk.VBox(False, 10)
92
leftChild.set_border_width(15)
96
filterLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Filter")))
97
filterLabel.props.xalign = 0.1
99
filterEntry = sexy.IconEntry()
100
filterEntry.add_clear_button()
102
filterEntry = gtk.Entry()
103
Tooltips.set_tip(filterEntry, _("Filter your Plugin list"))
104
filterEntry.connect("changed", self.FilterTable)
105
leftChild.pack_start(filterLabel, False, False)
106
leftChild.pack_start(filterEntry, False, False)
109
if len(getScreens()) > 1:
110
screenBox = gtk.combo_box_new_text()
111
for screen in getScreens():
112
screenBox.append_text(_("Screen %i") % screen)
113
name = self.Context.CurrentBackend.Name
114
screenBox.set_active(CurrentScreenNum)
115
screenBox.connect("changed", self.ScreenChanged)
116
screenLabel = Label()
117
screenLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Screen")))
118
leftChild.pack_start(screenLabel, False, False)
119
leftChild.pack_start(screenBox, False, False)
122
categoryBox = gtk.VBox()
123
categoryBox.set_border_width(10)
124
for category in sorted(self.Categories, self.CatSortCompare):
125
name = category or _("Uncategorized")
126
categoryToggleLabel = Label(name)
127
categoryToggle = gtk.Button()
128
categoryToggle.set_relief(gtk.RELIEF_NONE)
129
categoryToggle.add(categoryToggleLabel)
130
categoryToggle.connect("clicked", self.ToggleCategory, category)
131
categoryBox.pack_start(categoryToggle, False, False)
132
categoryLabel = Label()
133
categoryLabel.props.xalign = 0.1
134
categoryLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Category")))
135
leftChild.pack_start(categoryLabel, False, False)
136
leftChild.pack_start(categoryBox, False, False)
139
exitButton = gtk.Button(gtk.STOCK_CLOSE)
140
exitButton.set_use_stock(True)
141
exitButton.connect('clicked', self.Quit)
142
leftChild.pack_end(exitButton, False, False)
145
searchLabel = Label()
146
searchLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Advanced Search")))
147
searchImage = gtk.Image()
148
searchImage.set_from_stock(gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_BUTTON)
149
searchButton = gtk.Button()
150
searchButton.connect("clicked", self.ShowAdvancedFilter)
151
searchButton.set_relief(gtk.RELIEF_NONE)
152
searchFrame = gtk.HBox()
153
searchFrame.pack_start(searchLabel, False, False)
154
searchFrame.pack_end(searchImage, False, False)
155
searchButton.add(searchFrame)
156
leftChild.pack_end(searchButton, False, False)
160
prefLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Preferences")))
161
prefImage = gtk.Image()
162
prefImage.set_from_stock(gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_BUTTON)
163
prefButton = gtk.Button()
164
prefButton.connect("clicked", self.ShowPreferences)
165
prefButton.set_relief(gtk.RELIEF_NONE)
166
prefFrame = gtk.HBox()
167
prefFrame.pack_start(prefLabel, False, False)
168
prefFrame.pack_end(prefImage, False, False)
169
prefButton.add(prefFrame)
170
leftChild.pack_end(prefButton, False, False)
172
pluginsVPort.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.Style.BackgroundColor))
173
rightChild = gtk.ScrolledWindow()
174
rightChild.props.hscrollbar_policy = gtk.POLICY_NEVER
175
rightChild.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
176
rightChild.set_size_request(280,-1)
177
rightChild.add(pluginsVPort)
178
self.BuildTable(pluginsVPort)
179
rightChild.connect('size-allocate', self.RebuildTable)
180
self.SetMainWidgets(leftChild, rightChild)
182
def BuildTable(self, viewPort):
183
pluginWindow = gtk.VBox()
184
pluginWindow.set_border_width(10)
185
viewPort.add(pluginWindow)
188
self.TableAttached = False
190
for category in sorted(self.Categories, self.CatSortCompare):
191
pluginList = sorted(self.Categories[category], PluginSortCompare)
192
categoryBox = gtk.VBox()
193
categoryHeader = gtk.HBox()
194
categoryHeader.set_spacing(10)
195
categoryLabel = Label('', -1)
196
pluginWindow.pack_start(categoryBox, False, False)
198
name = category or _("Uncategorized")
199
categoryLabel.set_markup("<span color='#aaa' size='x-large' weight='800'>%s</span>" % name)
200
categoryImg = Image(name.lower().replace(" ", "_"), ImageCategory)
202
categoryHeader.pack_start(categoryImg, False, False)
203
categoryHeader.pack_start(categoryLabel, False, False)
204
categoryBox.pack_start(categoryHeader, False, False)
206
categoryTab = gtk.Table()
207
categoryTab.set_border_width(10)
208
self.TableCats[category] = (categoryTab, [], [])
209
categoryBox.pack_start(categoryTab, False, False)
211
for plugin in pluginList:
212
pluginButton = gtk.Button()
213
pluginButton.connect('clicked', self.ShowPlugin, plugin)
214
pluginButton.set_size_request(200, -1)
215
pluginButton.set_relief(gtk.RELIEF_NONE)
216
pluginButtonBox = gtk.HBox(False, 10)
217
pluginButtonBox.set_border_width(10)
218
pluginImage = self.PluginImages[plugin.Name]
219
pluginLabel = Label(plugin.ShortDesc, 120)
220
pluginButtonBox.pack_start(pluginImage, False, False)
221
pluginButtonBox.pack_start(pluginLabel, True, True)
222
pluginButton.add(pluginButtonBox)
223
pluginBox = gtk.HBox()
225
if plugin.Name != 'core':
226
pluginEnable = gtk.CheckButton()
227
Tooltips.set_tip(pluginEnable, _("Enable %s") % plugin.ShortDesc)
228
pluginEnable.set_active(plugin.Enabled)
229
pluginEnable.connect("toggled", self.EnablePlugin, plugin)
230
pluginEnable.set_sensitive(self.Context.AutoSort)
231
pluginBox.pack_start(pluginEnable, False, False)
233
Tooltips.set_tip(pluginButton, plugin.LongDesc)
234
pluginBox.pack_start(pluginButton, True, True)
235
pluginBox.set_size_request(220, -1)
236
self.TableCats[category][1].append(pluginBox)
237
self.TableCats[category][2].append(plugin)
240
# 0 = plugin name and short description
241
# 1 = plugin long description
243
def FilterTable(self, widget, target=0):
244
text = widget.get_text().lower()
248
if self.TableAttached:
249
for categoryName, categoryContainer in self.TableCats.items():
250
for pluginButton in categoryContainer[1]:
251
if pluginButton.get_parent():
252
categoryContainer[0].remove(pluginButton)
254
for categoryName, categoryContainer in self.TableCats.items():
258
for pluginButton in categoryContainer[1]:
259
index = categoryContainer[1].index(pluginButton)
260
shortDesc = categoryContainer[2][index].ShortDesc.lower()
261
longDesc = categoryContainer[2][index].LongDesc.lower()
262
name = categoryContainer[2][index].Name.lower()
263
category = categoryName.lower()
267
show = name.find(text) != -1 \
268
or shortDesc.find(text) != -1
270
show = name.find(text) != -1 \
271
or shortDesc.find(text) != -1 \
272
or longDesc.find(text) != -1
274
show = category.find(text) != -1
279
categoryContainer[0].attach(pluginButton, col, col+1, row, row+1, 0)
285
categoryContainer[0].get_parent().set_no_show_all(True)
286
categoryContainer[0].get_parent().hide()
288
categoryContainer[0].get_parent().set_no_show_all(False)
289
categoryContainer[0].attach(gtk.Label(), cols+5, cols+6, 0, 1, gtk.EXPAND)
291
# Search in long description
292
if not foundPlugin and target == 0:
293
self.FilterTable(widget, 1)
295
elif not foundPlugin and target == 1:
296
self.FilterTable(widget, 2)
297
# Nothing found -- Ported from Gnome-Control-Center.
298
elif not foundPlugin and target == 2:
300
# Already created only update message
301
if not self.TableAttached:
302
notFound = self.RightPane.get_child().get_child().get_child().get_children()[-1]
303
notFound.update(text)
306
self.TableAttached = False
308
box = self.RightPane.get_child().get_child().get_child()
309
notFound = NotFoundBox(text)
310
box.pack_start(notFound, True, False)
313
# Something found, display it
315
# Clean up not found Message
316
if not self.TableAttached:
317
self.RightPane.get_child().get_child().get_child().get_children()[-1].destroy()
319
self.TableAttached = True
322
def RebuildTable(self, widget, request):
323
cols = (request.width - 60) / 220
324
if cols == self.LastCols:
328
if self.TableAttached:
329
for categoryName, categoryContainer in self.TableCats.items():
330
for pluginButton in categoryContainer[1]:
331
categoryContainer[0].remove(pluginButton)
333
for categoryName, categoryContainer in self.TableCats.items():
336
for pluginButton in categoryContainer[1]:
337
categoryContainer[0].attach(pluginButton, col, col+1, row, row+1, 0)
342
categoryContainer[0].attach(gtk.Label(), cols+5, cols+6, 0, 1, gtk.EXPAND)
343
self.TableAttached = True
345
self.RightPane.get_child().props.vadjustment.value = self.RightVadj
347
def SetMainWidgets(self, leftWidget, rightWidget):
348
pane = self.LeftPane.get_child()
351
pane = self.RightPane.get_child()
354
self.LeftPane.add(leftWidget)
355
self.RightPane.add(rightWidget)
358
def CatSortCompare(self, v1, v2):
361
if self.Context.Plugins['core'].Category == v1:
362
return cmp('', v2 or 'zzzzzzzz')
363
if self.Context.Plugins['core'].Category == v2:
364
return cmp(v1 or 'zzzzzzz', '')
365
return cmp(v1 or 'zzzzzzzz', v2 or 'zzzzzzzz')
367
def ShowPlugin(self, obj, select):
368
self.RightVadj = self.RightPane.get_child().get_vadjustment().get_value()
369
for name, value in self.PluginImages.items():
370
widget = value.get_parent()
373
pluginPage = PluginPage(select, self)
374
self.ShowingPlugin = pluginPage
375
self.SetMainWidgets(pluginPage.LeftWidget, pluginPage.RightWidget)
377
def ShowAdvancedFilter(self, widget, run=0):
378
if run == 0: # Well thats rather a hack but it works...
379
self.TitleBuffer = self.get_title()
380
self.set_title(self.TitleBuffer + " - Loading...")
381
gobject.timeout_add(100, self.ShowAdvancedFilter, widget, 1)
384
self.RightVadj = self.RightPane.get_child().get_vadjustment().get_value()
385
for name, value in self.PluginImages.items():
386
widget = value.get_parent()
389
filterPage = FilterPage(self, self.Context)
390
self.SetMainWidgets(filterPage.LeftWidget, filterPage.RightWidget)
392
self.set_title(self.TitleBuffer)
393
self.TitleBuffer = False
397
def ShowPreferences(self, widget):
398
self.RightVadj = self.RightPane.get_child().get_vadjustment().get_value()
399
for name, value in self.PluginImages.items():
400
widget = value.get_parent()
403
preferencesPage = PreferencesPage(self, self.Context)
404
self.SetMainWidgets(preferencesPage.LeftWidget, preferencesPage.RightWidget)
406
def UpdatePlugins(self):
407
for category, container, plugins in self.TableCats.values():
408
for i in range(len(plugins)):
409
if plugins[i].Name != 'core':
410
check = container[i].get_children()[0]
411
self.BlockEnablePlugin += 1
412
check.set_active(plugins[i].Enabled)
413
self.BlockEnablePlugin -= 1
415
def EnablePlugin(self, widget, plugin):
416
if self.BlockEnablePlugin > 0:
419
# attempt to resolve conflicts...
420
conflicts = plugin.Enabled and plugin.DisableConflicts or plugin.EnableConflicts
421
conflict = PluginConflict(plugin, conflicts)
422
if conflict.Resolve():
423
plugin.Enabled = widget.get_active()
426
widget.set_active(plugin.Enabled)
427
plugin.Context.Write()
429
def ToggleCategory(self, widget, category):
430
categoryContainer = self.TableCats[category]
431
categoryY = categoryContainer[0].get_parent().get_allocation().y
432
parentY = self.RightPane.get_child().get_allocation().y
433
parentHeight = self.RightPane.get_child().get_allocation().height
434
categoryBox = self.RightPane.get_child().get_child().get_child()
435
boxHeight = categoryBox.get_allocation().height
436
posY = categoryY - parentY
437
neededHeight = posY + parentHeight
438
if neededHeight > boxHeight:
439
posY = boxHeight - parentHeight
440
self.RightPane.get_child().props.vadjustment.value = posY
442
def ScreenChanged(self, widget):
444
self.CurrentScreenNum = widget.get_active()
447
def BackToMain(self, obj):
448
self.VisibleSettings = []
449
self.ResetMainWidgets()
450
del self.ShowingPlugin
451
# make sure its cleaned up here, since this is a nice safe place to do so
452
self.ShowingPlugin = None
39
def __init__(self, Context):
40
gtk.Window.__init__(self)
41
self.ShowingPlugin = None
42
self.Context = Context
43
self.connect("destroy", self.Quit)
44
self.set_default_size(960, 580)
45
self.set_title(_("CompizConfig Settings Manager"))
47
self.set_icon (gtk.gdk.pixbuf_new_from_file(IconDir+"/apps/ccsm.svg"))
54
self.MainBox = gtk.HBox()
55
self.add(self.MainBox)
56
self.LeftPane = gtk.Alignment()
57
self.LeftPane.set_size_request(230, 520)
58
self.RightPane = gtk.Alignment()
59
self.RightPane.set_border_width(5)
60
self.RightPane.props.yscale = 1
61
self.RightPane.props.xscale = 1
62
self.RightPane.props.xalign = 0
63
self.RightPane.props.yalign = 0
64
self.LeftPane.props.yscale = 1
65
self.LeftPane.props.xscale = 1
66
self.LeftPane.props.xalign = 0
67
self.LeftPane.props.yalign = 0
68
self.MainBox.pack_start(self.LeftPane, False, False)
69
self.MainBox.pack_start(self.RightPane, True, True)
71
self.PluginImages = {}
74
for pluginName, plugin in self.Context.Plugins.items():
75
self.PluginImages[pluginName] = Image(plugin.Name, ImagePlugin)
77
for category in sorted(self.Context.Categories, self.CatSortCompare):
78
self.Categories[category] = []
79
for pluginName, plugin in self.Context.Plugins.items():
80
if plugin.Category == category:
81
self.Categories[category].append(plugin)
83
self.BlockEnablePlugin = 0
84
self.ResetMainWidgets()
86
def Quit(self, *args):
89
def ResetMainWidgets(self):
90
pluginsVPort = gtk.Viewport()
91
leftChild = gtk.VBox(False, 10)
92
leftChild.set_border_width(15)
96
filterLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Filter")))
97
filterLabel.props.xalign = 0.1
99
filterEntry = sexy.IconEntry()
100
filterEntry.add_clear_button()
102
filterEntry = gtk.Entry()
103
Tooltips.set_tip(filterEntry, _("Filter your Plugin list"))
104
filterEntry.connect("changed", self.FilterTable)
105
leftChild.pack_start(filterLabel, False, False)
106
leftChild.pack_start(filterEntry, False, False)
109
if len(getScreens()) > 1:
110
screenBox = gtk.combo_box_new_text()
111
for screen in getScreens():
112
screenBox.append_text(_("Screen %i") % screen)
113
name = self.Context.CurrentBackend.Name
114
screenBox.set_active(CurrentScreenNum)
115
screenBox.connect("changed", self.ScreenChanged)
116
screenLabel = Label()
117
screenLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Screen")))
118
leftChild.pack_start(screenLabel, False, False)
119
leftChild.pack_start(screenBox, False, False)
122
categoryBox = gtk.VBox()
123
categoryBox.set_border_width(10)
124
for category in sorted(self.Categories, self.CatSortCompare):
125
name = category or _("Uncategorized")
126
categoryToggleLabel = Label(name)
127
categoryToggle = PrettyButton()
128
categoryToggle.set_relief(gtk.RELIEF_NONE)
129
categoryToggle.add(categoryToggleLabel)
130
categoryToggle.connect("clicked", self.ToggleCategory, category)
131
categoryBox.pack_start(categoryToggle, False, False)
132
categoryLabel = Label()
133
categoryLabel.props.xalign = 0.1
134
categoryLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Category")))
135
leftChild.pack_start(categoryLabel, False, False)
136
leftChild.pack_start(categoryBox, False, False)
139
exitButton = gtk.Button(gtk.STOCK_CLOSE)
140
exitButton.set_use_stock(True)
141
exitButton.connect('clicked', self.Quit)
142
leftChild.pack_end(exitButton, False, False)
145
searchLabel = Label()
146
searchLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Advanced Search")))
147
searchImage = gtk.Image()
148
searchImage.set_from_stock(gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_BUTTON)
149
searchButton = gtk.Button()
150
searchButton.connect("clicked", self.ShowAdvancedFilter)
151
searchButton.set_relief(gtk.RELIEF_NONE)
152
searchFrame = gtk.HBox()
153
searchFrame.pack_start(searchLabel, False, False)
154
searchFrame.pack_end(searchImage, False, False)
155
searchButton.add(searchFrame)
156
leftChild.pack_end(searchButton, False, False)
160
prefLabel.set_markup("<span color='%s' size='large' weight='800'>%s</span>" % (self.Style.BrightColor, _("Preferences")))
161
prefImage = gtk.Image()
162
prefImage.set_from_stock(gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_BUTTON)
163
prefButton = gtk.Button()
164
prefButton.connect("clicked", self.ShowPreferences)
165
prefButton.set_relief(gtk.RELIEF_NONE)
166
prefFrame = gtk.HBox()
167
prefFrame.pack_start(prefLabel, False, False)
168
prefFrame.pack_end(prefImage, False, False)
169
prefButton.add(prefFrame)
170
leftChild.pack_end(prefButton, False, False)
172
pluginsVPort.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.Style.BackgroundColor))
173
rightChild = gtk.ScrolledWindow()
174
rightChild.props.hscrollbar_policy = gtk.POLICY_NEVER
175
rightChild.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC
176
rightChild.set_size_request(280,-1)
177
pluginsVPort.set_focus_vadjustment (rightChild.get_vadjustment ())
178
rightChild.add(pluginsVPort)
179
self.BuildTable(pluginsVPort)
180
rightChild.connect('size-allocate', self.RebuildTable)
181
self.SetMainWidgets(leftChild, rightChild)
183
def BuildTable(self, viewPort):
184
pluginWindow = gtk.VBox()
185
pluginWindow.set_border_width(10)
186
viewPort.add(pluginWindow)
189
self.TableAttached = False
191
for category in sorted(self.Categories, self.CatSortCompare):
192
pluginList = sorted(self.Categories[category], PluginSortCompare)
193
categoryBox = gtk.VBox()
194
categoryHeader = gtk.HBox()
195
categoryHeader.set_spacing(10)
196
categoryLabel = Label('', -1)
197
pluginWindow.pack_start(categoryBox, False, False)
199
name = category or _("Uncategorized")
200
categoryLabel.set_markup("<span color='#aaa' size='x-large' weight='800'>%s</span>" % name)
201
categoryImg = Image(name.lower().replace(" ", "_"), ImageCategory)
203
categoryHeader.pack_start(categoryImg, False, False)
204
categoryHeader.pack_start(categoryLabel, False, False)
205
categoryBox.pack_start(categoryHeader, False, False)
207
categoryTab = gtk.Table()
208
categoryTab.set_border_width(10)
209
self.TableCats[category] = (categoryTab, [], [])
210
categoryBox.pack_start(categoryTab, False, False)
212
for plugin in pluginList:
213
pluginButton = PrettyButton ()
214
pluginButton.connect('clicked', self.ShowPlugin, plugin)
215
pluginButton.set_size_request(200, -1)
216
pluginButtonBox = gtk.HBox(False, 10)
217
pluginButtonBox.set_border_width(10)
218
pluginImage = self.PluginImages[plugin.Name]
219
pluginLabel = Label(plugin.ShortDesc, 120)
220
pluginButtonBox.pack_start(pluginImage, False, False)
221
pluginButtonBox.pack_start(pluginLabel, True, True)
222
pluginButton.add(pluginButtonBox)
223
pluginBox = gtk.HBox()
225
if plugin.Name != 'core':
226
pluginEnable = gtk.CheckButton()
227
Tooltips.set_tip(pluginEnable, _("Enable %s") % plugin.ShortDesc)
228
pluginEnable.set_active(plugin.Enabled)
229
pluginEnable.connect("toggled", self.EnablePlugin, plugin)
230
pluginEnable.set_sensitive(self.Context.AutoSort)
231
pluginBox.pack_start(pluginEnable, False, False)
233
Tooltips.set_tip(pluginButton, plugin.LongDesc)
234
pluginBox.pack_start(pluginButton, True, True)
235
pluginBox.set_size_request(220, -1)
236
self.TableCats[category][1].append(pluginBox)
237
self.TableCats[category][2].append(plugin)
240
# 0 = plugin name and short description
241
# 1 = plugin long description
243
def FilterTable(self, widget, target=0):
244
text = widget.get_text().lower()
248
if self.TableAttached:
249
for categoryName, categoryContainer in self.TableCats.items():
250
for pluginButton in categoryContainer[1]:
251
if pluginButton.get_parent():
252
categoryContainer[0].remove(pluginButton)
254
for categoryName, categoryContainer in self.TableCats.items():
258
for pluginButton in categoryContainer[1]:
259
index = categoryContainer[1].index(pluginButton)
260
shortDesc = categoryContainer[2][index].ShortDesc.lower()
261
longDesc = categoryContainer[2][index].LongDesc.lower()
262
name = categoryContainer[2][index].Name.lower()
263
category = categoryName.lower()
267
show = name.find(text) != -1 \
268
or shortDesc.find(text) != -1
270
show = name.find(text) != -1 \
271
or shortDesc.find(text) != -1 \
272
or longDesc.find(text) != -1
274
show = category.find(text) != -1
279
categoryContainer[0].attach(pluginButton, col, col+1, row, row+1, 0)
285
categoryContainer[0].get_parent().set_no_show_all(True)
286
categoryContainer[0].get_parent().hide()
288
categoryContainer[0].get_parent().set_no_show_all(False)
289
categoryContainer[0].attach(gtk.Label(), cols+5, cols+6, 0, 1, gtk.EXPAND)
291
# Search in long description
292
if not foundPlugin and target == 0:
293
self.FilterTable(widget, 1)
295
elif not foundPlugin and target == 1:
296
self.FilterTable(widget, 2)
297
# Nothing found -- Ported from Gnome-Control-Center.
298
elif not foundPlugin and target == 2:
300
# Already created only update message
301
if not self.TableAttached:
302
notFound = self.RightPane.get_child().get_child().get_child().get_children()[-1]
303
notFound.update(text)
306
self.TableAttached = False
308
box = self.RightPane.get_child().get_child().get_child()
309
notFound = NotFoundBox(text)
310
box.pack_start(notFound, True, False)
313
# Something found, display it
315
# Clean up not found Message
316
if not self.TableAttached:
317
self.RightPane.get_child().get_child().get_child().get_children()[-1].destroy()
319
self.TableAttached = True
322
def RebuildTable(self, widget, request):
323
cols = (request.width - 60) / 220
324
if cols == self.LastCols:
328
if self.TableAttached:
329
for categoryName, categoryContainer in self.TableCats.items():
330
for pluginButton in categoryContainer[1]:
331
categoryContainer[0].remove(pluginButton)
333
for categoryName, categoryContainer in self.TableCats.items():
336
for pluginButton in categoryContainer[1]:
337
categoryContainer[0].attach(pluginButton, col, col+1, row, row+1, 0)
342
categoryContainer[0].attach(gtk.Label(), cols+5, cols+6, 0, 1, gtk.EXPAND)
343
self.TableAttached = True
345
self.RightPane.get_child().props.vadjustment.value = self.RightVadj
347
def SetMainWidgets(self, leftWidget, rightWidget):
348
pane = self.LeftPane.get_child()
351
pane = self.RightPane.get_child()
354
self.LeftPane.add(leftWidget)
355
self.RightPane.add(rightWidget)
358
def CatSortCompare(self, v1, v2):
361
if self.Context.Plugins['core'].Category == v1:
362
return cmp('', v2 or 'zzzzzzzz')
363
if self.Context.Plugins['core'].Category == v2:
364
return cmp(v1 or 'zzzzzzz', '')
365
return cmp(v1 or 'zzzzzzzz', v2 or 'zzzzzzzz')
367
def ShowPlugin(self, obj, select):
368
self.RightVadj = self.RightPane.get_child().get_vadjustment().get_value()
369
for name, value in self.PluginImages.items():
370
widget = value.get_parent()
373
pluginPage = PluginPage(select, self)
374
self.ShowingPlugin = pluginPage
375
self.SetMainWidgets(pluginPage.LeftWidget, pluginPage.RightWidget)
377
def ShowAdvancedFilter(self, widget, run=0):
378
if run == 0: # Well thats rather a hack but it works...
379
self.TitleBuffer = self.get_title()
380
self.set_title(self.TitleBuffer + " - Loading...")
381
gobject.timeout_add(100, self.ShowAdvancedFilter, widget, 1)
384
self.RightVadj = self.RightPane.get_child().get_vadjustment().get_value()
385
for name, value in self.PluginImages.items():
386
widget = value.get_parent()
389
filterPage = FilterPage(self, self.Context)
390
self.SetMainWidgets(filterPage.LeftWidget, filterPage.RightWidget)
392
self.set_title(self.TitleBuffer)
393
self.TitleBuffer = False
397
def ShowPreferences(self, widget):
398
self.RightVadj = self.RightPane.get_child().get_vadjustment().get_value()
399
for name, value in self.PluginImages.items():
400
widget = value.get_parent()
403
preferencesPage = PreferencesPage(self, self.Context)
404
self.SetMainWidgets(preferencesPage.LeftWidget, preferencesPage.RightWidget)
406
def UpdatePlugins(self):
407
for category, container, plugins in self.TableCats.values():
408
for i in range(len(plugins)):
409
if plugins[i].Name != 'core':
410
check = container[i].get_children()[0]
411
self.BlockEnablePlugin += 1
412
check.set_active(plugins[i].Enabled)
413
self.BlockEnablePlugin -= 1
415
def EnablePlugin(self, widget, plugin):
416
if self.BlockEnablePlugin > 0:
419
# attempt to resolve conflicts...
420
conflicts = plugin.Enabled and plugin.DisableConflicts or plugin.EnableConflicts
421
conflict = PluginConflict(plugin, conflicts)
422
if conflict.Resolve():
423
plugin.Enabled = widget.get_active()
426
self.BlockEnablePlugin += 1
427
widget.set_active(plugin.Enabled)
428
self.BlockEnablePlugin -= 1
429
plugin.Context.Write()
431
def ToggleCategory(self, widget, category):
432
categoryContainer = self.TableCats[category]
433
categoryY = categoryContainer[0].get_parent().get_allocation().y
434
parentY = self.RightPane.get_child().get_allocation().y
435
parentHeight = self.RightPane.get_child().get_allocation().height
436
categoryBox = self.RightPane.get_child().get_child().get_child()
437
boxHeight = categoryBox.get_allocation().height
438
posY = categoryY - parentY
439
neededHeight = posY + parentHeight
440
if neededHeight > boxHeight:
441
posY = boxHeight - parentHeight
442
self.RightPane.get_child().props.vadjustment.value = posY
444
def ScreenChanged(self, widget):
446
self.CurrentScreenNum = widget.get_active()
449
def BackToMain(self, obj):
450
self.VisibleSettings = []
451
self.ResetMainWidgets()
452
del self.ShowingPlugin
453
# make sure its cleaned up here, since this is a nice safe place to do so
454
self.ShowingPlugin = None