[gnome-contacts/nielsdg/gtk4] WIP
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts/nielsdg/gtk4] WIP
- Date: Wed, 13 Oct 2021 23:19:23 +0000 (UTC)
commit d2b5c89a6ddfd68335190304d3779b15ea70c8c3
Author: Niels De Graef <nielsdegraef gmail com>
Date: Thu Oct 14 01:19:13 2021 +0200
WIP
data/ui/contacts-contact-pane.ui | 8 +-
data/ui/contacts-main-window.ui | 30 +++---
data/ui/contacts-setup-window.ui | 7 +-
docs/meson.build | 4 +-
meson.build | 8 +-
meson_options.txt | 2 +-
src/cc-crop-area.c | 163 ++++++++++++++++------------
src/contacts-accounts-list.vala | 42 ++++----
src/contacts-addressbook-dialog.vala | 21 ++--
src/contacts-addressbook-list.vala | 26 +++--
src/contacts-app.vala | 35 +++---
src/contacts-avatar-selector.vala | 111 ++++++-------------
src/contacts-avatar.vala | 28 +----
src/contacts-contact-editor.vala | 15 ++-
src/contacts-contact-list.vala | 104 +++++++++---------
src/contacts-contact-pane.vala | 14 +--
src/contacts-contact-sheet.vala | 29 ++---
src/contacts-crop-cheese-dialog.vala | 9 +-
src/contacts-editor-persona.vala | 38 +++----
src/contacts-editor-property.vala | 180 ++++++++++++++++---------------
src/contacts-esd-setup.vala | 113 +++++++++----------
src/contacts-link-suggestion-grid.vala | 2 +-
src/contacts-linked-personas-dialog.vala | 7 +-
src/contacts-list-pane.vala | 12 +--
src/contacts-main-window.vala | 166 +++++++++++++---------------
src/contacts-setup-window.vala | 4 +-
src/contacts-utils.vala | 8 +-
src/meson.build | 10 +-
28 files changed, 579 insertions(+), 617 deletions(-)
---
diff --git a/data/ui/contacts-contact-pane.ui b/data/ui/contacts-contact-pane.ui
index b75c3be1..131179b1 100644
--- a/data/ui/contacts-contact-pane.ui
+++ b/data/ui/contacts-contact-pane.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.20"/>
- <template class="ContactsContactPane" parent="GtkBin">
+ <template class="ContactsContactPane" parent="GtkWidget">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
@@ -10,7 +10,7 @@
<property name="visible">True</property>
<property name="visible-child">none_selected_page</property>
<child>
- <object class="HdyStatusPage" id="none_selected_page">
+ <object class="AdwStatusPage" id="none_selected_page">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
@@ -30,7 +30,7 @@
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child>
- <object class="HdyClamp">
+ <object class="AdwClamp">
<property name="visible">True</property>
<property name="margin-top">32</property>
<property name="margin-bottom">32</property>
@@ -57,7 +57,7 @@
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child>
- <object class="HdyClamp">
+ <object class="AdwClamp">
<property name="visible">True</property>
<property name="margin-top">32</property>
<property name="margin-bottom">32</property>
diff --git a/data/ui/contacts-main-window.ui b/data/ui/contacts-main-window.ui
index ee0cfd1f..481cf48c 100644
--- a/data/ui/contacts-main-window.ui
+++ b/data/ui/contacts-main-window.ui
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 3.22 -->
<object class="GtkPopoverMenu" id="hamburger_menu_popover">
<child>
<object class="GtkBox" id="hamburger_menu_box">
@@ -23,17 +22,15 @@
</object>
</child>
<child>
- <object class="GtkModelButton" id="sort_on_firstname_button">
+ <object class="GtkCheckButton" id="sort_on_firstname_button">
<property name="visible">True</property>
<property name="text" translatable="yes">First Name</property>
- <property name="role">radio</property>
</object>
</child>
<child>
- <object class="GtkModelButton" id="sort_on_surname_button">
+ <object class="GtkCheckButton" id="sort_on_surname_button">
<property name="visible">True</property>
<property name="text" translatable="yes">Surname</property>
- <property name="role">radio</property>
</object>
</child>
<child>
@@ -115,7 +112,7 @@
</object>
</child>
<child>
- <object class="GtkModelButton" id="unlink_button">
+ <object class="GtkButton" id="unlink_button">
<property name="visible">True</property>
<property name="action-name">window.unlink-contact</property>
<property name="text" translatable="yes">Unlink</property>
@@ -136,27 +133,30 @@
</object>
</child>
</object>
- <template class="ContactsMainWindow" parent="HdyApplicationWindow">
+ <template class="ContactsMainWindow" parent="AdwApplicationWindow">
<property name="can_focus">False</property>
<property name="default_width">800</property>
<property name="default_height">600</property>
<property name="icon_name">gnome-contacts</property>
<property name="title" translatable="yes">Contacts</property>
- <signal name="key-press-event" handler="key_press_event_cb" object="ContactsMainWindow" after="yes"
swapped="no"/>
- <signal name="delete-event" handler="delete_event_cb" object="ContactsMainWindow" after="no"
swapped="no"/>
+ <child>
+ <object class="GtkEventControllerKey">
+ <signal name="key-pressed" handler="on_key_pressed"/>
+ </object>
+ </child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
- <object class="HdyLeaflet" id="header">
+ <object class="AdwLeaflet" id="header">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="mode-transition-duration" bind-source="content_box"
bind-property="mode-transition-duration" bind-flags="bidirectional|sync-create"/>
<property name="child-transition-duration" bind-source="content_box"
bind-property="child-transition-duration" bind-flags="bidirectional|sync-create"/>
<property name="transition-type" bind-source="content_box" bind-property="transition-type"
bind-flags="bidirectional|sync-create"/>
<child>
- <object class="HdyHeaderBar" id="left_header">
+ <object class="AdwHeaderBar" id="left_header">
<property name="visible">True</property>
<property name="hexpand">False</property>
<property name="can_focus">False</property>
@@ -262,7 +262,7 @@
</packing>
</child>
<child>
- <object class="HdyHeaderBar" id="right_header">
+ <object class="AdwHeaderBar" id="right_header">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="show_close_button">True</property>
@@ -384,7 +384,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="HdyLeaflet" id="content_box">
+ <object class="AdwLeaflet" id="content_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can-swipe-back">True</property>
@@ -475,14 +475,14 @@
<widget name="contact_pane_container"/>
</widgets>
</object>
- <object class="HdyHeaderGroup">
+ <object class="AdwHeaderGroup">
<property name="decorate-all" bind-source="content_box" bind-property="folded" bind-flags="sync-create"/>
<headerbars>
<headerbar name="left_header"/>
<headerbar name="right_header"/>
</headerbars>
</object>
- <object class="HdySwipeGroup" id="swipe_group">
+ <object class="AdwSwipeGroup" id="swipe_group">
<swipeables>
<swipeable name="header"/>
<swipeable name="content_box"/>
diff --git a/data/ui/contacts-setup-window.ui b/data/ui/contacts-setup-window.ui
index 845c7a0f..ab18cbb0 100644
--- a/data/ui/contacts-setup-window.ui
+++ b/data/ui/contacts-setup-window.ui
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 3.22 -->
- <template class="ContactsSetupWindow" parent="HdyApplicationWindow">
+ <template class="ContactsSetupWindow" parent="AdwApplicationWindow">
<property name="default_width">800</property>
<property name="default_height">600</property>
<child>
@@ -10,7 +9,7 @@
<property name="orientation">vertical</property>
<property name="width_request">360</property>
<child>
- <object class="HdyHeaderBar">
+ <object class="AdwHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Contacts Setup</property>
@@ -65,7 +64,7 @@
<property name="hscrollbar_policy">never</property>
<property name="propagate_natural_height">True</property>
<child>
- <object class="HdyClamp">
+ <object class="AdwClamp">
<property name="visible">True</property>
<property name="margin_top">24</property>
<property name="margin_bottom">24</property>
diff --git a/docs/meson.build b/docs/meson.build
index 8ec997d9..8640f4d2 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -13,14 +13,14 @@ custom_target('docs',
'--pkg=glib-2.0',
'--pkg=gio-2.0',
'--pkg=gio-unix-2.0',
- '--pkg=gtk+-3.0',
+ '--pkg=gtk4',
'--pkg=gnome-desktop-3.0',
'--pkg=gee-0.8',
'--pkg=goa-1.0',
'--pkg=folks',
'--pkg=folks-eds',
'--pkg=libedataserverui-1.2',
- '--pkg=libhandy-1',
+ '--pkg=libadwaita-1',
'--pkg=custom',
'--pkg=config',
'--directory=@OUTDIR@',
diff --git a/meson.build b/meson.build
index c9b09be3..2bb2c77c 100644
--- a/meson.build
+++ b/meson.build
@@ -47,14 +47,14 @@ gee = dependency('gee-0.8')
gio_unix = dependency('gio-unix-2.0', version: '>=' + min_glib_version)
glib = dependency('glib-2.0', version: '>=' + min_glib_version)
gmodule_export = dependency('gmodule-export-2.0', version: '>=' + min_glib_version)
-gnome_desktop = dependency('gnome-desktop-3.0')
+# gnome_desktop = dependency('gnome-desktop-3.0')
goa = dependency('goa-1.0')
-gtk = dependency('gtk+-3.0', version: '>= 3.23.1')
-libhandy = dependency('libhandy-1', version: '>= 1.1.0')
+gtk4_dep = dependency('gtk4', version: '>= 4.0')
+libadwaita_dep = dependency('libadwaita-1')
# E-D-S
libebook = dependency('libebook-1.2', version: '>=' + min_eds_version)
libedataserver = dependency('libedataserver-1.2', version: '>=' + min_eds_version)
-libedataserverui = dependency('libedataserverui-1.2', version: '>=' + min_eds_version)
+# libedataserverui = dependency('libedataserverui-1.2', version: '>=' + min_eds_version)
# Cheese
cheese_dep = dependency('cheese', required: get_option('cheese'))
cheese_gtk_dep = dependency('cheese-gtk', version: '>= 3.3.91', required: get_option('cheese'))
diff --git a/meson_options.txt b/meson_options.txt
index 101161cc..a8c87adf 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,5 +1,5 @@
option('profile', type: 'combo', choices: [ 'default', 'development' ], value: 'default', description:
'Indicate whether this is a nightly build (used for CI purposes)')
-option('cheese', type: 'feature', value: 'auto', description: 'If enabled, allows creaing an avatar with the
webcam')
+option('cheese', type: 'feature', value: 'disabled', description: 'If enabled, allows creaing an avatar with
the webcam')
option('telepathy', type: 'boolean', value: false, description: 'Enable Telepathy call/chat support.')
option('manpage', type: 'boolean', value: true, description: 'Enable building man pages.')
option('docs', type: 'boolean', value: false, description: 'Whether to build the valadoc docs.')
diff --git a/src/cc-crop-area.c b/src/cc-crop-area.c
index 799d55c1..e3114844 100644
--- a/src/cc-crop-area.c
+++ b/src/cc-crop-area.c
@@ -35,7 +35,7 @@ struct _CcCropArea {
GdkPixbuf *color_shifted;
gdouble scale;
GdkRectangle image;
- GdkCursorType current_cursor;
+ const char *current_cursor;
GdkRectangle crop;
gint active_region;
gint last_press_x;
@@ -90,14 +90,13 @@ shift_colors (GdkPixbuf *pixbuf,
static void
update_pixbufs (CcCropArea *area)
{
- gint width;
- gint height;
+ GtkWidget *widget = GTK_WIDGET (area);
+ int width;
+ int height;
GtkAllocation allocation;
- gdouble scale;
- gint dest_width, dest_height;
- GtkWidget *widget;
+ double scale;
+ int dest_width, dest_height;
- widget = GTK_WIDGET (area);
gtk_widget_get_allocation (widget, &allocation);
width = gdk_pixbuf_get_width (area->browse_pixbuf);
@@ -179,16 +178,19 @@ typedef enum {
RIGHT
} Location;
-static gboolean
-cc_crop_area_draw (GtkWidget *widget,
- cairo_t *cr)
+static void
+draw (GtkDrawingArea *draw_area,
+ cairo_t *cr,
+ int _width, // XXX
+ int _height, // XXX
+ gpointer user_data)
{
+ CcCropArea *uarea = CC_CROP_AREA (draw_area);
GdkRectangle crop;
- gint width, height, ix, iy;
- CcCropArea *uarea = CC_CROP_AREA (widget);
+ int width, height, ix, iy;
if (uarea->browse_pixbuf == NULL)
- return FALSE;
+ return;
update_pixbufs (uarea);
@@ -232,8 +234,6 @@ cc_crop_area_draw (GtkWidget *widget,
cairo_line_to (cr, crop.x, crop.y + crop.height - 15);
cairo_stroke (cr);
-
- return FALSE;
}
typedef enum {
@@ -287,7 +287,7 @@ update_cursor (CcCropArea *area,
gint x,
gint y)
{
- gint cursor_type;
+ const char *cursor_type;
GdkRectangle crop;
gint region;
@@ -299,43 +299,50 @@ update_cursor (CcCropArea *area,
switch (region) {
case OUTSIDE:
- cursor_type = GDK_LEFT_PTR;
+ cursor_type = "default";
break;
case TOP_LEFT:
- cursor_type = GDK_TOP_LEFT_CORNER;
+ cursor_type = "nw-resize";
break;
case TOP:
- cursor_type = GDK_TOP_SIDE;
+ cursor_type = "n-resize";
break;
case TOP_RIGHT:
- cursor_type = GDK_TOP_RIGHT_CORNER;
+ cursor_type = "ne-resize";
break;
case LEFT:
- cursor_type = GDK_LEFT_SIDE;
+ cursor_type = "w-resize";
break;
case INSIDE:
- cursor_type = GDK_FLEUR;
+ cursor_type = "move";
break;
case RIGHT:
- cursor_type = GDK_RIGHT_SIDE;
+ cursor_type = "e-resize";
break;
case BOTTOM_LEFT:
- cursor_type = GDK_BOTTOM_LEFT_CORNER;
+ cursor_type = "sw-resize";
break;
case BOTTOM:
- cursor_type = GDK_BOTTOM_SIDE;
+ cursor_type = "s-resize";
break;
case BOTTOM_RIGHT:
- cursor_type = GDK_BOTTOM_RIGHT_CORNER;
+ cursor_type = "se-resize";
break;
default:
g_assert_not_reached ();
}
if (cursor_type != area->current_cursor) {
- GdkCursor *cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (area)),
- cursor_type);
- gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (area)), cursor);
+ GtkNative *native;
+ GdkCursor *cursor;
+
+ native = gtk_widget_get_native (GTK_WIDGET (area));
+ if (!native) {
+ g_warning ("Can't adjust cursor: no GtkNative found");
+ return;
+ }
+ cursor = gdk_cursor_new_from_name (cursor_type, NULL);
+ gdk_surface_set_cursor (gtk_native_get_surface (native), cursor);
g_object_unref (cursor);
area->current_cursor = cursor_type;
}
@@ -356,10 +363,12 @@ eval_radial_line (gdouble center_x, gdouble center_y,
}
static gboolean
-cc_crop_area_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event)
+on_motion (GtkEventControllerMotion *controller,
+ double event_x,
+ double event_y,
+ gpointer user_data)
{
- CcCropArea *area = CC_CROP_AREA (widget);
+ CcCropArea *area = CC_CROP_AREA (user_data);
gint x, y;
gint delta_x, delta_y;
gint width, height;
@@ -374,18 +383,19 @@ cc_crop_area_motion_notify_event (GtkWidget *widget,
if (area->browse_pixbuf == NULL)
return FALSE;
- update_cursor (area, event->x, event->y);
+ update_cursor (area, event_x, event_y);
crop_to_widget (area, &damage);
- gtk_widget_queue_draw_area (widget,
- damage.x - 4, damage.y - 4,
- damage.width + 6, damage.height + 6);
+ // XXX
+ /* gtk_widget_queue_draw_area (GTK_WIDGET (area), */
+ /* damage.x - 4, damage.y - 4, */
+ /* damage.width + 6, damage.height + 6); */
pb_width = gdk_pixbuf_get_width (area->browse_pixbuf);
pb_height = gdk_pixbuf_get_height (area->browse_pixbuf);
- x = (event->x - area->image.x) / area->scale;
- y = (event->y - area->image.y) / area->scale;
+ x = (event_x - area->image.x) / area->scale;
+ y = (event_y - area->image.y) / area->scale;
delta_x = x - area->last_press_x;
delta_y = y - area->last_press_y;
@@ -609,18 +619,22 @@ cc_crop_area_motion_notify_event (GtkWidget *widget,
area->crop.height = bottom - top + 1;
crop_to_widget (area, &damage);
- gtk_widget_queue_draw_area (widget,
- damage.x - 4, damage.y - 4,
- damage.width + 6, damage.height + 6);
+ // XXX
+ /* gtk_widget_queue_draw_area (GTK_WIDGET (area), */
+ /* damage.x - 4, damage.y - 4, */
+ /* damage.width + 6, damage.height + 6); */
return FALSE;
}
static gboolean
-cc_crop_area_button_press_event (GtkWidget *widget,
- GdkEventButton *event)
+on_button_pressed (GtkGestureClick *gesture,
+ int n_press,
+ double x,
+ double y,
+ gpointer user_data)
{
- CcCropArea *area = CC_CROP_AREA (widget);
+ CcCropArea *area = CC_CROP_AREA (user_data);
GdkRectangle crop;
if (area->browse_pixbuf == NULL)
@@ -628,22 +642,26 @@ cc_crop_area_button_press_event (GtkWidget *widget,
crop_to_widget (area, &crop);
- area->last_press_x = (event->x - area->image.x) / area->scale;
- area->last_press_y = (event->y - area->image.y) / area->scale;
- area->active_region = find_location (&crop, event->x, event->y);
+ area->last_press_x = (x - area->image.x) / area->scale;
+ area->last_press_y = (y - area->image.y) / area->scale;
+ area->active_region = find_location (&crop, x, y);
- gtk_widget_queue_draw_area (widget,
- crop.x - 4, crop.y - 4,
- crop.width + 6, crop.height + 6);
+ // XXX
+ /* gtk_widget_queue_draw_area (GTK_WIDGET (area), */
+ /* crop.x - 4, crop.y - 4, */
+ /* crop.width + 6, crop.height + 6); */
- return FALSE;
+ return GDK_EVENT_PROPAGATE;
}
static gboolean
-cc_crop_area_button_release_event (GtkWidget *widget,
- GdkEventButton *event)
+on_button_released (GtkGestureClick *gesture,
+ int n_press,
+ double x,
+ double y,
+ gpointer user_data)
{
- CcCropArea *area = CC_CROP_AREA (widget);
+ CcCropArea *area = CC_CROP_AREA (user_data);
GdkRectangle crop;
if (area->browse_pixbuf == NULL)
@@ -655,11 +673,12 @@ cc_crop_area_button_release_event (GtkWidget *widget,
area->last_press_y = -1;
area->active_region = OUTSIDE;
- gtk_widget_queue_draw_area (widget,
- crop.x - 4, crop.y - 4,
- crop.width + 6, crop.height + 6);
+ // XXX
+ /* gtk_widget_queue_draw_area (GTK_WIDGET (area), */
+ /* crop.x - 4, crop.y - 4, */
+ /* crop.width + 6, crop.height + 6); */
- return FALSE;
+ return GDK_EVENT_PROPAGATE;
}
static void
@@ -693,21 +712,29 @@ static void
cc_crop_area_class_init (CcCropAreaClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = cc_crop_area_finalize;
- widget_class->draw = cc_crop_area_draw;
- widget_class->button_press_event = cc_crop_area_button_press_event;
- widget_class->button_release_event = cc_crop_area_button_release_event;
- widget_class->motion_notify_event = cc_crop_area_motion_notify_event;
}
static void
cc_crop_area_init (CcCropArea *area)
{
- gtk_widget_add_events (GTK_WIDGET (area), GDK_POINTER_MOTION_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK);
+ GtkGesture *gesture;
+ GtkEventController *controller;
+
+ /* Draw function */
+ gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (area), draw, NULL, NULL);
+
+ /* Add handlers for clicks */
+ gesture = gtk_gesture_click_new ();
+ g_signal_connect (gesture, "pressed", G_CALLBACK (on_button_pressed), area);
+ g_signal_connect (gesture, "released", G_CALLBACK (on_button_released), area);
+ gtk_widget_add_controller (GTK_WIDGET (area), GTK_EVENT_CONTROLLER (gesture));
+
+ /* Add handlers for motion events */
+ controller = gtk_event_controller_motion_new ();
+ g_signal_connect (gesture, "motion", G_CALLBACK (on_motion), area);
+ gtk_widget_add_controller (GTK_WIDGET (area), GTK_EVENT_CONTROLLER (controller));
area->scale = 0.0;
area->image.x = 0;
@@ -775,7 +802,8 @@ cc_crop_area_set_picture (CcCropArea *area,
area->image.width = 0;
area->image.height = 0;
- gtk_widget_queue_draw (GTK_WIDGET (area));
+ // XXX
+ /* gtk_widget_queue_draw (GTK_WIDGET (area)); */
}
void
@@ -804,4 +832,3 @@ cc_crop_area_set_constrain_aspect (CcCropArea *area,
area->aspect = -1;
}
}
-
diff --git a/src/contacts-accounts-list.vala b/src/contacts-accounts-list.vala
index 9690e917..10c67eff 100644
--- a/src/contacts-accounts-list.vala
+++ b/src/contacts-accounts-list.vala
@@ -23,16 +23,19 @@ public class Contacts.AccountsList : Gtk.ListBox {
private Store contacts_store;
- public PersonaStore? selected_store;
+ public PersonaStore? selected_store = null;
public signal void account_selected ();
+ construct {
+ this.row_activated.connect (on_row_activated);
+ }
+
public AccountsList (Store contacts_store) {
this.contacts_store = contacts_store;
- this.selected_store = null;
}
- public override void row_activated (Gtk.ListBoxRow row) {
+ private void on_row_activated (Gtk.ListBox listbox, Gtk.ListBoxRow row) {
if (row == null)
return;
@@ -58,9 +61,8 @@ public class Contacts.AccountsList : Gtk.ListBox {
}
public void update_contents (bool select_active) {
- foreach (var child in get_children ()) {
+ for (unowned Gtk.Widget? child = get_first_child (); child != null; child = child.get_next_sibling ())
child.destroy ();
- }
// Fill the list with address book
PersonaStore[] eds_stores = Utils.get_eds_address_books (this.contacts_store);
@@ -85,31 +87,28 @@ public class Contacts.AccountsList : Gtk.ListBox {
source_account_id = goa_source_ext.account_id;
}
- var row = new Hdy.ActionRow ();
+ var row = new Adw.ActionRow ();
row.set_data ("store", persona_store);
Gtk.Image provider_image;
if (source_account_id != "")
provider_image = Contacts.get_icon_for_goa_account (source_account_id);
else
- provider_image = new Gtk.Image.from_icon_name (Config.APP_ID,
- Gtk.IconSize.DIALOG);
+ provider_image = new Gtk.Image.from_icon_name (Config.APP_ID);
row.add_prefix (provider_image);
row.title = provider_name;
row.subtitle = parent_source.display_name;
- row.show_all ();
- row.no_show_all = true;
- var checkmark = new Gtk.Image.from_icon_name ("object-select-symbolic",
- Gtk.IconSize.MENU);
+
+ var checkmark = new Gtk.Image.from_icon_name ("object-select-symbolic");
checkmark.set ("margin-end", 6,
"valign", Gtk.Align.CENTER,
"halign", Gtk.Align.END,
"vexpand", true,
"hexpand", true);
- row.add (checkmark);
+ row.set_child (checkmark);
row.set_activatable_widget (checkmark);
row.set_data ("checkmark", checkmark);
- add (row);
+ append (row);
if (select_active &&
persona_store == this.contacts_store.aggregator.primary_store) {
@@ -118,30 +117,25 @@ public class Contacts.AccountsList : Gtk.ListBox {
}
if (local_store != null) {
- var local_row = new Hdy.ActionRow ();
- var provider_image = new Gtk.Image.from_icon_name (Config.APP_ID,
- Gtk.IconSize.DIALOG);
+ var local_row = new Adw.ActionRow ();
+ var provider_image = new Gtk.Image.from_icon_name (Config.APP_ID);
local_row.add_prefix (provider_image);
local_row.title = _("Local Address Book");
- local_row.show_all ();
- local_row.no_show_all = true;
- var checkmark = new Gtk.Image.from_icon_name ("object-select-symbolic", Gtk.IconSize.MENU);
+ var checkmark = new Gtk.Image.from_icon_name ("object-select-symbolic");
checkmark.set ("margin-end", 6,
"valign", Gtk.Align.CENTER,
"halign", Gtk.Align.END,
"vexpand", true,
"hexpand", true);
- local_row.add (checkmark);
+ local_row.set_child (checkmark);
local_row.set_activatable_widget (checkmark);
local_row.set_data ("checkmark", checkmark);
local_row.set_data ("store", local_store);
- add (local_row);
+ append (local_row);
if (select_active &&
local_store == this.contacts_store.aggregator.primary_store) {
row_activated (local_row);
}
}
-
- show_all ();
}
}
diff --git a/src/contacts-addressbook-dialog.vala b/src/contacts-addressbook-dialog.vala
index f9cc8275..91b7625e 100644
--- a/src/contacts-addressbook-dialog.vala
+++ b/src/contacts-addressbook-dialog.vala
@@ -32,35 +32,36 @@ public class Contacts.AddressbookDialog : Gtk.Dialog {
_("Cancel"), Gtk.ResponseType.CANCEL);
var content_area = get_content_area () as Gtk.Box;
- content_area.border_width = 0;
+ // content_area.border_width = 0; XXX
var ok_button = get_widget_for_response (Gtk.ResponseType.OK);
ok_button.sensitive = false;
ok_button.get_style_context ().add_class ("suggested-action");
- var scrolled_window = new Gtk.ScrolledWindow (null, null);
- scrolled_window.expand = true;
+ var scrolled_window = new Gtk.ScrolledWindow ();
+ scrolled_window.hexpand = true;
+ scrolled_window.vexpand = true;
scrolled_window.height_request = 300;
scrolled_window.hscrollbar_policy = Gtk.PolicyType.NEVER;
scrolled_window.propagate_natural_height = true;
- content_area.add (scrolled_window);
+ content_area.append (scrolled_window);
- var clamp = new Hdy.Clamp ();
+ var clamp = new Adw.Clamp ();
clamp.margin_top = 32;
clamp.margin_bottom = 32;
clamp.margin_start = 12;
clamp.margin_end = 12;
clamp.maximum_size = 400;
- scrolled_window.add (clamp);
+ scrolled_window.set_child (clamp);
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
box.valign = Gtk.Align.START;
- clamp.add (box);
+ clamp.set_child (box);
var explanation_label = new Gtk.Label (_("New contacts will be added to the selected address book.\nYou
are able to view and edit contacts from other address books."));
explanation_label.xalign = 0;
explanation_label.wrap = true;
- box.add (explanation_label);
+ box.append (explanation_label);
this.accounts_list = new AccountsList (contacts_store);
this.accounts_list.update_contents (true);
@@ -75,9 +76,7 @@ public class Contacts.AddressbookDialog : Gtk.Dialog {
this.accounts_list.update_contents (true);
});
- box.add (this.accounts_list);
-
- show_all ();
+ box.append (this.accounts_list);
}
public override void response (int response) {
diff --git a/src/contacts-addressbook-list.vala b/src/contacts-addressbook-list.vala
index a7b26167..ed029e30 100644
--- a/src/contacts-addressbook-list.vala
+++ b/src/contacts-addressbook-list.vala
@@ -30,6 +30,7 @@ public class Contacts.AddressbookList : Gtk.ListBox {
this.store = store;
this.show_icon = icon;
+ this.row_activated.connect (on_row_activated);
this.set_header_func (list_box_update_header_func);
this.update ();
}
@@ -44,7 +45,7 @@ public class Contacts.AddressbookList : Gtk.ListBox {
}
}
- public override void row_activated (Gtk.ListBoxRow row) {
+ private void on_row_activated (Gtk.ListBox listbox, Gtk.ListBoxRow row) {
var addressbook = row as AddressbookRow;
if (addressbook == null)
return;
@@ -62,8 +63,8 @@ public class Contacts.AddressbookList : Gtk.ListBox {
}
public void update () {
- foreach (var child in get_children ()) {
- child.destroy ();
+ for (unowned Gtk.Widget? child = get_first_child (); child != null; child = child.get_next_sibling ()) {
+ remove (child);
}
// Fill the list with address book
@@ -93,25 +94,24 @@ public class Contacts.AddressbookList : Gtk.ListBox {
if (source_account_id != "")
provider_image = Contacts.get_icon_for_goa_account (source_account_id);
else
- provider_image = new Gtk.Image.from_icon_name (Config.APP_ID, Gtk.IconSize.DIALOG);
+ provider_image = new Gtk.Image.from_icon_name (Config.APP_ID);
}
var row = new AddressbookRow (provider_name, parent_source.display_name, provider_image);
- add (row);
+ append (row);
}
if (local_store != null) {
- var provider_image = this.show_icon? new Gtk.Image.from_icon_name (Config.APP_ID, Gtk.IconSize.DIALOG)
: null;
+ var provider_image = this.show_icon? new Gtk.Image.from_icon_name (Config.APP_ID) : null;
var local_row = new AddressbookRow (_("Local Address Book"), null, provider_image);
- add (local_row);
+ append (local_row);
}
-
- show_all ();
}
}
-public class Contacts.AddressbookRow : Hdy.ActionRow {
+public class Contacts.AddressbookRow : Adw.ActionRow {
Gtk.Widget checkmark;
+
public AddressbookRow (string title, string? subtitle, Gtk.Widget? image = null) {
this.set_selectable (false);
if (image != null) {
@@ -121,15 +121,13 @@ public class Contacts.AddressbookRow : Hdy.ActionRow {
if (subtitle != null) {
this.subtitle = subtitle;
}
- this.show_all ();
- this.no_show_all = true;
- this.checkmark = new Gtk.Image.from_icon_name ("object-select-symbolic", Gtk.IconSize.MENU);
+ this.checkmark = new Gtk.Image.from_icon_name ("object-select-symbolic");
this.checkmark.set ("margin-end", 6,
"valign", Gtk.Align.CENTER,
"halign", Gtk.Align.END,
"vexpand", true,
"hexpand", true);
- this.add (this.checkmark);
+ this.set_child (this.checkmark);
}
public void unselect () {
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index b1adaf40..74cfbafd 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -22,7 +22,7 @@ public class Contacts.App : Gtk.Application {
private Store contacts_store;
- private MainWindow window;
+ private unowned MainWindow window;
private const GLib.ActionEntry[] action_entries = {
{ "quit", quit },
@@ -84,7 +84,7 @@ public class Contacts.App : Gtk.Application {
}
public void show_contact (Individual? individual) {
- window.set_shown_contact (individual);
+ this.window.set_shown_contact (individual);
}
public async void show_individual (string id) {
@@ -111,15 +111,15 @@ public class Contacts.App : Gtk.Application {
Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
_("No contact with id %s found"), id);
dialog.set_title (_("Contact not found"));
- dialog.run ();
- dialog.destroy ();
+ dialog.response.connect ((_) => dialog.close ());
+ dialog.show ();
}
}
public void change_address_book () {
var dialog = new AddressbookDialog (this.contacts_store, this.window);
- dialog.run ();
- dialog.destroy ();
+ dialog.response.connect ((_) => dialog.close ());
+ dialog.show ();
}
public void online_accounts () {
@@ -150,7 +150,7 @@ public class Contacts.App : Gtk.Application {
public void show_help () {
try {
- Gtk.show_uri_on_window (window, "help:gnome-help/contacts", Gtk.get_current_event_time ());
+ Gtk.show_uri (this.window, "help:gnome-help/contacts", Gdk.CURRENT_TIME);
} catch (GLib.Error e1) {
warning ("Error showing help: %s", e1.message);
}
@@ -166,7 +166,7 @@ public class Contacts.App : Gtk.Application {
string[] artists = {
"Allan Day <allanpday gmail com>"
};
- Gtk.show_about_dialog (window,
+ Gtk.show_about_dialog (this.window,
"artists", artists,
"authors", authors,
"translator-credits", _("translator-credits"),
@@ -191,23 +191,24 @@ public class Contacts.App : Gtk.Application {
Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
_("No contact with email address %s found"), email_address);
dialog.set_title (_("Contact not found"));
- dialog.run ();
- dialog.destroy ();
+ dialog.response.connect ((_) => dialog.close ());
+ dialog.show ();
}
}
public void show_search (string query) {
if (contacts_store.is_quiescent) {
- window.show_search (query);
+ this.window.show_search (query);
} else {
contacts_store.quiescent.connect_after (() => {
- window.show_search (query);
+ this.window.show_search (query);
});
}
}
private void create_window () {
- this.window = new MainWindow (this.settings, this, this.contacts_store);
+ var win = new MainWindow (this.settings, this, this.contacts_store);
+ this.window = win;
show_contact_list ();
}
@@ -244,7 +245,7 @@ public class Contacts.App : Gtk.Application {
this.contacts_store = new Store ();
base.startup ();
- Hdy.init ();
+ Adw.init ();
load_styling ();
create_actions ();
@@ -261,9 +262,9 @@ public class Contacts.App : Gtk.Application {
public void load_styling () {
var provider = new Gtk.CssProvider ();
provider.load_from_resource ("/org/gnome/Contacts/ui/style.css");
- Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default(),
- provider,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default(),
+ provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
public override void activate () {
diff --git a/src/contacts-avatar-selector.vala b/src/contacts-avatar-selector.vala
index 21790696..32a225b2 100644
--- a/src/contacts-avatar-selector.vala
+++ b/src/contacts-avatar-selector.vala
@@ -27,7 +27,7 @@ private class Contacts.Thumbnail : Gtk.FlowBoxChild {
this.get_style_context ().add_class ("circular");
var avatar = new Avatar (ICONS_SIZE);
avatar.set_pixbuf (source_pixbuf);
- add (avatar);
+ set_child (avatar);
}
public Thumbnail.for_persona (Persona persona) {
@@ -66,8 +66,6 @@ private class Contacts.Thumbnail : Gtk.FlowBoxChild {
public class Contacts.AvatarSelector : Gtk.Window {
const string AVATAR_BUTTON_CSS_NAME = "avatar-button";
- // This will provide the default thumbnails
- private Gnome.DesktopThumbnailFactory thumbnail_factory;
private Individual individual;
[GtkChild]
@@ -82,15 +80,14 @@ public class Contacts.AvatarSelector : Gtk.Window {
public AvatarSelector (Individual? individual, Gtk.Window? window = null) {
Object (transient_for: window);
- this.thumbnail_factory = new Gnome.DesktopThumbnailFactory (Gnome.ThumbnailSize.NORMAL);
this.individual = individual;
- unowned Gtk.BindingSet binding_set = Gtk.BindingSet.by_class (get_class ());
- Gtk.BindingEntry.add_signal (binding_set,
- Gdk.Key.Escape,
- 0,
- "close",
- 0);
+ // XXX
+ // get_class ().add_binding (Gdk.Key.Escape, 0,
+ // (dialog, variant) => {
+ // this.close();
+ // },
+ // null);
update_thumbnail_grid ();
@@ -121,10 +118,11 @@ public class Contacts.AvatarSelector : Gtk.Window {
base.close ();
}
- [GtkCallback]
- public bool on_delete_event () {
- return hide_on_delete ();
- }
+ // XXX
+ // [GtkCallback]
+ // public bool on_delete_event () {
+ // return hide_on_delete ();
+ // }
private Gdk.Pixbuf scale_pixbuf_for_avatar_use (Gdk.Pixbuf pixbuf) {
int w = pixbuf.get_width ();
@@ -156,13 +154,13 @@ public class Contacts.AvatarSelector : Gtk.Window {
} catch (Error e) {
warning ("Failed to set avatar: %s", e.message);
Utils.show_error_dialog (_("Failed to set avatar."),
- get_toplevel() as Gtk.Window);
+ get_root() as Gtk.Window);
}
});
} catch (GLib.Error e) {
warning ("Failed to set avatar: %s", e.message);
Utils.show_error_dialog (_("Failed to set avatar."),
- get_toplevel() as Gtk.Window);
+ get_root() as Gtk.Window);
}
}
private void update_thumbnail_grid () {
@@ -170,7 +168,7 @@ public class Contacts.AvatarSelector : Gtk.Window {
foreach (var p in individual.personas) {
var widget = new Thumbnail.for_persona (p);
if (widget.source_pixbuf != null)
- this.thumbnail_grid.add (widget);
+ this.thumbnail_grid.insert (widget, -1);
}
}
@@ -178,19 +176,18 @@ public class Contacts.AvatarSelector : Gtk.Window {
foreach (var file_name in stock_files) {
var widget = new Thumbnail.for_filename (file_name);
if (widget.source_pixbuf != null)
- this.thumbnail_grid.add (widget);
+ this.thumbnail_grid.insert (widget, -1);
}
- this.thumbnail_grid.show_all ();
}
[GtkCallback]
private void on_cheese_clicked (Gtk.Button button) {
- var dialog = new CropCheeseDialog.for_cheese (get_toplevel() as Gtk.Window);
- dialog.show_all ();
- dialog.picture_selected.connect ( (pix) => {
+ var dialog = new CropCheeseDialog.for_cheese (get_root() as Gtk.Window);
+ dialog.picture_selected.connect ((pix) => {
selected_pixbuf (scale_pixbuf_for_avatar_use (pix));
this.close ();
});
+ dialog.show();
}
[GtkCallback]
@@ -213,88 +210,46 @@ public class Contacts.AvatarSelector : Gtk.Window {
[GtkCallback]
private void on_file_clicked (Gtk.Button button) {
var chooser = new Gtk.FileChooserNative (_("Browse for more pictures"),
- get_toplevel () as Gtk.Window,
+ get_root () as Gtk.Window,
Gtk.FileChooserAction.OPEN,
_("_Open"), _("_Cancel"));
chooser.set_modal (true);
- chooser.set_local_only (false);
- var preview = new Gtk.Image ();
- preview.set_size_request (MAIN_SIZE, -1);
- chooser.set_preview_widget (preview);
- chooser.set_use_preview_label (false);
- preview.show ();
-
- chooser.update_preview.connect (update_preview);
- var folder = Environment.get_user_special_dir (UserDirectory.PICTURES);
- if (folder != null)
- chooser.set_current_folder (folder);
+ try {
+ unowned var pictures_folder = Environment.get_user_special_dir (UserDirectory.PICTURES);
+ if (pictures_folder != null)
+ chooser.set_current_folder (File.new_for_path (pictures_folder));
+ } catch (Error e) {
+ warning ("Couldn't set avatar selector to Pictures folder: %s", e.message);
+ }
- chooser.response.connect ( (response) => {
+ chooser.response.connect ((response) => {
if (response != Gtk.ResponseType.ACCEPT) {
- chooser.destroy ();
return;
}
+
try {
- var file = File.new_for_uri (chooser.get_uri ());
+ var file = chooser.get_file ();
var in_stream = file.read ();
var pixbuf = new Gdk.Pixbuf.from_stream (in_stream, null);
in_stream.close ();
if (pixbuf.get_width () > MAIN_SIZE || pixbuf.get_height () > MAIN_SIZE) {
- var dialog = new CropCheeseDialog.for_crop (get_toplevel () as Gtk.Window,
+ var dialog = new CropCheeseDialog.for_crop (get_root () as Gtk.Window,
pixbuf);
dialog.picture_selected.connect ( (pix) => {
selected_pixbuf (scale_pixbuf_for_avatar_use (pix));
});
- dialog.show_all();
+ dialog.show();
} else {
selected_pixbuf (scale_pixbuf_for_avatar_use (pixbuf));
}
} catch (GLib.Error e) {
warning ("Failed to set avatar: %s", e.message);
Utils.show_error_dialog (_("Failed to set avatar."),
- this.get_toplevel() as Gtk.Window);
+ this.get_root() as Gtk.Window);
}
-
- chooser.destroy ();
});
- chooser.run ();
this.close ();
}
-
- private void update_preview (Gtk.FileChooser chooser) {
- var uri = chooser.get_preview_uri ();
- if (uri != null) {
- Gdk.Pixbuf? pixbuf = null;
-
- var preview = chooser.get_preview_widget () as Gtk.Image;
-
- var file = File.new_for_uri (uri);
- try {
- var file_info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE,
- FileQueryInfoFlags.NONE, null);
- if (file_info != null) {
- var mime_type = file_info.get_content_type ();
-
- if (mime_type != null)
- pixbuf = this.thumbnail_factory.generate_thumbnail (uri, mime_type);
- }
- } catch (Error e) {
- debug ("Couldn't generate thumbnail for file '%s': %s", uri, e.message);
- }
-
- if (chooser is Gtk.Dialog)
- ((Gtk.Dialog) chooser).set_response_sensitive (Gtk.ResponseType.ACCEPT,
- (pixbuf != null));
-
- if (pixbuf != null)
- preview.set_from_pixbuf (pixbuf);
- else
- preview.set_from_icon_name ("dialog-question", Gtk.IconSize.DIALOG);
- }
-
- chooser.set_preview_widget_active (true);
- }
-
}
diff --git a/src/contacts-avatar.vala b/src/contacts-avatar.vala
index 33653065..68902137 100644
--- a/src/contacts-avatar.vala
+++ b/src/contacts-avatar.vala
@@ -21,8 +21,8 @@ using Folks;
* The Avatar of a Contact is responsible for showing an {@link Folks.Individual}'s
* avatar, or a fallback if it's not available.
*/
-public class Contacts.Avatar : Gtk.Bin {
- private Hdy.Avatar widget;
+public class Contacts.Avatar : Gtk.Widget {
+ private Adw.Avatar widget;
private unowned Individual? individual = null;
@@ -42,10 +42,8 @@ public class Contacts.Avatar : Gtk.Bin {
}
}
- this.widget = new Hdy.Avatar (size, name, show_initials);
- this.widget.set_image_load_func (size => load_avatar (size));
- this.widget.show ();
- add(this.widget);
+ this.widget = new Adw.Avatar (size, name, show_initials);
+ this.widget.set_parent (this);
show ();
}
@@ -54,23 +52,7 @@ public class Contacts.Avatar : Gtk.Bin {
* Manually set the avatar to the given pixbuf, even if the contact has an avatar.
*/
public void set_pixbuf (Gdk.Pixbuf? a_pixbuf) {
- this.widget.set_image_load_func (size => load_avatar (size, a_pixbuf));
- }
-
- private Gdk.Pixbuf? load_avatar (int size, Gdk.Pixbuf? pixbuf = null) {
- if (pixbuf != null) {
- return pixbuf.scale_simple (size, size, Gdk.InterpType.HYPER);
- } else {
- if (this.individual != null && this.individual.avatar != null) {
- try {
- var stream = this.individual.avatar.load (size, null);
- return new Gdk.Pixbuf.from_stream_at_scale (stream, size, size, true);
- } catch (Error e) {
- debug ("Couldn't load avatar of contact %s. Reason: %s", this.individual.display_name, e.message);
- }
- }
- }
- return null;
+ this.widget.set_custom_image (Gdk.Texture.for_pixbuf (a_pixbuf));
}
/* Find a nice name to generate the label and color for the fallback avatar
diff --git a/src/contacts-contact-editor.vala b/src/contacts-contact-editor.vala
index 85c34f74..7e90841d 100644
--- a/src/contacts-contact-editor.vala
+++ b/src/contacts-contact-editor.vala
@@ -32,14 +32,13 @@ public class Contacts.ContactEditor : Gtk.Box {
this.individual = individual;
Gtk.Box header = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
- header.add (create_avatar_button ());
- header.add (create_name_entry ());
- add (header);
+ header.append (create_avatar_button ());
+ header.append (create_name_entry ());
+ append (header);
foreach (var p in individual.personas) {
- add (new EditorPersona (p, aggregator));
+ append (new EditorPersona (p, aggregator));
}
- show_all ();
}
// Creates the contact's current avatar in a big button on top of the Editor
@@ -47,8 +46,8 @@ public class Contacts.ContactEditor : Gtk.Box {
this.avatar = new Avatar (PROFILE_SIZE, this.individual);
var button = new Gtk.Button ();
- button.get_accessible ().set_name (_("Change avatar"));
- button.image = this.avatar;
+ button.tooltip_text = _("Change avatar");
+ button.set_child (this.avatar);
button.clicked.connect (on_avatar_button_clicked);
return button;
@@ -57,7 +56,7 @@ public class Contacts.ContactEditor : Gtk.Box {
// Show the avatar popover when the avatar is clicked
private void on_avatar_button_clicked (Gtk.Button avatar_button) {
if (this.avatar_selector == null)
- this.avatar_selector = new AvatarSelector (this.individual, (Gtk.Window) this.get_toplevel());
+ this.avatar_selector = new AvatarSelector (this.individual, get_root() as Gtk.Window);
this.avatar_selector.show();
}
diff --git a/src/contacts-contact-list.vala b/src/contacts-contact-list.vala
index 266545d8..f31c1fd4 100644
--- a/src/contacts-contact-list.vala
+++ b/src/contacts-contact-list.vala
@@ -38,8 +38,10 @@ public class Contacts.ContactList : Gtk.ListBox {
get_style_context (). add_class ("contact-data-row");
Gtk.Grid grid = new Gtk.Grid ();
- grid.margin = 3;
grid.margin_start = 9;
+ grid.margin_end = 3;
+ grid.margin_top = 3;
+ grid.margin_bottom = 3;
grid.set_column_spacing (10);
this.avatar = new Avatar (LIST_AVATAR_SIZE, this.individual);
@@ -61,8 +63,7 @@ public class Contacts.ContactList : Gtk.ListBox {
grid.attach (this.avatar, 0, 0);
grid.attach (this.label, 1, 0);
grid.attach (this.selector_button, 2, 0);
- this.add (grid);
- this.show_all ();
+ this.set_child (grid);
}
private void on_contact_changed (Object obj, ParamSpec pspec) {
@@ -83,30 +84,41 @@ public class Contacts.ContactList : Gtk.ListBox {
private bool sort_on_surname = false; // keep in sync with the setting
- private Gtk.GestureLongPress long_press;
private bool got_long_press = false;
public UiState state { get; set; }
- public ContactList (Settings settings, Store store, Query query) {
+ construct {
this.selection_mode = Gtk.SelectionMode.BROWSE;
+
+ set_sort_func (compare_rows);
+ set_filter_func (filter_row);
+ set_header_func (update_header);
+
+ get_style_context ().add_class ("contacts-contact-list");
+
+ // Connect events right-click and long-press
+ var secondary_click_gesture = new Gtk.GestureClick ();
+ secondary_click_gesture.button = Gdk.BUTTON_SECONDARY;
+ secondary_click_gesture.pressed.connect (on_right_click);
+ add_controller (secondary_click_gesture);
+
+ var long_press_gesture = new Gtk.GestureLongPress ();
+ long_press_gesture.pressed.connect (on_long_press);
+ add_controller (long_press_gesture);
+
+ // Eow selection activation
+ this.row_activated.connect (on_row_activated);
+ this.row_selected.connect (on_row_selected);
+ }
+
+ public ContactList (Settings settings, Store store, Query query) {
this.store = store;
this.filter_query = query;
this.filter_query.notify.connect (() => { invalidate_filter (); });
- this.visible = true;
this.notify["state"].connect (on_ui_state_changed);
- // Connect long press gesture
- this.long_press = new Gtk.GestureLongPress (this);
- this.long_press.pressed.connect ((g, x, y) => {
- this.got_long_press = true;
- var row = (ContactDataRow) get_row_at_y ((int) Math.round (y));
- if (row != null) {
- row.selector_button.active = this.state != UiState.SELECTING || !row.selector_button.active;
- }
- });
-
this.sort_on_surname = settings.sort_on_surname;
settings.changed["sort-on-surname"].connect(() => {
this.sort_on_surname = settings.sort_on_surname;
@@ -117,17 +129,11 @@ public class Contacts.ContactList : Gtk.ListBox {
this.store.removed.connect (contact_removed_cb);
foreach (var i in this.store.get_contacts ())
contact_added_cb (this.store, i);
-
- get_style_context ().add_class ("contacts-contact-list");
-
- set_sort_func (compare_rows);
- set_filter_func (filter_row);
- set_header_func (update_header);
}
private void on_ui_state_changed (Object obj, ParamSpec pspec) {
- foreach (var widget in get_children ()) {
- var row = widget as ContactDataRow;
+ for (unowned Gtk.Widget? child = get_first_child (); child != null; child = child.get_next_sibling ()) {
+ unowned var row = child as ContactDataRow;
row.selector_button.visible = (this.state == UiState.SELECTING);
if (this.state != UiState.SELECTING)
@@ -188,9 +194,10 @@ public class Contacts.ContactList : Gtk.ListBox {
private Gtk.Label create_header_label (string text) {
var label = new Gtk.Label (text);
label.halign = Gtk.Align.START;
- label.margin = 3;
label.margin_start = 6;
+ label.margin_end = 3;
label.margin_top = 6;
+ label.margin_bottom = 3;
var attrs = new Pango.AttrList ();
attrs.insert (Pango.attr_weight_new (Pango.Weight.BOLD));
attrs.insert (Pango.attr_scale_new ((Pango.Scale.SMALL + Pango.Scale.MEDIUM) / 2.0));
@@ -206,7 +213,7 @@ public class Contacts.ContactList : Gtk.ListBox {
row.selector_button.toggled.connect ( () => { on_row_checkbox_toggled (row); });
row.selector_button.visible = (this.state == UiState.SELECTING);
- add (row);
+ append (row);
} else {
debug ("Contact %s was ignored", i.id);
}
@@ -228,9 +235,9 @@ public class Contacts.ContactList : Gtk.ListBox {
row.destroy ();
}
- public override void row_activated (Gtk.ListBoxRow row) {
+ private void on_row_activated (Gtk.ListBox listbox, Gtk.ListBoxRow row) {
if (!this.got_long_press) {
- var data = row as ContactDataRow;
+ unowned var data = row as ContactDataRow;
if (data != null && this.state == UiState.SELECTING)
data.selector_button.active = !data.selector_button.active;
} else {
@@ -238,10 +245,10 @@ public class Contacts.ContactList : Gtk.ListBox {
}
}
- public override void row_selected (Gtk.ListBoxRow? row) {
+ private void on_row_selected (Gtk.ListBox listbox, Gtk.ListBoxRow? row) {
if (this.state != UiState.SELECTING) {
- var data = row as ContactDataRow;
- var individual = data != null ? data.individual : null;
+ unowned var data = row as ContactDataRow;
+ unowned var individual = data != null ? data.individual : null;
selection_changed (individual);
#if HAVE_TELEPATHY
if (individual != null)
@@ -251,7 +258,7 @@ public class Contacts.ContactList : Gtk.ListBox {
}
private bool filter_row (Gtk.ListBoxRow row) {
- var individual = ((ContactDataRow) row).individual;
+ unowned var individual = ((ContactDataRow) row).individual;
return this.filter_query.is_match (individual) > 0;
}
@@ -290,8 +297,8 @@ public class Contacts.ContactList : Gtk.ListBox {
private unowned ContactDataRow? find_row_for_contact (Individual individual) {
- foreach (weak Gtk.Widget widget in get_children ()) {
- unowned var row = ((ContactDataRow) widget);
+ for (unowned Gtk.Widget? child = get_first_child (); child != null; child = child.get_next_sibling ()) {
+ unowned var row = ((ContactDataRow) child);
if (row.individual == individual)
return row;
}
@@ -301,8 +308,8 @@ public class Contacts.ContactList : Gtk.ListBox {
public Gee.LinkedList<Individual> get_marked_contacts () {
var cs = new Gee.LinkedList<Individual> ();
- foreach (weak Gtk.Widget widget in get_children ()) {
- unowned var row = widget as ContactDataRow;
+ for (unowned Gtk.Widget? child = get_first_child (); child != null; child = child.get_next_sibling ()) {
+ unowned var row = child as ContactDataRow;
if (row.selector_button.active)
cs.add (row.individual);
}
@@ -311,8 +318,8 @@ public class Contacts.ContactList : Gtk.ListBox {
public Gee.LinkedList<Individual> get_marked_contacts_and_hide () {
var cs = new Gee.LinkedList<Individual> ();
- foreach (weak Gtk.Widget widget in get_children ()) {
- unowned var row = widget as ContactDataRow;
+ for (unowned Gtk.Widget? child = get_first_child (); child != null; child = child.get_next_sibling ()) {
+ unowned var row = child as ContactDataRow;
if (row.selector_button.active) {
row.visible = false;
cs.add (row.individual);
@@ -321,17 +328,18 @@ public class Contacts.ContactList : Gtk.ListBox {
return cs;
}
-
- public override bool button_press_event (Gdk.EventButton event) {
- base.button_press_event (event);
-
- if (event.button == Gdk.BUTTON_SECONDARY) {
- unowned var row = (ContactDataRow) get_row_at_y ((int) Math.round (event.y));
- if (row != null) {
- row.selector_button.active = this.state != UiState.SELECTING || !row.selector_button.active;
- }
+ private void on_right_click (Gtk.GestureClick gesture, int n_press, double x, double y) {
+ unowned var row = (ContactDataRow) get_row_at_y ((int) Math.round (y));
+ if (row != null) {
+ row.selector_button.active = this.state != UiState.SELECTING || !row.selector_button.active;
}
+ }
- return false;
+ private void on_long_press (Gtk.GestureLongPress gesture, double x, double y) {
+ this.got_long_press = true;
+ var row = (ContactDataRow) get_row_at_y ((int) Math.round (y));
+ if (row != null) {
+ row.selector_button.active = this.state != UiState.SELECTING || !row.selector_button.active;
+ }
}
}
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index bb52992e..3d8e3c17 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -25,7 +25,7 @@ const int PROFILE_SIZE = 128;
* and a ContactEditor to edit contact information.
*/
[GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-contact-pane.ui")]
-public class Contacts.ContactPane : Gtk.Bin {
+public class Contacts.ContactPane : Gtk.Widget {
private MainWindow main_window;
@@ -37,13 +37,13 @@ public class Contacts.ContactPane : Gtk.Bin {
private unowned Gtk.Stack stack;
[GtkChild]
- private unowned Hdy.StatusPage none_selected_page;
+ private unowned Adw.StatusPage none_selected_page;
[GtkChild]
private unowned Gtk.ScrolledWindow contact_sheet_view;
[GtkChild]
- private unowned Gtk.Container contact_sheet_page;
+ private unowned Gtk.Box contact_sheet_page;
private ContactSheet? sheet = null;
[GtkChild]
@@ -113,7 +113,7 @@ public class Contacts.ContactPane : Gtk.Bin {
remove_contact_sheet();
this.sheet = new ContactSheet (this.individual, this.store);
- this.contact_sheet_page.add (this.sheet);
+ this.contact_sheet_page.append (this.sheet);
this.stack.set_visible_child (this.contact_sheet_view);
var matches = this.store.aggregator.get_potential_matches (this.individual, MatchResult.HIGH);
@@ -142,7 +142,7 @@ public class Contacts.ContactPane : Gtk.Bin {
this.editor = new ContactEditor (this.individual, store.aggregator);
- this.contact_editor_page.add (this.editor);
+ this.contact_editor_page.append (this.editor);
}
private void remove_contact_editor () {
@@ -267,8 +267,8 @@ public class Contacts.ContactPane : Gtk.Bin {
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
"%s", message);
- dialog.run ();
- dialog.destroy ();
+ dialog.response.connect ((_) => dialog.close ());
+ dialog.show ();
}
private void remove_suggestion_grid () {
diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index ceb41a54..69044f7d 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -63,7 +63,7 @@ public class Contacts.ContactSheet : Gtk.Grid {
}
private Gtk.Button create_button (string icon) {
- var button = new Gtk.Button.from_icon_name (icon, Gtk.IconSize.BUTTON);
+ var button = new Gtk.Button.from_icon_name (icon);
button.set_halign (Gtk.Align.END);
button.get_style_context ().add_class ("flatten");
@@ -84,7 +84,7 @@ public class Contacts.ContactSheet : Gtk.Grid {
this.attach (type_label, 0, this.last_row, 1, 1);
var value_label = new Gtk.Label (value);
- value_label.set_line_wrap (true);
+ value_label.wrap = true;
value_label.xalign = 0.0f;
value_label.set_halign (Gtk.Align.START);
value_label.set_ellipsize (Pango.EllipsizeMode.END);
@@ -94,12 +94,12 @@ public class Contacts.ContactSheet : Gtk.Grid {
if (btn1 != null || btn2 !=null) {
var value_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12);
- value_box.pack_start (value_label, false, false, 0);
+ value_box.append (value_label);
if (btn1 != null)
- value_box.pack_end (btn1, false, false, 0);
+ value_box.append (btn1);
if (btn2 != null)
- value_box.pack_end (btn2, false, false, 0);
+ value_box.append (btn2);
this.attach (value_box, 1, this.last_row, 1, 1);
} else {
this.attach (value_label, 1, this.last_row, 1, 1);
@@ -109,7 +109,14 @@ public class Contacts.ContactSheet : Gtk.Grid {
private void update () {
this.last_row = 0;
- this.foreach ((child) => this.remove (child));
+
+ // Remove all fields
+ var child = get_first_child();
+ while (child != null) {
+ var next = get_next_sibling();
+ remove(child);
+ child = next;
+ }
var image_frame = new Avatar (PROFILE_SIZE, this.individual);
image_frame.set_vexpand (false);
@@ -141,8 +148,6 @@ public class Contacts.ContactSheet : Gtk.Grid {
this.last_row--;
}
}
-
- show_all ();
}
private void update_name_label (Gtk.Label name_label) {
@@ -266,14 +271,14 @@ public class Contacts.ContactSheet : Gtk.Grid {
foreach (var url in url_details.urls) {
var button = create_button ("web-browser-symbolic");
button.clicked.connect (() => {
- unowned var window = button.get_toplevel () as MainWindow;
+ unowned var window = button.get_root () as MainWindow;
if (window == null)
return;
try {
- Gtk.show_uri_on_window (window,
- fallback_to_https (url.value),
- Gdk.CURRENT_TIME);
+ Gtk.show_uri (window,
+ fallback_to_https (url.value),
+ Gdk.CURRENT_TIME);
} catch (Error e) {
var message = "Failed to open url '%s'".printf(url.value);
diff --git a/src/contacts-crop-cheese-dialog.vala b/src/contacts-crop-cheese-dialog.vala
index 1904d8a4..bb4f678d 100644
--- a/src/contacts-crop-cheese-dialog.vala
+++ b/src/contacts-crop-cheese-dialog.vala
@@ -33,6 +33,10 @@ public class Contacts.CropCheeseDialog : Gtk.Window {
public signal void picture_selected (Gdk.Pixbuf buf);
+ construct {
+ this.close_request.connect(on_close_request);
+ }
+
public CropCheeseDialog.for_cheese (Gtk.Window parent) {
#if HAVE_CHEESE
setup_widget (parent);
@@ -97,8 +101,7 @@ public class Contacts.CropCheeseDialog : Gtk.Window {
destroy();
}
- [GtkCallback]
- private void on_destroy () {
+ private bool on_close_request () {
#if HAVE_CHEESE
/* Ensure the Vala garbage collector disposes of the Cheese widget.
* This prevents the 'Device or resource busy' warnings, see:
@@ -106,6 +109,8 @@ public class Contacts.CropCheeseDialog : Gtk.Window {
*/
this.cheese = null;
#endif
+
+ return Gdk.EVENT_STOP; // XXX what the hell am i supposed to retunr here?
}
}
diff --git a/src/contacts-editor-persona.vala b/src/contacts-editor-persona.vala
index f0888a07..1f5da079 100644
--- a/src/contacts-editor-persona.vala
+++ b/src/contacts-editor-persona.vala
@@ -45,11 +45,11 @@ public class Contacts.EditorPersona : Gtk.Box {
construct {
this.header = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
- add (this.header);
+ append (this.header);
this.content = new Gtk.ListBox ();
this.content.get_style_context ().add_class ("content");
- add (this.content);
+ append (this.content);
}
public EditorPersona (Persona persona, IndividualAggregator aggregator) {
@@ -66,7 +66,7 @@ public class Contacts.EditorPersona : Gtk.Box {
foreach (var row in rows) {
row.show_with_animation (false);
connect_row (row);
- this.content.add (row);
+ this.content.append (row);
}
}
// Add a row with a button to show all properties
@@ -80,18 +80,17 @@ public class Contacts.EditorPersona : Gtk.Box {
var rows = new EditorProperty (persona, property);
foreach (var row in rows) {
connect_row (row);
- this.content.add (row);
+ this.content.append (row);
row.show_with_animation ();
}
}
show_all_row.destroy ();
}
});
- Gtk.Image show_all = new Gtk.Image.from_icon_name ("view-more-symbolic",
- Gtk.IconSize.BUTTON);
- show_all.margin = 12;
- show_all_row.add (show_all);
- this.content.add (show_all_row);
+ Gtk.Image show_all = new Gtk.Image.from_icon_name ("view-more-symbolic");
+ // show_all.margin = 12; XXX
+ show_all_row.set_child (show_all);
+ this.content.append (show_all_row);
}
private void connect_row (EditorPropertyRow row) {
@@ -117,8 +116,8 @@ public class Contacts.EditorPersona : Gtk.Box {
private uint count_empty_rows (string type) {
uint count = 0;
- foreach (var row in this.content.get_children ()) {
- var prop = (row as EditorPropertyRow);
+ for (unowned Gtk.Widget? child = get_first_child (); child != null; child = child.get_next_sibling ()) {
+ var prop = (child as EditorPropertyRow);
if (prop != null && !prop.is_removed && prop.is_empty && prop.ptype == type) {
count++;
}
@@ -127,12 +126,13 @@ public class Contacts.EditorPersona : Gtk.Box {
}
private void destroy_empty_rows (Gtk.ListBoxRow current_row, string type) {
- foreach (var row in this.content.get_children ()) {
- if (current_row != row) {
- var prop = (row as EditorPropertyRow);
- if (prop != null && !prop.is_removed && prop.is_empty && prop.ptype == type) {
- prop.remove ();
- }
+ for (unowned Gtk.Widget? child = get_first_child (); child != null; child = child.get_next_sibling ()) {
+ if (current_row == child)
+ continue;
+
+ unowned var prop = (child as EditorPropertyRow);
+ if (prop != null && !prop.is_removed && prop.is_empty && prop.ptype == type) {
+ prop.remove ();
}
}
}
@@ -147,7 +147,7 @@ public class Contacts.EditorPersona : Gtk.Box {
}
Gtk.Label addressbook = new Gtk.Label (title);
- addressbook.get_style_context ().add_class ("heading");
- this.header.pack_start (addressbook, false, false, 0);
+ addressbook.add_css_class ("heading");
+ this.header.append (addressbook);
}
}
diff --git a/src/contacts-editor-property.vala b/src/contacts-editor-property.vala
index d03cde3b..edcd0c24 100644
--- a/src/contacts-editor-property.vala
+++ b/src/contacts-editor-property.vala
@@ -19,41 +19,39 @@
using Folks;
public class Contacts.BirthdayEditor : Gtk.Dialog {
- private Gtk.SpinButton day_spin;
- private Gtk.ComboBoxText month_combo;
- private Gtk.SpinButton year_spin;
+
+ private unowned Gtk.SpinButton day_spin;
+ private unowned Gtk.ComboBoxText month_combo;
+ private unowned Gtk.SpinButton year_spin;
+
public bool is_set { get; set; default = false; }
public signal void changed ();
- delegate void AdjustingDateFn ();
- public GLib.DateTime get_birthday () {
- return new GLib.DateTime.local (year_spin.get_value_as_int (),
- month_combo.get_active () + 1,
- day_spin.get_value_as_int (),
- 0, 0, 0).to_utc ();
- }
+ construct {
+ add_css_class ("birthday-editor");
- public BirthdayEditor (Gtk.Window window, DateTime birthday) {
- Object (transient_for: window, use_header_bar: 1);
- day_spin = new Gtk.SpinButton.with_range (1.0, 31.0, 1.0);
- day_spin.set_digits (0);
- day_spin.numeric = true;
- day_spin.set_value ((double)birthday.to_local ().get_day_of_month ());
+ // Day
+ var d_spin = new Gtk.SpinButton.with_range (1.0, 31.0, 1.0);
+ d_spin.digits = 0;
+ d_spin.numeric = true;
+ this.day_spin = d_spin;
- month_combo = new Gtk.ComboBoxText ();
+ // Month
+ var m_combo = new Gtk.ComboBoxText ();
var january = new DateTime.local (1, 1, 1, 1, 1, 1);
for (int i = 0; i < 12; i++) {
var month = january.add_months (i);
- month_combo.append_text (month.format ("%B"));
+ m_combo.append_text (month.format ("%B"));
}
- month_combo.set_active (birthday.to_local ().get_month () - 1);
- month_combo.hexpand = true;
+ m_combo.hexpand = true;
+ this.month_combo = m_combo;
- year_spin = new Gtk.SpinButton.with_range (1800, 3000, 1);
- year_spin.set_digits (0);
- year_spin.numeric = true;
- year_spin.set_value ((double)birthday.to_local ().get_year ());
+ // Year
+ var y_spin = new Gtk.SpinButton.with_range (1800, 3000, 1);
+ y_spin.set_digits (0);
+ y_spin.numeric = true;
+ this.year_spin = y_spin;
// Create grid and labels
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
@@ -72,18 +70,20 @@ public class Contacts.BirthdayEditor : Gtk.Dialog {
year.set_halign (Gtk.Align.END);
grid.attach (year, 0, 2);
grid.attach (year_spin, 1, 2);
- box.pack_start (grid);
+ box.append (grid);
+
+ // box.margin = 12; XXX
var content = this.get_content_area ();
content.set_valign (Gtk.Align.CENTER);
- content.add (box);
+ content.append (box);
this.title = _("Change Birthday");
add_buttons (_("Set"), Gtk.ResponseType.OK,
_("Cancel"), Gtk.ResponseType.CANCEL,
null);
var ok_button = this.get_widget_for_response (Gtk.ResponseType.OK);
- ok_button.get_style_context ().add_class ("suggested-action");
+ ok_button.add_css_class ("suggested-action");
this.response.connect ((id) => {
switch (id) {
case Gtk.ResponseType.OK:
@@ -95,39 +95,48 @@ public class Contacts.BirthdayEditor : Gtk.Dialog {
}
this.destroy ();
});
+ }
- box.margin = 12;
- box.show_all ();
-
- AdjustingDateFn fn = () => {
- int[] month_of_31 = {3, 5, 8, 10};
- if (month_combo.get_active () in month_of_31) {
- day_spin.set_range (1, 30);
- } else if (month_combo.get_active () == 1) {
- if (year_spin.get_value_as_int () % 400 == 0 ||
- (year_spin.get_value_as_int () % 4 == 0 &&
- year_spin.get_value_as_int () % 100 != 0)) {
- day_spin.set_range (1, 29);
- } else {
- day_spin.set_range (1, 28);
- }
- } else {
- day_spin.set_range (1, 31);
- }
- };
+ public BirthdayEditor (Gtk.Window window, DateTime birthday) {
+ Object (transient_for: window, use_header_bar: 1);
- /* adjusting day_spin value using selected month/year constraints*/
- fn ();
+ this.day_spin.set_value ((double) birthday.to_local ().get_day_of_month ());
+ this.month_combo.set_active (birthday.to_local ().get_month () - 1);
+ this.year_spin.set_value ((double)birthday.to_local ().get_year ());
+ update_date ();
month_combo.changed.connect (() => {
- /* adjusting day_spin value using selected month constraints*/
- fn ();
+ update_date ();
});
year_spin.value_changed.connect (() => {
- /* adjusting day_spin value using selected year constraints*/
- fn ();
+ update_date ();
});
}
+
+ public GLib.DateTime get_birthday () {
+ return new GLib.DateTime.local (year_spin.get_value_as_int (),
+ month_combo.get_active () + 1,
+ day_spin.get_value_as_int (),
+ 0, 0, 0).to_utc ();
+ }
+
+ private void update_date() {
+ const int[] month_of_31 = {3, 5, 8, 10};
+
+ if (this.month_combo.get_active () in month_of_31) {
+ this.day_spin.set_range (1, 30);
+ } else if (this.month_combo.get_active () == 1) {
+ if (this.year_spin.get_value_as_int () % 400 == 0 ||
+ (this.year_spin.get_value_as_int () % 4 == 0 &&
+ this.year_spin.get_value_as_int () % 100 != 0)) {
+ this.day_spin.set_range (1, 29);
+ } else {
+ this.day_spin.set_range (1, 28);
+ }
+ } else {
+ this.day_spin.set_range (1, 31);
+ }
+ }
}
public class Contacts.AddressEditor : Gtk.Box {
@@ -138,10 +147,14 @@ public class Contacts.AddressEditor : Gtk.Box {
public signal void changed ();
- public AddressEditor (PostalAddressFieldDetails details) {
+ construct {
set_hexpand (true);
set_orientation (Gtk.Orientation.VERTICAL);
+ add_css_class ("address-editor");
+ }
+
+ public AddressEditor (PostalAddressFieldDetails details) {
for (int i = 0; i < entries.length; i++) {
string postal_part;
details.value.get (AddressEditor.postal_element_props[i], out postal_part);
@@ -154,7 +167,7 @@ public class Contacts.AddressEditor : Gtk.Box {
entries[i].set_text (postal_part);
entries[i].get_style_context ().add_class ("contacts-postal-entry");
- add (entries[i]);
+ append (entries[i]);
var entry = entries[i];
var prop_name = AddressEditor.postal_element_props[i];
@@ -174,9 +187,10 @@ public class Contacts.AddressEditor : Gtk.Box {
return true;
}
- public override void grab_focus () {
- entries[0].grab_focus ();
- }
+ //XXX)
+ // public override void grab_focus () {
+ // entries[0].grab_focus ();
+ // }
}
public class Contacts.EditorPropertyRow : Gtk.ListBoxRow {
@@ -197,15 +211,15 @@ public class Contacts.EditorPropertyRow : Gtk.ListBoxRow {
this.container.set_can_focus (false);
this.header = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
this.header.set_can_focus (false);
- box.pack_start (this.header);
- box.pack_end (this.container);
+ box.append (this.header);
+ box.append (this.container);
this.set_activatable (false);
this.set_selectable (false);
this.set_can_focus (false);
- box.margin = 12;
- this.revealer.add (box);
- add (this.revealer);
- this.get_style_context ().add_class ("editor-property-row");
+ // box.margin = 12; XXX
+ this.revealer.set_child (box);
+ this.set_child (this.revealer);
+ this.add_css_class ("editor-property-row");
this.revealer.bind_property ("reveal-child", this, "is-removed", BindingFlags.INVERT_BOOLEAN);
}
@@ -232,9 +246,7 @@ public class Contacts.EditorPropertyRow : Gtk.ListBoxRow {
var duration = this.revealer.get_transition_duration ();
this.revealer.set_reveal_child (true);
this.revealer.set_transition_duration (duration);
- this.show_all ();
} else {
- this.show_all ();
this.revealer.set_reveal_child (true);
}
}
@@ -244,7 +256,7 @@ public class Contacts.EditorPropertyRow : Gtk.ListBoxRow {
title_label.set_hexpand (false);
title_label.set_halign (Gtk.Align.START);
title_label.margin_end = 6;
- this.header.pack_start (title_label);
+ this.header.append (title_label);
}
public void add_base_combo (Gee.Set<AbstractFieldDetails> details_set,
@@ -253,11 +265,11 @@ public class Contacts.EditorPropertyRow : Gtk.ListBoxRow {
AbstractFieldDetails details) {
var title_label = new Gtk.Label (label);
title_label.set_halign (Gtk.Align.START);
- this.header.pack_start (title_label);
+ this.header.append (title_label);
TypeCombo combo = new TypeCombo (combo_type);
combo.set_hexpand (false);
combo.set_active_from_field_details (details);
- this.header.pack_start (combo);
+ this.header.append (combo);
combo.changed.connect (() => {
combo.active_descriptor.save_to_field_details(details);
@@ -276,7 +288,7 @@ public class Contacts.EditorPropertyRow : Gtk.ListBoxRow {
value_entry.placeholder_text = placeholder;
value_entry.set_text (details.value);
value_entry.set_hexpand (true);
- this.container.pack_start (value_entry);
+ this.container.append (value_entry);
this.is_empty = details.value == "";
@@ -297,7 +309,7 @@ public class Contacts.EditorPropertyRow : Gtk.ListBoxRow {
value_entry.placeholder_text = placeholder;
value_entry.set_text (details.value);
value_entry.set_hexpand (true);
- this.container.pack_start (value_entry);
+ this.container.append (value_entry);
this.is_empty = details.value == "";
@@ -319,7 +331,7 @@ public class Contacts.EditorPropertyRow : Gtk.ListBoxRow {
value_entry.set_input_purpose (Gtk.InputPurpose.URL);
value_entry.set_text (details.value);
value_entry.set_hexpand (true);
- this.container.pack_start (value_entry);
+ this.container.append (value_entry);
this.is_empty = details.value == "";
@@ -336,10 +348,10 @@ public class Contacts.EditorPropertyRow : Gtk.ListBoxRow {
public void add_base_delete (Gee.Set<AbstractFieldDetails> details_set,
AbstractFieldDetails details) {
var delete_button = new Gtk.Button.from_icon_name ("user-trash-symbolic");
- delete_button.get_accessible ().set_name (_("Delete field"));
+ delete_button.tooltip_text = _("Delete field");
delete_button.set_valign (Gtk.Align.START);
this.bind_property ("is-empty", delete_button, "sensitive", BindingFlags.SYNC_CREATE |
BindingFlags.INVERT_BOOLEAN);
- this.container.pack_end (delete_button, false);
+ this.container.append (delete_button);
delete_button.clicked.connect (() => {
@@ -506,7 +518,7 @@ public class Contacts.EditorProperty : Gee.ArrayList<EditorPropertyRow> {
var value_entry = new Gtk.Entry ();
value_entry.set_text (details.nickname);
value_entry.set_hexpand (true);
- box.container.pack_start (value_entry);
+ box.container.append (value_entry);
value_entry.changed.connect (() => {
details.nickname = value_entry.get_text ();
@@ -531,14 +543,14 @@ public class Contacts.EditorProperty : Gee.ArrayList<EditorPropertyRow> {
var box = new EditorPropertyRow ("notes");
box.add_base_label (_("Note"));
- var sw = new Gtk.ScrolledWindow (null, null);
- sw.set_shadow_type (Gtk.ShadowType.OUT);
+ var sw = new Gtk.ScrolledWindow ();
+ sw.has_frame = true;
sw.set_size_request (-1, 100);
var value_text = new Gtk.TextView ();
value_text.get_buffer ().set_text (details.value);
value_text.set_hexpand (true);
- sw.add (value_text);
- box.container.pack_start (sw);
+ sw.set_child (value_text);
+ box.container.append (sw);
box.add_base_delete (details_set, details);
@@ -571,10 +583,10 @@ public class Contacts.EditorProperty : Gee.ArrayList<EditorPropertyRow> {
var box = new EditorPropertyRow ("birthday");
box.add_base_label (_("Birthday"));
- box.container.pack_start (button);
+ box.container.append (button);
button.clicked.connect (() => {
- var parent_window = button.get_toplevel () as Gtk.Window;
+ unowned var parent_window = button.get_root () as Gtk.Window;
if (parent_window != null) {
var dialog = new BirthdayEditor (parent_window, date);
@@ -585,17 +597,17 @@ public class Contacts.EditorProperty : Gee.ArrayList<EditorPropertyRow> {
box.is_empty = false;
}
});
- dialog.show_all ();
+ dialog.show ();
}
});
box.is_empty = details.birthday == null;
var delete_button = new Gtk.Button.from_icon_name ("user-trash-symbolic");
- delete_button.get_accessible ().set_name (_("Delete field"));
+ delete_button.tooltip_text = _("Delete field");
delete_button.set_valign (Gtk.Align.START);
box.bind_property ("is-empty", delete_button, "sensitive", BindingFlags.SYNC_CREATE |
BindingFlags.INVERT_BOOLEAN);
- box.container.pack_end (delete_button, false);
+ box.container.append (delete_button);
delete_button.clicked.connect (() => {
debug ("Birthday removed");
@@ -622,7 +634,7 @@ public class Contacts.EditorProperty : Gee.ArrayList<EditorPropertyRow> {
box.add_base_combo (details_set, _("Address"), TypeSet.general, details);
var value_address = new AddressEditor (details);
- box.container.pack_start (value_address);
+ box.container.append (value_address);
box.is_empty = value_address.is_empty ();
diff --git a/src/contacts-esd-setup.vala b/src/contacts-esd-setup.vala
index b0c58adb..c17723fd 100644
--- a/src/contacts-esd-setup.vala
+++ b/src/contacts-esd-setup.vala
@@ -23,7 +23,7 @@ extern bool e_trust_prompt_run_for_source_finish (E.Source source, AsyncResult r
namespace Contacts {
public E.SourceRegistry? eds_source_registry = null;
-private E.CredentialsPrompter? eds_credentials_prompter = null;
+// private E.CredentialsPrompter? eds_credentials_prompter = null;
public bool ensure_eds_accounts (bool allow_interaction) {
if (eds_source_registry != null)
@@ -39,70 +39,71 @@ public bool ensure_eds_accounts (bool allow_interaction) {
return false;
}
- eds_credentials_prompter = new E.CredentialsPrompter (eds_source_registry);
+ // XXX
+ // eds_credentials_prompter = new E.CredentialsPrompter (eds_source_registry);
- if (!allow_interaction)
- eds_credentials_prompter.set_auto_prompt (false);
+ // if (!allow_interaction)
+ // eds_credentials_prompter.set_auto_prompt (false);
- var credentials_provider = eds_credentials_prompter.get_provider ();
+ // var credentials_provider = eds_credentials_prompter.get_provider ();
- // First disable credentials prompt for all but addressbook sources...
- foreach (var source in eds_source_registry.list_sources (null)) {
- // Mark for skip also currently disabled sources
- if (!source.has_extension (E.SOURCE_EXTENSION_ADDRESS_BOOK))
- eds_credentials_prompter.set_auto_prompt_disabled_for (source, true);
- }
+ // // First disable credentials prompt for all but addressbook sources...
+ // foreach (var source in eds_source_registry.list_sources (null)) {
+ // // Mark for skip also currently disabled sources
+ // if (!source.has_extension (E.SOURCE_EXTENSION_ADDRESS_BOOK))
+ // eds_credentials_prompter.set_auto_prompt_disabled_for (source, true);
+ // }
- // ...then enable credentials prompt for credential source of the addressbook sources,
- // which can be a collection source.
- foreach (var source in eds_source_registry.list_sources (E.SOURCE_EXTENSION_ADDRESS_BOOK)) {
- var cred_source = credentials_provider.ref_credentials_source (source);
- if (cred_source != null && !source.equal (cred_source))
- eds_credentials_prompter.set_auto_prompt_disabled_for (cred_source, false);
- }
+ // // ...then enable credentials prompt for credential source of the addressbook sources,
+ // // which can be a collection source.
+ // foreach (var source in eds_source_registry.list_sources (E.SOURCE_EXTENSION_ADDRESS_BOOK)) {
+ // var cred_source = credentials_provider.ref_credentials_source (source);
+ // if (cred_source != null && !source.equal (cred_source))
+ // eds_credentials_prompter.set_auto_prompt_disabled_for (cred_source, false);
+ // }
- // The eds_credentials_prompter responses to REQUIRED and REJECTED reasons,
- // the SSL_FAILED should be handled elsewhere.
- eds_source_registry.credentials_required.connect((src, reason, cert_pem, cert_err, err) => {
- on_credentials_required.begin (src, reason, cert_pem, cert_err, err);
- });
+ // // The eds_credentials_prompter responses to REQUIRED and REJECTED reasons,
+ // // the SSL_FAILED should be handled elsewhere.
+ // eds_source_registry.credentials_required.connect((src, reason, cert_pem, cert_err, err) => {
+ // on_credentials_required.begin (src, reason, cert_pem, cert_err, err);
+ // });
- eds_credentials_prompter.process_awaiting_credentials ();
+ // eds_credentials_prompter.process_awaiting_credentials ();
return true;
}
-private async void on_credentials_required (E.Source source, E.SourceCredentialsReason reason, string
cert_pem, TlsCertificateFlags cert_errors, Error err) {
- if (eds_credentials_prompter.get_auto_prompt_disabled_for (source))
- return;
-
- if (reason == E.SourceCredentialsReason.ERROR && err != null) {
- warning ("Failed to authenticate for source \"%s\": %s", source.display_name, err.message);
- return;
- }
-
- if (reason == E.SourceCredentialsReason.SSL_FAILED) {
- e_trust_prompt_run_for_source (eds_credentials_prompter.get_dialog_parent (),
- source, cert_pem, cert_errors, (err != null)? err.message : null, true,
- null, (obj, res) => on_source_trust_prompt_has_run.begin (source, res));
- }
-}
-
-private async void on_source_trust_prompt_has_run (E.Source source, AsyncResult res) {
- try {
- e_trust_prompt_run_for_source_finish (source, res, null);
- } catch (Error e) {
- warning ("Failed to prompt for trust for source \"%s\": %s", source.display_name, e.message);
- return;
- }
-
- try {
- // Use null credentials to reuse those from the last time.
- yield source.invoke_authenticate (null, null);
- } catch (Error e) {
- warning ("Failed to invoke authenticate() for source \"%s\": %s", source.display_name, e.message);
- }
-}
+// private async void on_credentials_required (E.Source source, E.SourceCredentialsReason reason, string
cert_pem, TlsCertificateFlags cert_errors, Error err) {
+// if (eds_credentials_prompter.get_auto_prompt_disabled_for (source))
+// return;
+
+// if (reason == E.SourceCredentialsReason.ERROR && err != null) {
+// warning ("Failed to authenticate for source \"%s\": %s", source.display_name, err.message);
+// return;
+// }
+
+// if (reason == E.SourceCredentialsReason.SSL_FAILED) {
+// e_trust_prompt_run_for_source (eds_credentials_prompter.get_dialog_parent (),
+// source, cert_pem, cert_errors, (err != null)? err.message : null, true,
+// null, (obj, res) => on_source_trust_prompt_has_run.begin (source, res));
+// }
+// }
+
+// private async void on_source_trust_prompt_has_run (E.Source source, AsyncResult res) {
+// try {
+// e_trust_prompt_run_for_source_finish (source, res, null);
+// } catch (Error e) {
+// warning ("Failed to prompt for trust for source \"%s\": %s", source.display_name, e.message);
+// return;
+// }
+
+// try {
+// // Use null credentials to reuse those from the last time.
+// yield source.invoke_authenticate (null, null);
+// } catch (Error e) {
+// warning ("Failed to invoke authenticate() for source \"%s\": %s", source.display_name, e.message);
+// }
+// }
public bool has_goa_account () {
foreach (var source in eds_source_registry.list_sources (E.SOURCE_EXTENSION_GOA)) {
@@ -188,6 +189,6 @@ public Gtk.Image? get_icon_for_goa_account (string goa_id) {
return null;
}
- return new Gtk.Image.from_gicon (provider_icon, Gtk.IconSize.DIALOG);
+ return new Gtk.Image.from_gicon (provider_icon);
}
}
diff --git a/src/contacts-link-suggestion-grid.vala b/src/contacts-link-suggestion-grid.vala
index 967ed68f..0d386f50 100644
--- a/src/contacts-link-suggestion-grid.vala
+++ b/src/contacts-link-suggestion-grid.vala
@@ -43,7 +43,7 @@ public class Contacts.LinkSuggestionGrid : Gtk.Grid {
var image_frame = new Avatar (AVATAR_SIZE, individual);
image_frame.hexpand = false;
- image_frame.margin = 12;
+ // image_frame.margin = 12; XXX
image_frame.show ();
attach (image_frame, 0, 0, 1, 2);
diff --git a/src/contacts-linked-personas-dialog.vala b/src/contacts-linked-personas-dialog.vala
index 26f3ca36..4f89d892 100644
--- a/src/contacts-linked-personas-dialog.vala
+++ b/src/contacts-linked-personas-dialog.vala
@@ -51,7 +51,7 @@ public class Contacts.LinkedPersonasDialog : Gtk.Dialog {
var image_frame = new Avatar (AVATAR_SIZE, individual);
image_frame.set_hexpand (false);
- image_frame.margin = 6;
+ // image_frame.margin = 6; XXX
image_frame.margin_end = 12;
row_grid.attach (image_frame, 0, 0, 1, 2);
@@ -73,7 +73,7 @@ public class Contacts.LinkedPersonasDialog : Gtk.Dialog {
var button = new Gtk.Button.with_label (_("Unlink"));
button.margin_end = 6;
button.set_valign (Gtk.Align.CENTER);
- button.get_child ().margin = 1;
+ // button.get_child ().margin = 1; XXX
row_grid.attach (button, 2, 0, 1, 2);
/* signal */
@@ -81,8 +81,7 @@ public class Contacts.LinkedPersonasDialog : Gtk.Dialog {
// TODO: handly unlinking
});
- row_grid.show_all ();
- this.linked_accounts_view.add (row_grid);
+ this.linked_accounts_view.append (row_grid);
}
}
}
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index 5439b365..67bbc94f 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -59,7 +59,7 @@ public class Contacts.ListPane : Gtk.Frame {
// Load the ContactsView and connect the necessary signals
this.contacts_list = new ContactList (settings, contacts_store, this.filter_query);
bind_property ("state", this.contacts_list, "state", BindingFlags.BIDIRECTIONAL |
BindingFlags.SYNC_CREATE);
- this.contacts_list_container.add (this.contacts_list);
+ this.contacts_list_container.set_child (this.contacts_list);
this.contacts_list.selection_changed.connect( (l, individual) => {
selection_changed (individual);
@@ -73,7 +73,7 @@ public class Contacts.ListPane : Gtk.Frame {
}
public void undo_deletion () {
- contacts_list.show_all ();
+ contacts_list.show ();
}
private void on_ui_state_changed (Object obj, ParamSpec pspec) {
@@ -112,8 +112,8 @@ public class Contacts.ListPane : Gtk.Frame {
delete_contacts (this.contacts_list.get_marked_contacts_and_hide ());
}
- /* Limiting width hack */
- public override void get_preferred_width (out int minimum_width, out int natural_width) {
- minimum_width = natural_width = 300;
- }
+ /* Limiting width hack XXX */
+ // public override void get_preferred_width (out int minimum_width, out int natural_width) {
+ // minimum_width = natural_width = 300;
+ // }
}
diff --git a/src/contacts-main-window.vala b/src/contacts-main-window.vala
index 47c67e47..d999ebcd 100644
--- a/src/contacts-main-window.vala
+++ b/src/contacts-main-window.vala
@@ -18,7 +18,7 @@
using Folks;
[GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-main-window.ui")]
-public class Contacts.MainWindow : Hdy.ApplicationWindow {
+public class Contacts.MainWindow : Adw.ApplicationWindow {
private const GLib.ActionEntry[] action_entries = {
{ "edit-contact", edit_contact },
@@ -28,31 +28,32 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
};
[GtkChild]
- private unowned Hdy.Leaflet header;
+ private unowned Adw.Leaflet header;
[GtkChild]
- private unowned Hdy.Leaflet content_box;
+ private unowned Adw.Leaflet content_box;
[GtkChild]
private unowned Gtk.Revealer back_revealer;
[GtkChild]
private unowned Gtk.Stack list_pane_stack;
[GtkChild]
- private unowned Gtk.Container contact_pane_container;
+ private unowned Gtk.Overlay contact_pane_container;
[GtkChild]
- private unowned Hdy.HeaderBar left_header;
+ private unowned Adw.HeaderBar left_header;
[GtkChild]
private unowned Gtk.Separator header_separator;
[GtkChild]
- private unowned Hdy.HeaderBar right_header;
+ private unowned Adw.HeaderBar right_header;
[GtkChild]
private unowned Gtk.Overlay notification_overlay;
[GtkChild]
private unowned Gtk.Button select_cancel_button;
[GtkChild]
private unowned Gtk.MenuButton hamburger_menu_button;
+ // XXX make sure these are grouped together (like radio buttons in GTK3)
[GtkChild]
- private unowned Gtk.ModelButton sort_on_firstname_button;
+ private unowned Gtk.CheckButton sort_on_firstname_button;
[GtkChild]
- private unowned Gtk.ModelButton sort_on_surname_button;
+ private unowned Gtk.CheckButton sort_on_surname_button;
[GtkChild]
private unowned Gtk.MenuButton contact_menu_button;
[GtkChild]
@@ -78,8 +79,6 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
// Window state
public int window_width { get; set; }
public int window_height { get; set; }
- public bool window_maximized { get; set; }
- public bool window_fullscreen { get; set; }
public Settings settings { get; construct set; }
@@ -92,11 +91,11 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
actions.add_action_entries (action_entries, this);
insert_action_group ("window", actions);
- this.sort_on_firstname_button.clicked.connect (() => {
+ this.sort_on_firstname_button.toggled.connect (() => {
this.settings.sort_on_surname = false;
on_sort_changed ();
});
- this.sort_on_surname_button.clicked.connect (() => {
+ this.sort_on_surname_button.toggled.connect (() => {
this.settings.sort_on_surname = true;
on_sort_changed ();
});
@@ -107,6 +106,7 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
create_contact_pane ();
connect_button_signals ();
restore_window_state ();
+ this.close_request.connect(on_close_request);
if (Config.PROFILE == "development")
get_style_context ().add_class ("devel");
@@ -128,54 +128,24 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
}
private void restore_window_state () {
- // Load initial values
- this.window_width = this.settings.window_width;
- this.window_height = this.settings.window_height;
- this.window_maximized = this.settings.window_maximized;
- this.window_fullscreen = this.settings.window_fullscreen;
-
// Apply them
- if (this.window_width > 0 && this.window_height > 0)
- set_default_size (this.window_width, this.window_height);
- if (this.window_maximized)
+ if (this.settings.window_width > 0 && this.settings.window_height > 0)
+ set_default_size (this.settings.window_width, this.settings.window_height);
+ if (this.settings.window_maximized)
maximize ();
- if (this.window_fullscreen)
+ if (this.settings.window_fullscreen)
fullscreen ();
}
- public override bool window_state_event (Gdk.EventWindowState event) {
- this.window_maximized = (Gdk.WindowState.MAXIMIZED in event.new_window_state);
- this.window_fullscreen = (Gdk.WindowState.FULLSCREEN in event.new_window_state);
-
- return base.window_state_event (event);
- }
-
- // Called on window resize. Save window size for the next start.
- public override void size_allocate (Gtk.Allocation allocation) {
- base.size_allocate (allocation);
-
- if (this.window_fullscreen || this.window_maximized)
- return;
-
- // Get the size via widget.get_size() instead of the allocation
- // so that the window isn't ever-expanding (in case of CSD).
- int width = 0;
- int height = 0;
- get_size(out width, out height);
-
- this.window_width = width;
- this.window_height = height;
- }
-
private void create_contact_pane () {
this.contact_pane = new ContactPane (this, this.store);
this.contact_pane.visible = true;
this.contact_pane.hexpand = true;
this.contact_pane.contacts_linked.connect (contact_pane_contacts_linked_cb);
this.contact_pane.display_name_changed.connect ((display_name) => {
- this.right_header.title = display_name;
+ update_header_titles (null, display_name);
});
- this.contact_pane_container.add (this.contact_pane);
+ this.contact_pane_container.set_child (this.contact_pane);
}
/**
@@ -196,15 +166,14 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
list_pane.delete_contacts.connect (delete_contacts);
list_pane.contacts_marked.connect ((nr_contacts) => {
- if (this.state == UiState.SELECTING)
- this.left_header.title = ngettext ("%d Selected", "%d Selected", nr_contacts)
- .printf (nr_contacts);
- else
- this.left_header.title = _("Contacts");
- });
+ string left_title = _("Contacts");
+ if (this.state == UiState.SELECTING)
+ left_title = ngettext ("%d Selected", "%d Selected", nr_contacts)
+ .printf (nr_contacts);
+ update_header_titles (left_title, null);
+ });
- list_pane_stack.add (list_pane);
- list_pane.show ();
+ list_pane_stack.add_child (list_pane);
list_pane_stack.visible_child = list_pane;
if (this.contact_pane.individual != null)
@@ -228,7 +197,7 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
this.selection_button.visible = !(this.state == UiState.SELECTING || this.state.editing ());
if (this.state != UiState.SELECTING)
- this.left_header.title = _("Contacts");
+ update_header_titles (_("Contacts"), null);
// Editing UI
this.cancel_button.visible
@@ -281,7 +250,7 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
this.state = UiState.UPDATING;
unowned var name = this.contact_pane.individual.display_name;
- this.right_header.title = _("Editing %s").printf (name);
+ update_header_titles (null, _("Editing %s").printf (name));
this.contact_pane.edit_contact ();
}
@@ -300,8 +269,8 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
[GtkCallback]
private void on_selection_button_clicked () {
this.state = UiState.SELECTING;
- this.left_header.title = ngettext ("%d Selected", "%d Selected", 0)
- .printf (0);
+ update_header_titles (ngettext ("%d Selected", "%d Selected", 0) .printf (0),
+ null);
}
private void unlink_contact () {
@@ -351,9 +320,9 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
this.list_pane.scroll_to_contact ();
if (this.contact_pane.individual != null) {
- this.right_header.title = this.contact_pane.individual.display_name;
+ update_header_titles (null, this.contact_pane.individual.display_name);
} else {
- this.right_header.title = "";
+ update_header_titles (null, "");
}
}
@@ -377,10 +346,10 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
this.favorite_button.active = i.is_favourite;
this.ignore_favorite_button_toggled = false;
this.favorite_button.tooltip_text = (i.is_favourite)? _("Unmark as favorite")
- : _("Mark as favorite");
- this.right_header.title = i.display_name;
+ : _("Mark as favorite");
+ update_header_titles (null, i.display_name);
} else {
- this.right_header.title = "";
+ update_header_titles (null, "");
}
}
@@ -393,7 +362,7 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
this.state = UiState.CREATING;
- this.right_header.title = _("New Contact");
+ update_header_titles (null, _("New Contact"));
this.contact_pane.new_contact ();
show_contact_pane ();
@@ -423,6 +392,20 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
this.header.visible_child == this.right_header;
}
+ private void update_header_titles (string? left_title, string? right_title) {
+ if (left_title != null) {
+ var label = new Gtk.Label (left_title);
+ label.add_css_class ("title");
+ this.left_header.set_title_widget (label);
+ }
+
+ if (right_title != null) {
+ var label = new Gtk.Label (right_title);
+ label.add_css_class ("title");
+ this.right_header.set_title_widget (label);
+ }
+ }
+
private void show_list_pane () {
content_box.visible_child_name = "list-pane";
update_header ();
@@ -457,41 +440,46 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
}
[GtkCallback]
- bool key_press_event_cb (Gdk.EventKey event) {
- if ((event.keyval == Gdk.keyval_from_name ("q")) &&
- ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
+ bool on_key_pressed (Gtk.EventControllerKey controller,
+ uint keyval,
+ uint keycode,
+ Gdk.ModifierType state) {
+ if ((keyval == Gdk.keyval_from_name ("q")) &&
+ ((state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
// Clear the contacts so any changed information is stored
this.contact_pane.show_contact (null);
destroy ();
- } else if (((event.keyval == Gdk.Key.s) ||
- (event.keyval == Gdk.Key.f)) &&
- ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
+ } else if ((keyval == Gdk.Key.s || keyval == Gdk.Key.f) &&
+ ((state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
// Explicitly check if this.list_pane is already initialized,
// or we might crash at startup
if (this.list_pane != null && this.list_pane.filter_entry != null)
Utils.grab_entry_focus_no_select (this.list_pane.filter_entry);
- } else if (event.length >= 1 &&
- Gdk.keyval_to_unicode (event.keyval) != 0 &&
- (event.state & Gdk.ModifierType.CONTROL_MASK) == 0 &&
- (event.state & Gdk.ModifierType.MOD1_MASK) == 0 &&
- (event.keyval != Gdk.Key.Escape) &&
- (event.keyval != Gdk.Key.Tab) &&
- (event.keyval != Gdk.Key.BackSpace) ) {
+ } else if (Gdk.keyval_to_unicode (keyval) != 0 &&
+ (state & Gdk.ModifierType.CONTROL_MASK) == 0 &&
+ (state & Gdk.ModifierType.ALT_MASK) == 0 &&
+ (keyval != Gdk.Key.Escape) &&
+ (keyval != Gdk.Key.Tab) &&
+ (keyval != Gdk.Key.BackSpace) ) {
// Explicitly check if this.list_pane is already initialized,
// or we might crash at startup
if (this.list_pane != null && this.list_pane.filter_entry != null)
Utils.grab_entry_focus_no_select (this.list_pane.filter_entry);
- propagate_key_event (event);
}
- return false;
+ return Gdk.EVENT_PROPAGATE;
}
- [GtkCallback]
- bool delete_event_cb (Gdk.EventAny event) {
+ private bool on_close_request () {
// Clear the contacts so any changed information is stored
this.contact_pane.show_contact (null);
- return false;
+
+ this.settings.window_width = this.default_width; // XXX is default_ correct here?
+ this.settings.window_height = this.default_height;
+ this.settings.window_maximized = this.maximized;
+ this.settings.window_fullscreen = this.fullscreened;
+
+ return Gdk.EVENT_STOP; // XXX what the hell am i supposed to retunr here?
}
void list_pane_selection_changed_cb (Individual? new_selection) {
@@ -594,14 +582,4 @@ public class Contacts.MainWindow : Hdy.ApplicationWindow {
add_notification (notification);
}
-
- // Override the default destroy() to save the window state
- public override void destroy () {
- this.settings.window_width = this.window_width;
- this.settings.window_height = this.window_height;
- this.settings.window_maximized = this.window_maximized;
- this.settings.window_fullscreen = this.window_fullscreen;
-
- base.destroy ();
- }
}
diff --git a/src/contacts-setup-window.vala b/src/contacts-setup-window.vala
index 9305b8a9..4dad6759 100644
--- a/src/contacts-setup-window.vala
+++ b/src/contacts-setup-window.vala
@@ -18,7 +18,7 @@
using Folks;
[GtkTemplate (ui = "/org/gnome/Contacts/ui/contacts-setup-window.ui")]
-public class Contacts.SetupWindow : Hdy.ApplicationWindow {
+public class Contacts.SetupWindow : Adw.ApplicationWindow {
[GtkChild]
private unowned Gtk.Box content;
@@ -37,7 +37,7 @@ public class Contacts.SetupWindow : Hdy.ApplicationWindow {
this.setup_accounts_list = new AccountsList (store);
this.setup_accounts_list.hexpand = true;
this.setup_accounts_list.show ();
- this.content.add (this.setup_accounts_list);
+ this.content.append (this.setup_accounts_list);
// Listen for changes
store.backend_store.backend_available.connect ( () => {
diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala
index 48388765..f7a95f31 100644
--- a/src/contacts-utils.vala
+++ b/src/contacts-utils.vala
@@ -68,7 +68,7 @@ namespace Contacts.Utils {
public void compose_mail (string email) {
var mailto_uri = "mailto:" + Uri.escape_string (email, "@" , false);
try {
- Gtk.show_uri_on_window (null, mailto_uri, 0);
+ Gtk.show_uri (null, mailto_uri, 0);
} catch (Error e) {
debug ("Couldn't launch URI \"%s\": %s", mailto_uri, e.message);
}
@@ -116,7 +116,7 @@ namespace Contacts.Utils {
return null;
}
- public void grab_entry_focus_no_select (Gtk.Entry entry) {
+ public void grab_entry_focus_no_select (Gtk.SearchEntry entry) {
int start, end;
if (!entry.get_selection_bounds (out start, out end)) {
start = end = entry.get_position ();
@@ -189,8 +189,8 @@ namespace Contacts.Utils {
Gtk.MessageType.ERROR,
Gtk.ButtonsType.OK,
"%s", error);
- dialog.run();
- dialog.destroy();
+ dialog.response.connect(() => { dialog.destroy(); });
+ dialog.show();
}
public bool persona_is_main (Persona persona) {
diff --git a/src/meson.build b/src/meson.build
index d9776384..f4404b36 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -24,7 +24,7 @@ contacts_vala_args = [
contacts_c_args = [
'-include', 'config.h',
- '-DGNOME_DESKTOP_USE_UNSTABLE_API',
+ # '-DGNOME_DESKTOP_USE_UNSTABLE_API',
'-DLOCALEDIR="@0@"'.format(locale_dir),
]
@@ -34,13 +34,13 @@ contacts_deps = [
gee,
gio_unix,
glib,
- gnome_desktop,
+ # gnome_desktop,
goa,
- gtk,
+ gtk4_dep,
+ libadwaita_dep,
libebook,
libedataserver,
- libedataserverui,
- libhandy,
+ # libedataserverui,
math,
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]