aboutsummaryrefslogtreecommitdiff
path: root/libdino
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-11 12:13:06 +0100
committerfiaxh <git@mx.ax.lt>2017-03-11 12:22:55 +0100
commit47ab19b3a06b6f96965482e4a33d443c2276c1d8 (patch)
treef6616e248a92b707269eda6a396c94180687dc45 /libdino
parent7bb6ff6250e7bfc1f5d8ee4cc5d49c7aaf5ac435 (diff)
downloaddino-47ab19b3a06b6f96965482e4a33d443c2276c1d8.tar.gz
dino-47ab19b3a06b6f96965482e4a33d443c2276c1d8.zip
UI to choose PGP key/disabled in account settings
Diffstat (limited to 'libdino')
-rw-r--r--libdino/CMakeLists.txt11
-rw-r--r--libdino/data/manage_accounts/dialog.ui2
-rw-r--r--libdino/src/ui/manage_accounts/dialog.vala39
3 files changed, 45 insertions, 7 deletions
diff --git a/libdino/CMakeLists.txt b/libdino/CMakeLists.txt
index 92616eb2..6fc31050 100644
--- a/libdino/CMakeLists.txt
+++ b/libdino/CMakeLists.txt
@@ -128,8 +128,9 @@ SOURCES
src/ui/unified_window.vala
src/ui/util.vala
CUSTOM_VAPIS
- ${CMAKE_BINARY_DIR}/xmpp-vala/xmpp-vala.vapi
- ${CMAKE_BINARY_DIR}/qlite/qlite.vapi
+ "${CMAKE_BINARY_DIR}/xmpp-vala/xmpp-vala.vapi"
+ "${CMAKE_BINARY_DIR}/qlite/qlite.vapi"
+ "${CMAKE_BINARY_DIR}/gpgme-vala/gpgme.vapi"
PACKAGES
${LIBDINO_PACKAGES}
GENERATE_VAPI
@@ -144,11 +145,11 @@ OPTIONS
--thread
)
-set(CFLAGS ${VALA_CFLAGS} ${LIBDINO_CFLAGS} -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite)
+set(CFLAGS ${VALA_CFLAGS} ${LIBDINO_CFLAGS} -I${CMAKE_BINARY_DIR}/xmpp-vala -I${CMAKE_BINARY_DIR}/qlite -I${CMAKE_BINARY_DIR}/gpgme-vala -I${CMAKE_SOURCE_DIR}/gpgme-vala/src)
add_definitions(${CFLAGS})
add_library(libdino SHARED ${LIBDINO_VALA_C} ${LIBDINO_GRESOURCES_TARGET})
-add_dependencies(libdino xmpp-vala-vapi qlite-vapi)
-target_link_libraries(libdino xmpp-vala qlite ${LIBDINO_LIBRARIES} -lm)
+add_dependencies(libdino xmpp-vala-vapi qlite-vapi gpgme-vapi)
+target_link_libraries(libdino xmpp-vala qlite gpgme-vala ${LIBDINO_LIBRARIES} -lm)
set_target_properties(libdino PROPERTIES PREFIX "")
add_custom_target(dino-vapi
diff --git a/libdino/data/manage_accounts/dialog.ui b/libdino/data/manage_accounts/dialog.ui
index 64397fb7..d44cae71 100644
--- a/libdino/data/manage_accounts/dialog.ui
+++ b/libdino/data/manage_accounts/dialog.ui
@@ -282,7 +282,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBoxText" id="pgp_combobox">
+ <object class="GtkComboBox" id="pgp_combobox">
<property name="hexpand">True</property>
<property name="width_request">200</property>
<property name="visible">True</property>
diff --git a/libdino/src/ui/manage_accounts/dialog.vala b/libdino/src/ui/manage_accounts/dialog.vala
index 8f5fb7d1..879c6aee 100644
--- a/libdino/src/ui/manage_accounts/dialog.vala
+++ b/libdino/src/ui/manage_accounts/dialog.vala
@@ -1,5 +1,6 @@
using Gdk;
using Gtk;
+using Markup;
using Dino.Entities;
@@ -34,13 +35,17 @@ public class Dialog : Gtk.Window {
[GtkChild] public Stack pgp_stack;
[GtkChild] public Label pgp_label;
[GtkChild] public Button pgp_button;
- [GtkChild] public ComboBoxText pgp_combobox;
+ [GtkChild] public ComboBox pgp_combobox;
private Database db;
private StreamInteractor stream_interactor;
construct {
+ CellRendererText renderer = new Gtk.CellRendererText();
+ pgp_combobox.pack_start(renderer, true);
+ pgp_combobox.add_attribute(renderer, "markup", 0);
+
account_list.row_selected.connect(account_list_row_selected);
add_button.clicked.connect(add_button_clicked);
no_accounts_add.clicked.connect(add_button_clicked);
@@ -126,9 +131,41 @@ public class Dialog : Gtk.Window {
password_button.clicked.connect(() => { set_active_stack(password_stack); });
alias_button.clicked.connect(() => { set_active_stack(alias_stack); });
+ pgp_button.clicked.connect(() => { set_active_stack(pgp_stack); pgp_combobox.popup(); });
active_switch.state_set.connect(on_active_switch_state_changed);
+
+ populate_pgp_combobox(account);
+ }
+
+ private void populate_pgp_combobox(Account account) {
+
+ Gtk.ListStore list_store = new Gtk.ListStore(2, typeof(string), typeof(string?));
+ Gtk.TreeIter iter;
+
+ pgp_combobox.set_model(list_store);
+
+ list_store.append(out iter);
+ list_store.set(iter, 0, "Disabled", 1, null);
+ Gee.List<GPG.Key> list = GPGHelper.get_keylist(null, true);
+ foreach (GPG.Key key in list) {
+ list_store.append(out iter);
+ list_store.set(iter, 0, @"<span font='11'>$(escape_text(key.uids[0].uid))</span>\n<span font='9'>0x$(escape_text(key.fpr[0:16]))</span>");
+ list_store.set(iter, 1, key.fpr);
+ }
+
+ pgp_combobox.set_active(0);
+
+ pgp_combobox.changed.connect(() => {
+ TreeIter selected;
+ pgp_combobox.get_active_iter(out selected);
+ Value text;
+ list_store.get_value(selected, 0, out text);
+ pgp_label.set_markup((string) text);
+ pgp_stack.set_visible_child_name("label");
+ });
}
+
private void on_image_button_clicked() {
FileChooserDialog chooser = new FileChooserDialog (
"Select avatar", this, FileChooserAction.OPEN,