From 69a43a87e821c614fd856fd5ea103b9e7e51f984 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 27 Oct 2015 22:41:27 +0100 Subject: Make session list in toggle box configurable concerning font color and button bg color. --- src/settings.vala | 2 ++ src/toggle-box.vala | 33 ++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/settings.vala b/src/settings.vala index 9aef819..e7e424d 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -43,6 +43,8 @@ public class AGSettings public static const string KEY_GROUP_FILTER = "group-filter"; public static const string KEY_IDLE_TIMEOUT = "idle-timeout"; public static const string KEY_REMOTE_SERVICE_FQDN = "remote-service-fqdn"; + public static const string KEY_TOGGLEBOX_FONT_FGCOLOR = "togglebox-font-fgcolor"; + public static const string KEY_TOGGLEBOX_BUTTON_BGCOLOR = "togglebox-button-bgcolor"; public static bool get_boolean (string key) { diff --git a/src/toggle-box.vala b/src/toggle-box.vala index f1ef8b3..fc6c579 100644 --- a/src/toggle-box.vala +++ b/src/toggle-box.vala @@ -42,6 +42,23 @@ public class ToggleBox : Gtk.Box add (item); } + public void set_normal_button_style (Gtk.Button button) + { + /* Tighten padding on buttons to not be so large, default color scheme for buttons */ + var style = new Gtk.CssProvider (); + style.load_from_data ("* {padding: 8px;}\n"+ + "GtkButton {\n"+ + " background-color: %s;\n".printf("rgba(0,0,0,0)")+ + " background-image: none;"+ + "}\n"+ + ".button:hover,\n"+ + ".button:hover:active {\n"+ + " background-color: %s;\n".printf(AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_BUTTON_BGCOLOR))+ + "}\n", -1); + button.get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + return; + } + private Gtk.Button selected_button; construct @@ -67,19 +84,20 @@ public class ToggleBox : Gtk.Box { if (selected_button != null) { - selected_button.relief = Gtk.ReliefStyle.NONE; selected_button.get_style_context ().remove_class ("selected"); + set_normal_button_style (selected_button); } selected_button = button; - selected_button.relief = Gtk.ReliefStyle.NORMAL; - selected_button.get_style_context ().add_class ("selected"); selected_key = selected_button.get_data ("toggle-list-key"); + + var bg_color = Gdk.RGBA (); + bg_color.parse (AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_BUTTON_BGCOLOR)); + selected_button.override_background_color(Gtk.StateFlags.NORMAL, bg_color); } private Gtk.Button make_button (string key, string name_in, Gdk.Pixbuf? icon) { var item = new FlatButton (); - item.get_style_context ().add_class ("toggle-button"); item.relief = Gtk.ReliefStyle.NONE; item.clicked.connect (button_clicked_cb); @@ -99,7 +117,7 @@ public class ToggleBox : Gtk.Box } var label = new Gtk.Label (null); - label.set_markup ("%s".printf (name)); + label.set_markup ("%s".printf (AGSettings.get_string (AGSettings.KEY_TOGGLEBOX_FONT_FGCOLOR), name)); label.halign = Gtk.Align.START; hbox.pack_start (label, true, true, 0); @@ -109,10 +127,7 @@ public class ToggleBox : Gtk.Box try { - /* Tighten padding on buttons to not be so large */ - var style = new Gtk.CssProvider (); - style.load_from_data ("* {padding: 8px;}", -1); - item.get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + set_normal_button_style (item); } catch (Error e) { -- cgit v1.2.3