[seahorse] Sidebar: Update view when new item is added
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Sidebar: Update view when new item is added
- Date: Mon, 12 Nov 2018 07:28:18 +0000 (UTC)
commit 3664aa84bde455ec247e23f9645629bef474b209
Author: Anukul Sangwan <anukulsangwan icloud com>
Date: Sun Sep 2 01:35:52 2018 +0530
Sidebar: Update view when new item is added
src/generate-select.vala | 6 ++++++
src/key-manager.vala | 19 +++++++++++++++++++
src/sidebar.vala | 16 ++++++++++++++++
3 files changed, 41 insertions(+)
---
diff --git a/src/generate-select.vala b/src/generate-select.vala
index 723b198d..9bd42b0a 100644
--- a/src/generate-select.vala
+++ b/src/generate-select.vala
@@ -43,6 +43,7 @@ public class Seahorse.GenerateSelect : Gtk.Dialog {
// Fill up the model
var action_groups = (List<Gtk.ActionGroup>) Registry.object_instances("generator");
foreach (var action_group in action_groups) {
+ action_group.post_activate.connect(this.switch_view);
foreach (var action in action_group.list_actions())
store.append(action);
}
@@ -58,6 +59,11 @@ public class Seahorse.GenerateSelect : Gtk.Dialog {
}
}
+ private void switch_view(Gtk.Action action) {
+ string target = action.action_group.name.split("-", 2)[0];
+ ((KeyManager) this.transient_for).set_focused_place(target);
+ }
+
private Gtk.ListBoxRow on_create_row(GLib.Object item) {
return new GenerateSelectRow((Gtk.Action) item);
}
diff --git a/src/key-manager.vala b/src/key-manager.vala
index ae56ec76..8e04a05c 100644
--- a/src/key-manager.vala
+++ b/src/key-manager.vala
@@ -365,6 +365,25 @@ public class Seahorse.KeyManager : Catalog {
return KeyManagerStore.get_selected_objects(this.view);
}
+ public void set_focused_place(string target) {
+ string? uri_prefix = null;
+ switch(target) {
+ case "ssh":
+ case "pkcs11":
+ uri_prefix = "openssh";
+ break;
+ case "gpgme":
+ uri_prefix = "gnupg";
+ break;
+ case "gkr":
+ uri_prefix = "secret-service";
+ break;
+ }
+ if (uri_prefix != null) {
+ this.sidebar.set_focused_place(uri_prefix);
+ }
+ }
+
public override Place? get_focused_place() {
return this.sidebar.get_focused_place();
}
diff --git a/src/sidebar.vala b/src/sidebar.vala
index aa0a01d5..401cc12b 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -881,6 +881,22 @@ public class Seahorse.Sidebar : Gtk.ScrolledWindow {
return null;
}
+ public void set_focused_place(string uri_prefix) {
+ foreach (Backend backend in this.backends) {
+ foreach (weak GLib.Object obj in backend.get_objects()) {
+ Place place = obj as Place;
+ if (place == null)
+ continue;
+ else if (place.uri.has_prefix(uri_prefix)) {
+ var chosen = new GenericSet<string?>(str_hash, str_equal);
+ chosen.add(place.uri);
+ this.update_objects_for_chosen(chosen);
+ return;
+ }
+ }
+ }
+ }
+
public List<weak Backend>? get_backends() {
Gtk.TreeIter iter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]