From 94dec0b1573b487988bc5806398aa493418bc37f Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Tue, 11 Nov 2025 14:22:15 +0000 Subject: [PATCH 1/6] Bind visibility to privacy setting --- src/HistoryWidget.vala | 7 +++++++ src/Indicator.vala | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/HistoryWidget.vala b/src/HistoryWidget.vala index d2210f6..293680e 100644 --- a/src/HistoryWidget.vala +++ b/src/HistoryWidget.vala @@ -66,6 +66,13 @@ public class Clipboard.HistoryWidget : Gtk.Box { } } + public void clear_history () { + clipboard_text_set.clear (); + clipboard_item_list.@foreach ((child) => { + child.destroy (); + }); + } + private class ItemRow : Gtk.ListBoxRow { public string text { get; construct; } public string prettier_text { get; construct; } diff --git a/src/Indicator.vala b/src/Indicator.vala index 3824488..bee2288 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -5,6 +5,7 @@ public class Clipboard.Indicator : Wingpanel.Indicator { private static GLib.Settings settings; + private static GLib.Settings gnome_privacy_settings; private Gtk.Image panel_icon; private HistoryWidget history_widget; @@ -23,8 +24,11 @@ public class Clipboard.Indicator : Wingpanel.Indicator { settings = new GLib.Settings ("io.github.ellie_commons.indicator-clipboard"); settings.bind ("visible", this, "visible", GLib.SettingsBindFlags.DEFAULT); + gnome_privacy_settings = new Settings ("org.gnome.desktop.privacy"); + gnome_privacy_settings.bind ("remember-recent-files", this, "visible", GET); } + public override Gtk.Widget get_display_widget () { if (panel_icon == null) { panel_icon = new Gtk.Image.from_icon_name ("edit-copy-symbolic", Gtk.IconSize.SMALL_TOOLBAR); @@ -32,9 +36,12 @@ public class Clipboard.Indicator : Wingpanel.Indicator { if (server_type == Wingpanel.IndicatorManager.ServerType.GREETER) { this.visible = false; } else { - // var visible_settings = new Settings ("io.elementary.desktop.wingpanel.clipboard"); - // visible_settings.bind ("show-indicator", this, "visible", SettingsBindFlags.DEFAULT); - this.visible = true; + this.notify["visible"].connect (() => { + warning ("visible changed to %s", visible.to_string ()); + if (!visible) { + ((HistoryWidget) (get_widget ())).clear_history (); + } + }); } } From 1964cf9c8768d02ec4c0520f7cd2756600643280 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 12 Nov 2025 21:15:45 +0000 Subject: [PATCH 2/6] Do not wait for text if not visible; rework --- src/Indicator.vala | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Indicator.vala b/src/Indicator.vala index bee2288..650127f 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -23,9 +23,6 @@ public class Clipboard.Indicator : Wingpanel.Indicator { Intl.textdomain (GETTEXT_PACKAGE); settings = new GLib.Settings ("io.github.ellie_commons.indicator-clipboard"); - settings.bind ("visible", this, "visible", GLib.SettingsBindFlags.DEFAULT); - gnome_privacy_settings = new Settings ("org.gnome.desktop.privacy"); - gnome_privacy_settings.bind ("remember-recent-files", this, "visible", GET); } @@ -36,27 +33,24 @@ public class Clipboard.Indicator : Wingpanel.Indicator { if (server_type == Wingpanel.IndicatorManager.ServerType.GREETER) { this.visible = false; } else { - this.notify["visible"].connect (() => { - warning ("visible changed to %s", visible.to_string ()); - if (!visible) { - ((HistoryWidget) (get_widget ())).clear_history (); - } - }); + gnome_privacy_settings = new Settings ("org.gnome.desktop.privacy"); + gnome_privacy_settings.bind ("remember-recent-files", this, "visible", GET); } } - get_widget (); return panel_icon; } public override Gtk.Widget? get_widget () { if (history_widget == null && server_type == Wingpanel.IndicatorManager.ServerType.SESSION) { - history_widget = new HistoryWidget (); - history_widget.close_request.connect (() => { - close (); - }); - history_widget.wait_for_text (); + + history_widget = new HistoryWidget (); + history_widget.close_request.connect (() => { + close (); + }); + this.notify["visible"].connect (update_visibility); + update_visibility (); } return history_widget; @@ -67,6 +61,15 @@ public class Clipboard.Indicator : Wingpanel.Indicator { public override void closed () { } + + private void update_visibility () { + if (!visible) { + history_widget.clear_history (); + history_widget.stop_waiting_for_text (); + } else { + history_widget.wait_for_text (); + } + } } public Wingpanel.Indicator? get_indicator (Module module, Wingpanel.IndicatorManager.ServerType server_type) { From 7388a999c6a298a458e6452feed55b6284aa2aea Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Nov 2025 15:28:29 +0000 Subject: [PATCH 3/6] Implement inactive and always-hidden states --- data/gschema.xml | 8 ++++---- src/Indicator.vala | 48 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/data/gschema.xml b/data/gschema.xml index 26bc8d0..c28eb66 100644 --- a/data/gschema.xml +++ b/data/gschema.xml @@ -1,10 +1,10 @@ - - true - Whether indicator is visible - Hide indicator if set to false. It is still running, just hidden + + false + Whether indicator is hidden and inactive + Always hide indicator if set to true. While hidden the indicator does not monitor the clipboard. diff --git a/src/Indicator.vala b/src/Indicator.vala index 650127f..3d34c4c 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -6,8 +6,13 @@ public class Clipboard.Indicator : Wingpanel.Indicator { private static GLib.Settings settings; private static GLib.Settings gnome_privacy_settings; + private const string NORMAL_ICON_NAME = "edit-copy-symbolic"; + private const string STOPPED_ICON_NAME = "task-past-due-symbolic"; private Gtk.Image panel_icon; private HistoryWidget history_widget; + private Gtk.Box inactive_widget; + public bool always_hide { get; set; } + public bool privacy_on { get; set; } public Wingpanel.IndicatorManager.ServerType server_type { get; construct set; } @@ -22,19 +27,37 @@ public class Clipboard.Indicator : Wingpanel.Indicator { Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); Intl.textdomain (GETTEXT_PACKAGE); + visible = true; + settings = new GLib.Settings ("io.github.ellie_commons.indicator-clipboard"); + settings.bind ("always-hide", this, "always-hide", DEFAULT); + + var inactive_header_label = new Granite.HeaderLabel (_("The ClipboardManager is disabled")); + var inactive_subheader_label = new Gtk.Label ("") { + label = Granite.TOOLTIP_SECONDARY_TEXT_MARKUP.printf (_("History is off in the Privacy and Security settings")), + use_markup = true + }; + inactive_widget = new Gtk.Box (VERTICAL, 0) { + margin_start = 6, + margin_end = 6 + }; + inactive_widget.add (inactive_header_label); + inactive_widget.add (inactive_subheader_label); + // Ensure correct appearance before showing + get_display_widget (); + get_widget (); } public override Gtk.Widget get_display_widget () { if (panel_icon == null) { - panel_icon = new Gtk.Image.from_icon_name ("edit-copy-symbolic", Gtk.IconSize.SMALL_TOOLBAR); + panel_icon = new Gtk.Image.from_icon_name (NORMAL_ICON_NAME, Gtk.IconSize.SMALL_TOOLBAR); if (server_type == Wingpanel.IndicatorManager.ServerType.GREETER) { this.visible = false; } else { gnome_privacy_settings = new Settings ("org.gnome.desktop.privacy"); - gnome_privacy_settings.bind ("remember-recent-files", this, "visible", GET); + gnome_privacy_settings.bind ("remember-recent-files", this, "privacy-on", GET | INVERT_BOOLEAN); } } @@ -49,26 +72,35 @@ public class Clipboard.Indicator : Wingpanel.Indicator { history_widget.close_request.connect (() => { close (); }); - this.notify["visible"].connect (update_visibility); - update_visibility (); + + this.notify["privacy-on"].connect (update_appearance); + this.notify["always-hide"].connect (update_appearance); + update_appearance (); } - return history_widget; + // There doesn't seem to be a way of stopping Wingpanel showing the (blank) popover in the inactive state + // So show informative label. + return !privacy_on ? history_widget : inactive_widget; } public override void opened () { + } public override void closed () { } - private void update_visibility () { - if (!visible) { + private void update_appearance () { + if (privacy_on || always_hide) { history_widget.clear_history (); history_widget.stop_waiting_for_text (); - } else { + panel_icon.icon_name = STOPPED_ICON_NAME; + } else if (!privacy_on && !always_hide) { history_widget.wait_for_text (); + panel_icon.icon_name = NORMAL_ICON_NAME; } + + visible = !always_hide; } } From a94dc7404381b5841e43cf6ed3b8da2a27e80e5a Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Nov 2025 15:56:31 +0000 Subject: [PATCH 4/6] Add switch --- data/gschema.xml | 5 ++++ src/HistoryWidget.vala | 58 ++++++++++++++++++++++++++++++++++++++++++ src/Indicator.vala | 13 +++++----- 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/data/gschema.xml b/data/gschema.xml index c28eb66..f0586d3 100644 --- a/data/gschema.xml +++ b/data/gschema.xml @@ -6,5 +6,10 @@ Whether indicator is hidden and inactive Always hide indicator if set to true. While hidden the indicator does not monitor the clipboard. + + true + Whether indicator is active + Whether the indicator is monitoring and recording the clipboard contents + diff --git a/src/HistoryWidget.vala b/src/HistoryWidget.vala index 293680e..a121883 100644 --- a/src/HistoryWidget.vala +++ b/src/HistoryWidget.vala @@ -12,6 +12,15 @@ public class Clipboard.HistoryWidget : Gtk.Box { public signal void close_request (); construct { + orientation = VERTICAL; + spacing = 6; + + var active_switch = new Granite.SwitchModelButton (_("Clipboard Manager")) { + description = _("Monitoring the clipboard contents") + }; + + Clipboard.Indicator.settings.bind ("active", active_switch, "active", DEFAULT); + clipboard_text_set = new Gee.HashSet (); clipboard_item_list = new Gtk.ListBox () { @@ -24,6 +33,7 @@ public class Clipboard.HistoryWidget : Gtk.Box { scroll_box.hscrollbar_policy = Gtk.PolicyType.NEVER; scroll_box.add (clipboard_item_list); + add (active_switch); add (scroll_box); show_all (); @@ -105,4 +115,52 @@ public class Clipboard.HistoryWidget : Gtk.Box { add (label); } } + + // Taken from the Code project (https://github.com/elementary/code) + private class SettingSwitch : Gtk.Grid { + public string label { get; construct; } + public string settings_key { get; construct; } + public string description { get; construct; } + + public SettingSwitch (string label, string settings_key, string description = "") { + Object ( + description: description, + label: label, + settings_key: settings_key + ); + } + + construct { + var switch_widget = new Gtk.Switch () { + valign = CENTER + }; + + var label_widget = new Gtk.Label (label) { + halign = START, + hexpand = true, + mnemonic_widget = switch_widget + }; + + column_spacing = 12; + attach (label_widget, 0, 0); + attach (switch_widget, 1, 0, 1, 2); + + if (description != "") { + var description_label = new Gtk.Label (description) { + halign = START, + wrap = true, + xalign = 0 + }; + description_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + description_label.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL); + + attach (description_label, 0, 1); + + switch_widget.get_accessible ().accessible_description = description; + } + + Clipboard.Indicator.settings.bind (settings_key, switch_widget, "active", DEFAULT); + } + } + } diff --git a/src/Indicator.vala b/src/Indicator.vala index 3d34c4c..f2fcbbc 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -4,13 +4,13 @@ */ public class Clipboard.Indicator : Wingpanel.Indicator { - private static GLib.Settings settings; + public static GLib.Settings settings; private static GLib.Settings gnome_privacy_settings; private const string NORMAL_ICON_NAME = "edit-copy-symbolic"; private const string STOPPED_ICON_NAME = "task-past-due-symbolic"; private Gtk.Image panel_icon; private HistoryWidget history_widget; - private Gtk.Box inactive_widget; + private Gtk.Box privacy_widget; public bool always_hide { get; set; } public bool privacy_on { get; set; } @@ -37,12 +37,12 @@ public class Clipboard.Indicator : Wingpanel.Indicator { label = Granite.TOOLTIP_SECONDARY_TEXT_MARKUP.printf (_("History is off in the Privacy and Security settings")), use_markup = true }; - inactive_widget = new Gtk.Box (VERTICAL, 0) { + privacy_widget = new Gtk.Box (VERTICAL, 0) { margin_start = 6, margin_end = 6 }; - inactive_widget.add (inactive_header_label); - inactive_widget.add (inactive_subheader_label); + privacy_widget.add (inactive_header_label); + privacy_widget.add (inactive_subheader_label); // Ensure correct appearance before showing get_display_widget (); get_widget (); @@ -74,13 +74,14 @@ public class Clipboard.Indicator : Wingpanel.Indicator { }); this.notify["privacy-on"].connect (update_appearance); + // this.notify["privacy-on"].connect (get_widget); this.notify["always-hide"].connect (update_appearance); update_appearance (); } // There doesn't seem to be a way of stopping Wingpanel showing the (blank) popover in the inactive state // So show informative label. - return !privacy_on ? history_widget : inactive_widget; + return !privacy_on ? history_widget : privacy_widget; } public override void opened () { From a56b552002f4633ae029c8ae76a7f52f4f6dafbd Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Nov 2025 17:12:43 +0000 Subject: [PATCH 5/6] Refactor * Add Switch to HistoryWidget * Add "active" setting key * Change icon when inactive * Connect to owner-changed signal * Show different widget when Privacy is on and inactivate switch --- src/HistoryWidget.vala | 126 ++++++++++++++++++----------------------- src/Indicator.vala | 33 ++++------- 2 files changed, 66 insertions(+), 93 deletions(-) diff --git a/src/HistoryWidget.vala b/src/HistoryWidget.vala index a121883..6aeeced 100644 --- a/src/HistoryWidget.vala +++ b/src/HistoryWidget.vala @@ -8,6 +8,11 @@ public class Clipboard.HistoryWidget : Gtk.Box { private Gtk.ListBox clipboard_item_list; private string last_text = ""; private uint wait_timeout = 0; + private Granite.SwitchModelButton active_switch; + private Gtk.Box privacy_widget; + private Gtk.ScrolledWindow scroll_box; + private Gtk.Stack stack; + private unowned Gtk.Clipboard clipboard; public signal void close_request (); @@ -15,10 +20,22 @@ public class Clipboard.HistoryWidget : Gtk.Box { orientation = VERTICAL; spacing = 6; - var active_switch = new Granite.SwitchModelButton (_("Clipboard Manager")) { + active_switch = new Granite.SwitchModelButton (_("Clipboard Manager")) { description = _("Monitoring the clipboard contents") }; + var inactive_header_label = new Granite.HeaderLabel (_("The ClipboardManager is disabled")); + var inactive_subheader_label = new Gtk.Label ("") { + label = Granite.TOOLTIP_SECONDARY_TEXT_MARKUP.printf (_("History is off in the Privacy and Security settings")), + use_markup = true + }; + privacy_widget = new Gtk.Box (VERTICAL, 0) { + margin_start = 6, + margin_end = 6 + }; + privacy_widget.add (inactive_header_label); + privacy_widget.add (inactive_subheader_label); + Clipboard.Indicator.settings.bind ("active", active_switch, "active", DEFAULT); clipboard_text_set = new Gee.HashSet (); @@ -27,14 +44,20 @@ public class Clipboard.HistoryWidget : Gtk.Box { selection_mode = SINGLE }; clipboard_item_list.set_placeholder (new Gtk.Label (_("Clipboard Empty"))); - var scroll_box = new Gtk.ScrolledWindow (null, null); + + scroll_box = new Gtk.ScrolledWindow (null, null); scroll_box.max_content_height = 512; scroll_box.propagate_natural_height = true; scroll_box.hscrollbar_policy = Gtk.PolicyType.NEVER; scroll_box.add (clipboard_item_list); + stack = new Gtk.Stack (); + stack.add_named (scroll_box, "clipboard"); + stack.add_named (privacy_widget, "privacy"); + add (active_switch); - add (scroll_box); + add (stack); + show_all (); clipboard_item_list.row_activated.connect ((row) => { @@ -43,6 +66,8 @@ public class Clipboard.HistoryWidget : Gtk.Box { clipboard.set_text (text, -1); close_request (); }); + + clipboard = Gtk.Clipboard.get_default (Gdk.Display.get_default ()); } ~HistoryWidget () { @@ -51,31 +76,27 @@ public class Clipboard.HistoryWidget : Gtk.Box { // No notifications from clipboard? So poll it periodically for new text public void wait_for_text () { - var clipboard = Gtk.Clipboard.get_default (Gdk.Display.get_default ()); - wait_timeout = Timeout.add_full (Priority.LOW, 1000, () => { - if (clipboard.wait_is_text_available ()) { - clipboard.request_text ((cb, text) => { - if (text != last_text && !clipboard_text_set.contains (text)) { - last_text = text; - clipboard_text_set.add (text); - var new_item = new ItemRow (text); - clipboard_item_list.prepend (new_item); - clipboard_item_list.select_row (new_item); - clipboard_item_list.show_all (); - } - }); - } - - return Source.CONTINUE; - }); + clipboard.owner_change.connect (on_clipboard_owner_change); } - public void stop_waiting_for_text () { - if (wait_timeout > 0) { - Source.remove (wait_timeout); + private void on_clipboard_owner_change () requires (clipboard != null) { + if (clipboard.wait_is_text_available ()) { + clipboard.request_text ((cb, text) => { + if (!clipboard_text_set.contains (text)) { + clipboard_text_set.add (text); + var new_item = new ItemRow (text); + clipboard_item_list.prepend (new_item); + clipboard_item_list.select_row (new_item); + clipboard_item_list.show_all (); + } + }); } } + public void stop_waiting_for_text () requires (clipboard != null) { + clipboard.owner_change.disconnect (on_clipboard_owner_change); + } + public void clear_history () { clipboard_text_set.clear (); clipboard_item_list.@foreach ((child) => { @@ -83,6 +104,17 @@ public class Clipboard.HistoryWidget : Gtk.Box { }); } + public void set_privacy_mode (bool privacy_on) { + active_switch.sensitive = !privacy_on; + stack.visible_child_name = privacy_on ? "privacy" : "clipboard"; + if (privacy_on) { + stop_waiting_for_text (); + clear_history (); + } else { + wait_for_text (); + } + } + private class ItemRow : Gtk.ListBoxRow { public string text { get; construct; } public string prettier_text { get; construct; } @@ -115,52 +147,4 @@ public class Clipboard.HistoryWidget : Gtk.Box { add (label); } } - - // Taken from the Code project (https://github.com/elementary/code) - private class SettingSwitch : Gtk.Grid { - public string label { get; construct; } - public string settings_key { get; construct; } - public string description { get; construct; } - - public SettingSwitch (string label, string settings_key, string description = "") { - Object ( - description: description, - label: label, - settings_key: settings_key - ); - } - - construct { - var switch_widget = new Gtk.Switch () { - valign = CENTER - }; - - var label_widget = new Gtk.Label (label) { - halign = START, - hexpand = true, - mnemonic_widget = switch_widget - }; - - column_spacing = 12; - attach (label_widget, 0, 0); - attach (switch_widget, 1, 0, 1, 2); - - if (description != "") { - var description_label = new Gtk.Label (description) { - halign = START, - wrap = true, - xalign = 0 - }; - description_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); - description_label.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL); - - attach (description_label, 0, 1); - - switch_widget.get_accessible ().accessible_description = description; - } - - Clipboard.Indicator.settings.bind (settings_key, switch_widget, "active", DEFAULT); - } - } - } diff --git a/src/Indicator.vala b/src/Indicator.vala index f2fcbbc..4d3e75d 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -10,8 +10,9 @@ public class Clipboard.Indicator : Wingpanel.Indicator { private const string STOPPED_ICON_NAME = "task-past-due-symbolic"; private Gtk.Image panel_icon; private HistoryWidget history_widget; - private Gtk.Box privacy_widget; + public bool always_hide { get; set; } + public bool active { get; set; } public bool privacy_on { get; set; } public Wingpanel.IndicatorManager.ServerType server_type { get; construct set; } @@ -31,21 +32,13 @@ public class Clipboard.Indicator : Wingpanel.Indicator { settings = new GLib.Settings ("io.github.ellie_commons.indicator-clipboard"); settings.bind ("always-hide", this, "always-hide", DEFAULT); + settings.bind ("active", this, "active", DEFAULT); + - var inactive_header_label = new Granite.HeaderLabel (_("The ClipboardManager is disabled")); - var inactive_subheader_label = new Gtk.Label ("") { - label = Granite.TOOLTIP_SECONDARY_TEXT_MARKUP.printf (_("History is off in the Privacy and Security settings")), - use_markup = true - }; - privacy_widget = new Gtk.Box (VERTICAL, 0) { - margin_start = 6, - margin_end = 6 - }; - privacy_widget.add (inactive_header_label); - privacy_widget.add (inactive_subheader_label); // Ensure correct appearance before showing get_display_widget (); get_widget (); + update_appearance (); } @@ -57,7 +50,7 @@ public class Clipboard.Indicator : Wingpanel.Indicator { this.visible = false; } else { gnome_privacy_settings = new Settings ("org.gnome.desktop.privacy"); - gnome_privacy_settings.bind ("remember-recent-files", this, "privacy-on", GET | INVERT_BOOLEAN); + gnome_privacy_settings.bind ("remember-recent-files", this, "privacy-on", DEFAULT | INVERT_BOOLEAN); } } @@ -74,14 +67,12 @@ public class Clipboard.Indicator : Wingpanel.Indicator { }); this.notify["privacy-on"].connect (update_appearance); - // this.notify["privacy-on"].connect (get_widget); this.notify["always-hide"].connect (update_appearance); + this.notify["active"].connect (update_appearance); update_appearance (); } - // There doesn't seem to be a way of stopping Wingpanel showing the (blank) popover in the inactive state - // So show informative label. - return !privacy_on ? history_widget : privacy_widget; + return history_widget; } public override void opened () { @@ -92,16 +83,14 @@ public class Clipboard.Indicator : Wingpanel.Indicator { } private void update_appearance () { - if (privacy_on || always_hide) { - history_widget.clear_history (); - history_widget.stop_waiting_for_text (); + if (!active || privacy_on || always_hide) { panel_icon.icon_name = STOPPED_ICON_NAME; - } else if (!privacy_on && !always_hide) { - history_widget.wait_for_text (); + } else if (active && !privacy_on && !always_hide) { panel_icon.icon_name = NORMAL_ICON_NAME; } visible = !always_hide; + history_widget.set_privacy_mode (privacy_on); } } From 2994e42e26f514e286ae7b3e77d2a3a56b1ba537 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 13 Nov 2025 17:57:51 +0000 Subject: [PATCH 6/6] Change switch description when in privacy mode --- src/HistoryWidget.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/HistoryWidget.vala b/src/HistoryWidget.vala index 6aeeced..3226a34 100644 --- a/src/HistoryWidget.vala +++ b/src/HistoryWidget.vala @@ -4,6 +4,9 @@ */ public class Clipboard.HistoryWidget : Gtk.Box { + private const string ACTIVE_DESCRIPTION = N_("Monitoring the clipboard contents"); + private const string PRIVACY_DESCRIPTION = N_("Privacy Mode is On"); + private Gee.HashSet clipboard_text_set; private Gtk.ListBox clipboard_item_list; private string last_text = ""; @@ -21,7 +24,7 @@ public class Clipboard.HistoryWidget : Gtk.Box { spacing = 6; active_switch = new Granite.SwitchModelButton (_("Clipboard Manager")) { - description = _("Monitoring the clipboard contents") + description = _(ACTIVE_DESCRIPTION) }; var inactive_header_label = new Granite.HeaderLabel (_("The ClipboardManager is disabled")); @@ -87,7 +90,6 @@ public class Clipboard.HistoryWidget : Gtk.Box { var new_item = new ItemRow (text); clipboard_item_list.prepend (new_item); clipboard_item_list.select_row (new_item); - clipboard_item_list.show_all (); } }); } @@ -110,8 +112,10 @@ public class Clipboard.HistoryWidget : Gtk.Box { if (privacy_on) { stop_waiting_for_text (); clear_history (); + active_switch.description = _(PRIVACY_DESCRIPTION); } else { wait_for_text (); + active_switch.description = _(ACTIVE_DESCRIPTION); } }