# HG changeset patch
# Node ID 4ffef188f238
# Parent  d8636f8db50a
diff --git a/pidgin/prefs/pidginprefs.c b/pidgin/prefs/pidginprefs.c
--- a/pidgin/prefs/pidginprefs.c
+++ b/pidgin/prefs/pidginprefs.c
@@ -367,6 +367,45 @@ pidgin_prefs_bind_dropdown(PidginPrefCom
 }
 
 static void
+bind_combo_row_set(GObject *obj, G_GNUC_UNUSED GParamSpec *pspec,
+                   gpointer data)
+{
+	const gchar *key = data;
+	GObject *item = NULL;
+	const gchar *value = NULL;
+
+	item = adw_combo_row_get_selected_item(ADW_COMBO_ROW(obj));
+	value = gtk_string_object_get_string(GTK_STRING_OBJECT(item));
+	purple_prefs_set_string(key, value);
+}
+
+void
+pidgin_prefs_bind_combo_row(const gchar *key, GtkWidget *widget) {
+	GListModel *model = NULL;
+	const char *pref_value = NULL;
+
+	guint selected = GTK_INVALID_LIST_POSITION;
+	pref_value = purple_prefs_get_string(key);
+	model = adw_combo_row_get_model(ADW_COMBO_ROW(widget));
+	for(guint i = 0; i < g_list_model_get_n_items(model); i++) {
+		GObject *obj = g_list_model_get_item(model, i);
+		gchar *value = NULL;
+		g_object_get(obj, "string", &value, NULL);
+		if (purple_strequal(pref_value, value)) {
+			selected = i;
+			g_free(value);
+			break;
+		}
+		g_free(value);
+	}
+
+	adw_combo_row_set_selected(ADW_COMBO_ROW(widget), selected);
+
+	g_signal_connect(widget, "notify::selected",
+	                 G_CALLBACK(bind_combo_row_set), (gpointer)key);
+}
+
+static void
 set_bool_pref(GtkWidget *w, const char *key)
 {
 	purple_prefs_set_bool(key,
diff --git a/pidgin/prefs/pidginprefsinternal.h b/pidgin/prefs/pidginprefsinternal.h
--- a/pidgin/prefs/pidginprefsinternal.h
+++ b/pidgin/prefs/pidginprefsinternal.h
@@ -49,6 +49,9 @@ G_GNUC_INTERNAL
 void pidgin_prefs_bind_checkbox(const char *key, GtkWidget *button);
 
 G_GNUC_INTERNAL
+void pidgin_prefs_bind_combo_row(const gchar *key, GtkWidget *widget);
+
+G_GNUC_INTERNAL
 void pidgin_prefs_bind_dropdown(PidginPrefCombo *combo);
 
 G_GNUC_INTERNAL
diff --git a/pidgin/prefs/pidginproxyprefs.c b/pidgin/prefs/pidginproxyprefs.c
--- a/pidgin/prefs/pidginproxyprefs.c
+++ b/pidgin/prefs/pidginproxyprefs.c
@@ -41,7 +41,7 @@ struct _PidginProxyPrefs {
 	/* Non-GNOME version */
 	GtkWidget *nongnome;
 	GtkWidget *socks4_remotedns;
-	PidginPrefCombo type;
+	GtkWidget *type;
 	GtkWidget *options;
 	GtkWidget *host;
 	GtkWidget *port;
@@ -54,6 +54,30 @@ G_DEFINE_TYPE(PidginProxyPrefs, pidgin_p
 /******************************************************************************
  * Helpers
  *****************************************************************************/
+static gchar *
+proxy_type_expression_cb(GObject *self, G_GNUC_UNUSED gpointer data)
+{
+	const gchar *text = "";
+	const gchar *value = NULL;
+
+	value = gtk_string_object_get_string(GTK_STRING_OBJECT(self));
+	if(purple_strequal(value, "none")) {
+		text = _("No proxy");
+	} else if(purple_strequal(value, "socks4")) {
+		text = _("SOCKS 4");
+	} else if(purple_strequal(value, "socks5")) {
+		text = _("SOCKS 5");
+	} else if(purple_strequal(value, "tor")) {
+		text = _("Tor/Privacy (SOCKS 5)");
+	} else if(purple_strequal(value, "http")) {
+		text = _("HTTP");
+	} else if(purple_strequal(value, "envvar")) {
+		text = _("Use Environmental Settings");
+	}
+
+	return g_strdup(text);
+}
+
 static void
 proxy_changed_cb(const gchar *name, PurplePrefType type, gconstpointer value,
                  gpointer data)
@@ -141,7 +165,7 @@ pidgin_proxy_prefs_class_init(PidginProx
 	gtk_widget_class_bind_template_child(
 			widget_class, PidginProxyPrefs, socks4_remotedns);
 	gtk_widget_class_bind_template_child(
-			widget_class, PidginProxyPrefs, type.combo);
+			widget_class, PidginProxyPrefs, type);
 	gtk_widget_class_bind_template_child(
 			widget_class, PidginProxyPrefs, options);
 	gtk_widget_class_bind_template_child(
@@ -153,6 +177,8 @@ pidgin_proxy_prefs_class_init(PidginProx
 	gtk_widget_class_bind_template_child(
 			widget_class, PidginProxyPrefs, password);
 	gtk_widget_class_bind_template_callback(widget_class,
+	                                        proxy_type_expression_cb);
+	gtk_widget_class_bind_template_callback(widget_class,
 	                                        proxy_row_activated_cb);
 	gtk_widget_class_bind_template_callback(widget_class,
 			proxy_print_option);
@@ -197,9 +223,8 @@ pidgin_proxy_prefs_init(PidginProxyPrefs
 		pidgin_prefs_bind_switch("/purple/proxy/socks4_remotedns",
 		                         prefs->socks4_remotedns);
 
-		prefs->type.type = PURPLE_PREF_STRING;
-		prefs->type.key = "/purple/proxy/type";
-		pidgin_prefs_bind_dropdown(&prefs->type);
+		pidgin_prefs_bind_combo_row("/purple/proxy/type", prefs->type);
+
 		proxy_info = purple_global_proxy_get_info();
 
 		purple_prefs_connect_callback(prefs, "/purple/proxy/type",
diff --git a/pidgin/resources/Prefs/proxy.ui b/pidgin/resources/Prefs/proxy.ui
--- a/pidgin/resources/Prefs/proxy.ui
+++ b/pidgin/resources/Prefs/proxy.ui
@@ -28,39 +28,15 @@ along with this program; if not, see <ht
     <property name="step-increment">1</property>
     <property name="page-increment">10</property>
   </object>
-  <object class="GtkListStore" id="type.store">
-    <columns>
-      <!-- column-name text -->
-      <column type="gchararray"/>
-      <!-- column-name value -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">No proxy</col>
-        <col id="1">none</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">SOCKS 4</col>
-        <col id="1">socks4</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">SOCKS 5</col>
-        <col id="1">socks5</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Tor/Privacy (SOCKS 5)</col>
-        <col id="1">tor</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">HTTP</col>
-        <col id="1">http</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Use Environmental Settings</col>
-        <col id="1">envvar</col>
-      </row>
-    </data>
+  <object class="GtkStringList" id="type.store">
+    <items>
+      <item>none</item>
+      <item>socks4</item>
+      <item>socks5</item>
+      <item>tor</item>
+      <item>http</item>
+      <item>envvar</item>
+    </items>
   </object>
   <template class="PidginProxyPrefs" parent="AdwPreferencesPage">
     <child>
@@ -106,22 +82,13 @@ along with this program; if not, see <ht
           </object>
         </child>
         <child>
-          <object class="AdwActionRow">
-            <property name="activatable-widget">type.combo</property>
+          <object class="AdwComboRow" id="type">
             <property name="title" translatable="1">Proxy t_ype</property>
             <property name="use-underline">1</property>
-            <child>
-              <object class="GtkComboBox" id="type.combo">
-                <property name="model">type.store</property>
-                <property name="valign">center</property>
-                <child>
-                  <object class="GtkCellRendererText"/>
-                  <attributes>
-                    <attribute name="text">0</attribute>
-                  </attributes>
-                </child>
-              </object>
-            </child>
+            <property name="model">type.store</property>
+            <property name="expression">
+              <closure type="gchararray" function="proxy_type_expression_cb"/>
+            </property>
           </object>
         </child>
         <child>
