[gnome-contacts] Window: Add the Online Accounts hamburger menu button



commit d5f7f9e8502c303edcfe68a554af423fcda8fc97
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Aug 23 17:43:40 2018 +0200

    Window: Add the Online Accounts hamburger menu button
    
    Add the 'app.online-accounts' displaying the online account settings and
    and the Online Accounts button to the hamburger menu to trigger it.
    
    This closer matches the new design.

 data/ui/contacts-window.ui |  9 +++++++++
 src/contacts-app.vala      | 37 ++++++++++++++++++++++++++++++++-----
 2 files changed, 41 insertions(+), 5 deletions(-)
---
diff --git a/data/ui/contacts-window.ui b/data/ui/contacts-window.ui
index a2ca62d..12498ad 100644
--- a/data/ui/contacts-window.ui
+++ b/data/ui/contacts-window.ui
@@ -90,6 +90,15 @@
             <property name="visible">True</property>
           </object>
         </child>
+        <child>
+          <object class="GtkModelButton">
+            <property name="can_focus">True</property>
+            <property name="text" translatable="yes">Online Accounts &lt;sup&gt;↗&lt;/sup&gt;</property>
+            <property name="action-name">app.online-accounts</property>
+            <property name="use-markup">True</property>
+            <property name="visible">True</property>
+          </object>
+        </child>
         <child>
           <object class="GtkSeparator">
             <property name="margin-top">6</property>
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 079b144..3cbded9 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -29,11 +29,12 @@ public class Contacts.App : Gtk.Application {
   private bool is_quiescent_scheduled = false;
 
   private const GLib.ActionEntry[] action_entries = {
-    { "quit",        quit                },
-    { "help",        show_help           },
-    { "about",       show_about          },
-    { "change-book", change_address_book },
-    { "new-contact", new_contact         }
+    { "quit",            quit                },
+    { "help",            show_help           },
+    { "about",           show_about          },
+    { "change-book",     change_address_book },
+    { "online-accounts", online_accounts     },
+    { "new-contact",     new_contact         }
   };
 
   private const OptionEntry[] options = {
@@ -159,6 +160,32 @@ public class Contacts.App : Gtk.Application {
       });
   }
 
+  public void online_accounts () {
+    try {
+      var proxy = new DBusProxy.for_bus_sync (BusType.SESSION,
+                                              DBusProxyFlags.NONE,
+                                              null,
+                                              "org.gnome.ControlCenter",
+                                              "/org/gnome/ControlCenter",
+                                              "org.gtk.Actions");
+
+      var builder = new VariantBuilder (new VariantType ("av") );
+      builder.add ("v", new Variant.string (""));
+      var param = new Variant.tuple ({
+        new Variant.string ("launch-panel"),
+        new Variant.array (new VariantType ("v"), {
+          new Variant ("v", new Variant ("(sav)", "online-accounts", builder))
+        }),
+        new Variant.array (new VariantType ("{sv}"), {})
+      });
+
+      proxy.call_sync ("Activate", param, DBusCallFlags.NONE, -1);
+    } catch (Error e) {
+      // TODO: Show error dialog
+      warning ("Couldn't open online-accounts: %s", e.message);
+    }
+  }
+
   public void show_help () {
     try {
       Gtk.show_uri_on_window (window, "help:gnome-help/contacts", Gtk.get_current_event_time ());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]