2019-08-01 13:25:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018, 2019 Purism SPC
|
|
|
|
*
|
|
|
|
* This file is part of Calls.
|
|
|
|
*
|
|
|
|
* Calls is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calls is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calls. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Bob Ham <bob.ham@puri.sm>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "calls-call-record-row.h"
|
2019-12-09 14:51:21 +00:00
|
|
|
#include "calls-best-match.h"
|
2019-08-01 13:25:53 +00:00
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
#include <glib-object.h>
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
#define AVATAR_SIZE 32
|
|
|
|
|
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
struct _CallsCallRecordRow
|
|
|
|
{
|
|
|
|
GtkOverlay parent_instance;
|
|
|
|
|
|
|
|
GtkImage *avatar;
|
|
|
|
GtkImage *type;
|
|
|
|
GtkLabel *target;
|
|
|
|
GtkLabel *time;
|
|
|
|
|
|
|
|
CallsCallRecord *record;
|
|
|
|
gulong answered_notify_handler_id;
|
|
|
|
gulong end_notify_handler_id;
|
|
|
|
guint date_change_timeout;
|
|
|
|
|
2019-10-29 10:09:48 +00:00
|
|
|
CallsContacts *contacts;
|
2019-12-09 14:51:21 +00:00
|
|
|
CallsBestMatch *contact;
|
2019-10-29 10:09:48 +00:00
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
CallsNewCallBox *new_call;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (CallsCallRecordRow, calls_call_record_row, GTK_TYPE_BOX);
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_RECORD,
|
2019-10-29 10:09:48 +00:00
|
|
|
PROP_CONTACTS,
|
2019-08-01 13:25:53 +00:00
|
|
|
PROP_NEW_CALL,
|
|
|
|
PROP_LAST_PROP,
|
|
|
|
};
|
|
|
|
static GParamSpec *props[PROP_LAST_PROP];
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
redial_clicked_cb (CallsCallRecordRow *self)
|
|
|
|
{
|
|
|
|
gchar *target;
|
|
|
|
|
|
|
|
g_object_get (self->record,
|
|
|
|
"target", &target,
|
|
|
|
NULL);
|
|
|
|
g_assert (target != NULL);
|
|
|
|
|
|
|
|
calls_new_call_box_dial (self->new_call, target);
|
|
|
|
g_free (target);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
nice_time (GDateTime *t,
|
|
|
|
gchar **nice,
|
|
|
|
gboolean *final)
|
|
|
|
{
|
|
|
|
GDateTime *now = g_date_time_new_now_local ();
|
|
|
|
const gboolean today =
|
|
|
|
calls_date_time_is_same_day (now, t);
|
|
|
|
const gboolean yesterday =
|
|
|
|
(!today && calls_date_time_is_yesterday (now, t));
|
|
|
|
|
|
|
|
g_assert (nice != NULL);
|
|
|
|
g_assert (final != NULL);
|
|
|
|
|
|
|
|
if (today || yesterday)
|
|
|
|
{
|
|
|
|
gchar *n = g_date_time_format (t, "%R");
|
|
|
|
|
|
|
|
if (yesterday)
|
|
|
|
{
|
|
|
|
gchar *s;
|
|
|
|
s = g_strdup_printf (_("%s\nyesterday"), n);
|
|
|
|
g_free (n);
|
|
|
|
n = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
*nice = n;
|
|
|
|
*final = FALSE;
|
|
|
|
}
|
|
|
|
else if (calls_date_time_is_same_year (now, t))
|
|
|
|
{
|
|
|
|
*nice = g_date_time_format (t, "%b %-d");
|
|
|
|
*final = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*nice = g_date_time_format (t, "%Y");
|
|
|
|
*final = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_date_time_unref (now);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2019-10-29 10:09:48 +00:00
|
|
|
update_time_text (CallsCallRecordRow *self,
|
|
|
|
GDateTime *end,
|
|
|
|
gboolean *final)
|
2019-08-01 13:25:53 +00:00
|
|
|
{
|
|
|
|
gchar *nice;
|
|
|
|
nice_time (end, &nice, final);
|
|
|
|
gtk_label_set_text (self->time, nice);
|
|
|
|
g_free (nice);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean date_change_cb (CallsCallRecordRow *self);
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_date_change_timeout (CallsCallRecordRow *self)
|
|
|
|
{
|
|
|
|
GDateTime *gnow, *gnextday, *gtomorrow;
|
|
|
|
struct timeval now, tomorrow, delta;
|
|
|
|
int err;
|
|
|
|
guint interval;
|
|
|
|
|
|
|
|
// Get the time now
|
|
|
|
gnow = g_date_time_new_now_local ();
|
|
|
|
|
|
|
|
// Get the next day
|
|
|
|
gnextday = g_date_time_add_days (gnow, 1);
|
|
|
|
g_date_time_unref (gnow);
|
|
|
|
|
|
|
|
// Get the start of the next day
|
|
|
|
gtomorrow =
|
|
|
|
g_date_time_new (g_date_time_get_timezone (gnextday),
|
|
|
|
g_date_time_get_year (gnextday),
|
|
|
|
g_date_time_get_month (gnextday),
|
|
|
|
g_date_time_get_day_of_month (gnextday),
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0.0);
|
|
|
|
g_date_time_unref (gnextday);
|
|
|
|
|
|
|
|
// Convert to a timeval
|
|
|
|
tomorrow.tv_sec = g_date_time_to_unix (gtomorrow);
|
|
|
|
tomorrow.tv_usec = 0;
|
|
|
|
g_date_time_unref (gtomorrow);
|
|
|
|
|
|
|
|
// Get the precise time now
|
|
|
|
err = gettimeofday (&now, NULL);
|
|
|
|
if (err == -1)
|
|
|
|
{
|
|
|
|
g_warning ("Error getting time to set date change timeout: %s",
|
|
|
|
g_strerror (errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find how long from now until the start of the next day
|
|
|
|
timersub (&tomorrow, &now, &delta);
|
|
|
|
|
|
|
|
// Convert to milliseconds
|
|
|
|
interval =
|
|
|
|
(delta.tv_sec * 1000)
|
|
|
|
+
|
|
|
|
(delta.tv_usec / 1000);
|
|
|
|
|
|
|
|
// Add the timeout
|
|
|
|
self->date_change_timeout =
|
|
|
|
g_timeout_add (interval,
|
|
|
|
(GSourceFunc)date_change_cb,
|
|
|
|
self);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
date_change_cb (CallsCallRecordRow *self)
|
|
|
|
{
|
|
|
|
GDateTime *end;
|
|
|
|
gboolean final;
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (self->record),
|
|
|
|
"end", &end,
|
|
|
|
NULL);
|
|
|
|
g_assert (end != NULL);
|
|
|
|
|
2019-10-29 10:09:48 +00:00
|
|
|
update_time_text (self, end, &final);
|
2019-08-01 13:25:53 +00:00
|
|
|
g_date_time_unref (end);
|
|
|
|
|
|
|
|
if (final)
|
|
|
|
{
|
|
|
|
self->date_change_timeout = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setup_date_change_timeout (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2019-10-29 10:09:48 +00:00
|
|
|
update_time (CallsCallRecordRow *self,
|
|
|
|
gboolean inbound,
|
|
|
|
GDateTime *answered,
|
|
|
|
GDateTime *end)
|
2019-08-01 13:25:53 +00:00
|
|
|
{
|
|
|
|
gboolean missed = FALSE;
|
|
|
|
gchar *type_icon_name;
|
|
|
|
|
|
|
|
if (end)
|
|
|
|
{
|
|
|
|
gboolean time_final;
|
|
|
|
|
2019-10-29 10:09:48 +00:00
|
|
|
update_time_text (self, end, &time_final);
|
2019-08-01 13:25:53 +00:00
|
|
|
|
|
|
|
if (!time_final && !self->date_change_timeout)
|
|
|
|
{
|
|
|
|
setup_date_change_timeout (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!answered)
|
|
|
|
{
|
|
|
|
missed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type_icon_name = g_strdup_printf
|
|
|
|
("call-arrow-%s%s-symbolic",
|
|
|
|
inbound ? "incoming" : "outgoing",
|
|
|
|
missed ? "-missed" : "");
|
|
|
|
gtk_image_set_from_icon_name (self->type, type_icon_name,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
|
|
|
|
|
|
|
g_free (type_icon_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2019-10-29 10:09:48 +00:00
|
|
|
notify_time_cb (CallsCallRecordRow *self,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
CallsCallRecord *record)
|
2019-08-01 13:25:53 +00:00
|
|
|
{
|
|
|
|
gboolean inbound;
|
|
|
|
GDateTime *answered;
|
|
|
|
GDateTime *end;
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (self->record),
|
|
|
|
"inbound", &inbound,
|
|
|
|
"answered", &answered,
|
|
|
|
"end", &end,
|
|
|
|
NULL);
|
|
|
|
|
2019-10-29 10:09:48 +00:00
|
|
|
update_time (self, inbound, answered, end);
|
2019-08-01 13:25:53 +00:00
|
|
|
|
|
|
|
if (answered)
|
|
|
|
{
|
|
|
|
g_date_time_unref (answered);
|
|
|
|
calls_clear_signal (record, &self->answered_notify_handler_id);
|
|
|
|
}
|
|
|
|
if (end)
|
|
|
|
{
|
|
|
|
g_date_time_unref (end);
|
|
|
|
calls_clear_signal (record, &self->end_notify_handler_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-29 10:09:48 +00:00
|
|
|
static void
|
|
|
|
setup_time (CallsCallRecordRow *self,
|
|
|
|
gboolean inbound,
|
|
|
|
GDateTime *answered,
|
|
|
|
GDateTime *end)
|
|
|
|
{
|
|
|
|
if (!end)
|
|
|
|
{
|
|
|
|
self->end_notify_handler_id =
|
|
|
|
g_signal_connect_swapped (self->record,
|
|
|
|
"notify::end",
|
|
|
|
G_CALLBACK (notify_time_cb),
|
|
|
|
self);
|
|
|
|
|
|
|
|
if (!answered)
|
|
|
|
{
|
|
|
|
self->answered_notify_handler_id =
|
|
|
|
g_signal_connect_swapped (self->record,
|
|
|
|
"notify::answered",
|
|
|
|
G_CALLBACK (notify_time_cb),
|
|
|
|
self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
update_time (self, inbound, answered, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2019-12-09 14:51:21 +00:00
|
|
|
contact_name_cb (CallsCallRecordRow *self)
|
2019-10-29 10:09:48 +00:00
|
|
|
{
|
2019-12-09 14:51:21 +00:00
|
|
|
const gchar *name = NULL;
|
|
|
|
|
2019-10-29 10:09:48 +00:00
|
|
|
if (self->contact)
|
|
|
|
{
|
2019-12-09 14:51:21 +00:00
|
|
|
name = calls_best_match_get_name (self->contact);
|
|
|
|
}
|
2019-10-29 10:09:48 +00:00
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
if (name)
|
|
|
|
{
|
2019-10-29 10:09:48 +00:00
|
|
|
gtk_label_set_text (self->target, name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *target;
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (self->record),
|
|
|
|
"target", &target,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_label_set_text (self->target, target);
|
|
|
|
|
|
|
|
g_free (target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
static void
|
|
|
|
set_avatar (CallsCallRecordRow *self,
|
|
|
|
GdkPixbuf *avatar)
|
2019-10-29 10:09:48 +00:00
|
|
|
{
|
2019-12-09 14:51:21 +00:00
|
|
|
if (avatar)
|
|
|
|
{
|
|
|
|
gtk_image_set_from_pixbuf (self->avatar, avatar);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_image_set_from_icon_name (self->avatar,
|
|
|
|
"avatar-default-symbolic",
|
|
|
|
GTK_ICON_SIZE_DND);
|
|
|
|
}
|
2019-10-29 10:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
static void
|
|
|
|
contact_avatar_cb (CallsCallRecordRow *self,
|
|
|
|
gint size,
|
|
|
|
GdkPixbuf *avatar,
|
|
|
|
CallsBestMatch *contact)
|
2019-10-29 10:09:48 +00:00
|
|
|
{
|
2019-12-09 14:51:21 +00:00
|
|
|
if (size != AVATAR_SIZE)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_avatar (self, avatar);
|
2019-10-29 10:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2019-12-09 14:51:21 +00:00
|
|
|
request_contact_avatar (CallsCallRecordRow *self)
|
2019-10-29 10:09:48 +00:00
|
|
|
{
|
2019-12-09 14:51:21 +00:00
|
|
|
GdkPixbuf *avatar;
|
2019-10-29 10:09:48 +00:00
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
if (!self->contact)
|
2019-10-29 10:09:48 +00:00
|
|
|
{
|
2019-12-09 14:51:21 +00:00
|
|
|
return;
|
2019-10-29 10:09:48 +00:00
|
|
|
}
|
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
avatar = calls_best_match_request_avatar
|
|
|
|
(self->contact, AVATAR_SIZE);
|
|
|
|
|
|
|
|
set_avatar (self, avatar);
|
2019-10-29 10:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2019-12-09 14:51:21 +00:00
|
|
|
setup_contact (CallsCallRecordRow *self)
|
2019-10-29 10:09:48 +00:00
|
|
|
{
|
|
|
|
g_autofree gchar *target = NULL;
|
|
|
|
EPhoneNumber *phone_number;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
// Get the target number
|
|
|
|
g_object_get (G_OBJECT (self->record),
|
|
|
|
"target", &target,
|
|
|
|
NULL);
|
|
|
|
g_assert (target != NULL);
|
|
|
|
|
|
|
|
// Parse it
|
|
|
|
phone_number = e_phone_number_from_string
|
|
|
|
(target, NULL, &error);
|
|
|
|
if (!phone_number)
|
|
|
|
{
|
|
|
|
g_warning ("Error parsing phone number `%s': %s",
|
|
|
|
target, error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
// Look up the best match object
|
|
|
|
self->contact = calls_contacts_lookup_phone_number
|
2019-10-29 10:09:48 +00:00
|
|
|
(self->contacts, phone_number);
|
2019-12-09 14:51:21 +00:00
|
|
|
g_assert (self->contact != NULL);
|
2019-10-29 10:09:48 +00:00
|
|
|
g_clear_object (&self->contacts);
|
|
|
|
e_phone_number_free (phone_number);
|
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
g_signal_connect_swapped (self->contact,
|
|
|
|
"notify::name",
|
|
|
|
G_CALLBACK (contact_name_cb),
|
|
|
|
self);
|
|
|
|
g_signal_connect_swapped (self->contact,
|
|
|
|
"avatar",
|
|
|
|
G_CALLBACK (contact_avatar_cb),
|
2019-10-29 10:09:48 +00:00
|
|
|
self);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
static void
|
|
|
|
set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (object);
|
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_RECORD:
|
|
|
|
g_set_object (&self->record,
|
|
|
|
CALLS_CALL_RECORD (g_value_get_object (value)));
|
|
|
|
break;
|
|
|
|
|
2019-10-29 10:09:48 +00:00
|
|
|
case PROP_CONTACTS:
|
|
|
|
g_set_object (&self->contacts,
|
|
|
|
CALLS_CONTACTS (g_value_get_object (value)));
|
|
|
|
break;
|
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
case PROP_NEW_CALL:
|
|
|
|
g_set_object (&self->new_call,
|
|
|
|
CALLS_NEW_CALL_BOX (g_value_get_object (value)));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GObjectClass *obj_class = g_type_class_peek (G_TYPE_OBJECT);
|
|
|
|
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (object);
|
|
|
|
gboolean inbound;
|
|
|
|
GDateTime *answered;
|
|
|
|
GDateTime *end;
|
|
|
|
|
|
|
|
g_object_get (G_OBJECT (self->record),
|
|
|
|
"inbound", &inbound,
|
|
|
|
"answered", &answered,
|
|
|
|
"end", &end,
|
|
|
|
NULL);
|
|
|
|
|
2019-10-29 10:09:48 +00:00
|
|
|
setup_time (self, inbound, answered, end);
|
2019-08-01 13:25:53 +00:00
|
|
|
calls_date_time_unref (answered);
|
|
|
|
calls_date_time_unref (end);
|
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
setup_contact (self);
|
|
|
|
contact_name_cb (self);
|
|
|
|
request_contact_avatar (self);
|
2019-10-29 10:09:48 +00:00
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
obj_class->constructed (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (object);
|
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_RECORD:
|
|
|
|
g_value_set_object (value, self->record);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GObjectClass *obj_class = g_type_class_peek (G_TYPE_OBJECT);
|
|
|
|
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (object);
|
|
|
|
|
|
|
|
g_clear_object (&self->new_call);
|
|
|
|
|
2019-12-09 14:51:21 +00:00
|
|
|
g_clear_object (&self->contact);
|
2019-10-29 10:09:48 +00:00
|
|
|
g_clear_object (&self->contacts);
|
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
calls_clear_source (&self->date_change_timeout);
|
|
|
|
calls_clear_signal (self->record, &self->answered_notify_handler_id);
|
|
|
|
calls_clear_signal (self->record, &self->end_notify_handler_id);
|
|
|
|
g_clear_object (&self->record);
|
|
|
|
|
|
|
|
obj_class->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
calls_call_record_row_class_init (CallsCallRecordRowClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->set_property = set_property;
|
|
|
|
object_class->constructed = constructed;
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
|
|
|
props[PROP_RECORD] =
|
|
|
|
g_param_spec_object ("record",
|
|
|
|
_("Record"),
|
|
|
|
_("The call record for this row"),
|
|
|
|
CALLS_TYPE_CALL_RECORD,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
2019-10-29 10:09:48 +00:00
|
|
|
props[PROP_CONTACTS] =
|
|
|
|
g_param_spec_object ("contacts",
|
|
|
|
_("Contacts"),
|
|
|
|
_("Interface for libfolks"),
|
|
|
|
CALLS_TYPE_CONTACTS,
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
props[PROP_NEW_CALL] =
|
|
|
|
g_param_spec_object ("new-call",
|
|
|
|
_("New call"),
|
|
|
|
_("The UI box for making calls"),
|
|
|
|
CALLS_TYPE_NEW_CALL_BOX,
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
|
|
|
|
|
|
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/sm/puri/calls/ui/call-record-row.ui");
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsCallRecordRow, avatar);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsCallRecordRow, type);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsCallRecordRow, target);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsCallRecordRow, time);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, redial_clicked_cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
calls_call_record_row_init (CallsCallRecordRow *self)
|
|
|
|
{
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CallsCallRecordRow *
|
|
|
|
calls_call_record_row_new (CallsCallRecord *record,
|
2019-10-29 10:09:48 +00:00
|
|
|
CallsContacts *contacts,
|
2019-08-01 13:25:53 +00:00
|
|
|
CallsNewCallBox *new_call)
|
|
|
|
{
|
|
|
|
return g_object_new (CALLS_TYPE_CALL_RECORD_ROW,
|
|
|
|
"record", record,
|
2019-10-29 10:09:48 +00:00
|
|
|
"contacts", contacts,
|
2019-08-01 13:25:53 +00:00
|
|
|
"new-call", new_call,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CallsCallRecord *
|
|
|
|
calls_call_record_row_get_record (CallsCallRecordRow *self)
|
|
|
|
{
|
|
|
|
return self->record;
|
|
|
|
}
|