pidgin/pidgin

850137e8737c
Parents 548fed625b8a
Children 2fc55152b79c
Select the proper protocol in the account editor.

* Make sure the proper protocol is select in the account editor.
* Replace `pidgin_protocol_chooser_[gs]et_name` with
`pidgin_protocol_chooser_[gs]et_id`.
* Removed `pidgin_protocol_store_finalize` as it was only used
to disconnect purple signals that we aren't using anymore.

Testing Done:
Compiled and ran locally. Verified via adding a new account, checking a connected account, and a disconnected account.

Bugs closed: PIDGIN-17494

Reviewed at https://reviews.imfreedom.org/r/465/
--- a/pidgin/gtkaccount.c Sat Jan 30 00:36:07 2021 -0600
+++ b/pidgin/gtkaccount.c Sat Jan 30 00:38:35 2021 -0600
@@ -468,7 +468,8 @@
/* Protocol */
if(dialog->protocol_menu == NULL) {
dialog->protocol_menu = pidgin_protocol_chooser_new();
- gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->protocol_menu), 0);
+ pidgin_protocol_chooser_set_selected_id(PIDGIN_PROTOCOL_CHOOSER(dialog->protocol_menu),
+ dialog->protocol_id);
g_signal_connect(G_OBJECT(dialog->protocol_menu), "changed",
G_CALLBACK(set_account_protocol_cb), dialog);
gtk_widget_show(dialog->protocol_menu);
--- a/pidgin/pidginprotocolchooser.c Sat Jan 30 00:36:07 2021 -0600
+++ b/pidgin/pidginprotocolchooser.c Sat Jan 30 00:38:35 2021 -0600
@@ -83,45 +83,45 @@
}
gchar *
-pidgin_protocol_chooser_get_selected_name(PidginProtocolChooser *chooser) {
+pidgin_protocol_chooser_get_selected_id(PidginProtocolChooser *chooser) {
GtkTreeIter iter;
- gchar *name = NULL;
+ gchar *id = NULL;
g_return_val_if_fail(PIDGIN_IS_PROTOCOL_CHOOSER(chooser), NULL);
if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(chooser), &iter)) {
gtk_tree_model_get(GTK_TREE_MODEL(chooser->model), &iter,
- PIDGIN_PROTOCOL_STORE_COLUMN_NAME, &name,
+ PIDGIN_PROTOCOL_STORE_COLUMN_ID, &id,
-1);
}
- return name;
+ return id;
}
void
-pidgin_protocol_chooser_set_selected_name(PidginProtocolChooser *chooser,
- const gchar *name)
+pidgin_protocol_chooser_set_selected_id(PidginProtocolChooser *chooser,
+ const gchar *id)
{
GtkTreeIter iter;
- gchar *iter_name = NULL;
+ gchar *iter_id = NULL;
g_return_if_fail(PIDGIN_IS_PROTOCOL_CHOOSER(chooser));
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(chooser->model), &iter)) {
do {
gtk_tree_model_get(GTK_TREE_MODEL(chooser->model), &iter,
- PIDGIN_PROTOCOL_STORE_COLUMN_NAME, &iter_name,
+ PIDGIN_PROTOCOL_STORE_COLUMN_ID, &iter_id,
-1);
- if(purple_strequal(iter_name, name)) {
+ if(purple_strequal(iter_id, id)) {
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(chooser), &iter);
- g_free(iter_name);
+ g_free(iter_id);
return;
}
- g_free(iter_name);
+ g_free(iter_id);
} while(gtk_tree_model_iter_next(GTK_TREE_MODEL(chooser->model),
&iter));
}
--- a/pidgin/pidginprotocolchooser.h Sat Jan 30 00:36:07 2021 -0600
+++ b/pidgin/pidginprotocolchooser.h Sat Jan 30 00:38:35 2021 -0600
@@ -71,28 +71,29 @@
PurpleProtocol *pidgin_protocol_chooser_get_selected(PidginProtocolChooser *chooser);
/**
- * pidgin_protocol_chooser_get_selected_name:
+ * pidgin_protocol_chooser_get_selected_id:
* @chooser: The #PidginProtocolChooser instance.
*
- * Gets the name of the currently selected protocol from @chooser.
+ * Gets the id of the currently selected protocol from @chooser.
*
- * Returns: (transfer full): The selected #PurpleProtocol or %NULL if nothing
- * is selected
+ * Returns: (transfer full): The id of the selected #PurpleProtocol or %NULL if
+ * nothing is selected.
*
* Since: 3.0.0
*/
-gchar *pidgin_protocol_chooser_get_selected_name(PidginProtocolChooser *chooser);
+gchar *pidgin_protocol_chooser_get_selected_id(PidginProtocolChooser *chooser);
/**
- * pidgin_protocol_chooser_set_selected_name:
+ * pidgin_protocol_chooser_set_selected_id:
* @chooser: The #PidginProtocolChooser instance.
- * @name: The name of the protocol to select.
+ * @id: The id of the protocol to select.
*
- * Sets the currently selected protocol of @chooser to @protocol.
+ * Sets the currently selected protocol of @chooser to the #PurpleProtocol with
+ * an id of @id.
*
* Since: 3.0.0
*/
-void pidgin_protocol_chooser_set_selected_name(PidginProtocolChooser *chooser, const gchar *name);
+void pidgin_protocol_chooser_set_selected_id(PidginProtocolChooser *chooser, const gchar *id);
G_END_DECLS
--- a/pidgin/pidginprotocolstore.c Sat Jan 30 00:36:07 2021 -0600
+++ b/pidgin/pidginprotocolstore.c Sat Jan 30 00:38:35 2021 -0600
@@ -47,6 +47,7 @@
GTK_LIST_STORE(store),
&iter,
PIDGIN_PROTOCOL_STORE_COLUMN_PROTOCOL, protocol,
+ PIDGIN_PROTOCOL_STORE_COLUMN_ID, purple_protocol_get_id(protocol),
PIDGIN_PROTOCOL_STORE_COLUMN_NAME, purple_protocol_get_name(protocol),
PIDGIN_PROTOCOL_STORE_COLUMN_ICON, pixbuf,
-1
@@ -137,6 +138,7 @@
GType types[PIDGIN_PROTOCOL_STORE_N_COLUMNS] = {
PURPLE_TYPE_PROTOCOL,
G_TYPE_STRING,
+ G_TYPE_STRING,
GDK_TYPE_PIXBUF,
};
@@ -160,17 +162,7 @@
}
static void
-pidgin_protocol_store_finalize(GObject *obj) {
- purple_signals_disconnect_by_handle(obj);
-
- G_OBJECT_CLASS(pidgin_protocol_store_parent_class)->finalize(obj);
-}
-
-static void
pidgin_protocol_store_class_init(PidginProtocolStoreClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
- obj_class->finalize = pidgin_protocol_store_finalize;
}
/******************************************************************************
--- a/pidgin/pidginprotocolstore.h Sat Jan 30 00:36:07 2021 -0600
+++ b/pidgin/pidginprotocolstore.h Sat Jan 30 00:38:35 2021 -0600
@@ -45,8 +45,9 @@
* PidginProtocolStoreColumn:
* @PIDGIN_PROTOCOL_STORE_COLUMN_PROTOCOL: This column holds a reference to a
* #PurpleProtocol.
+ * @PIDGIN_PROTOCOL_STORE_COLUMN_ID: This column holds the id of the protocol.
* @PIDGIN_PROTOCOL_STORE_COLUMN_NAME: This column holds the name of the
- * protocol.
+ * protocol which is used for display.
* @PIDGIN_PROTOCOL_STORE_COLUMN_ICON: This column holds a #GdkPixbuf of the
* logo of the protocol.
*
@@ -56,6 +57,7 @@
*/
typedef enum {
PIDGIN_PROTOCOL_STORE_COLUMN_PROTOCOL,
+ PIDGIN_PROTOCOL_STORE_COLUMN_ID,
PIDGIN_PROTOCOL_STORE_COLUMN_NAME,
PIDGIN_PROTOCOL_STORE_COLUMN_ICON,
/*< private >*/
--- a/pidgin/resources/Protocols/chooser.ui Sat Jan 30 00:36:07 2021 -0600
+++ b/pidgin/resources/Protocols/chooser.ui Sat Jan 30 00:38:35 2021 -0600
@@ -32,13 +32,13 @@
<child>
<object class="GtkCellRendererPixbuf" id="icon"/>
<attributes>
- <attribute name="pixbuf">2</attribute>
+ <attribute name="pixbuf">3</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="name"/>
<attributes>
- <attribute name="text">1</attribute>
+ <attribute name="text">2</attribute>
</attributes>
</child>
</template>