[NetworkManager-openvpn/bg/lr/compress-option: 4/4] properties/editor: support more compression options
- From: Beniamino Galvani <bgalvani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [NetworkManager-openvpn/bg/lr/compress-option: 4/4] properties/editor: support more compression options
- Date: Wed, 26 Feb 2020 20:29:32 +0000 (UTC)
commit 8f10448b8fc3c3d9b3056ae67f40994a174d7271
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Thu Jul 12 23:08:26 2018 +0200
properties/editor: support more compression options
In addition to the old, deprecated 'comp-lzo' options, support
'compress' ones.
Co-authored-by: Beniamino Galvani <bgalvani redhat com>
properties/nm-openvpn-dialog.ui | 41 +++++++++++++++++-----
properties/nm-openvpn-editor.c | 75 +++++++++++------------------------------
2 files changed, 52 insertions(+), 64 deletions(-)
---
diff --git a/properties/nm-openvpn-dialog.ui b/properties/nm-openvpn-dialog.ui
index 82b3b2b..4080265 100644
--- a/properties/nm-openvpn-dialog.ui
+++ b/properties/nm-openvpn-dialog.ui
@@ -64,6 +64,29 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkListStore" id="compression">
+ <columns>
+ <!-- column-name gchararray -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">LZO</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">LZ4</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Automatic</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">LZO disabled (legacy)</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">LZO adaptive (legacy)</col>
+ </row>
+ </data>
+ </object>
<object class="GtkListStore" id="liststore1"/>
<object class="GtkListStore" id="liststore2"/>
<object class="GtkListStore" id="model1">
@@ -1011,8 +1034,8 @@ config: reneg-sec</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <object class="GtkCheckButton" id="lzo_checkbutton">
- <property name="label" translatable="yes">Use L_ZO data compression</property>
+ <object class="GtkCheckButton" id="compress_checkbutton">
+ <property name="label" translatable="yes">Data _compression:</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -1030,14 +1053,14 @@ config: comp-lzo</property>
</packing>
</child>
<child>
- <object class="GtkComboBox" id="lzo_combo">
+ <object class="GtkComboBox" id="compress_combo">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tooltip_text" translatable="yes">Select the LZO data compression
mode.
-config: comp-lzo</property>
- <property name="model">model4</property>
+ <property name="can_focus">False</property>
+ <property name="model">compression</property>
+ <property name="active">0</property>
+ <property name="id_column">0</property>
<child>
- <object class="GtkCellRendererText" id="renderer13"/>
+ <object class="GtkCellRendererText" id="renderer8"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
@@ -1045,7 +1068,7 @@ config: comp-lzo</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
diff --git a/properties/nm-openvpn-editor.c b/properties/nm-openvpn-editor.c
index 4ab8650..00b200a 100644
--- a/properties/nm-openvpn-editor.c
+++ b/properties/nm-openvpn-editor.c
@@ -52,38 +52,6 @@ static GtkFileFilter *sk_file_chooser_filter_new (void);
/*****************************************************************************/
-static const char *comp_lzo_values[] = {
- "adaptive",
- "yes",
- "no-by-default",
-};
-
-static const char *
-comp_lzo_values_conf_coerce (const char *value_conf)
-{
- if (!value_conf || nm_streq (value_conf, "no"))
- return NULL;
- if (nm_streq (value_conf, "yes"))
- return "yes";
- if (nm_streq (value_conf, "no-by-default"))
- return "no-by-default";
- return "adaptive";
-}
-
-static const char *
-comp_lzo_values_conf_to_display (const char *value_conf)
-{
- if (nm_streq (value_conf, "yes"))
- return "yes";
- if (nm_streq (value_conf, "no-by-default"))
- return "no";
- if (nm_streq (value_conf, "adaptive"))
- return "adaptive";
- g_return_val_if_reached ("adaptive");
-}
-
-/*****************************************************************************/
-
/* From gnome-control-center/panels/network/connection-editor/ui-helpers.c */
static void
@@ -680,6 +648,7 @@ sk_file_chooser_filter_new (void)
static const char *const advanced_keys[] = {
NM_OPENVPN_KEY_AUTH,
NM_OPENVPN_KEY_CIPHER,
+ NM_OPENVPN_KEY_COMPRESS,
NM_OPENVPN_KEY_COMP_LZO,
NM_OPENVPN_KEY_CONNECT_TIMEOUT,
NM_OPENVPN_KEY_CRL_VERIFY_DIR,
@@ -1461,10 +1430,10 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
GtkListStore *store;
GtkTreeIter iter;
int vint;
- guint i;
guint32 active;
NMSettingSecretFlags pw_flags;
GError *error = NULL;
+ NMOvpnComp comp;
g_return_val_if_fail (hash != NULL, NULL);
@@ -1582,24 +1551,14 @@ advanced_dialog_new (GHashTable *hash, const char *contype)
_builder_init_optional_spinbutton (builder, "fragment_checkbutton", "fragment_spinbutton", !!value,
_nm_utils_ascii_str_to_int64 (value, 10, 0, 65535, 1300));
+ comp = nmovpn_compression_from_options (g_hash_table_lookup (hash, NM_OPENVPN_KEY_COMP_LZO),
+ g_hash_table_lookup (hash, NM_OPENVPN_KEY_COMPRESS));
- value = comp_lzo_values_conf_coerce (g_hash_table_lookup (hash, NM_OPENVPN_KEY_COMP_LZO));
- widget = GTK_WIDGET (_builder_init_toggle_button (builder, "lzo_checkbutton", value != NULL));
- combo = GTK_WIDGET (gtk_builder_get_object (builder, "lzo_combo"));
- store = gtk_list_store_new (1, G_TYPE_STRING);
- active = 0;
- for (i = 0; i < G_N_ELEMENTS (comp_lzo_values); i++) {
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- 0, comp_lzo_values_conf_to_display (comp_lzo_values[i]),
- -1);
- if (nm_streq (comp_lzo_values[i], value ?: "adaptive"))
- active = i;
- }
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
- g_object_unref (store);
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active);
+ combo = GTK_WIDGET (gtk_builder_get_object (builder, "compress_combo"));
+ widget = GTK_WIDGET (_builder_init_toggle_button (builder, "compress_checkbutton", comp !=
NMOVPN_COMP_DISABLED));
g_object_bind_property (widget, "active", combo, "sensitive", G_BINDING_SYNC_CREATE);
+ if (comp != NMOVPN_COMP_DISABLED)
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), comp - 1);
_builder_init_toggle_button (builder, "mssfix_checkbutton", _hash_get_boolean (hash,
NM_OPENVPN_KEY_MSSFIX));
_builder_init_toggle_button (builder, "float_checkbutton", _hash_get_boolean (hash,
NM_OPENVPN_KEY_FLOAT));
@@ -1836,7 +1795,6 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog)
GtkBuilder *builder;
const char *contype = NULL;
const char *value;
- int active;
int proxy_type = PROXY_TYPE_NONE;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -1943,12 +1901,19 @@ advanced_dialog_new_hash_from_dialog (GtkWidget *dialog)
}
}
- widget = GTK_WIDGET (gtk_builder_get_object (builder, "lzo_checkbutton"));
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, "compress_checkbutton"));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
- combo = GTK_WIDGET (gtk_builder_get_object (builder, "lzo_combo"));
- active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
- if (active >= 0 && active < G_N_ELEMENTS (comp_lzo_values))
- g_hash_table_insert (hash, NM_OPENVPN_KEY_COMP_LZO, g_strdup
(comp_lzo_values[active]));
+ const char *opt_compress;
+ const char *opt_comp_lzo;
+ NMOvpnComp comp;
+
+ combo = GTK_WIDGET (gtk_builder_get_object (builder, "compress_combo"));
+ comp = gtk_combo_box_get_active (GTK_COMBO_BOX (combo)) + 1;
+ nmovpn_compression_to_options (comp, &opt_comp_lzo, &opt_compress);
+ if (opt_compress)
+ g_hash_table_insert (hash, NM_OPENVPN_KEY_COMPRESS, g_strdup (opt_compress));
+ if (opt_comp_lzo)
+ g_hash_table_insert (hash, NM_OPENVPN_KEY_COMP_LZO, g_strdup (opt_comp_lzo));
}
widget = GTK_WIDGET (gtk_builder_get_object (builder, "mssfix_checkbutton"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]