@@ -12,6 +12,15 @@ public class Clipboard.HistoryWidget : Gtk.Box {
1212 public signal void close_request ();
1313
1414 construct {
15+ orientation = VERTICAL ;
16+ spacing = 6 ;
17+
18+ var active_switch = new Granite .SwitchModelButton (_(" Clipboard Manager" )) {
19+ description = _ ("Monitoring the clipboard contents ")
20+ };
21+
22+ Clipboard.Indicator.settings.bind ("active ", active_switch , "active ", DEFAULT );
23+
1524 clipboard_text_set = new Gee .HashSet<string> ();
1625
1726 clipboard_item_list = new Gtk .ListBox () {
@@ -24,6 +33,7 @@ public class Clipboard.HistoryWidget : Gtk.Box {
2433 scroll_box. hscrollbar_policy = Gtk . PolicyType . NEVER ;
2534 scroll_box.add (clipboard_item_list );
2635
36+ add (active_switch );
2737 add (scroll_box );
2838 show_all ();
2939
@@ -105,4 +115,52 @@ public class Clipboard.HistoryWidget : Gtk.Box {
105115 add (label);
106116 }
107117 }
118+
119+ // Taken from the Code project (https://github.com/elementary/code)
120+ private class SettingSwitch : Gtk .Grid {
121+ public string label { get ; construct; }
122+ public string settings_key { get ; construct; }
123+ public string description { get ; construct; }
124+
125+ public SettingSwitch (string label , string settings_key , string description = "") {
126+ Object (
127+ description: description,
128+ label: label,
129+ settings_key: settings_key
130+ );
131+ }
132+
133+ construct {
134+ var switch_widget = new Gtk .Switch () {
135+ valign = CENTER
136+ };
137+
138+ var label_widget = new Gtk .Label (label) {
139+ halign = START ,
140+ hexpand = true ,
141+ mnemonic_widget = switch_widget
142+ };
143+
144+ column_spacing = 12 ;
145+ attach (label_widget, 0 , 0 );
146+ attach (switch_widget, 1 , 0 , 1 , 2 );
147+
148+ if (description != " " ) {
149+ var description_label = new Gtk .Label (description) {
150+ halign = START ,
151+ wrap = true ,
152+ xalign = 0
153+ };
154+ description_label. get_style_context (). add_class (Gtk . STYLE_CLASS_DIM_LABEL );
155+ description_label. get_style_context (). add_class (Granite . STYLE_CLASS_SMALL_LABEL );
156+
157+ attach (description_label, 0 , 1 );
158+
159+ switch_widget. get_accessible (). accessible_description = description;
160+ }
161+
162+ Clipboard . Indicator . settings. bind (settings_key, switch_widget, " active" , DEFAULT );
163+ }
164+ }
165+
108166}
0 commit comments