|
4 | 4 | from JsonSettingsWidgets import *
|
5 | 5 | from gi.repository import Gio, Gtk
|
6 | 6 |
|
7 |
| -class TwoCheckButtonsTitleWidget(SettingsWidget): |
8 |
| - def __init__(self, info, key, settings): |
| 7 | +class FireColorChooser(SettingsWidget): |
| 8 | + def __init__(self, info, key, settings): |
9 | 9 | SettingsWidget.__init__(self)
|
10 | 10 | self.key = key
|
11 | 11 | self.settings = settings
|
12 | 12 | self.info = info
|
| 13 | + rgba = Gdk.RGBA() |
13 | 14 |
|
14 |
| - self.descLabel = Gtk.Label('', halign=Gtk.Align.START) |
15 |
| - self.descLabel.set_markup('<b>' + _(info['description']) + '</b>'); |
| 15 | + self.pack_start(Gtk.Label(_(info['description']), halign=Gtk.Align.START), True, True, 0) |
| 16 | + self.cBtn1 = Gtk.ColorButton() |
| 17 | + self.cBtn1.set_use_alpha(True) |
| 18 | + self.cBtn1.set_margin_start(2) |
| 19 | + |
| 20 | + self.cBtn2 = Gtk.ColorButton() |
| 21 | + self.cBtn2.set_use_alpha(True) |
| 22 | + self.cBtn2.set_margin_start(2) |
| 23 | + |
| 24 | + self.cBtn3 = Gtk.ColorButton() |
| 25 | + self.cBtn3.set_use_alpha(True) |
| 26 | + self.cBtn3.set_margin_start(2) |
| 27 | + |
| 28 | + self.cBtn4 = Gtk.ColorButton() |
| 29 | + self.cBtn4.set_use_alpha(True) |
| 30 | + self.cBtn4.set_margin_start(2) |
16 | 31 |
|
17 |
| - self.label1 = Gtk.Label('', halign=Gtk.Align.END) |
18 |
| - self.label1.set_markup('<b>' + _(info['titleB']) + '</b>'); |
| 32 | + self.cBtn5 = Gtk.ColorButton() |
| 33 | + self.cBtn5.set_use_alpha(True) |
| 34 | + self.cBtn5.set_margin_start(2) |
19 | 35 |
|
20 |
| - self.label2 = Gtk.Label('', halign=Gtk.Align.END) |
21 |
| - self.label2.set_markup('<b>' + _(info['titleA']) + '</b>'); |
| 36 | + self.pack_end(self.cBtn5, False, False, 2) |
| 37 | + self.pack_end(self.cBtn4, False, False, 2) |
| 38 | + self.pack_end(self.cBtn3, False, False, 2) |
| 39 | + self.pack_end(self.cBtn2, False, False, 2) |
| 40 | + self.pack_end(self.cBtn1, False, False, 2) |
22 | 41 |
|
23 |
| - self.pack_start(self.descLabel, True, True, 0) |
24 |
| - self.pack_end(self.label1, False, False, 10) |
25 |
| - self.pack_end(self.label2, False, False, 10) |
| 42 | + rgba.parse(settings.get_value(info["color1"])) |
| 43 | + self.cBtn1.set_rgba(rgba); |
| 44 | + rgba.parse(settings.get_value(info["color2"])) |
| 45 | + self.cBtn2.set_rgba(rgba); |
| 46 | + rgba.parse(settings.get_value(info["color3"])) |
| 47 | + self.cBtn3.set_rgba(rgba); |
| 48 | + rgba.parse(settings.get_value(info["color4"])) |
| 49 | + self.cBtn4.set_rgba(rgba); |
| 50 | + rgba.parse(settings.get_value(info["color5"])) |
| 51 | + self.cBtn5.set_rgba(rgba); |
26 | 52 |
|
| 53 | + self.cBtn1.connect('color-set', self.on_my_value_changed) |
| 54 | + self.cBtn2.connect('color-set', self.on_my_value_changed) |
| 55 | + self.cBtn3.connect('color-set', self.on_my_value_changed) |
| 56 | + self.cBtn4.connect('color-set', self.on_my_value_changed) |
| 57 | + self.cBtn5.connect('color-set', self.on_my_value_changed) |
27 | 58 |
|
28 |
| -class TwoCheckButtonsWidget(SettingsWidget): |
29 |
| - def __init__(self, info, key, settings): |
| 59 | + def on_my_value_changed(self, widget): |
| 60 | + color_string = self.cBtn1.get_rgba().to_string() |
| 61 | + self.settings.set_value(self.info["color1"], color_string) |
| 62 | + color_string = self.cBtn2.get_rgba().to_string() |
| 63 | + self.settings.set_value(self.info["color2"], color_string) |
| 64 | + color_string = self.cBtn3.get_rgba().to_string() |
| 65 | + self.settings.set_value(self.info["color3"], color_string) |
| 66 | + color_string = self.cBtn4.get_rgba().to_string() |
| 67 | + self.settings.set_value(self.info["color4"], color_string) |
| 68 | + color_string = self.cBtn5.get_rgba().to_string() |
| 69 | + self.settings.set_value(self.info["color5"], color_string) |
| 70 | + |
| 71 | + |
| 72 | +class MushroomColorChooser(SettingsWidget): |
| 73 | + def __init__(self, info, key, settings): |
30 | 74 | SettingsWidget.__init__(self)
|
31 | 75 | self.key = key
|
32 | 76 | self.settings = settings
|
33 | 77 | self.info = info
|
| 78 | + rgba = Gdk.RGBA() |
34 | 79 |
|
35 | 80 | self.pack_start(Gtk.Label(_(info['description']), halign=Gtk.Align.START), True, True, 0)
|
36 |
| - self.chkBtn1 = Gtk.CheckButton() |
37 |
| - self.chkBtn1.set_margin_start(17) |
38 |
| - self.chkBtn2 = Gtk.CheckButton() |
39 |
| - self.chkBtn2.set_margin_start(17) |
40 |
| - self.settings.bind(info['close'], self.chkBtn1, 'active', Gio.SettingsBindFlags.DEFAULT) |
41 |
| - self.settings.bind(info['open'], self.chkBtn2, 'active', Gio.SettingsBindFlags.DEFAULT) |
42 |
| - self.pack_end(self.chkBtn1, False, False, 10) |
43 |
| - self.pack_end(self.chkBtn2, False, False, 10) |
| 81 | + self.cBtn1 = Gtk.ColorButton() |
| 82 | + self.cBtn1.set_use_alpha(True) |
| 83 | + self.cBtn1.set_margin_start(2) |
| 84 | + |
| 85 | + self.cBtn2 = Gtk.ColorButton() |
| 86 | + self.cBtn2.set_use_alpha(True) |
| 87 | + self.cBtn2.set_margin_start(2) |
| 88 | + |
| 89 | + self.cBtn3 = Gtk.ColorButton() |
| 90 | + self.cBtn3.set_use_alpha(True) |
| 91 | + self.cBtn3.set_margin_start(2) |
| 92 | + |
| 93 | + self.cBtn4 = Gtk.ColorButton() |
| 94 | + self.cBtn4.set_use_alpha(True) |
| 95 | + self.cBtn4.set_margin_start(2) |
| 96 | + |
| 97 | + self.cBtn5 = Gtk.ColorButton() |
| 98 | + self.cBtn5.set_use_alpha(True) |
| 99 | + self.cBtn5.set_margin_start(2) |
| 100 | + |
| 101 | + self.cBtn6 = Gtk.ColorButton() |
| 102 | + self.cBtn6.set_use_alpha(True) |
| 103 | + self.cBtn6.set_margin_start(2) |
| 104 | + |
| 105 | + self.pack_end(self.cBtn6, False, False, 2) |
| 106 | + self.pack_end(self.cBtn5, False, False, 2) |
| 107 | + self.pack_end(self.cBtn4, False, False, 2) |
| 108 | + self.pack_end(self.cBtn3, False, False, 2) |
| 109 | + self.pack_end(self.cBtn2, False, False, 2) |
| 110 | + self.pack_end(self.cBtn1, False, False, 2) |
| 111 | + |
| 112 | + rgba.parse(settings.get_value(info["color1"])) |
| 113 | + self.cBtn1.set_rgba(rgba); |
| 114 | + rgba.parse(settings.get_value(info["color2"])) |
| 115 | + self.cBtn2.set_rgba(rgba); |
| 116 | + rgba.parse(settings.get_value(info["color3"])) |
| 117 | + self.cBtn3.set_rgba(rgba); |
| 118 | + rgba.parse(settings.get_value(info["color4"])) |
| 119 | + self.cBtn4.set_rgba(rgba); |
| 120 | + rgba.parse(settings.get_value(info["color5"])) |
| 121 | + self.cBtn5.set_rgba(rgba); |
| 122 | + rgba.parse(settings.get_value(info["color6"])) |
| 123 | + self.cBtn6.set_rgba(rgba); |
| 124 | + |
| 125 | + self.cBtn1.connect('color-set', self.on_my_value_changed) |
| 126 | + self.cBtn2.connect('color-set', self.on_my_value_changed) |
| 127 | + self.cBtn3.connect('color-set', self.on_my_value_changed) |
| 128 | + self.cBtn4.connect('color-set', self.on_my_value_changed) |
| 129 | + self.cBtn5.connect('color-set', self.on_my_value_changed) |
| 130 | + self.cBtn6.connect('color-set', self.on_my_value_changed) |
| 131 | + |
| 132 | + def on_my_value_changed(self, widget): |
| 133 | + color_string = self.cBtn1.get_rgba().to_string() |
| 134 | + self.settings.set_value(self.info["color1"], color_string) |
| 135 | + color_string = self.cBtn2.get_rgba().to_string() |
| 136 | + self.settings.set_value(self.info["color2"], color_string) |
| 137 | + color_string = self.cBtn3.get_rgba().to_string() |
| 138 | + self.settings.set_value(self.info["color3"], color_string) |
| 139 | + color_string = self.cBtn4.get_rgba().to_string() |
| 140 | + self.settings.set_value(self.info["color4"], color_string) |
| 141 | + color_string = self.cBtn5.get_rgba().to_string() |
| 142 | + self.settings.set_value(self.info["color5"], color_string) |
| 143 | + color_string = self.cBtn6.get_rgba().to_string() |
| 144 | + self.settings.set_value(self.info["color6"], color_string) |
0 commit comments