292
304
settings_buttons.append (tempo_button);
293
305
settings_buttons.append (beat_button);
295
var reset = new Gtk.Button ();
307
var sidebar_toogle = new Gtk.Button ();
308
sidebar_toogle.image = new Gtk.Image.from_icon_name ("pane-show-symbolic-rtl", Gtk.IconSize.LARGE_TOOLBAR);
309
sidebar_toogle.relief = Gtk.ReliefStyle.NONE;
310
sidebar_toogle.clicked.connect (() => {
311
if (sidebar.visible) {
312
sidebar.visible = false;
313
sidebar_toogle.image = new Gtk.Image.from_icon_name ("pane-show-symbolic-rtl", Gtk.IconSize.LARGE_TOOLBAR);
315
sidebar.visible = true;
316
sidebar_toogle.image = new Gtk.Image.from_icon_name ("pane-hide-symbolic-rtl", Gtk.IconSize.LARGE_TOOLBAR);
320
headerbar.pack_end (sidebar_toogle);
322
/*var reset = new Gtk.Button ();
296
323
reset.image = new Gtk.Image.from_icon_name ("document-revert-symbolic", Gtk.IconSize.LARGE_TOOLBAR);
297
324
reset.tooltip_text = _("Revert all settings");
298
325
reset.relief = Gtk.ReliefStyle.NONE;
299
326
reset.clicked.connect (reset_settings);
301
headerbar.pack_end (reset);
328
headerbar.pack_end (reset);*/
304
331
private void build_volume_sliders () {
348
375
volumes.attach (icon_quaver, 3, 1, 1, 1);
350
377
content.attach (volumes, 0, 0, 4, 1);
379
root.pack1 (content, true, false);
382
private void build_sidebar () {
384
sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
385
sidebar.visible = false;
386
sidebar.width_request = 140;
388
var list_scroll = new Gtk.ScrolledWindow (null, null);
389
list_scroll.vexpand = true;
390
list_scroll.get_style_context().set_junction_sides(Gtk.JunctionSides.BOTTOM);
393
list_box = new Gtk.ListBox ();
394
list_box.expand = true;
395
list_box.row_activated.connect ((row) => {
396
var custom_setting = (((Metronome.SettingRow)row).setting);
397
tempo.set_value (custom_setting.tempo);
398
beat.set_value (custom_setting.beat);
401
list_scroll.add (list_box);
403
var list_toolbar = new Gtk.Toolbar ();
404
list_toolbar.expand = false;
405
list_toolbar.set_style (Gtk.ToolbarStyle.ICONS);
406
list_toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR);
407
list_toolbar.set_show_arrow (false);
408
list_toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR);
409
list_toolbar.get_style_context().set_junction_sides(Gtk.JunctionSides.TOP);
414
var list_toolbar_add = new Gtk.ToolButton (null, null);
415
list_toolbar_add.icon_name = "list-add-symbolic";
416
list_toolbar.insert (list_toolbar_add, -1);
419
var popover_grid = new Gtk.Grid ();
420
popover_grid.margin = 6;
421
popover_grid.row_spacing = 6;
422
popover_grid.column_spacing = 6;
424
var new_setting_label = new Gtk.Label (_("Title:"));
426
var new_setting_title = new Gtk.Entry ();
427
new_setting_title.hexpand = true;
428
new_setting_title.set_placeholder_text (_("Setting title"));
430
var add_setting_popover = new Gtk.Popover (list_toolbar_add);
431
add_setting_popover.position = Gtk.PositionType.TOP;
432
add_setting_popover.add (popover_grid);
434
var new_setting_add = new Gtk.Button.with_label (_("Add"));
435
new_setting_add.clicked.connect (() => {
436
if (new_setting_title.buffer.text != "") {
437
var new_custom_setting = new Metronome.Setting ();
438
new_custom_setting.title = new_setting_title.buffer.text;
439
new_custom_setting.tempo = click.current_tempo;
440
new_custom_setting.beat = click.current_beat;
442
add_custom_setting (new_custom_setting);
443
add_setting_popover.hide ();
447
popover_grid.attach (new_setting_label, 0, 0, 1, 1);
448
popover_grid.attach (new_setting_title, 1, 0, 1, 1);
449
popover_grid.attach (new_setting_add, 0, 1, 2, 1);
451
list_toolbar_add.clicked.connect (() => {
452
new_setting_title.text = "";
453
add_setting_popover.show_all ();
457
var list_toolbar_remove = new Gtk.ToolButton (null, null);
458
list_toolbar_remove.icon_name = "list-remove-symbolic";
459
list_toolbar_remove.clicked.connect (() => {
460
list_box.remove(list_box.get_selected_row ());
462
list_toolbar.insert (list_toolbar_remove, -1);
465
var list_toolbar_save = new Gtk.ToolButton (null, null);
466
list_toolbar_save.icon_name = "document-save-symbolic";
467
list_toolbar_save.clicked.connect (() => {
468
(list_box.get_selected_row () as Metronome.SettingRow).setting.beat = click.current_beat;
469
(list_box.get_selected_row () as Metronome.SettingRow).setting.tempo = click.current_tempo;
471
list_toolbar.insert (list_toolbar_save, -1);
473
sidebar.pack_start (list_scroll, true, true);
474
sidebar.pack_start (list_toolbar, false, false);
476
root.pack2 (sidebar, true, false);
353
479
private void do_click (click_interval interval, bool beat) {
463
595
settings.volume_minim = volume_minim.get_value ();
464
596
settings.volume_crotchet = volume_crotchet.get_value ();
465
597
settings.volume_quaver = volume_quaver.get_value ();
599
GLib.Array<string> custom_settings = new GLib.Array<string> ();
600
foreach (Gtk.Widget row in list_box.get_children ()) {
601
if (row is Metronome.SettingRow) {
602
debug ("save custom setting %s", (row as Metronome.SettingRow).setting.get_setting_string ());
603
custom_settings.append_val((row as Metronome.SettingRow).setting.get_setting_string ());
606
settings.custom_settings = custom_settings.data;
468
private void reset_settings () {
471
foreach(string key in settings.schema.list_keys ())
472
settings.schema.reset (key);
609
private void add_custom_setting (Metronome.Setting custom_setting) {
610
var row = new Metronome.SettingRow (custom_setting);
612
row.get_style_context ().remove_class("button");
613
debug ("add custom setting %s", custom_setting.title);