Unverified Commit b2d0a275 authored by Julian Sparber's avatar Julian Sparber

Merge branch 'librem5' into pureos/sloppy

parents ede5f221 ce72dbf7
stages:
- build-flatpak
- build-arm-flatpak
# We always use flatpak-builder to check if everything still works.
flatpak:master:
tags:
- flatpak
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
stage: build-flatpak
script:
- flatpak-builder --stop-at=gnome-contacts app data/flatpak/org.gnome.Contacts.json
# Make sure to keep this in sync with the Flatpak manifest, all arguments
# are passed except the config-args because we build it ourselves
- flatpak build app meson --prefix=/app _build
- flatpak build app ninja -C _build test
- flatpak build app ninja -C _build install
- flatpak-builder --finish-only --repo=repo app data/flatpak/org.gnome.Contacts.json
# Make a Flatpak Contacts bundle for people to test
- flatpak build-bundle repo contacts-dev.flatpak --runtime-repo=https://nightly.gnome.org/gnome-nightly.flatpakrepo org.gnome.Contacts
# Run the tests
- bash +x ./.gitlab-ci/run-tests.sh
artifacts:
reports:
junit: "_build/${CI_JOB_NAME}-report.xml"
name: "gnome-contacts-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
when: always
paths:
- contacts-dev.flatpak
- _build/meson-logs/
expire_in: 14 days
cache:
paths:
- .flatpak-builder/cache
flatpak-arm64:master:
tags:
- ARM64
image: jsparber/ci-arm64:arm64
stage: build-arm-flatpak
script:
- flatpak-builder --stop-at=gnome-contacts app data/flatpak/org.gnome.Contacts.json
# Make sure to keep this in sync with the Flatpak manifest, all arguments
# are passed except the config-args because we build it ourselves
- flatpak build app meson --prefix=/app _build
- flatpak build app ninja -C _build test
- flatpak build app ninja -C _build install
- flatpak-builder --finish-only --repo=repo app data/flatpak/org.gnome.Contacts.json
# Make a Flatpak Contacts bundle for people to test
- flatpak build-bundle repo contacts-dev.flatpak --runtime-repo=https://nightly.gnome.org/gnome-nightly.flatpakrepo org.gnome.Contacts
# Run the tests
- bash +x ./.gitlab-ci/run-tests.sh
artifacts:
reports:
junit: "_build/${CI_JOB_NAME}-report.xml"
name: "gnome-contacts-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
when: always
paths:
- contacts-dev.flatpak
- _build/meson-logs/
expire_in: 14 days
cache:
paths:
- .flatpak-builder/cache
......@@ -170,7 +170,7 @@
<property name="halign">center</property>
<property name="valign">center</property>
<property name="tooltip_text" translatable="yes">Create new contact</property>
<signal name="clicked" handler="new_contact" object="ContactsWindow" after="no" swapped="no"/>
<property name="action-name">app.new-contact</property>
<child internal-child="accessible">
<object class="AtkObject" id="add_button_atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Add contact</property>
......
......@@ -16,6 +16,7 @@
*/
using Gtk;
using Gee;
using Hdy;
using Folks;
......@@ -35,7 +36,8 @@ public class Contacts.App : Gtk.Application {
{ "about", show_about },
{ "change-book", change_address_book },
{ "online-accounts", online_accounts },
{ "new-contact", new_contact },
{ "new-contact", on_new_contact },
{ "new-contact-data", on_new_contact, "a(ss)" },
{ "show-contact", on_show_contact, "s"}
};
......@@ -406,8 +408,66 @@ public class Contacts.App : Gtk.Application {
window.present ();
}
public void new_contact () {
window.new_contact ();
private void on_new_contact (SimpleAction action, Variant? param) {
HashTable<string, Value?> details = null;
if (param != null)
details = array_to_details (param);
if (window == null)
create_window ();
window.present ();
window.new_contact (details);
}
private void add_field_details<T> (HashTable<string, Value?> details, string key, string value) {
var val = details.get(key);
Set<T> current = (val != null) ? (Set<T>) details.get(key): null;
if (current == null) {
current = new HashSet<T> ();
details.set (key, current);
}
// WORKAROUND: This is a workaround for https://gitlab.gnome.org/GNOME/vala/issues/871
var obj = Object.new (typeof (T),
"t-type", typeof(string),
"t-dup-func", string.dup,
"t-destroy-func", free,
"value", value);
current.add (obj);
}
/* This converts a array of (key, value) to HashTable details expected by folks */
/* Todo: implement all property, currently only a couple of properties can be set via dbus */
private HashTable<string, Value?> array_to_details (Variant param) {
var details = new HashTable<string, Value?> (str_hash, str_equal);
foreach (Variant item in param) {
string? key = item.get_child_value(0) as string;
string? value = item.get_child_value(1) as string;
if (key == null || value == null)
continue;
switch (key) {
case "alias":
case "full-name":
case "nickname":
details.set (key, value);
break;
case "email-addresses":
add_field_details<EmailFieldDetails> (details, key, value);
break;
case "notes":
add_field_details<NoteFieldDetails> (details, key, value);
break;
case "phone-numbers":
add_field_details<PhoneFieldDetails> (details, key, value);
break;
default:
warning ("Not implemented or unknown property '%s'", key);
break;
}
}
return details;
}
private void on_show_contact(SimpleAction action, Variant? param) {
......
......@@ -38,10 +38,18 @@ public class Contacts.Avatar : DrawingArea {
this.individual = individual;
if (individual != null) {
individual.notify["avatar"].connect ( (s, p) => {
load_avatar.begin ();
this.avatar_loaded = (individual == null || individual.avatar == null);
this.cache = null;
queue_draw ();
});
}
notify["scale-factor"].connect ( () => {
this.avatar_loaded = (individual == null || individual.avatar == null);
this.cache = null;
queue_draw ();
});
this.size = size;
this.display_size = size;
set_size_request (size, size);
......@@ -74,9 +82,12 @@ public class Contacts.Avatar : DrawingArea {
this.avatar_loaded = true;
try {
var stream = yield this.individual.avatar.load_async (this.size);
var stream = yield this.individual.avatar.load_async (this.size * this.scale_factor);
this.cache = null;
this.pixbuf = yield new Gdk.Pixbuf.from_stream_at_scale_async (stream, this.size, this.size, true);
this.pixbuf = yield new Gdk.Pixbuf.from_stream_at_scale_async (stream,
this.size * this.scale_factor,
this.size * this.scale_factor,
true);
queue_draw ();
} catch (Error e) {
debug ("Couldn't load avatar of contact %s. Reason: %s", this.individual.display_name, e.message);
......@@ -106,6 +117,8 @@ public class Contacts.Avatar : DrawingArea {
cr.scale(scale, scale);
}
cr.scale(1.0 / this.scale_factor, 1.0 / this.scale_factor);
Gdk.cairo_set_source_pixbuf (cr, this.cache, 0, 0);
cr.paint ();
}
......@@ -128,7 +141,7 @@ public class Contacts.Avatar : DrawingArea {
show_label = true;
}
}
var pixbuf = AvatarUtils.generate_user_picture(name, this.size, show_label);
var pixbuf = AvatarUtils.generate_user_picture(name, this.size * this.scale_factor, show_label);
pixbuf = AvatarUtils.round_image(pixbuf);
return pixbuf;
......
......@@ -235,8 +235,7 @@ public class Contacts.ContactPane : ScrolledWindow {
start_editing ();
}
public void new_contact () {
var details = new HashTable<string, Value?> (str_hash, str_equal);
public void new_contact (HashTable<string, Value?> details) {
string[] writeable_properties;
if (this.store.aggregator.primary_store == null) {
......
......@@ -224,7 +224,7 @@ public class Contacts.ContactSheet : Grid {
if (this.store.caller_account != null) {
var call_button = create_button ("call-start-symbolic");
call_button.clicked.connect (() => {
Utils.start_call (phone.value, this.store.caller_account);
Utils.start_call (phone.get_normalised (), this.store.caller_account);
});
add_row_with_label (TypeSet.phone.format_type (phone), phone.value, call_button);
......@@ -238,13 +238,13 @@ public class Contacts.ContactSheet : Grid {
if (AppInfo.get_all_for_type ("x-scheme-handler/tel").length () > 0) {
call_button = create_button ("call-start-symbolic");
call_button.clicked.connect (() => {
Utils.start_call (phone.value);
Utils.start_call (phone.get_normalised ());
});
}
if (AppInfo.get_all_for_type ("x-scheme-handler/sms").length () > 0) {
sms_button = create_button ("mail-unread-symbolic");
sms_button.clicked.connect (() => {
Utils.send_sms (phone.value);
Utils.send_sms (phone.get_normalised ());
});
}
......
......@@ -355,21 +355,6 @@ public class Contacts.Window : Gtk.ApplicationWindow {
}
}
[GtkCallback]
public void new_contact () {
if (this.state == UiState.UPDATING || this.state == UiState.CREATING)
return;
this.list_pane.select_contact (null);
this.state = UiState.CREATING;
this.right_header.title = _("New Contact");
this.contact_pane.new_contact ();
show_contact_pane ();
}
[GtkCallback]
private void on_cancel_visible () {
update ();
......@@ -392,6 +377,21 @@ public class Contacts.Window : Gtk.ApplicationWindow {
back_revealer.reveal_child = back_revealer.visible = this.content_box.fold == Fold.FOLDED && !this.cancel_button.visible && header.visible_child == right_header;
}
public void new_contact (HashTable<string, Value?>? details = null) {
if (this.state == UiState.UPDATING || this.state == UiState.CREATING)
return;
this.list_pane.select_contact (null);
this.state = UiState.CREATING;
this.right_header.title = _("New Contact");
this.contact_pane.new_contact (
(details != null) ? details: new HashTable<string, Value?> (str_hash, str_equal));
show_contact_pane ();
}
private void show_list_pane () {
content_box.visible_child_name = "list-pane";
update ();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment