From 13b18a12b0b6c7dc32a7bf1c03386eb0eb9cceba Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 10 Mar 2017 20:14:39 -0800 Subject: [PATCH 1/2] show copy button for all single fields --- item_view.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/item_view.h b/item_view.h index bb02506..1627975 100644 --- a/item_view.h +++ b/item_view.h @@ -53,10 +53,10 @@ class ItemView : public Gtk::Grid { } void processSingleField(const KeychainField& field) { - processSingleField(field.name, field.value, field.password); + processSingleField(field.name, field.value, field.password, true); } - void processSingleField(std::string label, std::string value, bool conceal) { + void processSingleField(std::string label, std::string value, bool conceal, bool copy_button) { auto my_index = row_index++; auto label_widget = Gtk::manage(new Gtk::Label(label)); @@ -81,9 +81,9 @@ class ItemView : public Gtk::Grid { if (conceal && !isTOTP) value_widget->set_visibility(false); - attach(*value_widget, 1, my_index, conceal ? 1 : 3, 1); + attach(*value_widget, 1, my_index, conceal || copy_button ? 1 : 3, 1); - if (conceal) { + if (copy_button) { auto copy_button = Gtk::manage(new Gtk::Button("_Copy", true)); copy_button->signal_clicked().connect([value_widget]() { auto valueText = value_widget->get_text(); @@ -92,6 +92,9 @@ class ItemView : public Gtk::Grid { clipboard->store(); }); attach(*copy_button, 2, my_index, 1, 1); + } + + if (conceal) { if (isTOTP) { auto calculate_button = Gtk::manage(new Gtk::Button("_Calculate", true)); calculate_button->signal_clicked().connect([value, value_widget]() { From 91bf4b97477c93cc8e91df6258892d93dea6d006 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 13 Mar 2017 21:58:24 -0700 Subject: [PATCH 2/2] No need for copy_button param --- item_view.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/item_view.h b/item_view.h index 1627975..cf642e3 100644 --- a/item_view.h +++ b/item_view.h @@ -53,10 +53,10 @@ class ItemView : public Gtk::Grid { } void processSingleField(const KeychainField& field) { - processSingleField(field.name, field.value, field.password, true); + processSingleField(field.name, field.value, field.password); } - void processSingleField(std::string label, std::string value, bool conceal, bool copy_button) { + void processSingleField(std::string label, std::string value, bool conceal) { auto my_index = row_index++; auto label_widget = Gtk::manage(new Gtk::Label(label)); @@ -81,18 +81,16 @@ class ItemView : public Gtk::Grid { if (conceal && !isTOTP) value_widget->set_visibility(false); - attach(*value_widget, 1, my_index, conceal || copy_button ? 1 : 3, 1); - - if (copy_button) { - auto copy_button = Gtk::manage(new Gtk::Button("_Copy", true)); - copy_button->signal_clicked().connect([value_widget]() { - auto valueText = value_widget->get_text(); - auto clipboard = Gtk::Clipboard::get(); - clipboard->set_text(valueText); - clipboard->store(); - }); - attach(*copy_button, 2, my_index, 1, 1); - } + attach(*value_widget, 1, my_index, 1, 1); + + auto copy_button = Gtk::manage(new Gtk::Button("_Copy", true)); + copy_button->signal_clicked().connect([value_widget]() { + auto valueText = value_widget->get_text(); + auto clipboard = Gtk::Clipboard::get(); + clipboard->set_text(valueText); + clipboard->store(); + }); + attach(*copy_button, 2, my_index, 1, 1); if (conceal) { if (isTOTP) {