mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 20:35:31 +00:00
application: settings: Add autoload-plugins setting
This setting will be used to define the provider plugins to be loaded on application startup if calls has been invoked without `--provider`
This commit is contained in:
parent
4f6fb722b1
commit
e00b90d64e
4 changed files with 56 additions and 7 deletions
|
@ -14,5 +14,11 @@
|
||||||
<description>The country code is used for contact name lookup</description>
|
<description>The country code is used for contact name lookup</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
<key name="autoload-plugins" type="as">
|
||||||
|
<default>["mm", "sip"]</default>
|
||||||
|
<summary>The plugins to load automatically</summary>
|
||||||
|
<description>These plugins will be automatically loaded on application startup.</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
|
|
@ -206,6 +206,8 @@ set_default_providers_action (GSimpleAction *action,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
CallsApplication *self = CALLS_APPLICATION (user_data);
|
||||||
|
g_auto (GStrv) plugins = NULL;
|
||||||
/**
|
/**
|
||||||
* Only add default providers when there are none added yet,
|
* Only add default providers when there are none added yet,
|
||||||
* This makes sure we're not resetting explicitly set providers
|
* This makes sure we're not resetting explicitly set providers
|
||||||
|
@ -213,7 +215,10 @@ set_default_providers_action (GSimpleAction *action,
|
||||||
if (calls_manager_has_any_provider (calls_manager_get_default ()))
|
if (calls_manager_has_any_provider (calls_manager_get_default ()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* TODO get defaults from GSettings */
|
plugins = calls_settings_get_autoload_plugins (self->settings);
|
||||||
|
for (guint i = 0; plugins[i] != NULL; i++) {
|
||||||
|
calls_manager_add_provider (calls_manager_get_default (), plugins[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_AUTO_USE_DEFAULT_ORIGINS,
|
PROP_AUTO_USE_DEFAULT_ORIGINS,
|
||||||
PROP_COUNTRY_CODE,
|
PROP_COUNTRY_CODE,
|
||||||
|
PROP_AUTOLOAD_PLUGINS,
|
||||||
PROP_LAST_PROP
|
PROP_LAST_PROP
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
@ -70,6 +71,10 @@ calls_settings_set_property (GObject *object,
|
||||||
calls_settings_set_country_code (self, g_value_get_string (value));
|
calls_settings_set_country_code (self, g_value_get_string (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_AUTOLOAD_PLUGINS:
|
||||||
|
calls_settings_set_autoload_plugins (self, g_value_get_boxed (value));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -94,6 +99,10 @@ calls_settings_get_property (GObject *object,
|
||||||
g_value_set_string (value, calls_settings_get_country_code (self));
|
g_value_set_string (value, calls_settings_get_country_code (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_AUTOLOAD_PLUGINS:
|
||||||
|
g_value_set_boxed (value, calls_settings_get_autoload_plugins (self));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -147,6 +156,13 @@ calls_settings_class_init (CallsSettingsClass *klass)
|
||||||
"",
|
"",
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
props[PROP_AUTOLOAD_PLUGINS] =
|
||||||
|
g_param_spec_boxed ("autoload-plugins",
|
||||||
|
"autoload plugins",
|
||||||
|
"The plugins to automatically load on startup",
|
||||||
|
G_TYPE_STRV,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,3 +248,22 @@ calls_settings_set_country_code (CallsSettings *self,
|
||||||
g_debug ("Setting country code to %s", country_code);
|
g_debug ("Setting country code to %s", country_code);
|
||||||
g_settings_set_string (G_SETTINGS (self->settings), "country-code", country_code);
|
g_settings_set_string (G_SETTINGS (self->settings), "country-code", country_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char **
|
||||||
|
calls_settings_get_autoload_plugins (CallsSettings *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CALLS_IS_SETTINGS (self), NULL);
|
||||||
|
|
||||||
|
return g_settings_get_strv (G_SETTINGS (self->settings), "autoload-plugins");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
calls_settings_set_autoload_plugins (CallsSettings *self,
|
||||||
|
const char * const *plugins)
|
||||||
|
{
|
||||||
|
g_return_if_fail (CALLS_IS_SETTINGS (self));
|
||||||
|
|
||||||
|
g_settings_set_strv (G_SETTINGS (self->settings), "autoload-plugins", plugins);
|
||||||
|
}
|
||||||
|
|
|
@ -33,12 +33,15 @@ G_BEGIN_DECLS
|
||||||
G_DECLARE_FINAL_TYPE (CallsSettings, calls_settings, CALLS, SETTINGS, GObject)
|
G_DECLARE_FINAL_TYPE (CallsSettings, calls_settings, CALLS, SETTINGS, GObject)
|
||||||
|
|
||||||
CallsSettings *calls_settings_new (void);
|
CallsSettings *calls_settings_new (void);
|
||||||
gboolean calls_settings_get_use_default_origins (CallsSettings *self);
|
gboolean calls_settings_get_use_default_origins (CallsSettings *self);
|
||||||
void calls_settings_set_use_default_origins (CallsSettings *self,
|
void calls_settings_set_use_default_origins (CallsSettings *self,
|
||||||
gboolean enable);
|
gboolean enable);
|
||||||
char *calls_settings_get_country_code (CallsSettings *self);
|
char *calls_settings_get_country_code (CallsSettings *self);
|
||||||
void calls_settings_set_country_code (CallsSettings *self,
|
void calls_settings_set_country_code (CallsSettings *self,
|
||||||
const char *country_code);
|
const char *country_code);
|
||||||
|
char **calls_settings_get_autoload_plugins (CallsSettings *self);
|
||||||
|
void calls_settings_set_autoload_plugins (CallsSettings *self,
|
||||||
|
const char * const *plugins);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue