mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 12:25:31 +00:00
new-call-box: Don't auto select offline accounts
This commit is contained in:
parent
ee64b33e24
commit
36b10bc764
1 changed files with 21 additions and 4 deletions
|
@ -24,6 +24,7 @@
|
|||
|
||||
#define G_LOG_DOMAIN "CallsNewCallBox"
|
||||
|
||||
#include "calls-account.h"
|
||||
#include "calls-main-window.h"
|
||||
#include "calls-manager.h"
|
||||
#include "calls-new-call-box.h"
|
||||
|
@ -85,23 +86,39 @@ get_origin (CallsNewCallBox *self,
|
|||
CallsManager *manager = calls_manager_get_default ();
|
||||
CallsSettings *settings = calls_manager_get_settings (manager);
|
||||
|
||||
g_autoptr (CallsOrigin) origin = NULL;
|
||||
GListModel *model;
|
||||
gboolean auto_use_def_origin =
|
||||
calls_settings_get_use_default_origins (settings);
|
||||
|
||||
if (auto_use_def_origin) {
|
||||
guint n_items;
|
||||
|
||||
model = calls_manager_get_suitable_origins (calls_manager_get_default (),
|
||||
target);
|
||||
if (g_list_model_get_n_items (model) == 0)
|
||||
n_items = g_list_model_get_n_items (model);
|
||||
|
||||
if (n_items == 0)
|
||||
return NULL;
|
||||
|
||||
origin = g_list_model_get_item (model, 0);
|
||||
for (guint i = 0; i < n_items; i++) {
|
||||
g_autoptr (CallsOrigin) origin = g_list_model_get_item (model, i);
|
||||
g_autofree char *origin_name = NULL;
|
||||
|
||||
return g_steal_pointer (&origin);
|
||||
if (CALLS_IS_ACCOUNT (origin) &&
|
||||
calls_account_get_state (CALLS_ACCOUNT (origin)) != CALLS_ACCOUNT_STATE_ONLINE)
|
||||
continue;
|
||||
|
||||
origin_name = calls_origin_get_name (origin);
|
||||
g_debug ("Using origin '%s' for call to '%s'",
|
||||
origin_name, target);
|
||||
|
||||
return g_steal_pointer (&origin);
|
||||
}
|
||||
} else {
|
||||
return get_selected_origin (self);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue