prateek/pidgin

Completed page 1 of the Pidgin Account Assistant
draft account-assistant
2021-07-15, Prateek Pardeshi
cd142d30eb47
Parents f1b381d8fa20
Children f2a4c3c4b4ca
Completed page 1 of the Pidgin Account Assistant
--- a/libpurple/protocol.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocol.c Thu Jul 15 01:01:40 2021 +0530
@@ -28,6 +28,7 @@
PROP_0,
PROP_ID,
PROP_NAME,
+ PROP_DESCRIPTION,
PROP_OPTIONS,
N_PROPERTIES,
};
@@ -36,7 +37,7 @@
typedef struct {
gchar *id;
gchar *name;
-
+ gchar *description;
PurpleProtocolOptions options;
} PurpleProtocolPrivate;
@@ -69,6 +70,17 @@
}
static void
+purple_protocol_set_description(PurpleProtocol *protocol, const gchar *description) {
+ PurpleProtocolPrivate *priv = NULL;
+
+ priv = purple_protocol_get_instance_private(protocol);
+ g_free(priv->description);
+ priv->description = g_strdup(description);
+
+ g_object_notify_by_pspec(G_OBJECT(protocol), properties[PROP_DESCRIPTION]);
+}
+
+static void
purple_protocol_set_options(PurpleProtocol *protocol,
PurpleProtocolOptions options)
{
@@ -96,6 +108,9 @@
case PROP_NAME:
g_value_set_string(value, purple_protocol_get_name(protocol));
break;
+ case PROP_DESCRIPTION:
+ g_value_set_string(value, purple_protocol_get_description(protocol));
+ break;
case PROP_OPTIONS:
g_value_set_flags(value, purple_protocol_get_options(protocol));
break;
@@ -118,6 +133,9 @@
case PROP_NAME:
purple_protocol_set_name(protocol, g_value_get_string(value));
break;
+ case PROP_DESCRIPTION:
+ purple_protocol_set_description(protocol, g_value_get_string(value));
+ break;
case PROP_OPTIONS:
purple_protocol_set_options(protocol, g_value_get_flags(value));
break;
@@ -141,7 +159,7 @@
g_clear_pointer(&priv->id, g_free);
g_clear_pointer(&priv->name, g_free);
-
+ g_clear_pointer(&priv->description, g_free);
/* I'm not sure that we can finalize a protocol plugin if an account is
* still using it.. Right now accounts don't ref protocols, but maybe
* they should?
@@ -203,6 +221,17 @@
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
/**
+ * PurpleProtocol::description:
+ *
+ * The description to show in user interface for the protocol.
+ */
+ properties[PROP_DESCRIPTION] = g_param_spec_string(
+ "description", "description",
+ "The description of the protocol to show in the user interface",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ /**
* PurpleProtocol::options:
*
* The #PurpleProtocolOptions for the protocol.
@@ -242,6 +271,17 @@
return priv->name;
}
+const gchar *
+purple_protocol_get_description(PurpleProtocol *protocol) {
+ PurpleProtocolPrivate *priv = NULL;
+
+ g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL);
+
+ priv = purple_protocol_get_instance_private(protocol);
+
+ return priv->description;
+}
+
PurpleProtocolOptions
purple_protocol_get_options(PurpleProtocol *protocol) {
PurpleProtocolPrivate *priv = NULL;
--- a/libpurple/protocol.h Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocol.h Thu Jul 15 01:01:40 2021 +0530
@@ -199,6 +199,18 @@
const gchar *purple_protocol_get_name(PurpleProtocol *protocol);
/**
+ * purple_protocol_get_description:
+ * @protocol: The #PurpleProtocol instance.
+ *
+ * Gets the description of a protocol.
+ *
+ * Returns: The Description of the protocol.
+ *
+ * Since: 3.0.0
+ */
+const gchar *purple_protocol_get_description(PurpleProtocol *protocol);
+
+/**
* purple_protocol_get_options:
* @protocol: The #PurpleProtocol instance.
*
--- a/libpurple/protocols/bonjour/bonjour.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocols/bonjour/bonjour.c Thu Jul 15 01:01:40 2021 +0530
@@ -753,6 +753,7 @@
BONJOUR_TYPE_PROTOCOL,
"id", "prpl-bonjour",
"name", "Bonjour",
+ "description","Bonjour is a serverless protocol, developed by Apple",
"options", OPT_PROTO_NO_PASSWORD,
NULL));
}
--- a/libpurple/protocols/facebook/facebook.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocols/facebook/facebook.c Thu Jul 15 01:01:40 2021 +0530
@@ -1706,6 +1706,7 @@
fb_protocol = g_object_new(FACEBOOK_TYPE_PROTOCOL,
"id", FB_PROTOCOL_ID,
"name", "Facebook",
+ "description","Facebook is a chat app",
"options", OPT_PROTO_CHAT_TOPIC,
NULL);
--- a/libpurple/protocols/gg/gg.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocols/gg/gg.c Thu Jul 15 01:01:40 2021 +0530
@@ -1209,6 +1209,7 @@
GGP_TYPE_PROTOCOL,
"id", "prpl-gg",
"name", "Gadu-Gadu",
+ "description", "Gadu-Gadu is a Polish instant messaging client",
NULL));
}
--- a/libpurple/protocols/irc/irc.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocols/irc/irc.c Thu Jul 15 01:01:40 2021 +0530
@@ -1135,6 +1135,7 @@
IRC_TYPE_PROTOCOL,
"id", "prpl-irc",
"name", "IRC",
+ "description","IRC is a messaging client",
"options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL |
OPT_PROTO_SLASH_COMMANDS_NATIVE,
NULL));
--- a/libpurple/protocols/jabber/xmpp.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocols/jabber/xmpp.c Thu Jul 15 01:01:40 2021 +0530
@@ -146,6 +146,7 @@
XMPP_TYPE_PROTOCOL,
"id", XMPP_PROTOCOL_ID,
"name", "XMPP",
+ "description", "Extensible Messaging and Presence Protocol for IM, voice and video",
"options", options,
NULL
));
--- a/libpurple/protocols/novell/novell.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocols/novell/novell.c Thu Jul 15 01:01:40 2021 +0530
@@ -3625,6 +3625,7 @@
NOVELL_TYPE_PROTOCOL,
"id", "prpl-novell",
"name", "GroupWise",
+ "description","GroupWise is a messaging and collaboration platform from Micro Focus",
NULL));
}
--- a/libpurple/protocols/sametime/sametime.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocols/sametime/sametime.c Thu Jul 15 01:01:40 2021 +0530
@@ -68,6 +68,7 @@
#define PROTOCOL_ID "prpl-meanwhile"
#define PROTOCOL_NAME "Sametime"
+#define PROTOCOL_DESCRIPTION "Sametime chat by Lotus"
/* considering that there's no display of this information for protocols,
@@ -5385,6 +5386,7 @@
MW_TYPE_PROTOCOL,
"id", PROTOCOL_ID,
"name", PROTOCOL_NAME,
+ "description", PROTOCOL_DESCRIPTION,
NULL));
}
--- a/libpurple/protocols/silc/silc.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocols/silc/silc.c Thu Jul 15 01:01:40 2021 +0530
@@ -2341,6 +2341,7 @@
SILCPURPLE_TYPE_PROTOCOL,
"id", "prpl-silc",
"name", "SILC",
+ "description", "SILC - Secure Internet Live Conferencing protocol",
"options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME |
OPT_PROTO_PASSWORD_OPTIONAL |
OPT_PROTO_SLASH_COMMANDS_NATIVE,
--- a/libpurple/protocols/zephyr/zephyr.c Tue Jun 08 22:34:45 2021 -0500
+++ b/libpurple/protocols/zephyr/zephyr.c Thu Jul 15 01:01:40 2021 +0530
@@ -1713,6 +1713,7 @@
ZEPHYR_TYPE_PROTOCOL,
"id", "prpl-zephyr",
"name", "Zephyr",
+ "description", "Zephyr is an instant messaging protocol, created at MIT",
"options", OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD,
NULL));
}
--- a/pidgin/assistant/pidginaccountassistant.c Tue Jun 08 22:34:45 2021 -0500
+++ b/pidgin/assistant/pidginaccountassistant.c Thu Jul 15 01:01:40 2021 +0530
@@ -23,7 +23,7 @@
#include <purple.h>
#include "pidginaccountassistant.h"
-
+#include "pidginassistantprotocolpage.h"
struct _PidginAccountAssistant {
GtkAssistant parent;
};
@@ -69,6 +69,19 @@
}
/******************************************************************************
+ * Overrides
+ *****************************************************************************/
+static void
+pidgin_account_assistant_constructed(GObject *object)
+{
+ G_OBJECT_CLASS(pidgin_account_assistant_parent_class)->constructed(object);
+
+ gtk_assistant_append_page(GTK_ASSISTANT(object), pidgin_assistant_protocol_page_new());
+
+}
+
+
+/******************************************************************************
* GObject Implementation
*****************************************************************************/
static void
@@ -80,8 +93,11 @@
static void
pidgin_account_assistant_class_init(PidginAccountAssistantClass *klass)
{
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ obj_class->constructed = pidgin_account_assistant_constructed;
+
gtk_widget_class_set_template_from_resource(
widget_class,
"/im/pidgin/Pidgin/Assistant/accountassistant.ui"
--- a/pidgin/assistant/pidginaccountassistant.h Tue Jun 08 22:34:45 2021 -0500
+++ b/pidgin/assistant/pidginaccountassistant.h Thu Jul 15 01:01:40 2021 +0530
@@ -56,7 +56,7 @@
/**
* PidginAccountAssistant:
*
- * A widget that displays a credential provider.
+ * A widget that helps users create accounts.
*
* Since: 3.0.0
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/assistant/pidginassistantprotocolpage.c Thu Jul 15 01:01:40 2021 +0530
@@ -0,0 +1,154 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <purple.h>
+
+#include <handy.h>
+
+#include "pidginassistantprotocolpage.h"
+#include "pidginassistantprotocolrow.h"
+
+struct _PidginAssistantProtocolPage {
+ HdyPreferencesPage parent;
+
+ GtkWidget *protocol_list;
+};
+
+G_DEFINE_TYPE(PidginAssistantProtocolPage, pidgin_assistant_protocol_page,
+ HDY_TYPE_PREFERENCES_PAGE)
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static void
+pidgin_assistant_protocol_page_create_row(PurpleProtocol *protocol,
+ gpointer data)
+{
+ GtkListBox *box = GTK_LIST_BOX(data);
+ GtkWidget *row = NULL;
+
+ row = pidgin_assistant_protocol_row_new(protocol);
+ gtk_list_box_prepend(box, row);
+}
+
+static gint
+pidgin_assistant_protocol_page_sort_rows(GtkListBoxRow *row1, GtkListBoxRow *row2,
+ G_GNUC_UNUSED gpointer user_data)
+{
+
+}
+
+static void
+pidgin_assistant_protocol_page_set_selected_protocol(PidginAssistantProtocolPage *page,
+ const gchar *new_id)
+{
+ GList *rows = NULL;
+
+ rows = gtk_container_get_children(GTK_CONTAINER(page->protocol_list));
+ for (; rows; rows = g_list_delete_link(rows, rows)) {
+ PidginAssistantProtocolRow *row = NULL;
+ PurpleProtocol *protocol = NULL;
+ const gchar *id = NULL;
+
+ row = PIDGIN_ASSISTANT_PROTOCOL_ROW(rows->data);
+ protocol = pidgin_assistant_protocol_row_get_protocol(row);
+ id = purple_protocol_get_id(protocol);
+
+ pidgin_assistant_protocol_row_set_selected(row,
+ purple_strequal(new_id, id));
+ }
+}
+
+static void
+pidgin_assistant_protocol_page_selected_protocol_changed_cb(const gchar *name,
+ PurplePrefType type,
+ gconstpointer value,
+ gpointer data)
+{
+ PidginAssistantProtocolPage *page = PIDGIN_ASSISTANT_PROTOCOL_PAGE(data);
+
+ pidgin_assistant_protocol_page_set_selected_protocol(page, (const gchar *)value);
+}
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+static void
+pidgin_assistant_protocol_page_finalize(GObject *obj) {
+
+ G_OBJECT_CLASS(pidgin_assistant_protocol_page_parent_class)->finalize(obj);
+}
+
+static void
+pidgin_assistant_protocol_page_init(PidginAssistantProtocolPage *page) {
+
+ PurpleProtocolManager *manager = NULL;
+ const gchar *selected = NULL;
+ GList *protocols = NULL;
+
+ manager = purple_protocol_manager_get_default();
+
+ protocols = purple_protocol_manager_get_all(manager);
+
+ gtk_widget_init_template(GTK_WIDGET(page));
+
+ g_list_foreach(protocols, pidgin_assistant_protocol_page_create_row,
+ page->protocol_list);
+ g_list_free(protocols);
+
+ // purple_protocol_manager_get_all(manager);
+
+ gtk_list_box_set_sort_func(GTK_LIST_BOX(page->protocol_list),
+ pidgin_assistant_protocol_page_sort_rows,NULL, NULL);
+
+ selected = purple_protocol_get_name(protocols);
+ pidgin_assistant_protocol_page_set_selected_protocol(page, selected);
+
+}
+
+static void
+pidgin_assistant_protocol_page_class_init(PidginAssistantProtocolPageClass *klass) {
+
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+ obj_class->finalize = pidgin_assistant_protocol_page_finalize;
+
+ gtk_widget_class_set_template_from_resource(
+ widget_class,
+ "/im/pidgin/Pidgin/Assistant/assistantprotocolpage.ui"
+ );
+ gtk_widget_class_bind_template_child(widget_class, PidginAssistantProtocolPage,
+ protocol_list);
+ gtk_widget_class_bind_template_callback(widget_class,
+ pidgin_assistant_protocol_page_selected_protocol_changed_cb);
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+GtkWidget *
+pidgin_assistant_protocol_page_new(void) {
+
+ return GTK_WIDGET(g_object_new(PIDGIN_TYPE_ASSISTANT_PROTOCOL_PAGE, NULL));
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/assistant/pidginassistantprotocolpage.h Thu Jul 15 01:01:40 2021 +0530
@@ -0,0 +1,81 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
+# error "only <pidgin.h> may be included directly"
+#endif
+
+#ifndef PIDGIN_ASSISTANT_PROTOCOL_PAGE_H
+#define PIDGIN_ASSISTANT_PROTOCOL_PAGE_H
+
+/**
+ * SECTION:pidginassistantprotocolpage
+ * @section_id: pidgin-pidginassistantprotocolpage
+ * @short_description: The protocol widget for selecting protocol from asssistant.
+ * @title: Protocol selection widget
+ *
+ * #PidginAssistantProtocolPage is a widget for the account assistant window to let users
+ * choose and configure their protocol provider.
+ */
+
+#include <glib.h>
+
+#include <gtk/gtk.h>
+#include <handy.h>
+
+G_BEGIN_DECLS
+
+/**
+ * PIDGIN_TYPE_ASSISTANT_PROTOCOL_PAGE:
+ *
+ * The standard _get_type macro for #PidginAssistantProtocolPage.
+ *
+ * Since: 3.0.0
+ */
+#define PIDGIN_TYPE_ASSISTANT_PROTOCOL_PAGE (pidgin_assistant_protocol_page_get_type())
+G_DECLARE_FINAL_TYPE(PidginAssistantProtocolPage,
+ pidgin_assistant_protocol_page,
+ PIDGIN, ASSISTANT_PROTOCOL_PAGE,
+ HdyPreferencesPage)
+
+/**
+ * PidginAssistantProtocolPage:
+ *
+ * A widget that displays a page of protocols in assistant.
+ *
+ * Since: 3.0.0
+ */
+
+/**
+ * pidgin_assistant_protocol_page_new:
+ *
+ * Creates a new #PidginAssistantProtocolPage instance.
+ *
+ * Returns: (transfer full): The new #PidginAssistantProtocolPage instance.
+ *
+ * Since: 3.0.0
+ */
+GtkWidget *pidgin_assistant_protocol_page_new(void);
+
+G_END_DECLS
+
+#endif /* PIDGIN_ASSISTANT_PROTOCOL_PAGE_H */
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/assistant/pidginassistantprotocolrow.c Thu Jul 15 01:01:40 2021 +0530
@@ -0,0 +1,205 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <purple.h>
+
+#include <handy.h>
+
+#include "pidginassistantprotocolrow.h"
+
+
+struct _PidginAssistantProtocolRow {
+ HdyActionRow parent;
+
+ PurpleProtocol *protocol;
+
+ GtkWidget *selected;
+};
+
+enum {
+ PROP_0,
+ PROP_PROTOCOL,
+ PROP_SELECTED,
+ N_PROPERTIES,
+};
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+
+G_DEFINE_TYPE(PidginAssistantProtocolRow, pidgin_assistant_protocol_row,
+ HDY_TYPE_ACTION_ROW)
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static void
+pidgin_assistant_protocol_row_set_protocol(PidginAssistantProtocolRow *row,
+ PurpleProtocol *protocol)
+{
+ if(!g_set_object(&row->protocol, protocol)) {
+ return;
+ }
+
+ if(PURPLE_IS_PROTOCOL(protocol)) {
+ hdy_preferences_row_set_title(
+ HDY_PREFERENCES_ROW(row),
+ purple_protocol_get_name(protocol));
+ hdy_action_row_set_subtitle(
+ HDY_ACTION_ROW(row),
+ purple_protocol_get_description(protocol));
+ }
+
+ /* Notify that we changed. */
+ g_object_notify_by_pspec(G_OBJECT(row), properties[PROP_PROTOCOL]);
+}
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+static void
+pidgin_assistant_protocol_row_get_property(GObject *obj, guint param_id, GValue *value,
+ GParamSpec *pspec)
+{
+ PidginAssistantProtocolRow *protocol = PIDGIN_ASSISTANT_PROTOCOL_ROW(obj);
+
+ switch(param_id) {
+ case PROP_PROTOCOL:
+ g_value_set_object(value, pidgin_assistant_protocol_row_get_protocol(protocol));
+ break;
+ case PROP_SELECTED:
+ g_value_set_boolean(value, pidgin_assistant_protocol_row_get_protocol(protocol));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+ break;
+ }
+}
+
+static void
+pidgin_assistant_protocol_row_set_property(GObject *obj, guint param_id, const GValue *value,
+ GParamSpec *pspec)
+{
+ PidginAssistantProtocolRow *protocol = PIDGIN_ASSISTANT_PROTOCOL_ROW(obj);
+
+ switch(param_id) {
+ case PROP_PROTOCOL:
+ pidgin_assistant_protocol_row_set_protocol(protocol, g_value_get_object(value));
+ break;
+ case PROP_SELECTED:
+ pidgin_assistant_protocol_row_set_selected(protocol, g_value_get_boolean(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+ break;
+ }
+}
+
+static void
+pidgin_assistant_protocol_row_finalize(GObject *obj)
+{
+ PidginAssistantProtocolRow *row = PIDGIN_ASSISTANT_PROTOCOL_ROW(obj);
+
+ g_clear_object(&row->protocol);
+}
+
+static void
+pidgin_assistant_protocol_row_init(PidginAssistantProtocolRow *row) {
+
+ gtk_widget_init_template(GTK_WIDGET(row));
+
+}
+
+static void
+pidgin_assistant_protocol_row_class_init(PidginAssistantProtocolRowClass *klass) {
+
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+ obj_class->get_property = pidgin_assistant_protocol_row_get_property;
+ obj_class->set_property = pidgin_assistant_protocol_row_set_property;
+ obj_class->finalize = pidgin_assistant_protocol_row_finalize;
+
+ /**
+ * PidginAssistantProtocolRow::id:
+ *
+ * The identifier for the protocol.
+ */
+ properties[PROP_PROTOCOL] = g_param_spec_object(
+ "protocol", "protocol",
+ "The identifier for the protocol",
+ PURPLE_TYPE_PROTOCOL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ /**
+ * PidginAssistantProtocolRow::selected
+ *
+ * Whether the #PurpleProtocol is currently selected.
+ */
+ properties[PROP_SELECTED] = g_param_spec_boolean(
+ "selected", "selected",
+ "Marks the selected PurpleProtocol",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+
+ gtk_widget_class_set_template_from_resource(
+ widget_class,
+ "/im/pidgin/Pidgin/Assistant/assistantprotocolrow.ui"
+ );
+
+ gtk_widget_class_bind_template_child(widget_class,
+ PidginAssistantProtocolRow,
+ selected);
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+GtkWidget *
+pidgin_assistant_protocol_row_new(PurpleProtocol *protocol) {
+ g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL);
+ return GTK_WIDGET(g_object_new(PIDGIN_TYPE_ASSISTANT_PROTOCOL_ROW,
+ "protocol", protocol, NULL));
+}
+
+PurpleProtocol *
+pidgin_assistant_protocol_row_get_protocol(PidginAssistantProtocolRow *row) {
+ return row->protocol;
+}
+
+gboolean
+pidgin_assistant_protocol_row_get_selected(PidginAssistantProtocolRow *row) {
+ g_return_val_if_fail(PIDGIN_IS_ASSISTANT_PROTOCOL_ROW(row), FALSE);
+
+ return gtk_widget_get_visible(row->selected);
+}
+
+void
+pidgin_assistant_protocol_row_set_selected(PidginAssistantProtocolRow *row,
+ gboolean selected)
+{
+ g_return_if_fail(PIDGIN_IS_ASSISTANT_PROTOCOL_ROW(row));
+
+ gtk_widget_set_visible(row->selected, selected);
+
+ g_object_notify_by_pspec(G_OBJECT(row), properties[PROP_SELECTED]);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/assistant/pidginassistantprotocolrow.h Thu Jul 15 01:01:40 2021 +0530
@@ -0,0 +1,118 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
+# error "only <pidgin.h> may be included directly"
+#endif
+
+#ifndef PIDGIN_ASSISTANT_PROTOCOL_ROW_H
+#define PIDGIN_ASSISTANT_PROTOCOL_ROW_H
+
+/**
+ * SECTION:pidginassistantprotocolrow
+ * @section_id: pidgin-pidginassistantprotocolrow
+ * @short_description: The protocol widget for selecting protocol from asssistant.
+ * @title: Protocol selection widget
+ *
+ * #PidginAssistantProtocolRow is a widget for the account assistant window to let users
+ * choose and configure their protocol provider.
+ */
+
+#include <glib.h>
+
+#include <gtk/gtk.h>
+#include <handy.h>
+#include <purple.h>
+
+G_BEGIN_DECLS
+
+/**
+ * PIDGIN_TYPE_ASSISTANT_PROTOCOL_ROW:
+ *
+ * The standard _get_type macro for #PidginAssistantProtocolRow.
+ *
+ * Since: 3.0.0
+ */
+#define PIDGIN_TYPE_ASSISTANT_PROTOCOL_ROW (pidgin_assistant_protocol_row_get_type())
+G_DECLARE_FINAL_TYPE(PidginAssistantProtocolRow,
+ pidgin_assistant_protocol_row,
+ PIDGIN, ASSISTANT_PROTOCOL_ROW, HdyActionRow)
+
+/**
+ * PidginAssistantProtocolRow:
+ *
+ * A widget that displays a page of protocols in assistant.
+ *
+ * Since: 3.0.0
+ */
+
+/**
+ * pidgin_assistant_protocol_row_new:
+ *
+ * Creates a new #PidginAssistantProtocolRow instance.
+ *
+ * Returns: (transfer full): The new #PidginAssistantProtocol instance.
+ *
+ * Since: 3.0.0
+ */
+GtkWidget *pidgin_assistant_protocol_row_new(PurpleProtocol *protocol);
+
+
+/**
+ * pidgin_assistant_protocol_row_get_provider:
+ * @row: The row instance.
+ *
+ * Gets the #PidginAssistantProtocol displayed by this widget.
+ *
+ * Returns: (transfer none): The displayed #PidginAssistantProtocol.
+ *
+ * Since: 3.0.0
+ */
+PurpleProtocol *pidgin_assistant_protocol_row_get_protocol(PidginAssistantProtocolRow *row);
+
+/**
+ * pidgin_assistant_protocol_row_get_selected:
+ * @row: The row instance.
+ *
+ * Gets whether the row is displayed as selected.
+ *
+ * Returns: Whether the row is selected.
+ *
+ * Since: 3.0.0
+ */
+gboolean pidgin_assistant_protocol_row_get_selected(PidginAssistantProtocolRow *row);
+
+/**
+ * pidgin_assistant_protocol_row_set_selected:
+ * @row: The row instance.
+ * @selected: Whether to display as selected.
+ *
+ * Sets whether the row is displayed as selected.
+ *
+ * Since: 3.0.0
+ */
+void pidgin_assistant_protocol_row_set_selected(PidginAssistantProtocolRow *row, gboolean selected);
+
+G_END_DECLS
+
+#endif /* PIDGIN_ASSISTANT_PROTOCOL_ROW_H */
+
--- a/pidgin/meson.build Tue Jun 08 22:34:45 2021 -0500
+++ b/pidgin/meson.build Thu Jul 15 01:01:40 2021 +0530
@@ -1,5 +1,7 @@
libpidgin_SOURCES = [
'assistant/pidginaccountassistant.c',
+ 'assistant/pidginassistantprotocolpage.c',
+ 'assistant/pidginassistantprotocolrow.c',
'pidginstock.c',
'gtkaccount.c',
'gtkblist.c',
@@ -71,6 +73,8 @@
libpidgin_headers = [
'assistant/pidginaccountassistant.h',
+ 'assistant/pidginassistantprotocolpage.h',
+ 'assistant/pidginassistantprotocolrow.h',
'gtkaccount.h',
'gtkblist.h',
'gtkconn.h',
--- a/pidgin/resources/Assistant/accountassistant.ui Tue Jun 08 22:34:45 2021 -0500
+++ b/pidgin/resources/Assistant/accountassistant.ui Thu Jul 15 01:01:40 2021 +0530
@@ -1,5 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 -->
+<!-- Generated with glade 3.38.2
+
+Pidgin - Internet Messenger
+Copyright (C) Pidgin Developers <devel@pidgin.im>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+-->
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="PidginAccountAssistant" parent="GtkAssistant">
@@ -7,48 +26,17 @@
<signal name="cancel" handler="pidgin_account_assistant_cancel_cb" swapped="no"/>
<signal name="delete-event" handler="pidgin_account_assistant_delete_cb" swapped="no"/>
<child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="label" translatable="yes">Introduction page</property>
- </object>
- <packing>
- <property name="page-type">intro</property>
- <property name="has-padding">False</property>
- </packing>
+ <placeholder/>
</child>
<child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="label" translatable="yes">Content page</property>
- </object>
- <packing>
- <property name="has-padding">False</property>
- </packing>
+ <placeholder/>
</child>
<child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can-focus">False</property>
- <property name="label" translatable="yes">Confirmation page</property>
- </object>
- <packing>
- <property name="page-type">confirm</property>
- <property name="has-padding">False</property>
- </packing>
+ <placeholder/>
</child>
<child internal-child="action_area">
<object class="GtkBox">
<property name="can-focus">False</property>
- <property name="halign">end</property>
- <property name="margin-left">6</property>
- <property name="margin-right">6</property>
- <property name="margin-start">6</property>
- <property name="margin-end">6</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="spacing">6</property>
</object>
<packing>
<property name="has-padding">False</property>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/Assistant/assistantprotocolpage.ui Thu Jul 15 01:01:40 2021 +0530
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2
+
+Pidgin - Internet Messenger
+Copyright (C) Pidgin Developers <devel@pidgin.im>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+-->
+<interface>
+ <requires lib="gtk+" version="3.24"/>
+ <requires lib="libhandy" version="0.0"/>
+ <template class="PidginAssistantProtocolPage" parent="HdyPreferencesPage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="title" translatable="yes">Protocols</property>
+ <child>
+ <object class="HdyPreferencesGroup">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="description" translatable="yes">Pidgin Supports all the protocols available below</property>
+ <property name="title" translatable="yes">Supported Protocols</property>
+ <child>
+ <object class="GtkListBox" id="protocol_list">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <style>
+ <class name="content"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/Assistant/assistantprotocolrow.ui Thu Jul 15 01:01:40 2021 +0530
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2
+
+Pidgin - Internet Messenger
+Copyright (C) Pidgin Developers <devel@pidgin.im>
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+-->
+<interface>
+ <requires lib="gtk+" version="3.24"/>
+ <requires lib="libhandy" version="0.0"/>
+ <template class="PidginAssistantProtocolRow" parent="HdyActionRow">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="activatable">False</property>
+ <child>
+ <object class="GtkImage" id="selected">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="valign">center</property>
+ <property name="xpad">6</property>
+ <property name="ypad">6</property>
+ <property name="icon-name">emblem-default-symbolic</property>
+ </object>
+ </child>
+ </template>
+</interface>
--- a/pidgin/resources/pidgin.gresource.xml Tue Jun 08 22:34:45 2021 -0500
+++ b/pidgin/resources/pidgin.gresource.xml Thu Jul 15 01:01:40 2021 +0530
@@ -10,6 +10,8 @@
<file compressed="true">Accounts/entry.css</file>
<file compressed="true">Accounts/menu.ui</file>
<file compressed="true">Assistant/accountassistant.ui</file>
+ <file compressed="true">Assistant/assistantprotocolpage.ui</file>
+ <file compressed="true">Assistant/assistantprotocolrow.ui</file>
<file compressed="true">Avatar/avatar.ui</file>
<file compressed="true">Avatar/menu.ui</file>
<file compressed="true">BuddyList/window.ui</file>