-
Notifications
You must be signed in to change notification settings - Fork 40
/
dbx_preference
executable file
·2323 lines (2109 loc) · 101 KB
/
dbx_preference
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python2
# dbx_preference.py
#
# Copyright 2008, 2009, 2010 Aleksey Shaferov and Matias Sars
#
# DockbarX is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DockbarX is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with dockbar. If not, see <http://www.gnu.org/licenses/>.
import pygtk
pygtk.require("2.0")
import gtk
import gconf
import os
from tarfile import open as taropen
from xml.sax import make_parser
from xml.sax.handler import ContentHandler
import dbus
from dockbarx.common import *
from dockbarx.applets import DockXApplets
from dockbarx.theme import PopupStyle, DockTheme
import dockbarx.i18n
_ = dockbarx.i18n.language.gettext
dockbarx.i18n.load_theme_translation()
GCONF_CLIENT = gconf.client_get_default()
GCONF_DIR = "/apps/dockbarx"
class ThemeHandler(ContentHandler):
"""Reads the xml-file into a ODict"""
def __init__(self):
self.dict = ODict()
self.name = None
self.nested_contents = []
self.nested_contents.append(self.dict)
self.nested_attributes = []
def startElement(self, name, attrs):
name = name.lower().encode()
if name == "theme":
for attr in attrs.keys():
if attr.lower() == "name":
self.name = attrs[attr]
return
# Add all attributes to a dictionary
d = {}
for key, value in attrs.items():
# make sure that all text is in lower
# except for file_names
if key.encode().lower() == "file_name":
d[key.encode().lower()] = value.encode()
else:
d[key.encode().lower()] = value.encode().lower()
# Add a ODict to the dictionary in which all
# content will be put.
d["content"] = ODict()
self.nested_contents[-1][name] = d
# Append content ODict to the list so that it
# next element will be put there.
self.nested_contents.append(d["content"])
self.nested_attributes.append(d)
def endElement(self, name):
if name == "theme":
return
# Pop the last element of nested_contents
# so that the new elements won't show up
# as a content to the ended element.
if len(self.nested_contents)>1:
self.nested_contents.pop()
# Remove Content Odict if the element
# had no content.
d = self.nested_attributes.pop()
if d["content"].keys() == []:
d.pop("content")
def get_dict(self):
return self.dict
def get_name(self):
return self.name
class Theme():
@staticmethod
def check(path_to_tar):
#TODO: Optimize this
tar = taropen(path_to_tar)
config = tar.extractfile("config")
parser = make_parser()
theme_handler = ThemeHandler()
try:
parser.setContentHandler(theme_handler)
parser.parse(config)
except:
tar.close()
raise
tar.close()
return theme_handler.get_name()
@staticmethod
def get_info(path_to_tar):
tar = taropen(path_to_tar)
config = tar.extractfile("config")
if "info" in tar.getnames():
f = tar.extractfile("info")
info = f.read()
f.close()
else:
info = None
tar.close()
return info
def __init__(self, path_to_tar):
tar = taropen(path_to_tar)
config = tar.extractfile("config")
# Parse
parser = make_parser()
theme_handler = ThemeHandler()
parser.setContentHandler(theme_handler)
parser.parse(config)
self.theme = theme_handler.get_dict()
# Name
self.name = theme_handler.get_name()
# Popup style
ps = self.theme.get("popup_style", {})
self.default_popup_style = ps.get("file_name", "dbx.tar.gz")
# Colors
self.color_names = {}
self.default_colors = {}
self.default_alphas = {}
colors = {}
if self.theme.has_key("colors"):
colors = self.theme["colors"]["content"]
for i in range(1, 9):
c = "color%s"%i
if colors.has_key(c):
d = colors[c]
if d.has_key("name"):
self.color_names[c] = d["name"]
if d.has_key("default"):
if self.test_color(d["default"]):
self.default_colors[c] = d["default"]
else:
print "Theme error: %s\'s default" % c + \
" for theme %s cannot be read." % self.name
print "A default color should start with an \"#\"" + \
" and be followed by six hex-digits, " + \
"for example \"#FF13A2\"."
if d.has_key("opacity"):
alpha = d["opacity"]
if self.test_alpha(alpha):
self.default_alphas[c] = alpha
else:
print "Theme error: %s\'s opacity" % c + \
" for theme %s cannot be read." % self.name
print "The opacity should be a number (\"0\"-\"100\")" + \
" or the words \"not used\"."
tar.close()
def get_name(self):
return self.name
def get_gap(self):
return int(self.theme["button_pixmap"].get("gap", 0))
def get_windows_cnt(self):
return int(self.theme["button_pixmap"].get("windows_cnt", 1))
def get_aspect_ratio(self):
ar = self.theme["button_pixmap"].get("aspect_ratio", "1")
l = ar.split("/",1)
if len(l) == 2:
ar = float(l[0])/float(l[1])
else:
ar = float(ar)
return ar
def get_default_colors(self):
return self.default_colors
def get_default_alphas(self):
return self.default_alphas
def get_color_names(self):
return self.color_names
def test_color(self, color):
if len(color) != 7:
return False
try:
t = int(color[1:], 16)
except:
return False
return True
def test_alpha(self, alpha):
if "no" in alpha:
return True
try:
t = int(alpha)
except:
return False
if t<0 or t>100:
return False
return True
class AppletsFrame():
def __init__(self):
self.globals = Globals()
self.applets = DockXApplets()
applet_list = self.applets.get_list()
unused_list = self.applets.get_unused_list()
self.box = gtk.VBox(False, 7)
hbox = gtk.HBox()
vbox = gtk.VBox()
self.applet_view = self.create_treeview(applet_list, "Applets", True)
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.add(self.applet_view)
#~ frame = gtk.Frame("Applets in use")
#~ frame.add(sw)
vbox.pack_start(gtk.Label("Applets in use"), False)
vbox.pack_start(sw, True, True)
hbox.pack_start(vbox)
bbox = gtk.VBox()
self.add_button = self.create_image_button(gtk.STOCK_GO_BACK,
self.on_add_button_clicked,
bbox)
self.add_button.set_sensitive(False)
self.remove_button = self.create_image_button(gtk.STOCK_GO_FORWARD,
self.on_remove_button_clicked,
bbox)
self.remove_button.set_sensitive(False)
self.preferences_button = self.create_image_button(
gtk.STOCK_PREFERENCES,
self.on_preferences_button_clicked,
bbox)
self.preferences_button.set_sensitive(False)
reload_button = self.create_image_button(gtk.STOCK_REFRESH,
self.on_reload_button_clicked,
bbox)
ali = gtk.Alignment(0.5, 0.5, 1, 0)
ali.add(bbox)
hbox.pack_start(ali, False, False)
vbox = gtk.VBox()
self.av_applet_view = self.create_treeview(unused_list,
"Available applets",
False, True)
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.add(self.av_applet_view)
vbox.pack_start(gtk.Label("Available applets"), False)
vbox.pack_start(sw, True, True)
#~ frame = gtk.Frame("Available applets")
#~ frame.add(self.av_applet_view)
#~ vbox.pack_start(frame)
hbox.pack_start(vbox)
self.box.pack_start(hbox)
self.textbuffer = self.create_textview(self.box)
self.box.show_all()
def get_box(self):
return self.box
def create_image_button(self, stock, call_func=None, parent=None):
button = gtk.Button()
button.add(gtk.image_new_from_stock(stock,
gtk.ICON_SIZE_LARGE_TOOLBAR))
if call_func:
button.connect("clicked", call_func)
if parent:
parent.pack_start(button, padding=5)
return button
def create_textview(self, parent):
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.set_size_request(-1, 150)
textview = gtk.TextView()
textview.set_wrap_mode(gtk.WRAP_WORD)
sw.add(textview)
if parent:
parent.pack_start(sw, False, False)
return textview.get_buffer()
def create_treeview(self, content, name, reorderable=False, sort=False):
store = gtk.ListStore(str)
self.reload_model(store, content)
tree_view = gtk.TreeView(store)
tree_view.connect("row-activated", self.on_activated)
tree_view.connect("cursor-changed", self.on_cursor_changed)
tree_view.set_headers_visible(False)
#~ tree_view.set_rules_hint(True)
tree_view.set_reorderable(reorderable)
if sort:
store.set_sort_column_id(0, gtk.SORT_ASCENDING)
self.create_columns(tree_view, name)
return tree_view
def reload_model(self, store, content):
store.clear()
for row in content:
store.append([row])
return store
def create_columns(self, tree_view, name):
rendererText = gtk.CellRendererText()
column = gtk.TreeViewColumn(name, rendererText, text=0)
tree_view.append_column(column)
def on_activated(self, treeview, row, col):
self.on_preferences_button_clicked()
def on_cursor_changed(self, treeview):
# Set description.
s = treeview.get_selection()
model, i = s.get_selected()
if i is None:
self.textbuffer.set_text("")
return
name = model[i][0]
description = _(self.applets.get_description(name))
if name == "Spacer":
description = "Makes some empty space between applets when the dock type is set to panel."
elif name == "DockbarX":
description = ""
self.textbuffer.set_text("%s\n\n%s" % (name, description))
# Set the buttons sensitivities
if treeview == self.applet_view:
self.remove_button.set_sensitive(name != "DockbarX")
self.add_button.set_sensitive(False)
if not name in ("DockbarX", "Spacer") and \
hasattr(self.applets.get(name), "run_applet_dialog"):
self.preferences_button.set_sensitive(True)
else:
self.preferences_button.set_sensitive(False)
other_selection = self.av_applet_view.get_selection()
else:
self.remove_button.set_sensitive(False)
self.add_button.set_sensitive(True)
self.preferences_button.set_sensitive(False)
other_selection = self.applet_view.get_selection()
# Unselect selection in the other treeview.
if other_selection.get_selected()[1] is not None:
other_selection.unselect_all()
def on_add_button_clicked(self, *args):
s = self.av_applet_view.get_selection()
model, i = s.get_selected()
if i is None:
return
applet = model[i][0]
model.remove(i)
self.applet_view.get_model().append([applet])
self.textbuffer.set_text("")
self.add_button.set_sensitive(False)
self.remove_button.set_sensitive(False)
self.preferences_button.set_sensitive(False)
def on_remove_button_clicked(self, *args):
s = self.applet_view.get_selection()
model, i = s.get_selected()
if i is None:
return
applet = model[i][0]
model.remove(i)
self.av_applet_view.get_model().append([applet])
self.textbuffer.set_text("")
self.add_button.set_sensitive(False)
self.remove_button.set_sensitive(False)
self.preferences_button.set_sensitive(False)
def on_preferences_button_clicked(self, *args):
s = self.applet_view.get_selection()
model, i = s.get_selected()
if i is None:
return
name = model[i][0]
if name in ("DockbarX", "Spacer"):
return
applet = self.applets.get(name)
if hasattr(applet, "run_applet_dialog"):
self.applets.get(name).run_applet_dialog(name)
def on_reload_button_clicked(self, *args):
applet_list = [applet[0] for applet in self.applet_view.get_model()]
self.applets.set_list(applet_list)
# Reload DockX
obj = BUS.get_object("org.dockbar.DockX", "/org/dockbar/DockX")
iface = dbus.Interface(obj, "org.dockbar.DockX")
func = getattr(iface, "Reload")
if func:
func(reply_handler=self.dbus_reply_handler,
error_handler=self.dbus_reply_handler)
# Refresh lists
applet_list = self.applets.get_list()
unused_list = self.applets.get_unused_list()
self.reload_model(self.applet_view.get_model(), applet_list)
self.reload_model(self.av_applet_view.get_model(), unused_list)
def dbus_reply_handler(*args):
pass
class PrefDialog():
def __init__ (self):
self.globals = Globals()
self.__load_theme()
self.popup_style = PopupStyle()
if self.theme:
self.popup_styles = \
self.popup_style.get_styles(self.theme.get_name())
else:
self.popup_styles = {}
self.dock_theme = DockTheme()
self.dock_themes = self.dock_theme.get_themes()
self.globals.connect("theme-changed", self.__on_theme_changed)
self.globals.connect("preference-update", self.__update)
self.dialog = gtk.Dialog(_("DockBarX preferences"))
self.dialog.connect("response", self.__dialog_close)
self.dialog.set_icon_name("dockbarx")
try:
ca = self.dialog.get_content_area()
except:
ca = self.dialog.vbox
notebook = gtk.Notebook()
notebook.set_tab_pos(gtk.POS_LEFT)
appearance_box = gtk.VBox()
windowbutton_box = gtk.VBox()
groupbutton_box = gtk.VBox()
plugins_box = gtk.VBox()
advanced_box = gtk.VBox()
popup_box = gtk.VBox()
dock_box = gtk.VBox()
self.applets_frame = AppletsFrame()
dock_applets_box = self.applets_frame.get_box()
awn_box = gtk.VBox()
#--- Window item page
hbox = gtk.HBox()
frame = gtk.Frame(_("Window item actions"))
frame.set_border_width(5)
table = gtk.Table(True)
table.set_border_width(5)
self.wb_labels_and_settings = ODict((
(_("Left mouse button"), "windowbutton_left_click_action"),
(_("Shift + left mouse button"),
"windowbutton_shift_and_left_click_action"),
(_("Middle mouse button"),
"windowbutton_middle_click_action"),
(_("Shift + middle mouse button"),
"windowbutton_shift_and_middle_click_action"),
(_("Right mouse button"),
"windowbutton_right_click_action"),
(_("Shift + right mouse button"),
"windowbutton_shift_and_right_click_action"),
(_("Scroll up"), "windowbutton_scroll_up"),
(_("Scroll down"), "windowbutton_scroll_down")
))
self.wb_actions = ODict((
("select or minimize window",
_("select or minimize window")),
("select window", _("select window")),
("maximize window", _("maximize window")),
("close window", _("close window")),
("show menu", _("show menu")),
("shade window", _("shade window")),
("unshade window", _("unshade window")),
("no action", _("no action"))
))
self.wb_combos = {}
for text in self.wb_labels_and_settings:
label = gtk.Label(text)
label.set_alignment(1,0.5)
self.wb_combos[text] = gtk.combo_box_new_text()
for action in self.wb_actions.values():
self.wb_combos[text].append_text(action)
self.wb_combos[text].connect("changed", self.__cb_changed)
row = self.wb_labels_and_settings.get_index(text)
table.attach(label, 0, 1, row, row + 1, xpadding = 5)
table.attach(self.wb_combos[text], 1, 2, row, row + 1 )
self.wb_close_popup_checkbutton_names = [
"windowbutton_close_popup_on_left_click",
"windowbutton_close_popup_on_shift_and_left_click",
"windowbutton_close_popup_on_middle_click",
"windowbutton_close_popup_on_shift_and_middle_click",
"windowbutton_close_popup_on_right_click",
"windowbutton_close_popup_on_shift_and_right_click",
"windowbutton_close_popup_on_scroll_up",
"windowbutton_close_popup_on_scroll_down"]
self.wb_close_popup_checkbutton = {}
for i in range(len(self.wb_close_popup_checkbutton_names)):
name = self.wb_close_popup_checkbutton_names[i]
self.wb_close_popup_checkbutton[name] = \
gtk.CheckButton(_("Close window list"))
self.wb_close_popup_checkbutton[name].connect(
"toggled",
self.__checkbutton_toggled,
name)
table.attach(self.wb_close_popup_checkbutton[name],
2, 3, i, i + 1, xpadding = 5 )
hbox.pack_start(table, False)
frame.add(hbox)
windowbutton_box.pack_start(frame, False, padding=5)
self.show_close_button_cb = gtk.CheckButton(
_("Show close button"))
self.show_close_button_cb.connect("toggled", self.__checkbutton_toggled,
"show_close_button")
self.show_close_button_cb.set_border_width(10)
windowbutton_box.pack_start(self.show_close_button_cb,
False)
#--- Appearance page
hbox = gtk.HBox()
label = gtk.Label(_("Theme:"))
label.set_alignment(1,0.5)
self.theme_combo = gtk.combo_box_new_text()
theme_names = self.themes.keys()
theme_names.sort()
for theme in theme_names:
self.theme_combo.append_text(theme)
button = gtk.Button()
image = gtk.image_new_from_stock(gtk.STOCK_REFRESH,
gtk.ICON_SIZE_SMALL_TOOLBAR)
button.add(image)
button.connect("clicked", self.__set_theme)
info_button = gtk.Button()
image = gtk.image_new_from_stock(gtk.STOCK_INFO,
gtk.ICON_SIZE_SMALL_TOOLBAR)
info_button.add(image)
info_button.connect("clicked", self.__show_theme_info)
hbox.pack_start(label, False, padding=5)
hbox.pack_start(self.theme_combo, False)
hbox.pack_start(info_button, False)
hbox.pack_start(button, False)
appearance_box.pack_start(hbox, False, padding=5)
# Settings and Colors frame
frame = gtk.Frame()
self.theme_settings_frame = frame
frame.set_border_width(5)
table = gtk.Table(True)
align = gtk.Alignment(0.5, 0.5, 0, 0)
hbox = gtk.HBox()
hbox.set_border_width(10)
align.add(hbox)
label = gtk.Label(_("Window list style:"))
label.set_alignment(1,0.5)
self.popup_style_combo = gtk.combo_box_new_text()
style_names = self.popup_styles.keys()
style_names.sort()
for style in style_names:
self.popup_style_combo.append_text(style)
self.popup_style_combo.connect("changed", self.__popup_style_changed)
button = gtk.Button()
image = gtk.image_new_from_stock(gtk.STOCK_CLEAR,
gtk.ICON_SIZE_SMALL_TOOLBAR)
button.add(image)
button.connect("clicked", self.__reset_popup_style)
hbox.pack_start(label, False, padding=5)
hbox.pack_start(self.popup_style_combo, False)
hbox.pack_start(button, False)
table.attach(align, 0,6, 0,1)
self.default_color_names = {
"color1": "Window list background",
"color2": "Normal text",
"color3": "Active window",
"color4": "Minimized window text",
"color5": "Active color",
"color6": "Not used",
"color7": "Not used",
"color8": "Not used" }
if self.theme:
color_names = self.theme.get_color_names()
else:
color_names={}
for i in range(1,9):
color_names["color%s"%i]="Not used"
self.color_labels = {}
self.color_buttons = {}
self.clear_buttons = {}
for i in range(0, 8):
c = "color%s"%(i+1)
self.color_labels[c] = gtk.Label()
self.color_labels[c].set_no_show_all(True)
self.color_labels[c].show()
self.color_labels[c].set_alignment(1,0.5)
self.color_buttons[c] = gtk.ColorButton()
self.color_buttons[c].set_no_show_all(True)
self.color_buttons[c].show()
self.color_buttons[c].connect("color-set", self.__color_set, c)
self.clear_buttons[c] = gtk.Button()
image = gtk.image_new_from_stock(gtk.STOCK_CLEAR,
gtk.ICON_SIZE_SMALL_TOOLBAR)
self.clear_buttons[c].add(image)
self.clear_buttons[c].show_all()
self.clear_buttons[c].set_no_show_all(True)
self.clear_buttons[c].connect("clicked", self.__color_reset, c)
# Every second label + combobox on a new row
row = (i // 2) + 1
# Pack odd numbered comboboxes from 3rd column
column = (i % 2)*3
table.attach(self.color_labels[c], column, column + 1, row,
row + 1, xoptions = gtk.FILL, xpadding = 5)
table.attach(self.color_buttons[c], column+1,
column+2, row, row + 1)
table.attach(self.clear_buttons[c], column+2, column+3,
row, row + 1, xoptions = gtk.FILL)
table.set_border_width(5)
frame.add(table)
appearance_box.pack_start(frame, False, padding=5)
self.__update_color_labels()
# Needs attention effect frame
hbox = gtk.HBox()
frame = gtk.Frame(_("Needs attention effect"))
frame.set_border_width(5)
vbox = gtk.VBox()
vbox.set_border_width(10)
self.rb1_1 = gtk.RadioButton(None, _("Compiz water"))
self.rb1_1.connect("toggled", self.__rb_toggled, "rb1_compwater")
self.rb1_2 = gtk.RadioButton(self.rb1_1, _("Blinking"))
self.rb1_2.connect("toggled", self.__rb_toggled, "rb1_blink")
self.rb1_3 = gtk.RadioButton(self.rb1_1, _("Static"))
self.rb1_3.connect("toggled", self.__rb_toggled, "rb1_red")
self.rb1_4 = gtk.RadioButton(self.rb1_1, _("No effect"))
self.rb1_4.connect("toggled", self.__rb_toggled, "rb1_nothing")
vbox.pack_start(self.rb1_1, False)
vbox.pack_start(self.rb1_2, False)
vbox.pack_start(self.rb1_3, False)
vbox.pack_start(self.rb1_4, False)
frame.add(vbox)
hbox.pack_start(frame, True)
appearance_box.pack_start(hbox, False, padding=5)
self.old_menu_cb = gtk.CheckButton(
_("Use gtk menu (old style) instead of DockbarX style menu."))
self.old_menu_cb.connect("toggled",
self.__checkbutton_toggled, "old_menu")
alignment = gtk.Alignment()
alignment.set_padding(5, 5, 10, 10)
alignment.add(self.old_menu_cb)
appearance_box.pack_start(alignment, False)
bpbox = gtk.HBox()
# Badge frame
frame = gtk.Frame(_("Badge"))
frame.set_border_width(5)
vbox = gtk.VBox()
vbox.set_border_width(10)
label = gtk.Label(_("Custom colors"))
vbox.pack_start(label, False)
table = gtk.Table(True)
self.custom_badge_color_cbs = []
self.badge_color_buttons = []
for i in (0, 1):
text = (_("Text"), _("Background"))[i]
s = ("badge_custom_fg_color", "badge_custom_bg_color")[i]
self.custom_badge_color_cbs.append(gtk.CheckButton(text))
self.custom_badge_color_cbs[i].connect("toggled",
self.__checkbutton_toggled,
s)
self.badge_color_buttons.append(gtk.ColorButton())
text = (_("Custom badge text color"),
_("Custom badge background color"))[i]
s = ("badge_fg", "badge_bg")[i]
self.badge_color_buttons[i].set_title(text)
self.badge_color_buttons[i].set_use_alpha(True)
self.badge_color_buttons[i].connect("color-set",
self.__bp_color_set, s)
table.attach(self.custom_badge_color_cbs[i], 0, 1, i, i + 1,
xoptions = gtk.FILL, xpadding = 5)
table.attach(self.badge_color_buttons[i], 1, 2, i, i + 1)
vbox.pack_start(table, False)
bfbox = gtk.HBox()
self.custom_badge_cb = gtk.CheckButton(_("Custom font and size"))
self.custom_badge_cb.connect("toggled", self.__checkbutton_toggled,
"badge_use_custom_font")
bfbox.pack_start(self.custom_badge_cb, False)
self.badge_font_button = gtk.FontButton()
self.badge_font_button.set_use_font(True)
self.badge_font_button.set_use_size(True)
self.badge_font_button.set_show_style(True)
self.badge_font_button.set_title(_("Badge font"))
self.badge_font_button.connect("font_set", self.__set_font,
"badge_font")
bfbox.pack_start(self.badge_font_button, False, padding=5)
vbox.pack_start(bfbox, False, padding = 5)
frame.add(vbox)
bpbox.pack_start(frame)
# Progress frame
frame = gtk.Frame(_("Progress bar"))
frame.set_border_width(5)
vbox = gtk.VBox()
vbox.set_border_width(10)
label = gtk.Label(_("Custom colors"))
vbox.pack_start(label, False)
table = gtk.Table(True)
self.custom_progress_color_cbs = []
self.progress_color_buttons = []
for i in (0, 1):
text = (_("Foreground"), _("Background"))[i]
s = ("progress_custom_fg_color",
"progress_custom_bg_color")[i]
self.custom_progress_color_cbs.append(gtk.CheckButton(text))
self.custom_progress_color_cbs[i].connect("toggled",
self.__checkbutton_toggled,
s)
self.progress_color_buttons.append(gtk.ColorButton())
text = (_("Custom progress bar foreground color"),
_("Custom progress bar background color"))[i]
s = ("progress_fg", "progress_bg")[i]
self.progress_color_buttons[i].set_title(text)
self.progress_color_buttons[i].set_use_alpha(True)
self.progress_color_buttons[i].connect("color-set",
self.__bp_color_set, s)
table.attach(self.custom_progress_color_cbs[i], 0, 1,
i, i + 1, xoptions = gtk.FILL, xpadding = 5)
table.attach(self.progress_color_buttons[i], 1, 2, i, i + 1)
vbox.pack_start(table, False)
frame.add(vbox)
bpbox.pack_start(frame)
appearance_box.pack_start(bpbox)
#--- Popup page
popup_box.set_border_width(5)
self.reorder_window_list_cb = gtk.CheckButton(
_("Reorder the window list so that the last activated window is first in the list."))
self.reorder_window_list_cb.connect("toggled", self.__checkbutton_toggled,
"reorder_window_list")
popup_box.pack_start(self.reorder_window_list_cb, False, padding=5)
self.no_popup_cb = gtk.CheckButton(
_("Show window list only if more than one window is open"))
self.no_popup_cb.connect("toggled", self.__checkbutton_toggled,
"no_popup_for_one_window")
popup_box.pack_start(self.no_popup_cb, False, padding=5)
self.show_tooltip_cb = gtk.CheckButton(
_("Show tooltip when no window is open"))
self.show_tooltip_cb.connect("toggled", self.__checkbutton_toggled,
"groupbutton_show_tooltip")
popup_box.pack_start(self.show_tooltip_cb, False, padding=5)
self.preview_size_spinbox = gtk.HBox()
self.preview_size_spinbox.set_border_width(5)
spinlabel = gtk.Label(_("Preview size"))
spinlabel.set_alignment(0,0.5)
adj = gtk.Adjustment(200, 50, 800, 1, 50)
self.preview_size_spin = gtk.SpinButton(adj, 0.5, 0)
self.preview_size_spinbox.pack_start(spinlabel, False)
self.preview_size_spinbox.pack_start(self.preview_size_spin,
False, padding=5)
adj.connect("value_changed", self.__adjustment_changed, "preview_size")
self.preview_size_spinbox.show_all()
self.preview_size_spinbox.set_no_show_all(True)
popup_box.pack_start(self.preview_size_spinbox, False, padding=5)
self.window_title_width_spinbox = gtk.HBox()
self.window_title_width_spinbox.set_border_width(5)
spinlabel = gtk.Label(_("Window title width"))
spinlabel.set_alignment(0,0.5)
adj = gtk.Adjustment(200, 50, 800, 1, 50)
self.window_title_width_spin = gtk.SpinButton(adj, 0.5, 0)
self.window_title_width_spinbox.pack_start(spinlabel, False)
self.window_title_width_spinbox.pack_start(self.window_title_width_spin,
False, padding=5)
adj.connect("value_changed",
self.__adjustment_changed, "window_title_width")
self.window_title_width_spinbox.show_all()
self.window_title_width_spinbox.set_no_show_all(True)
popup_box.pack_start(self.window_title_width_spinbox, False, padding=5)
# Delay
vbox = gtk.VBox()
label1 = gtk.Label("<b><big>%s</big></b>"%_("Delay"))
label1.set_alignment(0,0.5)
label1.set_use_markup(True)
vbox.pack_start(label1,False)
spinbox = gtk.HBox()
spinlabel = gtk.Label(_("Delay"))
spinlabel.set_alignment(0,0.5)
adj = gtk.Adjustment(0, 0, 2000, 1, 50)
self.delay_spin = gtk.SpinButton(adj, 0.5, 0)
adj.connect("value_changed", self.__adjustment_changed, "popup_delay")
spinbox.pack_start(spinlabel, False)
spinbox.pack_start(self.delay_spin, False, padding=5)
vbox.pack_start(spinbox, False)
spinbox = gtk.HBox()
spinlabel = gtk.Label(_("Delay for switching between window lists"))
spinlabel.set_alignment(0,0.5)
adj = gtk.Adjustment(0, 0, 2000, 1, 50)
self.second_delay_spin = gtk.SpinButton(adj, 0.5, 0)
adj.connect("value_changed", self.__adjustment_changed,
"second_popup_delay")
spinbox.pack_start(spinlabel, False)
spinbox.pack_start(self.second_delay_spin, False, padding=5)
vbox.pack_start(spinbox, False)
popup_box.pack_start(vbox, False, padding=5)
# Previews
vbox = gtk.VBox()
label1 = gtk.Label("<b><big>%s</big></b>"%_("Previews"))
label1.set_alignment(0,0.5)
label1.set_use_markup(True)
vbox.pack_start(label1, False)
self.preview_cb = gtk.CheckButton(_("Show previews"))
self.preview_cb.connect("toggled", self.__checkbutton_toggled, "preview")
vbox.pack_start(self.preview_cb, False)
self.preview_minimized_cb = gtk.CheckButton(_("Show previews for minimized windows"))
self.preview_minimized_cb.set_tooltip_text(_("To get previews for minimized windows you need to active \"Keep previews of minimized windows\" in Compiz plugin Workarounds."))
self.preview_minimized_cb.connect("toggled", self.__checkbutton_toggled, "preview_minimized")
vbox.pack_start(self.preview_minimized_cb, False)
self.preview_minimized_cb.set_no_show_all(True)
if self.globals.get_compiz_version() >= "0.9":
self.preview_minimized_cb.show()
popup_box.pack_start(vbox, False, padding=5)
# Locked list
vbox = gtk.VBox()
label1 = gtk.Label("<b><big>%s</big></b>"%_("Locked list"))
label1.set_alignment(0,0.5)
label1.set_use_markup(True)
vbox.pack_start(label1, False)
self.locked_list_menu_cb = gtk.CheckButton(
_("Show \"locked list\" option in menu"))
self.locked_list_menu_cb.set_tooltip_text(_("The option is only shown when a program has more than one window opened."))
self.locked_list_menu_cb.connect("toggled", self.__checkbutton_toggled,
"locked_list_in_menu")
vbox.pack_start(self.locked_list_menu_cb, False)
self.locked_list_no_overlap_cb = gtk.CheckButton(
_("Maximized windows should not overlap the locked list"))
self.locked_list_no_overlap_cb .connect("toggled",
self.__checkbutton_toggled,
"locked_list_no_overlap")
vbox.pack_start(self.locked_list_no_overlap_cb, False)
popup_box.pack_start(vbox, False, padding=5)
# "Select" action options frame
vbox = gtk.VBox()
label1 = gtk.Label("<b><big>%s</big></b>"%_("\"Select next\" behavior"))
label1.set_alignment(0,0.5)
label1.set_use_markup(True)
vbox.pack_start(label1, False)
self.select_next_use_lastest_active_cb = gtk.CheckButton(_("\"Select next\" selects the most recently used window in the group"))
self.select_next_use_lastest_active_cb.set_tooltip_text(_("If set, \"Select Next\" action selects the window that has been used most recently, otherwise it activates the next window in the window list."))
self.select_next_use_lastest_active_cb.connect("toggled",
self.__checkbutton_toggled,
"select_next_use_lastest_active")
vbox.pack_start(self.select_next_use_lastest_active_cb, False)
self.select_next_activate_immediately_cb = gtk.CheckButton(
_("Use no delay with \"Select next\""))
self.select_next_activate_immediately_cb.set_tooltip_text(_("If set, \"Select Next\" action selects the next window immediately without any delay"))
self.select_next_activate_immediately_cb.connect("toggled",
self.__checkbutton_toggled,
"select_next_activate_immediately")
vbox.pack_start(self.select_next_activate_immediately_cb, False)
popup_box.pack_start(vbox, False, padding=5)
#--- Groupbutton page
frame = gtk.Frame(_("Group button actions"))
frame.set_border_width(5)
table = gtk.Table(True)
table.set_border_width(5)
self.gb_labels_and_settings = ODict((
(_("Left mouse button"), "groupbutton_left_click_action"),
(_("Shift + left mouse button"),
"groupbutton_shift_and_left_click_action"),
(_("Middle mouse button"), "groupbutton_middle_click_action"),
(_("Shift + middle mouse button"),
"groupbutton_shift_and_middle_click_action"),
(_("Right mouse button"), "groupbutton_right_click_action"),
(_("Shift + right mouse button"),
"groupbutton_shift_and_right_click_action"),
(_("Scroll up"), "groupbutton_scroll_up"),
(_("Scroll down"), "groupbutton_scroll_down")
))
self.gb_actions = ODict((
("select", _("select")),
("close all windows", _("close all windows")),
("minimize all windows", _("minimize all windows")),
("maximize all windows", _("maximize all windows")),
("launch application", _("launch application")),
("show menu", _("show menu")),
("remove launcher", _("remove launcher")),
("select next window", _("select next window")),
("select previous window", _("select previous window")),
("minimize all other groups", _("minimize all other groups")),
("compiz scale windows", _("compiz scale windows")),
("compiz shift windows", _("compiz shift windows")),
("compiz scale all", _("compiz scale all")),
("show preference dialog", _("show preference dialog")),
("no action", _("no action"))
))
self.gb_combos = {}
for text in self.gb_labels_and_settings:
label = gtk.Label(text)
label.set_alignment(1,0.5)
self.gb_combos[text] = gtk.combo_box_new_text()
for (action) in self.gb_actions.values():
self.gb_combos[text].append_text(action)
self.gb_combos[text].connect("changed", self.__cb_changed)
row = self.gb_labels_and_settings.get_index(text)
table.attach(label, 0, 1, row, row + 1, xpadding = 5 )
table.attach(self.gb_combos[text], 1, 2, row, row + 1 )
self.gb_doubleclick_checkbutton_names = [
"groupbutton_left_click_double",
"groupbutton_shift_and_left_click_double",
"groupbutton_middle_click_double",
"groupbutton_shift_and_middle_click_double",
"groupbutton_right_click_double",
"groupbutton_shift_and_right_click_double"]
self.gb_doubleclick_checkbutton = {}
for i in range(len(self.gb_doubleclick_checkbutton_names)):
name = self.gb_doubleclick_checkbutton_names[i]
self.gb_doubleclick_checkbutton[name] = \
gtk.CheckButton(_("Double click"))
self.gb_doubleclick_checkbutton[name].connect("toggled",
self.__checkbutton_toggled, name)
table.attach(self.gb_doubleclick_checkbutton[name],
2, 3, i, i + 1, xpadding = 5 )
frame.add(table)
groupbutton_box.pack_start(frame, False, padding=5)
# "Select" action options frame
hbox = gtk.HBox()
frame = gtk.Frame(_("\"Select\" action options"))
frame.set_border_width(5)
table = gtk.Table(True)
table.set_border_width(5)
label = gtk.Label(_("One window open"))
label.set_alignment(1,0.5)
self.select_one_cg = gtk.combo_box_new_text()
self.select_one_cg.append_text(_("select window"))
self.select_one_cg.append_text(_("select or minimize window"))
self.select_one_cg.connect("changed", self.__cb_changed)
table.attach(label,0,1,0,1, xpadding = 5 )
table.attach(self.select_one_cg,1,2,0,1)