mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-06 03:25:31 +00:00
origin: Add country-code property
And add a binding in CallsManager for the default origin
This commit is contained in:
parent
69b170ecfe
commit
7d69d78b70
6 changed files with 59 additions and 1 deletions
|
@ -58,6 +58,7 @@ enum {
|
|||
PROP_NAME,
|
||||
|
||||
PROP_CALLS,
|
||||
PROP_COUNTRY_CODE,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
@ -198,6 +199,10 @@ get_property (GObject *object,
|
|||
g_value_set_pointer (value, g_list_copy (self->calls));
|
||||
break;
|
||||
|
||||
case PROP_COUNTRY_CODE:
|
||||
g_value_set_string (value, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -252,6 +257,7 @@ calls_dummy_origin_class_init (CallsDummyOriginClass *klass)
|
|||
|
||||
IMPLEMENTS (PROP_NAME, "name");
|
||||
IMPLEMENTS (PROP_CALLS, "calls");
|
||||
IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
|
||||
|
||||
#undef IMPLEMENTS
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ enum {
|
|||
PROP_NAME,
|
||||
PROP_CALLS,
|
||||
PROP_MODEM,
|
||||
PROP_COUNTRY_CODE,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
@ -645,6 +646,10 @@ get_property (GObject *object,
|
|||
g_value_set_pointer(value, g_hash_table_get_values (self->calls));
|
||||
break;
|
||||
|
||||
case PROP_COUNTRY_CODE:
|
||||
g_value_set_string (value, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -823,6 +828,7 @@ calls_mm_origin_class_init (CallsMMOriginClass *klass)
|
|||
|
||||
IMPLEMENTS (PROP_NAME, "name");
|
||||
IMPLEMENTS (PROP_CALLS, "calls");
|
||||
IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
|
||||
|
||||
#undef IMPLEMENTS
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ enum {
|
|||
PROP_NAME,
|
||||
PROP_CALLS,
|
||||
PROP_MODEM,
|
||||
PROP_COUNTRY_CODE,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
@ -161,6 +162,10 @@ get_property (GObject *object,
|
|||
g_value_set_pointer(value, g_hash_table_get_values (self->calls));
|
||||
break;
|
||||
|
||||
case PROP_COUNTRY_CODE:
|
||||
g_value_set_string (value, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -558,6 +563,7 @@ calls_ofono_origin_class_init (CallsOfonoOriginClass *klass)
|
|||
|
||||
IMPLEMENTS (PROP_NAME, "name");
|
||||
IMPLEMENTS (PROP_CALLS, "calls");
|
||||
IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
|
||||
|
||||
#undef IMPLEMENTS
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ enum {
|
|||
PROP_SIP_LOCAL_PORT,
|
||||
PROP_ACC_STATE,
|
||||
PROP_CALLS,
|
||||
PROP_COUNTRY_CODE,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
@ -889,6 +890,10 @@ calls_sip_origin_get_property (GObject *object,
|
|||
g_value_set_int (value, self->local_port);
|
||||
break;
|
||||
|
||||
case PROP_COUNTRY_CODE:
|
||||
g_value_set_string (value, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -1060,6 +1065,7 @@ calls_sip_origin_class_init (CallsSipOriginClass *klass)
|
|||
|
||||
IMPLEMENTS (PROP_NAME, "name");
|
||||
IMPLEMENTS (PROP_CALLS, "calls");
|
||||
IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
|
||||
|
||||
#undef IMPLEMENTS
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ struct _CallsManager
|
|||
CallsOrigin *default_origin;
|
||||
CallsManagerState state;
|
||||
CallsCall *primary_call;
|
||||
char *country_code;
|
||||
GBinding *country_code_binding;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (CallsManager, calls_manager, G_TYPE_OBJECT);
|
||||
|
@ -50,6 +52,7 @@ enum {
|
|||
PROP_PROVIDER,
|
||||
PROP_DEFAULT_ORIGIN,
|
||||
PROP_STATE,
|
||||
PROP_COUNTRY_CODE,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
|
@ -294,6 +297,10 @@ calls_manager_get_property (GObject *object,
|
|||
g_value_set_enum (value, calls_manager_get_state (self));
|
||||
break;
|
||||
|
||||
case PROP_COUNTRY_CODE:
|
||||
g_value_set_string (value, self->country_code);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -317,6 +324,11 @@ calls_manager_set_property (GObject *object,
|
|||
calls_manager_set_default_origin (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_COUNTRY_CODE:
|
||||
g_free (self->country_code);
|
||||
self->country_code = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -331,6 +343,7 @@ calls_manager_finalize (GObject *object)
|
|||
g_clear_object (&self->provider);
|
||||
g_clear_pointer (&self->provider_name, g_free);
|
||||
g_clear_object (&self->contacts_provider);
|
||||
g_clear_pointer (&self->country_code, g_free);
|
||||
|
||||
G_OBJECT_CLASS (calls_manager_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -427,6 +440,12 @@ calls_manager_class_init (CallsManagerClass *klass)
|
|||
CALLS_TYPE_ORIGIN,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
props[PROP_COUNTRY_CODE] = g_param_spec_string ("country-code",
|
||||
"country code",
|
||||
"The default country code to use",
|
||||
NULL,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||
}
|
||||
|
||||
|
@ -606,10 +625,17 @@ calls_manager_set_default_origin (CallsManager *self,
|
|||
if (self->default_origin == origin)
|
||||
return;
|
||||
|
||||
g_clear_pointer (&self->country_code_binding, g_binding_unbind);
|
||||
|
||||
g_clear_object (&self->default_origin);
|
||||
|
||||
if (origin)
|
||||
if (origin) {
|
||||
self->default_origin = g_object_ref (origin);
|
||||
self->country_code_binding =
|
||||
g_object_bind_property (origin, "country-code",
|
||||
self, "country-code",
|
||||
G_BINDING_SYNC_CREATE);
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_DEFAULT_ORIGIN]);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,14 @@ calls_origin_default_init (CallsOriginInterface *iface)
|
|||
"The list of current calls",
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_interface_install_property (
|
||||
iface,
|
||||
g_param_spec_string ("country-code",
|
||||
"country code",
|
||||
"The country code of the origin, if any",
|
||||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
signals[SIGNAL_CALL_ADDED] =
|
||||
g_signal_newv ("call-added",
|
||||
G_TYPE_FROM_INTERFACE (iface),
|
||||
|
|
Loading…
Reference in a new issue