summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2017-08-22 11:55:40 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2017-08-22 11:56:14 +0200
commit0b745460ec5ae30bb3995fc81ec77ca693b4d17a (patch)
tree58dc5854f5ac6971148fbe7c16d0acfdb55239f4
parentb91c9b1e8f1c297acf2c8d7a508fd6293ad9e837 (diff)
downloadgnome-contacts-0b745460ec5ae30bb3995fc81ec77ca693b4d17a.tar.gz
Cleanup, use GtkTemplate for AccountsList
-rw-r--r--data/Makefile.am1
-rw-r--r--data/contacts.gresource.xml1
-rw-r--r--data/ui/contacts-accounts-list.ui44
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/contacts-accounts-list.vala63
5 files changed, 67 insertions, 43 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index 28e5191..32d56d9 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -37,6 +37,7 @@ EXTRA_DIST = \
org.gnome.Contacts.SearchProvider.service.in \
contacts.gresource.xml \
ui/app-menu.ui \
+ ui/contacts-accounts-list.ui \
ui/contacts-address-map.ui \
ui/contacts-avatar-dialog.ui \
ui/contacts-contact-editor.ui \
diff --git a/data/contacts.gresource.xml b/data/contacts.gresource.xml
index 52be8a9..69cacc7 100644
--- a/data/contacts.gresource.xml
+++ b/data/contacts.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/org/gnome/contacts">
<file compressed="true">ui/style.css</file>
<file compressed="true" preprocess="xml-stripblanks">ui/app-menu.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">ui/contacts-accounts-list.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-address-map.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-avatar-dialog.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/contacts-contact-editor.ui</file>
diff --git a/data/ui/contacts-accounts-list.ui b/data/ui/contacts-accounts-list.ui
new file mode 100644
index 0000000..5b6152c
--- /dev/null
+++ b/data/ui/contacts-accounts-list.ui
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.22 -->
+ <template class="ContactsAccountsList" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolled">
+ <property name="visible">True</property>
+ <property name="min_content_height">210</property>
+ <property name="shadow_type">in</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkListBox" id="accounts_view">
+ <property name="visible">True</property>
+ <property name="selection_mode">none</property>
+ <property name="width_request">372</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="goa_button">
+ <property name="visible">True</property>
+ <signal name="clicked" handler="on_goa_button_clicked" swapped="no"/>
+ <style>
+ <class name="raised"/>
+ </style>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Online Accounts</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0f80370..008f079 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,6 +3,7 @@
data/org.gnome.Contacts.appdata.xml.in
data/org.gnome.Contacts.desktop.in
data/ui/app-menu.ui
+data/ui/contacts-accounts-list.ui
data/ui/contacts-avatar-dialog.ui
data/ui/contacts-contact-editor.ui
data/ui/contacts-contact-pane.ui
diff --git a/src/contacts-accounts-list.vala b/src/contacts-accounts-list.vala
index 0dd7f17..e742819 100644
--- a/src/contacts-accounts-list.vala
+++ b/src/contacts-accounts-list.vala
@@ -1,4 +1,3 @@
-/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 8 -*- */
/*
* Copyright (C) 2011 Erick PĂ©rez Castellanos <erick.red@gmail.com>
*
@@ -19,54 +18,22 @@
using Gtk;
using Folks;
-public class Contacts.AccountsList : Grid {
- ListBox accounts_view;
- ListBoxRow last_selected_row;
- Button add_account_button;
+[GtkTemplate (ui = "/org/gnome/contacts/ui/contacts-accounts-list.ui")]
+public class Contacts.AccountsList : Box {
+ [GtkChild]
+ private ListBox accounts_view;
+
+ private ListBoxRow last_selected_row;
public PersonaStore selected_store;
public signal void account_selected ();
construct {
- set_orientation (Orientation.VERTICAL);
- set_row_spacing (12);
-
- selected_store = null;
-
- accounts_view = new ListBox ();
- accounts_view.set_selection_mode (SelectionMode.NONE);
- accounts_view.set_size_request (372, -1);
- accounts_view.set_header_func (add_separator);
-
- var scrolled = new ScrolledWindow(null, null);
- scrolled.set_min_content_height (210);
- scrolled.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
- scrolled.set_shadow_type (ShadowType.IN);
- scrolled.add (accounts_view);
-
- add_account_button = new Button.with_label (_("Online Accounts"));
- add_account_button.get_style_context ().add_class (STYLE_CLASS_RAISED);
- add_account_button.get_child ().margin_start = 6;
- add_account_button.get_child ().margin_end = 6;
- add_account_button.get_child ().margin_top = 3;
- add_account_button.get_child ().margin_bottom = 3;
- add_account_button.clicked.connect (() => {
- try {
- Process.spawn_command_line_async ("gnome-control-center online-accounts");
- }
- catch (Error e) {
- // TODO: Show error dialog
- }
- });
-
- add (scrolled);
- add (add_account_button);
-
- show_all ();
-
- /* signal handling */
- accounts_view.row_activated.connect (row_activated);
+ this.selected_store = null;
+
+ this.accounts_view.set_header_func (add_separator);
+ this.accounts_view.row_activated.connect (row_activated);
}
private void row_activated (ListBoxRow? row) {
@@ -183,4 +150,14 @@ public class Contacts.AccountsList : Grid {
accounts_view.show_all ();
}
+
+ [GtkCallback]
+ private void on_goa_button_clicked () {
+ try {
+ Process.spawn_command_line_async ("gnome-control-center online-accounts");
+ } catch (Error e) {
+ // TODO: Show error dialog
+ warning ("Couldn't open GOA: %s", e.message);
+ }
+ }
}