1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-12 15:47:35 +00:00

application: Open only the first 'tel:' URI

Calls can't handle multiple calls, so there is no
point in handling all URIs.

Handle opening URI in activate(), which will be helpful
when we use local_command_line()

Also, this commit fixes presenting window on initial
launch of Calls with a “tel:” URI
This commit is contained in:
Mohammed Sadiq 2021-02-24 12:53:52 +05:30 committed by Evangelos Ribeiro Tzaras
parent 5b34342134
commit 994853910d

View file

@ -62,6 +62,8 @@ struct _CallsApplication
CallsRecordStore *record_store; CallsRecordStore *record_store;
CallsMainWindow *main_window; CallsMainWindow *main_window;
CallsCallWindow *call_window; CallsCallWindow *call_window;
char *uri;
}; };
G_DEFINE_TYPE (CallsApplication, calls_application, GTK_TYPE_APPLICATION); G_DEFINE_TYPE (CallsApplication, calls_application, GTK_TYPE_APPLICATION);
@ -382,37 +384,6 @@ start_proper (CallsApplication *self)
return TRUE; return TRUE;
} }
static void
activate (GApplication *application)
{
CallsApplication *self = CALLS_APPLICATION (application);
gboolean present;
g_debug ("Activated");
if (self->main_window)
{
present = TRUE;
}
else
{
gboolean ok = start_proper (self);
if (!ok)
{
return;
}
present = !self->daemon;
}
if (present)
{
gtk_window_present (GTK_WINDOW (self->main_window));
}
}
static void static void
open_tel_uri (CallsApplication *self, open_tel_uri (CallsApplication *self,
const gchar *uri) const gchar *uri)
@ -444,6 +415,39 @@ open_tel_uri (CallsApplication *self,
dial_str); dial_str);
} }
static void
activate (GApplication *application)
{
CallsApplication *self = CALLS_APPLICATION (application);
gboolean present;
g_debug ("Activated");
if (self->main_window)
{
present = TRUE;
}
else
{
gboolean ok = start_proper (self);
if (!ok)
{
return;
}
present = !self->daemon;
}
if (present || self->uri)
{
gtk_window_present (GTK_WINDOW (self->main_window));
}
if (self->uri)
open_tel_uri (self, self->uri);
g_clear_pointer (&self->uri, g_free);
}
static void static void
app_open (GApplication *application, app_open (GApplication *application,
@ -452,38 +456,34 @@ app_open (GApplication *application,
const gchar *hint) const gchar *hint)
{ {
CallsApplication *self = CALLS_APPLICATION (application); CallsApplication *self = CALLS_APPLICATION (application);
gint i;
g_assert (n_files > 0); g_assert (n_files > 0);
g_debug ("Opened (%i files)", n_files); if (n_files > 1)
g_warning ("Calls can handle only one call a time. %u items provided", n_files);
start_proper (self); if (g_file_has_uri_scheme (files[0], "tel"))
for (i = 0; i < n_files; ++i)
{ {
g_autofree gchar *uri = NULL; g_free (self->uri);
if (g_file_has_uri_scheme (files[i], "tel")) self->uri = g_file_get_uri (files[0]);
{ g_debug ("Opening %s", self->uri);
uri = g_file_get_uri (files[i]);
open_tel_uri (self, uri); g_application_activate (application);
} }
else else
{ {
g_autofree gchar *msg = NULL; g_autofree char *msg = NULL;
g_autofree char *uri = NULL;
uri = g_file_get_parse_name (files[i]); uri = g_file_get_parse_name (files[0]);
g_warning ("Don't know how to" g_warning ("Don't know how to"
" open file `%s', ignoring", " open file `%s', ignoring",
uri); uri);
msg = g_strdup_printf (_("Don't know how to open `%s'"), uri); msg = g_strdup_printf (_("Don't know how to open `%s'"), uri);
g_signal_emit_by_name (calls_manager_get_default (), g_signal_emit_by_name (calls_manager_get_default (),
"error", "error", msg);
msg);
}
} }
} }
@ -498,6 +498,7 @@ finalize (GObject *object)
g_clear_object (&self->record_store); g_clear_object (&self->record_store);
g_clear_object (&self->ringer); g_clear_object (&self->ringer);
g_clear_object (&self->notifier); g_clear_object (&self->notifier);
g_free (self->uri);
G_OBJECT_CLASS (calls_application_parent_class)->finalize (object); G_OBJECT_CLASS (calls_application_parent_class)->finalize (object);
} }