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
|
# File 'lib/gswax/settings_manager.rb', line 45
def init_ui
@win = Gtk::Window.new
@win.title = "gsWax Settings"
@win.icon = Gdk::Pixbuf.new File.join(DIR, '../static/gshoes-icon.png')
@win.set_size_request(400, 400)
@win.signal_connect("destroy"){
changed; notify_observers("SETTINGS_CLOSED")
}
nb = Gtk::Notebook.new
page1 = Gtk::VBox.new(false, 2)
mdir_frame = SettingsCell.new
mdir_frame.set("music library directory:", 0.95, nil, 50)
mdir_btn = Gtk::EventBox.new()
@mdir_text = Gtk::Label.new(Settings.music_dir)
@mdir_text.set_alignment(0.05, 0.3)
@mdir_text.set_wrap(true)
@mdir_text.justify = Gtk::JUSTIFY_LEFT
mdir_btn.add(@mdir_text)
mdir_btn.signal_connect("button_press_event"){music_dir_select}
mdir_btn.signal_connect("enter_notify_event"){mdir_frame.hover}
mdir_btn.signal_connect("leave_notify_event"){mdir_frame.leave}
mdir_frame.add(mdir_btn)
hbox1 = Gtk::HBox.new(false, 5)
hbox1.set_height_request(50)
scale_frame = SettingsCell.new
scale_frame.set("scale: [0.35 - 1.0]", 0.05, 193, nil)
scale_btn = Gtk::EventBox.new()
@scale_text = Gtk::Entry.new
@scale_text.text = Settings.scale.to_s
@scale_text.xalign = 0.95
@scale_text.signal_connect("enter_notify_event"){scale_frame.hover}
@scale_text.signal_connect("leave_notify_event"){scale_frame.leave}
scale_btn.add(@scale_text)
scale_frame.add(scale_btn)
bg_frame = SettingsCell.new
bg_frame.set("background color:", 0.95, nil, nil)
@bg_btn = Gtk::EventBox.new()
@bg_btn.modify_bg(Gtk::STATE_NORMAL, @bg_color)
@bg_btn.signal_connect("button_press_event"){bg_color_select}
@bg_btn.signal_connect("enter_notify_event"){bg_frame.hover}
@bg_btn.signal_connect("leave_notify_event"){bg_frame.leave}
bg_frame.add(@bg_btn)
hbox1.pack_start(scale_frame, false, false, 0)
hbox1.pack_start(bg_frame, true, true, 2)
hbox2 = Gtk::HBox.new(false, 5)
hbox2.set_height_request(50)
font_frame = SettingsCell.new
font_frame.set("text font:", 0.05, 193, nil)
font_btn = Gtk::EventBox.new()
@font_text = Gtk::Label.new(@font_desc)
@font_text.modify_font(@font_desc)
@font_text.xalign = 0.95
@font_text.justify = Gtk::JUSTIFY_RIGHT
font_btn.add(@font_text)
font_btn.signal_connect("button_press_event"){font_select}
font_btn.signal_connect("enter_notify_event"){font_frame.hover}
font_btn.signal_connect("leave_notify_event"){font_frame.leave}
font_frame.add(font_btn)
txtclr_frame = SettingsCell.new
txtclr_frame.set("text color:", 0.95, nil, nil)
@txtclr_btn = Gtk::EventBox.new()
@txtclr_btn.modify_bg(Gtk::STATE_NORMAL, @text_color)
@txtclr_btn.modify_fg(Gtk::STATE_SELECTED, @text_color)
@txtclr_btn.signal_connect("button_press_event"){text_color_select}
@txtclr_btn.signal_connect("enter_notify_event"){txtclr_frame.hover}
@txtclr_btn.signal_connect("leave_notify_event"){txtclr_frame.leave}
txtclr_frame.add(@txtclr_btn)
hbox2.pack_start(font_frame, false, false, 0)
hbox2.pack_start(txtclr_frame, true, true, 2)
format_frame = SettingsCell.new
format_frame.set("title format:", 0.05, nil, nil)
format_box = Gtk::EventBox.new
vbox = Gtk::VBox.new(false, 5)
valign = Gtk::Alignment.new(0.05, 0.15, 0, 0)
@format_text = Gtk::TextView.new
@format_text.set_size_request(390, 200)
@format_text.wrap_mode = Gtk::TextTag::WRAP_WORD
@format_text.justification = Gtk::JUSTIFY_LEFT
@format_text.editable = true
@format_text.cursor_visible = true
@format_text.pixels_above_lines = 5
@format_text.pixels_below_lines = 5
@format_text.pixels_inside_wrap = 5
@format_text.left_margin = 10
@format_text.right_margin = 10
@format_text.buffer.text = Settings.title_format
valign.add(@format_text)
halign = Gtk::Alignment.new(0.01, 0, 1, 0)
add_field = Gtk::ComboBox.new
fields = ["add field", "#track-number#", "#title#", "#album#",
"#artist#", "#album-artist#", "#genre#", "#comments#"
]
fields.each{|field| add_field.append_text(field)}
add_field.active = 0
add_field.signal_connect("changed"){
@format_text.buffer.insert(
@format_text.buffer.end_iter, add_field.active_iter[0]
)
}
halign.add(add_field)
vbox.pack_start(valign, true, true, 2)
vbox.pack_start(halign, false, false, 2)
format_box.add(vbox)
format_box.signal_connect("enter_notify_event"){format_frame.hover}
format_box.signal_connect("leave_notify_event"){format_frame.leave}
format_frame.add(format_box)
btn_box = Gtk::HBox.new(false, 2)
save_btn = Gtk::Button.new(" save settings ")
save_btn.signal_connect("clicked"){save_settings}
close_btn = Gtk::Button.new(" close ")
close_btn.signal_connect("clicked"){@win.destroy}
btn_box.pack_end(close_btn, false, false, 2)
btn_box.pack_end(save_btn, false, false, 2)
page1.pack_start(mdir_frame, false, false, 10)
page1.pack_start(hbox1, false, false, 2)
page1.pack_start(hbox2, false, false, 2)
page1.pack_start(format_frame, true, true, 12)
page1.pack_start(btn_box, false, false, 0)
page2 = Gtk::VBox.new(false, 2)
about_frame = Gtk::Frame.new()
about = "gsWax version 0.0.2\nhttps://github.com/lljk/gsWax"
about_text = Gtk::Label.new(about)
about_text.set_alignment(0.05, 0.5)
about_text.set_wrap(true)
about_text.justify = Gtk::JUSTIFY_CENTER
about_frame.add(about_text)
page2.pack_start(about_frame, true, true, 2)
label1 = Gtk::Label.new(" general ")
label2 = Gtk::Label.new(" about ")
nb.append_page(page1, label1)
nb.append_page(page2, label2)
@win.add(nb)
@win.show_all
end
|