summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pidgin/gtkblist.c190
-rw-r--r--pidgin/meson.build2
-rw-r--r--pidgin/pidginaddchatdialog.c464
-rw-r--r--pidgin/pidginaddchatdialog.h65
-rw-r--r--pidgin/resources/Dialogs/addchat.ui302
-rw-r--r--pidgin/resources/pidgin.gresource.xml1
-rw-r--r--po/POTFILES.in2
7 files changed, 840 insertions, 186 deletions
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
index 04fa9afb33..af6ab6cb06 100644
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -41,6 +41,7 @@
#include "pidgin/pidginaccountstore.h"
#include "pidgin/pidginactiongroup.h"
#include "pidgin/pidginaddbuddydialog.h"
+#include "pidgin/pidginaddchatdialog.h"
#include "pidgin/pidgincontactlistwindow.h"
#include "pidgin/pidgincore.h"
#include "pidgin/pidgindebug.h"
@@ -106,7 +107,6 @@ static void sort_method_status(PurpleBlistNode *node, PurpleBuddyList *blist, Gt
static PidginBuddyList *gtkblist = NULL;
-static GList *groups_tree(void);
static void pidgin_blist_update_buddy(PurpleBuddyList *list, PurpleBlistNode *node, gboolean status_change);
static void pidgin_blist_selection_changed(GtkTreeSelection *selection, gpointer data);
static void pidgin_blist_update(PurpleBuddyList *list, PurpleBlistNode *node);
@@ -3736,33 +3736,6 @@ static void pidgin_blist_set_visible(PurpleBuddyList *list, gboolean show)
}
}
-static GList *
-groups_tree(void)
-{
- static GList *list = NULL;
- PurpleGroup *g;
- PurpleBlistNode *gnode;
-
- g_list_free(list);
- list = NULL;
-
- gnode = purple_blist_get_default_root();
- if (gnode == NULL) {
- list = g_list_append(list,
- (gpointer)PURPLE_BLIST_DEFAULT_GROUP_NAME);
- } else {
- for (; gnode != NULL; gnode = gnode->next) {
- if (PURPLE_IS_GROUP(gnode))
- {
- g = (PurpleGroup *)gnode;
- list = g_list_append(list, (char *) purple_group_get_name(g));
- }
- }
- }
-
- return list;
-}
-
static void
pidgin_blist_request_add_buddy(PurpleBuddyList *list, PurpleAccount *account,
const char *username, const char *group,
@@ -3776,170 +3749,15 @@ pidgin_blist_request_add_buddy(PurpleBuddyList *list, PurpleAccount *account,
}
static void
-add_chat_cb(GtkWidget *w, PidginAddChatData *data)
-{
- GList *tmp;
- PurpleChat *chat;
- GHashTable *components;
-
- components = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, g_free);
-
- for (tmp = data->chat_data.entries; tmp; tmp = tmp->next)
- {
- if (g_object_get_data(tmp->data, "is_spin"))
- {
- g_hash_table_replace(components,
- g_strdup(g_object_get_data(tmp->data, "identifier")),
- g_strdup_printf("%d",
- gtk_spin_button_get_value_as_int(tmp->data)));
- }
- else
- {
- const char *value = gtk_entry_get_text(tmp->data);
-
- if (*value != '\0')
- g_hash_table_replace(components,
- g_strdup(g_object_get_data(tmp->data, "identifier")),
- g_strdup(value));
- }
- }
-
- chat = purple_chat_new(data->chat_data.rq_data.account,
- gtk_entry_get_text(GTK_ENTRY(data->alias_entry)),
- components);
-
- if (chat != NULL) {
- PurpleGroup *group;
- const char *group_name;
-
- group_name = pidgin_text_combo_box_entry_get_text(data->group_combo);
-
- group = NULL;
- if ((group_name != NULL) && (*group_name != '\0') &&
- ((group = purple_blist_find_group(group_name)) == NULL))
- {
- group = purple_group_new(group_name);
- purple_blist_add_group(group, NULL);
- }
-
- purple_blist_add_chat(chat, group, NULL);
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->autojoin)))
- purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat), "gtk-autojoin", TRUE);
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->persistent)))
- purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat), "gtk-persistent", TRUE);
- }
-
- gtk_widget_destroy(data->chat_data.rq_data.window);
- g_free(data->chat_data.default_chat_name);
- g_list_free(data->chat_data.entries);
- g_free(data);
-}
-
-static void
-add_chat_resp_cb(GtkWidget *w, int resp, PidginAddChatData *data)
-{
- if (resp == GTK_RESPONSE_OK)
- {
- add_chat_cb(NULL, data);
- }
- else if (resp == 1)
- {
- pidgin_roomlist_dialog_show_with_account(data->chat_data.rq_data.account);
- }
- else
- {
- gtk_widget_destroy(data->chat_data.rq_data.window);
- g_free(data->chat_data.default_chat_name);
- g_list_free(data->chat_data.entries);
- g_free(data);
- }
-}
-
-static void
pidgin_blist_request_add_chat(PurpleBuddyList *list, PurpleAccount *account,
PurpleGroup *group, const char *alias,
const char *name)
{
- PidginAddChatData *data;
- GList *l;
- PurpleConnection *gc;
- GtkBox *vbox;
- PurpleProtocol *protocol = NULL;
-
- if (account != NULL) {
- gc = purple_account_get_connection(account);
- protocol = purple_connection_get_protocol(gc);
-
- if (!PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, join)) {
- purple_notify_error(gc, NULL, _("This protocol does not"
- " support chat rooms."), NULL,
- purple_request_cpar_from_account(account));
- return;
- }
- } else {
- /* Find an account with chat capabilities */
- for (l = purple_connections_get_all(); l != NULL; l = l->next) {
- gc = (PurpleConnection *)l->data;
- protocol = purple_connection_get_protocol(gc);
-
- if (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, join)) {
- account = purple_connection_get_account(gc);
- break;
- }
- }
-
- if (account == NULL) {
- purple_notify_error(NULL, NULL,
- _("You are not currently signed on with any "
- "protocols that have the ability to chat."), NULL, NULL);
- return;
- }
- }
-
- data = g_new0(PidginAddChatData, 1);
- vbox = GTK_BOX(make_blist_request_dialog((PidginBlistRequestData *)data, account,
- _("Add Chat"), "add_chat",
- _("Please enter an alias, and the appropriate information "
- "about the chat you would like to add to your buddy list.\n"),
- G_CALLBACK(chat_select_account_cb), chat_account_filter_func,
- G_CALLBACK(add_chat_resp_cb)));
- gtk_dialog_add_buttons(GTK_DIALOG(data->chat_data.rq_data.window),
- _("Room List"), 1,
- _("Cancel"), GTK_RESPONSE_CANCEL,
- _("Add"), GTK_RESPONSE_OK,
- NULL);
- gtk_dialog_set_default_response(GTK_DIALOG(data->chat_data.rq_data.window),
- GTK_RESPONSE_OK);
-
- data->chat_data.default_chat_name = g_strdup(name);
-
- rebuild_chat_entries((PidginChatData *)data, name);
-
- data->alias_entry = gtk_entry_new();
- if (alias != NULL)
- gtk_entry_set_text(GTK_ENTRY(data->alias_entry), alias);
- gtk_entry_set_activates_default(GTK_ENTRY(data->alias_entry), TRUE);
-
- pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("A_lias:"),
- data->chat_data.rq_data.sg, data->alias_entry,
- TRUE, NULL);
- if (name != NULL)
- gtk_widget_grab_focus(data->alias_entry);
-
- data->group_combo = pidgin_text_combo_box_entry_new(group ? purple_group_get_name(group) : NULL, groups_tree());
- pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_Group:"),
- data->chat_data.rq_data.sg, data->group_combo,
- TRUE, NULL);
+ GtkWidget *dialog = NULL;
- data->autojoin = gtk_check_button_new_with_mnemonic(_("Automatically _join when account connects"));
- data->persistent = gtk_check_button_new_with_mnemonic(_("_Remain in chat after window is closed"));
- gtk_box_pack_start(GTK_BOX(vbox), data->autojoin, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), data->persistent, FALSE, FALSE, 0);
+ dialog = pidgin_add_chat_dialog_new(account, group, alias, name);
- gtk_widget_show_all(data->chat_data.rq_data.window);
+ gtk_widget_show(dialog);
}
static void
diff --git a/pidgin/meson.build b/pidgin/meson.build
index 9d1d64a3df..e6ba754cca 100644
--- a/pidgin/meson.build
+++ b/pidgin/meson.build
@@ -28,6 +28,7 @@ libpidgin_SOURCES = [
'pidginaccountstore.c',
'pidginactiongroup.c',
'pidginaddbuddydialog.c',
+ 'pidginaddchatdialog.c',
'pidginapplication.c',
'pidginattachment.c',
'pidginavatar.c',
@@ -99,6 +100,7 @@ libpidgin_headers = [
'pidginaccountstore.h',
'pidginactiongroup.h',
'pidginaddbuddydialog.h',
+ 'pidginaddchatdialog.h',
'pidginapplication.h',
'pidginattachment.h',
'pidginavatar.h',
diff --git a/pidgin/pidginaddchatdialog.c b/pidgin/pidginaddchatdialog.c
new file mode 100644
index 0000000000..3dd5d2294f
--- /dev/null
+++ b/pidgin/pidginaddchatdialog.c
@@ -0,0 +1,464 @@
+/*
+ * 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 <glib/gi18n.h>
+
+#include "pidginaddchatdialog.h"
+
+#include "gtkaccount.h"
+#include "gtkroomlist.h"
+#include "pidginaccountchooser.h"
+#include "pidginaccountstore.h"
+#include "pidgincore.h"
+
+struct _PidginAddChatDialog {
+ GtkDialog parent;
+
+ GtkTreeModel *filter;
+
+ const gchar *default_name;
+
+ GtkWidget *account;
+ GtkWidget *dynamic_box;
+ GtkWidget *alias;
+ GtkWidget *group;
+ GtkWidget *autojoin;
+ GtkWidget *persistent;
+ GtkSizeGroup *sg;
+
+ GList *inputs;
+};
+
+G_DEFINE_TYPE(PidginAddChatDialog, pidgin_add_chat_dialog, GTK_TYPE_DIALOG)
+
+/* ugh, prototypes... */
+static void pidgin_add_chat_dialog_remove_widget_cb(GtkWidget *child, gpointer data);
+static void pidgin_add_chat_dialog_input_changed_cb(GtkEditable *editable, gpointer data);
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static void
+pidgin_add_chat_dialog_validate_input(gpointer data, gpointer user_data) {
+ gboolean *valid = user_data;
+
+ if(!g_object_get_data(data, "integer")) {
+ gboolean required = FALSE;
+
+ required = GPOINTER_TO_INT(g_object_get_data(data, "required"));
+ if(required) {
+ const gchar *value = NULL;
+
+ value = gtk_entry_get_text(GTK_ENTRY(data));
+ if(value == NULL || *value == '\0') {
+ *valid = FALSE;
+ }
+ }
+ }
+}
+
+static void
+pidgin_add_chat_dialog_validate(PidginAddChatDialog *dialog) {
+ gboolean valid = TRUE;
+
+ /* The callback should only set valid to FALSE if a field is invalid and
+ * not set valid if the field is valid.
+ */
+ g_list_foreach(dialog->inputs,
+ pidgin_add_chat_dialog_validate_input,
+ &valid);
+
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK,
+ valid);
+}
+
+static void
+pidgin_add_chat_dialog_update_components(PidginAddChatDialog *dialog) {
+ PurpleAccount *account = NULL;
+ PurpleConnection *connection = NULL;
+ PurpleProtocol *protocol = NULL;
+ GList *info = NULL;
+ GHashTable *defaults = NULL;
+ gboolean focus_set = FALSE;
+
+ account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(dialog->account));
+ connection = purple_account_get_connection(account);
+ protocol = purple_account_get_protocol(account);
+
+ /* Clean up the dynamic box and our list of entires. */
+ gtk_container_foreach(GTK_CONTAINER(dialog->dynamic_box),
+ pidgin_add_chat_dialog_remove_widget_cb,
+ dialog->dynamic_box);
+ g_clear_pointer(&dialog->inputs, g_list_free);
+
+ info = purple_protocol_chat_info(PURPLE_PROTOCOL_CHAT(protocol),
+ connection);
+ defaults = purple_protocol_chat_info_defaults(PURPLE_PROTOCOL_CHAT(protocol),
+ connection,
+ dialog->default_name);
+
+ while(info != NULL) {
+ GtkWidget *box = NULL, *label = NULL, *input = NULL;
+ PurpleProtocolChatEntry *pce = info->data;
+
+ if(pce->is_int) {
+ GtkAdjustment *adjustment = gtk_adjustment_new(pce->min, pce->min,
+ pce->max, 1, 10, 10);
+ input = gtk_spin_button_new(adjustment, 1, 0);
+ } else {
+ gchar *value = NULL;
+
+ input = gtk_entry_new();
+ g_signal_connect(input, "changed",
+ G_CALLBACK(pidgin_add_chat_dialog_input_changed_cb),
+ dialog);
+
+ value = g_hash_table_lookup(defaults, pce->identifier);
+ if(value != NULL) {
+ gtk_entry_set_text(GTK_ENTRY(input), value);
+ }
+
+ if(pce->secret) {
+ gtk_entry_set_visibility(GTK_ENTRY(input), FALSE);
+ gtk_entry_set_input_purpose(GTK_ENTRY(input),
+ GTK_INPUT_PURPOSE_PASSWORD);
+ }
+ }
+
+ box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_box_pack_start(GTK_BOX(dialog->dynamic_box), box, FALSE, FALSE, 0);
+
+ label = gtk_label_new_with_mnemonic(pce->label);
+ gtk_label_set_xalign(GTK_LABEL(label), 0.0f);
+ gtk_label_set_yalign(GTK_LABEL(label), 0.0f);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0);
+ gtk_size_group_add_widget(dialog->sg, label);
+
+ gtk_box_pack_start(GTK_BOX(box), input, TRUE, TRUE, 0);
+ if(!focus_set) {
+ gtk_widget_grab_focus(input);
+ focus_set = TRUE;
+ }
+
+ g_object_set_data(G_OBJECT(input), "identifier",
+ (gpointer)pce->identifier);
+ g_object_set_data(G_OBJECT(input), "integer",
+ GINT_TO_POINTER(pce->is_int));
+ g_object_set_data(G_OBJECT(input), "required",
+ GINT_TO_POINTER(pce->required));
+
+ dialog->inputs = g_list_append(dialog->inputs, input);
+
+ g_free(pce);
+
+ info = g_list_delete_link(info, info);
+ }
+
+ g_hash_table_destroy(defaults);
+
+ gtk_widget_show_all(dialog->dynamic_box);
+
+ pidgin_add_chat_dialog_validate(dialog);
+}
+
+static gboolean
+pidgin_add_chat_dialog_filter_accounts(GtkTreeModel *model, GtkTreeIter *iter,
+ gpointer data)
+{
+ PurpleAccount *account = NULL;
+ PurpleProtocol *protocol = NULL;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail(GTK_IS_TREE_MODEL(model), FALSE);
+ g_return_val_if_fail(iter != NULL, FALSE);
+
+ gtk_tree_model_get(model, iter, PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT,
+ &account, -1);
+
+ if(!PURPLE_IS_ACCOUNT(account)) {
+ return FALSE;
+ }
+
+ protocol = purple_account_get_protocol(account);
+ if(PURPLE_IS_PROTOCOL(protocol)) {
+ ret = PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, info);
+ }
+
+ g_object_unref(G_OBJECT(account));
+
+ return ret;
+}
+
+static void
+pidgin_add_chat_dialog_add_input_to_components(gpointer data,
+ gpointer user_data)
+{
+ GHashTable *components = user_data;
+ gchar *identifier = NULL;
+ gchar *value = NULL;
+
+ identifier = g_strdup(g_object_get_data(data, "identifier"));
+
+ if(g_object_get_data(data, "integer")) {
+ gint int_value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data));
+
+ value = g_strdup_printf("%d", int_value);
+ } else {
+ const gchar *str_value = gtk_entry_get_text(GTK_ENTRY(data));
+
+ if(*str_value != '\0') {
+ value = g_strdup(str_value);
+ }
+ }
+
+ /* If the value was changed to an empty string, we should remove it from the
+ * components.
+ */
+ if(value == NULL) {
+ g_hash_table_remove(components, identifier);
+ g_free(identifier);
+ } else {
+ g_hash_table_replace(components, identifier, value);
+ }
+}
+
+/******************************************************************************
+ * Callbacks
+ *****************************************************************************/
+static void
+pidgin_add_chat_dialog_input_changed_cb(G_GNUC_UNUSED GtkEditable *editable,
+ gpointer data)
+{
+ pidgin_add_chat_dialog_validate(data);
+}
+
+static void
+pidgin_add_chat_dialog_remove_widget_cb(GtkWidget *child, gpointer data) {
+ GtkContainer *parent = data;
+
+ gtk_container_remove(parent, child);
+}
+
+static void
+pidgin_add_chat_dialog_response_cb(GtkDialog *dialog, gint response_id,
+ G_GNUC_UNUSED gpointer data)
+{
+ PurpleAccount *account = NULL;
+ PidginAddChatDialog *acdialog = PIDGIN_ADD_CHAT_DIALOG(dialog);
+ gboolean close = TRUE;
+
+ account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(acdialog->account));
+
+ if(response_id == 1) {
+ pidgin_roomlist_dialog_show_with_account(account);
+
+ close = FALSE;
+ } else if(response_id == GTK_RESPONSE_OK) {
+ PurpleChat *chat = NULL;
+ GHashTable *components = NULL;
+ const gchar *alias = NULL;
+
+ components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+ g_free);
+ g_list_foreach(acdialog->inputs,
+ pidgin_add_chat_dialog_add_input_to_components,
+ components);
+
+ alias = gtk_entry_get_text(GTK_ENTRY(acdialog->alias));
+
+ chat = purple_chat_new(account, alias, components);
+
+ if(PURPLE_IS_CHAT(chat)) {
+ PurpleGroup *group = NULL;
+ gchar *group_name = NULL;
+
+ group_name = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(acdialog->group));
+ if(group_name != NULL && *group_name != '\0') {
+ group = purple_blist_find_group(group_name);
+ }
+
+ if(!PURPLE_IS_GROUP(group)) {
+ group = purple_group_new(group_name);
+ purple_blist_add_group(group, NULL);
+ }
+
+ purple_blist_add_chat(chat, group, NULL);
+
+ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(acdialog->autojoin))) {
+ purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat),
+ "gtk-autojoin", TRUE);
+ }
+ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(acdialog->persistent))) {
+ purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat),
+ "gtk-persistent", TRUE);
+ }
+
+ g_free(group_name);
+ } else {
+ g_warning("failed to create chat");
+ }
+ }
+
+ if(close) {
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+ }
+}
+
+static void
+pidgin_add_chat_dialog_account_changed_cb(GtkComboBox *widget, gpointer data) {
+ PidginAddChatDialog *dialog = data;
+ PurpleAccount *account = NULL;
+
+ account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(widget));
+
+ if(PURPLE_IS_ACCOUNT(account)) {
+ PurpleProtocol *protocol = purple_account_get_protocol(account);
+
+ if(PURPLE_IS_PROTOCOL(protocol)) {
+ gboolean roomlist = FALSE;
+
+ roomlist = PURPLE_PROTOCOL_IMPLEMENTS(protocol, ROOMLIST, get_list);
+
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 1, roomlist);
+ }
+ }
+
+ pidgin_add_chat_dialog_update_components(dialog);
+
+ pidgin_add_chat_dialog_validate(dialog);
+}
+
+static void
+pidgin_add_chat_dialog_username_changed_cb(G_GNUC_UNUSED GtkEditable *editable,
+ gpointer data)
+{
+ pidgin_add_chat_dialog_validate(data);
+}
+
+static void
+pidgin_add_chat_dialog_group_cb(PurpleBlistNode *node, gpointer data) {
+ PidginAddChatDialog *dialog = data;
+ PurpleGroup *group = PURPLE_GROUP(node);
+
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(dialog->group),
+ purple_group_get_name(group));
+}
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+static void
+pidgin_add_chat_dialog_finalize(GObject *obj) {
+ PidginAddChatDialog *dialog = PIDGIN_ADD_CHAT_DIALOG(obj);
+
+ g_list_free(dialog->inputs);
+
+ G_OBJECT_CLASS(pidgin_add_chat_dialog_parent_class)->finalize(obj);
+}
+
+static void
+pidgin_add_chat_dialog_init(PidginAddChatDialog *dialog) {
+ gtk_widget_init_template(GTK_WIDGET(dialog));
+
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
+
+ gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(dialog->filter),
+ pidgin_add_chat_dialog_filter_accounts,
+ NULL, NULL);
+ gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(dialog->filter));
+
+ gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->account), 0);
+
+ purple_blist_walk(pidgin_add_chat_dialog_group_cb, NULL, NULL, NULL,
+ dialog);
+}
+
+static void
+pidgin_add_chat_dialog_class_init(PidginAddChatDialogClass *klass) {
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+ obj_class->finalize = pidgin_add_chat_dialog_finalize;
+
+ gtk_widget_class_set_template_from_resource(
+ widget_class,
+ "/im/pidgin/Pidgin3/Dialogs/addchat.ui"
+ );
+
+ gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
+ filter);
+
+ gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
+ account);
+ gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
+ dynamic_box);
+ gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
+ alias);
+ gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
+ group);
+ gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
+ autojoin);
+ gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
+ persistent);
+ gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
+ sg);
+
+ gtk_widget_class_bind_template_callback(widget_class,
+ pidgin_add_chat_dialog_response_cb);
+ gtk_widget_class_bind_template_callback(widget_class,
+ pidgin_add_chat_dialog_account_changed_cb);
+ gtk_widget_class_bind_template_callback(widget_class,
+ pidgin_add_chat_dialog_username_changed_cb);
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+GtkWidget *
+pidgin_add_chat_dialog_new(PurpleAccount *account, PurpleGroup *group,
+ const gchar *alias, const gchar *name)
+{
+ GtkWidget *dialog = g_object_new(PIDGIN_TYPE_ADD_CHAT_DIALOG, NULL);
+ PidginAddChatDialog *acdialog = PIDGIN_ADD_CHAT_DIALOG(dialog);
+
+ if(PURPLE_IS_ACCOUNT(account)) {
+ pidgin_account_chooser_set_selected(PIDGIN_ACCOUNT_CHOOSER(acdialog->account),
+ account);
+ }
+
+ if(alias != NULL) {
+ gtk_entry_set_text(GTK_ENTRY(acdialog->alias), alias);
+ }
+
+ if(PURPLE_IS_GROUP(group)) {
+ GtkWidget *entry = NULL;
+
+ entry = gtk_bin_get_child(GTK_BIN(acdialog->group));
+ gtk_entry_set_text(GTK_ENTRY(entry), purple_group_get_name(group));
+ }
+
+ acdialog->default_name = name;
+
+ pidgin_add_chat_dialog_update_components(acdialog);
+
+ return dialog;
+}
diff --git a/pidgin/pidginaddchatdialog.h b/pidgin/pidginaddchatdialog.h
new file mode 100644
index 0000000000..55dc18649b
--- /dev/null
+++ b/pidgin/pidginaddchatdialog.h
@@ -0,0 +1,65 @@
+/*
+ * 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_ADD_CHAT_DIALOG_H
+#define PIDGIN_ADD_CHAT_DIALOG_H
+
+#include <gtk/gtk.h>
+
+#include <purple.h>
+
+G_BEGIN_DECLS
+
+/**
+ * PidginAddChatDialog:
+ *
+ * A dialog for adding chats to your contact list.
+ *
+ * Since: 3.0.0
+ */
+
+#define PIDGIN_TYPE_ADD_CHAT_DIALOG (pidgin_add_chat_dialog_get_type())
+G_DECLARE_FINAL_TYPE(PidginAddChatDialog, pidgin_add_chat_dialog, PIDGIN,
+ ADD_CHAT_DIALOG, GtkDialog)
+
+/**
+ * pidgin_add_chat_dialog_new:
+ * @account: (nullable): The [class@Purple.Account] to pre-select.
+ * @group: (nullable): The [class@Purple.Group] to pre-fill.
+ * @alias: (nullable): The alias to pre-fill.
+ * @name: (nullable): The name of the chat to pre-fill.
+ *
+ * Creates an add chat dialog with the pre-filled optional values.
+ *
+ * Returns: (transfer full): The widget.
+ *
+ * Since: 3.0.0
+ */
+GtkWidget *pidgin_add_chat_dialog_new(PurpleAccount *account, PurpleGroup *group, const gchar *alias, const gchar *name);
+
+G_END_DECLS
+
+#endif /* PIDGIN_ADD_CHAT_DIALOG_H */
diff --git a/pidgin/resources/Dialogs/addchat.ui b/pidgin/resources/Dialogs/addchat.ui
new file mode 100644
index 0000000000..54e2e6dd1d
--- /dev/null
+++ b/pidgin/resources/Dialogs/addchat.ui
@@ -0,0 +1,302 @@
+<?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="pidgin" version="3.0"/>
+ <!-- interface-license-type gplv2 -->
+ <!-- interface-name Pidgin -->
+ <!-- interface-description Internet Messenger -->
+ <!-- interface-copyright Pidgin Developers <devel@pidgin.im> -->
+ <object class="PidginAccountStore" id="account_store"/>
+ <object class="PidginAccountFilterConnected" id="account_filter_connected">
+ <property name="child-model">account_store</property>
+ </object>
+ <object class="GtkTreeModelFilter" id="filter">
+ <property name="child-model">account_filter_connected</property>
+ </object>
+ <template class="PidginAddChatDialog" parent="GtkDialog">
+ <property name="can-focus">False</property>
+ <property name="border-width">12</property>
+ <property name="title" translatable="yes">Add Chat</property>
+ <property name="resizable">False</property>
+ <property name="type-hint">dialog</property>
+ <signal name="response" handler="pidgin_add_chat_dialog_response_cb" swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">Please enter an alias, and the appropriate information about the chat you would like to add to your buddy list.</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="spacer">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">A_ccount:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">account</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="PidginAccountChooser" id="account">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="model">filter</property>
+ <signal name="changed" handler="pidgin_add_chat_dialog_account_changed_cb" object="PidginAddChatDialog" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="dynamic_box">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">A_lias:</property>
+ <property name="use-underline">True</property>
+ <property name="mnemonic-widget">alias</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="alias">
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="label" translatable="yes">_Group:</property>
+ <property name="use-underline">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="group">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="has-entry">True</property>
+ <child internal-child="entry">
+ <object class="GtkEntry">
+ <property name="can-focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="autojoin">
+ <property name="label" translatable="yes">Automatically _join when account connects</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="halign">start</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="persistent">
+ <property name="label" translatable="yes">_Remain in chat after window is closed</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="halign">start</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">7</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="button3">
+ <property name="label" translatable="yes">Room List</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="button1">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="button2">
+ <property name="label" translatable="yes">_Add</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can-focus">True</property>
+ <property name="can-default">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="1">button3</action-widget>
+ <action-widget response="-6">button1</action-widget>
+ <action-widget response="-5">button2</action-widget>
+ </action-widgets>
+ </template>
+ <object class="GtkSizeGroup" id="sg">
+ <widgets>
+ <widget name="label1"/>
+ <widget name="label4"/>
+ <widget name="label5"/>
+ </widgets>
+ </object>
+</interface>
diff --git a/pidgin/resources/pidgin.gresource.xml b/pidgin/resources/pidgin.gresource.xml
index ad4b0df799..0a0c298d97 100644
--- a/pidgin/resources/pidgin.gresource.xml
+++ b/pidgin/resources/pidgin.gresource.xml
@@ -20,6 +20,7 @@
<file compressed="true">Debug/filter.css</file>
<file compressed="true">Debug/plugininfo.ui</file>
<file compressed="true">Dialogs/addbuddy.ui</file>
+ <file compressed="true">Dialogs/addchat.ui</file>
<file compressed="true">Keypad/keypad.ui</file>
<file compressed="true">Log/log-viewer.ui</file>
<file compressed="true">Media/window.ui</file>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6c474dbe65..84c55f3fd3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -344,6 +344,7 @@ pidgin/pidginaccountsenabledmenu.c
pidgin/pidginaccountstore.c
pidgin/pidginactiongroup.c
pidgin/pidginaddbuddydialog.c
+pidgin/pidginaddchatdialog.c
pidgin/pidginapplication.c
pidgin/pidginattachment.c
pidgin/pidginavatar.c
@@ -409,6 +410,7 @@ pidgin/resources/Conversations/window.ui
pidgin/resources/Debug/debug.ui
pidgin/resources/Debug/plugininfo.ui
pidgin/resources/Dialogs/addbuddy.ui
+pidgin/resources/Dialogs/addchat.ui
pidgin/resources/Keypad/keypad.ui
pidgin/resources/Log/log-viewer.ui
pidgin/resources/Media/window.ui