2018-05-17 13:16:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2018 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-main-window.h"
|
2021-05-11 16:18:35 +00:00
|
|
|
|
#include "calls-account-overview.h"
|
2018-05-17 13:16:51 +00:00
|
|
|
|
#include "calls-origin.h"
|
2020-07-07 12:41:55 +00:00
|
|
|
|
#include "calls-ussd.h"
|
2018-08-01 09:41:25 +00:00
|
|
|
|
#include "calls-new-call-box.h"
|
2021-01-20 14:13:52 +00:00
|
|
|
|
#include "calls-contacts-box.h"
|
2019-08-01 13:25:53 +00:00
|
|
|
|
#include "calls-history-box.h"
|
2020-03-02 18:01:20 +00:00
|
|
|
|
#include "calls-in-app-notification.h"
|
2020-03-18 10:29:41 +00:00
|
|
|
|
#include "calls-manager.h"
|
2018-08-30 06:50:37 +00:00
|
|
|
|
#include "config.h"
|
2018-05-17 13:16:51 +00:00
|
|
|
|
#include "util.h"
|
2021-04-16 16:15:59 +00:00
|
|
|
|
#include "version.h"
|
2018-05-17 13:16:51 +00:00
|
|
|
|
|
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
#include <handy.h>
|
|
|
|
|
|
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
struct _CallsMainWindow {
|
|
|
|
|
HdyApplicationWindow parent_instance;
|
2018-05-17 13:16:51 +00:00
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
GListModel *record_store;
|
2018-05-17 13:16:51 +00:00
|
|
|
|
|
2020-03-02 18:01:20 +00:00
|
|
|
|
CallsInAppNotification *in_app_notification;
|
2018-05-17 13:16:51 +00:00
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
HdyViewSwitcherTitle *title_switcher;
|
|
|
|
|
GtkStack *main_stack;
|
2019-08-01 13:25:53 +00:00
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
GtkRevealer *permanent_error_revealer;
|
|
|
|
|
GtkLabel *permanent_error_label;
|
2020-03-19 16:41:08 +00:00
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
CallsAccountOverview *account_overview;
|
|
|
|
|
CallsNewCallBox *new_call;
|
2020-07-07 12:41:55 +00:00
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
GtkDialog *ussd_dialog;
|
|
|
|
|
GtkStack *ussd_stack;
|
|
|
|
|
GtkSpinner *ussd_spinner;
|
|
|
|
|
GtkBox *ussd_content;
|
|
|
|
|
GtkLabel *ussd_label;
|
|
|
|
|
GtkEntry *ussd_entry;
|
|
|
|
|
GtkButton *ussd_close_button;
|
|
|
|
|
GtkButton *ussd_cancel_button;
|
|
|
|
|
GtkButton *ussd_reply_button;
|
2018-05-17 13:16:51 +00:00
|
|
|
|
};
|
|
|
|
|
|
2021-07-15 07:35:32 +00:00
|
|
|
|
G_DEFINE_TYPE (CallsMainWindow, calls_main_window, HDY_TYPE_APPLICATION_WINDOW);
|
2018-05-17 13:16:51 +00:00
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
2019-08-01 13:25:53 +00:00
|
|
|
|
PROP_RECORD_STORE,
|
2018-05-17 13:16:51 +00:00
|
|
|
|
PROP_LAST_PROP,
|
|
|
|
|
};
|
|
|
|
|
static GParamSpec *props[PROP_LAST_PROP];
|
|
|
|
|
|
|
|
|
|
|
2018-08-30 06:50:37 +00:00
|
|
|
|
static void
|
|
|
|
|
about_action (GSimpleAction *action,
|
|
|
|
|
GVariant *parameter,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
CallsMainWindow *self = user_data;
|
|
|
|
|
|
|
|
|
|
const gchar *version = NULL;
|
|
|
|
|
|
|
|
|
|
static const gchar *authors[] = {
|
|
|
|
|
"Adrien Plazas <kekun.plazas@laposte.net>",
|
|
|
|
|
"Bob Ham <rah@settrans.net>",
|
|
|
|
|
"Guido Günther <agx@sigxcpu.org>",
|
2021-07-15 08:57:11 +00:00
|
|
|
|
"Julian Sparber <julian@sparber.net>",
|
|
|
|
|
"Evangelos Ribeiro Tzaras <devrtz@fortysixandtwo.eu>",
|
2018-08-30 06:50:37 +00:00
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const gchar *artists[] = {
|
|
|
|
|
"Tobias Bernard <tbernard@gnome.org>",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const gchar *documenters[] = {
|
|
|
|
|
"Heather Ellsworth <heather.ellsworth@puri.sm>",
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
version = g_str_equal (VCS_TAG, "") ?
|
|
|
|
|
PACKAGE_VERSION : PACKAGE_VERSION "-" VCS_TAG;
|
2018-08-30 06:50:37 +00:00
|
|
|
|
|
2020-05-31 13:48:52 +00:00
|
|
|
|
/*
|
|
|
|
|
* “program-name” defaults to g_get_application_name().
|
|
|
|
|
* Don’t set it explicitly so that there is one less
|
|
|
|
|
* string to translate.
|
|
|
|
|
*/
|
2018-08-30 06:50:37 +00:00
|
|
|
|
gtk_show_about_dialog (GTK_WINDOW (self),
|
|
|
|
|
"artists", artists,
|
|
|
|
|
"authors", authors,
|
2022-02-12 23:00:23 +00:00
|
|
|
|
"copyright", "Copyright © 2018 - 2022 Purism",
|
2018-08-30 06:50:37 +00:00
|
|
|
|
"documenters", documenters,
|
|
|
|
|
"license-type", GTK_LICENSE_GPL_3_0,
|
|
|
|
|
"logo-icon-name", APP_ID,
|
|
|
|
|
"translator-credits", _("translator-credits"),
|
|
|
|
|
"version", version,
|
|
|
|
|
"website", PACKAGE_URL,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
static const GActionEntry window_entries[] =
|
2018-08-30 06:50:37 +00:00
|
|
|
|
{
|
|
|
|
|
{ "about", about_action },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2020-07-07 12:41:55 +00:00
|
|
|
|
static void
|
|
|
|
|
window_update_ussd_state (CallsMainWindow *self,
|
|
|
|
|
CallsUssd *ussd)
|
|
|
|
|
{
|
|
|
|
|
CallsUssdState state;
|
|
|
|
|
|
|
|
|
|
g_assert (CALLS_IS_MAIN_WINDOW (self));
|
|
|
|
|
g_assert (CALLS_IS_USSD (ussd));
|
|
|
|
|
|
|
|
|
|
state = calls_ussd_get_state (ussd);
|
|
|
|
|
|
|
|
|
|
/* If state changed in an active USSD session, don't update */
|
|
|
|
|
if (state == CALLS_USSD_STATE_ACTIVE &&
|
|
|
|
|
gtk_widget_get_visible (GTK_WIDGET (self->ussd_reply_button)))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->ussd_reply_button),
|
|
|
|
|
state == CALLS_USSD_STATE_USER_RESPONSE);
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->ussd_entry),
|
|
|
|
|
state == CALLS_USSD_STATE_USER_RESPONSE);
|
|
|
|
|
|
|
|
|
|
if (state == CALLS_USSD_STATE_USER_RESPONSE ||
|
|
|
|
|
state == CALLS_USSD_STATE_ACTIVE)
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (self->ussd_cancel_button));
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (self->ussd_close_button));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
window_ussd_added_cb (CallsMainWindow *self,
|
|
|
|
|
CallsUssd *ussd,
|
|
|
|
|
char *response)
|
|
|
|
|
{
|
|
|
|
|
g_assert (CALLS_IS_MAIN_WINDOW (self));
|
|
|
|
|
g_assert (CALLS_IS_USSD (ussd));
|
|
|
|
|
|
|
|
|
|
if (!response || !*response)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_label_set_label (self->ussd_label, response);
|
|
|
|
|
g_object_set_data_full (G_OBJECT (self->ussd_dialog), "ussd",
|
|
|
|
|
g_object_ref (ussd), g_object_unref);
|
|
|
|
|
window_update_ussd_state (self, ussd);
|
|
|
|
|
gtk_window_present (GTK_WINDOW (self->ussd_dialog));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
window_ussd_cancel_clicked_cb (CallsMainWindow *self)
|
|
|
|
|
{
|
|
|
|
|
CallsUssd *ussd;
|
|
|
|
|
|
|
|
|
|
g_assert (CALLS_IS_MAIN_WINDOW (self));
|
|
|
|
|
|
|
|
|
|
ussd = g_object_get_data (G_OBJECT (self->ussd_dialog), "ussd");
|
|
|
|
|
|
|
|
|
|
if (ussd)
|
|
|
|
|
calls_ussd_cancel_async (ussd, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
gtk_window_close (GTK_WINDOW (self->ussd_dialog));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
window_ussd_entry_changed_cb (CallsMainWindow *self,
|
|
|
|
|
GtkEntry *entry)
|
|
|
|
|
{
|
|
|
|
|
const char *text;
|
|
|
|
|
gboolean allow_send;
|
|
|
|
|
|
|
|
|
|
g_assert (CALLS_IS_MAIN_WINDOW (self));
|
|
|
|
|
g_assert (GTK_IS_ENTRY (entry));
|
|
|
|
|
|
|
|
|
|
text = gtk_entry_get_text (entry);
|
|
|
|
|
allow_send = text && *text;
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->ussd_reply_button), allow_send);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
window_ussd_respond_cb (GObject *object,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2021-02-10 23:38:10 +00:00
|
|
|
|
g_autoptr (GError) error = NULL;
|
2022-04-24 10:24:55 +00:00
|
|
|
|
g_autofree char *response = NULL;
|
|
|
|
|
CallsMainWindow *self = user_data;
|
2020-07-07 12:41:55 +00:00
|
|
|
|
CallsUssd *ussd;
|
|
|
|
|
|
|
|
|
|
ussd = g_object_get_data (G_OBJECT (self->ussd_dialog), "ussd");
|
|
|
|
|
response = calls_ussd_respond_finish (ussd, result, &error);
|
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
if (error) {
|
|
|
|
|
gtk_dialog_response (self->ussd_dialog, GTK_RESPONSE_CLOSE);
|
|
|
|
|
g_warning ("USSD Error: %s", error->message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-07-07 12:41:55 +00:00
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
if (response && *response) {
|
|
|
|
|
window_update_ussd_state (self, ussd);
|
|
|
|
|
gtk_label_set_text (self->ussd_label, response);
|
|
|
|
|
}
|
2020-07-07 12:41:55 +00:00
|
|
|
|
|
|
|
|
|
gtk_spinner_stop (self->ussd_spinner);
|
|
|
|
|
gtk_stack_set_visible_child (self->ussd_stack, GTK_WIDGET (self->ussd_content));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
window_ussd_reply_clicked_cb (CallsMainWindow *self)
|
|
|
|
|
{
|
|
|
|
|
CallsUssd *ussd;
|
|
|
|
|
g_autofree char *response = NULL;
|
|
|
|
|
|
|
|
|
|
g_assert (CALLS_IS_MAIN_WINDOW (self));
|
|
|
|
|
|
|
|
|
|
ussd = g_object_get_data (G_OBJECT (self->ussd_dialog), "ussd");
|
|
|
|
|
g_assert (CALLS_IS_USSD (ussd));
|
|
|
|
|
|
|
|
|
|
response = g_strdup (gtk_entry_get_text (self->ussd_entry));
|
|
|
|
|
gtk_entry_set_text (self->ussd_entry, "");
|
|
|
|
|
calls_ussd_respond_async (ussd, response, NULL,
|
|
|
|
|
window_ussd_respond_cb, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
main_window_ussd_send_cb (GObject *object,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2021-02-10 23:38:10 +00:00
|
|
|
|
g_autoptr (GError) error = NULL;
|
2022-04-24 10:24:55 +00:00
|
|
|
|
g_autofree char *response = NULL;
|
|
|
|
|
CallsMainWindow *self = user_data;
|
2020-07-07 12:41:55 +00:00
|
|
|
|
CallsUssd *ussd;
|
|
|
|
|
|
|
|
|
|
response = calls_new_call_box_send_ussd_finish (self->new_call, result, &error);
|
|
|
|
|
ussd = g_task_get_task_data (G_TASK (result));
|
|
|
|
|
|
2022-04-24 10:24:55 +00:00
|
|
|
|
if (error) {
|
|
|
|
|
gtk_dialog_response (self->ussd_dialog, GTK_RESPONSE_CLOSE);
|
|
|
|
|
g_warning ("USSD Error: %s", error->message);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-07-07 12:41:55 +00:00
|
|
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (self->ussd_dialog), "ussd",
|
|
|
|
|
g_object_ref (ussd), g_object_unref);
|
|
|
|
|
window_update_ussd_state (self, ussd);
|
|
|
|
|
gtk_label_set_text (self->ussd_label, response);
|
|
|
|
|
gtk_spinner_stop (self->ussd_spinner);
|
|
|
|
|
gtk_stack_set_visible_child (self->ussd_stack, GTK_WIDGET (self->ussd_content));
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 13:16:51 +00:00
|
|
|
|
static void
|
|
|
|
|
set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
|
|
|
|
|
|
|
|
|
|
switch (property_id) {
|
2019-08-01 13:25:53 +00:00
|
|
|
|
case PROP_RECORD_STORE:
|
|
|
|
|
g_set_object (&self->record_store,
|
|
|
|
|
G_LIST_MODEL (g_value_get_object (value)));
|
2018-05-17 13:16:51 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-03-19 16:41:08 +00:00
|
|
|
|
static void
|
|
|
|
|
state_changed_cb (CallsMainWindow *self,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
CallsManager *manager)
|
|
|
|
|
{
|
|
|
|
|
const gchar *error = NULL;
|
2022-01-26 13:18:24 +00:00
|
|
|
|
CallsManagerFlags state_flags = calls_manager_get_state_flags (manager);
|
2021-05-04 19:49:07 +00:00
|
|
|
|
|
2022-01-26 13:18:24 +00:00
|
|
|
|
if (!(state_flags & CALLS_MANAGER_FLAGS_HAS_CELLULAR_MODEM) &&
|
|
|
|
|
!(state_flags & CALLS_MANAGER_FLAGS_HAS_VOIP_ACCOUNT))
|
|
|
|
|
error = _("Can't place calls: No modem or VoIP account available");
|
|
|
|
|
else if (state_flags & CALLS_MANAGER_FLAGS_UNKNOWN)
|
|
|
|
|
error = _("Can't place calls: No plugin loaded");
|
2020-03-19 16:41:08 +00:00
|
|
|
|
|
|
|
|
|
gtk_label_set_text (self->permanent_error_label, error);
|
2022-01-26 13:18:24 +00:00
|
|
|
|
gtk_revealer_set_reveal_child (self->permanent_error_revealer, !!error);
|
2020-03-19 16:41:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-08-30 06:50:37 +00:00
|
|
|
|
static void
|
|
|
|
|
constructed (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
|
|
|
|
|
GSimpleActionGroup *simple_action_group;
|
2019-08-01 13:25:53 +00:00
|
|
|
|
GtkContainer *main_stack = GTK_CONTAINER (self->main_stack);
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
CallsHistoryBox *history;
|
2018-10-05 11:27:55 +00:00
|
|
|
|
|
2020-03-18 10:29:41 +00:00
|
|
|
|
// Show errors in in-app-notification
|
|
|
|
|
g_signal_connect_swapped (calls_manager_get_default (),
|
2021-12-28 14:35:10 +00:00
|
|
|
|
"message",
|
2020-03-18 10:29:41 +00:00
|
|
|
|
G_CALLBACK (calls_in_app_notification_show),
|
|
|
|
|
self->in_app_notification);
|
2018-10-08 10:46:00 +00:00
|
|
|
|
|
2020-07-07 12:41:55 +00:00
|
|
|
|
g_signal_connect_swapped (calls_manager_get_default (),
|
|
|
|
|
"ussd-added",
|
|
|
|
|
G_CALLBACK (window_ussd_added_cb),
|
|
|
|
|
self);
|
|
|
|
|
g_signal_connect_swapped (calls_manager_get_default (),
|
|
|
|
|
"ussd-state-changed",
|
|
|
|
|
G_CALLBACK (window_update_ussd_state),
|
|
|
|
|
self);
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (self->ussd_dialog), GTK_WINDOW (self));
|
|
|
|
|
|
2021-01-20 14:13:52 +00:00
|
|
|
|
// Add contacs box
|
|
|
|
|
widget = calls_contacts_box_new ();
|
|
|
|
|
gtk_stack_add_titled (self->main_stack, widget,
|
|
|
|
|
"contacts", _("Contacts"));
|
|
|
|
|
gtk_container_child_set (main_stack, widget,
|
|
|
|
|
"icon-name", "system-users-symbolic",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_set_visible (widget, TRUE);
|
|
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
|
// Add new call box
|
2020-03-18 10:29:41 +00:00
|
|
|
|
self->new_call = calls_new_call_box_new ();
|
2019-08-01 13:25:53 +00:00
|
|
|
|
widget = GTK_WIDGET (self->new_call);
|
|
|
|
|
gtk_stack_add_titled (self->main_stack, widget,
|
2019-07-03 12:55:09 +00:00
|
|
|
|
"dial-pad", _("Dial Pad"));
|
2019-08-01 13:25:53 +00:00
|
|
|
|
gtk_container_child_set (main_stack, widget,
|
2019-07-03 12:34:48 +00:00
|
|
|
|
"icon-name", "input-dialpad-symbolic",
|
|
|
|
|
NULL);
|
2019-08-01 13:25:53 +00:00
|
|
|
|
// Add call records
|
2020-06-17 11:44:11 +00:00
|
|
|
|
history = calls_history_box_new (self->record_store);
|
2019-08-01 13:25:53 +00:00
|
|
|
|
widget = GTK_WIDGET (history);
|
|
|
|
|
gtk_stack_add_titled (self->main_stack, widget,
|
2021-10-18 14:59:50 +00:00
|
|
|
|
/* Recent as in "Recent calls" (the call history) */
|
2019-08-01 13:25:53 +00:00
|
|
|
|
"recent", _("Recent"));
|
|
|
|
|
gtk_container_child_set
|
|
|
|
|
(main_stack, widget,
|
2022-04-24 10:24:55 +00:00
|
|
|
|
"icon-name", "document-open-recent-symbolic",
|
|
|
|
|
"position", 0,
|
|
|
|
|
NULL);
|
2019-08-01 13:25:53 +00:00
|
|
|
|
gtk_widget_set_visible (widget, TRUE);
|
|
|
|
|
gtk_stack_set_visible_child_name (self->main_stack, "recent");
|
|
|
|
|
|
|
|
|
|
// Add actions
|
2018-08-30 06:50:37 +00:00
|
|
|
|
simple_action_group = g_simple_action_group_new ();
|
|
|
|
|
g_action_map_add_action_entries (G_ACTION_MAP (simple_action_group),
|
|
|
|
|
window_entries,
|
|
|
|
|
G_N_ELEMENTS (window_entries),
|
|
|
|
|
self);
|
|
|
|
|
gtk_widget_insert_action_group (GTK_WIDGET (self),
|
|
|
|
|
"win",
|
|
|
|
|
G_ACTION_GROUP (simple_action_group));
|
|
|
|
|
g_object_unref (simple_action_group);
|
|
|
|
|
|
2018-10-02 17:19:10 +00:00
|
|
|
|
|
2020-03-19 16:41:08 +00:00
|
|
|
|
g_signal_connect_swapped (calls_manager_get_default (),
|
|
|
|
|
"notify::state",
|
|
|
|
|
G_CALLBACK (state_changed_cb),
|
|
|
|
|
self);
|
|
|
|
|
|
|
|
|
|
state_changed_cb (self, NULL, calls_manager_get_default ());
|
|
|
|
|
|
2020-02-18 15:01:22 +00:00
|
|
|
|
G_OBJECT_CLASS (calls_main_window_parent_class)->constructed (object);
|
2018-05-17 13:16:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
|
|
2018-05-17 13:16:51 +00:00
|
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
|
|
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
|
g_clear_object (&self->record_store);
|
2021-05-11 16:18:35 +00:00
|
|
|
|
g_clear_object (&self->account_overview);
|
2018-05-17 13:16:51 +00:00
|
|
|
|
|
2020-02-18 15:01:22 +00:00
|
|
|
|
G_OBJECT_CLASS (calls_main_window_parent_class)->dispose (object);
|
2018-05-17 13:16:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-07-03 12:34:48 +00:00
|
|
|
|
static void
|
|
|
|
|
size_allocate (GtkWidget *widget,
|
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
|
{
|
|
|
|
|
CallsMainWindow *self = CALLS_MAIN_WINDOW (widget);
|
|
|
|
|
|
2020-09-29 10:43:22 +00:00
|
|
|
|
hdy_view_switcher_title_set_view_switcher_enabled (self->title_switcher,
|
|
|
|
|
allocation->width > 400);
|
2019-07-03 12:34:48 +00:00
|
|
|
|
|
2020-02-18 15:01:22 +00:00
|
|
|
|
GTK_WIDGET_CLASS (calls_main_window_parent_class)->size_allocate (widget, allocation);
|
2019-07-03 12:34:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-05-17 13:16:51 +00:00
|
|
|
|
static void
|
|
|
|
|
calls_main_window_class_init (CallsMainWindowClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
object_class->set_property = set_property;
|
2018-08-30 06:50:37 +00:00
|
|
|
|
object_class->constructed = constructed;
|
2018-05-17 13:16:51 +00:00
|
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
|
2019-08-01 13:25:53 +00:00
|
|
|
|
props[PROP_RECORD_STORE] =
|
|
|
|
|
g_param_spec_object ("record-store",
|
2020-05-29 05:38:11 +00:00
|
|
|
|
"Record store",
|
|
|
|
|
"The store of call records",
|
2019-08-01 13:25:53 +00:00
|
|
|
|
G_TYPE_LIST_MODEL,
|
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
2018-05-17 13:16:51 +00:00
|
|
|
|
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
|
|
|
|
|
|
|
|
|
|
2019-07-03 12:34:48 +00:00
|
|
|
|
widget_class->size_allocate = size_allocate;
|
|
|
|
|
|
2021-07-10 02:15:22 +00:00
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Calls/ui/main-window.ui");
|
2020-03-02 18:01:20 +00:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, in_app_notification);
|
2020-09-29 10:43:22 +00:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, title_switcher);
|
2018-05-17 13:16:51 +00:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, main_stack);
|
2020-03-19 16:41:08 +00:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, permanent_error_revealer);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, permanent_error_label);
|
2020-07-07 12:41:55 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, ussd_dialog);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, ussd_stack);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, ussd_spinner);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, ussd_content);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, ussd_label);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, ussd_entry);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, ussd_close_button);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, ussd_cancel_button);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, ussd_reply_button);
|
|
|
|
|
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, window_ussd_cancel_clicked_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, window_ussd_entry_changed_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, window_ussd_reply_clicked_cb);
|
2018-05-17 13:16:51 +00:00
|
|
|
|
}
|
2019-07-03 12:34:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
calls_main_window_init (CallsMainWindow *self)
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CallsMainWindow *
|
2019-08-01 13:25:53 +00:00
|
|
|
|
calls_main_window_new (GtkApplication *application,
|
2020-06-17 11:44:11 +00:00
|
|
|
|
GListModel *record_store)
|
2019-07-03 12:34:48 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL);
|
2019-08-01 13:25:53 +00:00
|
|
|
|
g_return_val_if_fail (G_IS_LIST_MODEL (record_store), NULL);
|
2019-07-03 12:34:48 +00:00
|
|
|
|
|
|
|
|
|
return g_object_new (CALLS_TYPE_MAIN_WINDOW,
|
|
|
|
|
"application", application,
|
2019-08-01 13:25:53 +00:00
|
|
|
|
"record-store", record_store,
|
2019-07-03 12:34:48 +00:00
|
|
|
|
NULL);
|
|
|
|
|
}
|
2019-08-05 10:25:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
calls_main_window_dial (CallsMainWindow *self,
|
|
|
|
|
const gchar *target)
|
|
|
|
|
{
|
2022-04-24 10:24:55 +00:00
|
|
|
|
if (calls_number_is_ussd (target)) {
|
|
|
|
|
gtk_widget_hide (GTK_WIDGET (self->ussd_cancel_button));
|
|
|
|
|
gtk_widget_hide (GTK_WIDGET (self->ussd_reply_button));
|
|
|
|
|
gtk_stack_set_visible_child (self->ussd_stack, GTK_WIDGET (self->ussd_spinner));
|
|
|
|
|
gtk_spinner_start (self->ussd_spinner);
|
|
|
|
|
|
|
|
|
|
calls_new_call_box_send_ussd_async (self->new_call, target, NULL,
|
|
|
|
|
main_window_ussd_send_cb, self);
|
|
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (self->ussd_dialog));
|
|
|
|
|
} else {
|
|
|
|
|
calls_new_call_box_dial (self->new_call, target);
|
|
|
|
|
}
|
2019-08-05 10:25:45 +00:00
|
|
|
|
}
|
2021-05-11 16:18:35 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
calls_main_window_show_accounts_overview (CallsMainWindow *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (CALLS_IS_MAIN_WINDOW (self));
|
|
|
|
|
|
|
|
|
|
if (self->account_overview == NULL) {
|
|
|
|
|
self->account_overview = calls_account_overview_new ();
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (self->account_overview),
|
|
|
|
|
GTK_WINDOW (self));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (self->account_overview));
|
|
|
|
|
}
|