mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 05:50:28 +01:00
cli: drop nmc_property_set_default_value()
It's wrong to pretend that all properties are GObject based. Drop nmc_property_set_default_value() and use nmc_setting_reset_property() instead.
This commit is contained in:
parent
7b5d514aef
commit
f24ada398a
3 changed files with 13 additions and 19 deletions
|
|
@ -6954,7 +6954,7 @@ property_edit_submenu (NmCli *nmc,
|
|||
*/
|
||||
if (cmdsub == NMC_EDITOR_SUB_CMD_SET) {
|
||||
nmc_property_get_gvalue (curr_setting, prop_name, &prop_g_value);
|
||||
nmc_property_set_default_value (curr_setting, prop_name);
|
||||
nmc_setting_reset_property (nmc->client, curr_setting, prop_name, NULL);
|
||||
}
|
||||
|
||||
set_result = nmc_setting_set_property (nmc->client, curr_setting, prop_name, prop_val_user, &tmp_err);
|
||||
|
|
@ -6978,7 +6978,7 @@ property_edit_submenu (NmCli *nmc,
|
|||
prop_name);
|
||||
|
||||
nmc_property_get_gvalue (curr_setting, prop_name, &prop_g_value);
|
||||
nmc_property_set_default_value (curr_setting, prop_name);
|
||||
nmc_setting_reset_property (nmc->client, curr_setting, prop_name, NULL);
|
||||
|
||||
if (!nmc_setting_set_property (nmc->client, curr_setting, prop_name, prop_val_user, &tmp_err)) {
|
||||
g_print (_("Error: failed to set '%s' property: %s\n"), prop_name, tmp_err->message);
|
||||
|
|
|
|||
|
|
@ -543,8 +543,18 @@ nmc_setting_set_property (NMClient *client, NMSetting *setting, const char *prop
|
|||
goto out_fail_read_only;
|
||||
|
||||
if (!value) {
|
||||
nm_auto_unset_gvalue GValue gvalue = G_VALUE_INIT;
|
||||
GParamSpec *param_spec;
|
||||
|
||||
/* No value argument sets default value */
|
||||
nmc_property_set_default_value (setting, prop);
|
||||
|
||||
/* FIXME: this only works with GObject based properties. */
|
||||
param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
|
||||
if (param_spec) {
|
||||
g_value_init (&gvalue, G_PARAM_SPEC_VALUE_TYPE (param_spec));
|
||||
g_param_value_set_default (param_spec, &gvalue);
|
||||
g_object_set_property (G_OBJECT (setting), prop, &gvalue);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -575,20 +585,6 @@ out_fail_read_only:
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nmc_property_set_default_value (NMSetting *setting, const char *prop)
|
||||
{
|
||||
GValue value = G_VALUE_INIT;
|
||||
GParamSpec *param_spec;
|
||||
|
||||
param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (setting)), prop);
|
||||
if (param_spec) {
|
||||
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (param_spec));
|
||||
g_param_value_set_default (param_spec, &value);
|
||||
g_object_set_property (G_OBJECT (setting), prop, &value);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
nmc_setting_remove_property_option (NMSetting *setting,
|
||||
const char *prop,
|
||||
|
|
|
|||
|
|
@ -61,8 +61,6 @@ gboolean nmc_setting_remove_property_option (NMSetting *setting,
|
|||
const char *value,
|
||||
GError **error);
|
||||
|
||||
void nmc_property_set_default_value (NMSetting *setting, const char *prop);
|
||||
|
||||
gboolean nmc_property_get_gvalue (NMSetting *setting, const char *prop, GValue *value);
|
||||
gboolean nmc_property_set_gvalue (NMSetting *setting, const char *prop, GValue *value);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue