mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 12:25:31 +00:00
new-call-box: Honour auto-use-default-origins setting
This commit is contained in:
parent
fef1531749
commit
3f3b108cea
1 changed files with 33 additions and 16 deletions
|
@ -22,6 +22,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "calls-application.h"
|
||||||
#include "calls-new-call-box.h"
|
#include "calls-new-call-box.h"
|
||||||
#include "calls-ussd.h"
|
#include "calls-ussd.h"
|
||||||
#include "calls-main-window.h"
|
#include "calls-main-window.h"
|
||||||
|
@ -49,11 +50,25 @@ G_DEFINE_TYPE (CallsNewCallBox, calls_new_call_box, GTK_TYPE_BOX);
|
||||||
|
|
||||||
|
|
||||||
static CallsOrigin *
|
static CallsOrigin *
|
||||||
get_origin (CallsNewCallBox *self)
|
get_origin (CallsNewCallBox *self,
|
||||||
|
const char *target)
|
||||||
{
|
{
|
||||||
|
CallsApplication *app = CALLS_APPLICATION (g_application_get_default ());
|
||||||
g_autoptr (CallsOrigin) origin = NULL;
|
g_autoptr (CallsOrigin) origin = NULL;
|
||||||
GListModel *model;
|
GListModel *model;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
gboolean auto_use_def_origin =
|
||||||
|
calls_application_get_use_default_origins_setting (app);
|
||||||
|
|
||||||
|
if (auto_use_def_origin) {
|
||||||
|
model = calls_manager_get_suitable_origins (calls_manager_get_default (),
|
||||||
|
target);
|
||||||
|
if (g_list_model_get_n_items (model) == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
origin = g_list_model_get_item (model, 0);
|
||||||
|
return origin;
|
||||||
|
}
|
||||||
|
|
||||||
model = hdy_combo_row_get_model (self->origin_list);
|
model = hdy_combo_row_get_model (self->origin_list);
|
||||||
|
|
||||||
|
@ -125,11 +140,20 @@ dial_clicked_cb (CallsNewCallBox *self)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dial_queued_cb (gchar *target,
|
dial_queued_cb (gchar *target,
|
||||||
CallsOrigin *origin)
|
CallsNewCallBox *self)
|
||||||
{
|
{
|
||||||
g_debug ("Dialing queued target `%s'", target);
|
CallsOrigin *origin = NULL;
|
||||||
calls_origin_dial (origin, target);
|
g_debug ("Try dialing queued target `%s'", target);
|
||||||
|
|
||||||
|
origin = get_origin (self,
|
||||||
|
target);
|
||||||
|
if (origin) {
|
||||||
|
calls_origin_dial (origin, target);
|
||||||
|
self->dial_queue = g_list_remove (self->dial_queue, target);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_debug ("No suitable origin found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,22 +168,15 @@ clear_dial_queue (CallsNewCallBox *self)
|
||||||
static void
|
static void
|
||||||
dial_queued (CallsNewCallBox *self)
|
dial_queued (CallsNewCallBox *self)
|
||||||
{
|
{
|
||||||
CallsOrigin *origin;
|
|
||||||
|
|
||||||
if (!self->dial_queue)
|
if (!self->dial_queue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_debug ("Dialing %u queued targets",
|
g_debug ("Try dialing %u queued targets",
|
||||||
g_list_length (self->dial_queue));
|
g_list_length (self->dial_queue));
|
||||||
|
|
||||||
origin = get_origin (self);
|
|
||||||
g_assert (origin != NULL);
|
|
||||||
|
|
||||||
g_list_foreach (self->dial_queue,
|
g_list_foreach (self->dial_queue,
|
||||||
(GFunc) dial_queued_cb,
|
(GFunc) dial_queued_cb,
|
||||||
origin);
|
self);
|
||||||
|
|
||||||
clear_dial_queue (self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,7 +297,7 @@ calls_new_call_box_dial (CallsNewCallBox *self,
|
||||||
g_return_if_fail (CALLS_IS_NEW_CALL_BOX (self));
|
g_return_if_fail (CALLS_IS_NEW_CALL_BOX (self));
|
||||||
g_return_if_fail (target != NULL);
|
g_return_if_fail (target != NULL);
|
||||||
|
|
||||||
origin = get_origin (self);
|
origin = get_origin (self, target);
|
||||||
if (!origin) {
|
if (!origin) {
|
||||||
// Queue for dialing when an origin appears
|
// Queue for dialing when an origin appears
|
||||||
g_debug ("Can't submit call with no origin, queuing for later");
|
g_debug ("Can't submit call with no origin, queuing for later");
|
||||||
|
@ -307,7 +324,7 @@ calls_new_call_box_send_ussd_async (CallsNewCallBox *self,
|
||||||
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
|
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
|
||||||
g_return_if_fail (target && *target);
|
g_return_if_fail (target && *target);
|
||||||
|
|
||||||
origin = get_origin (self);
|
origin = get_origin (self, target);
|
||||||
|
|
||||||
task = g_task_new (self, cancellable, callback, user_data);
|
task = g_task_new (self, cancellable, callback, user_data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue