pidgin/pidginaddchatdialog.c

Mon, 12 Sep 2022 22:08:59 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 12 Sep 2022 22:08:59 -0500
changeset 41679
ddd97cdcbefc
parent 41629
f617ffec2950
child 41854
c1d7e7445b0f
permissions
-rw-r--r--

Remove the list_icon vfunc from PurpleProtocol.

This was replaced by the icon-name, icon-resource-path, and icon-search-path
properties.

Testing Done:
Compiled

Reviewed at https://reviews.imfreedom.org/r/1749/

41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n.h>
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "pidginaddchatdialog.h"
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "gtkaccount.h"
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 #include "gtkroomlist.h"
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 #include "pidginaccountchooser.h"
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 #include "pidginaccountstore.h"
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 #include "pidgincore.h"
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 struct _PidginAddChatDialog {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 GtkDialog parent;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 GtkTreeModel *filter;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 const gchar *default_name;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 GtkWidget *account;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 GtkWidget *dynamic_box;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 GtkWidget *alias;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 GtkWidget *group;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 GtkWidget *autojoin;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 GtkWidget *persistent;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 GtkSizeGroup *sg;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 GList *inputs;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 };
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 G_DEFINE_TYPE(PidginAddChatDialog, pidgin_add_chat_dialog, GTK_TYPE_DIALOG)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 /* ugh, prototypes... */
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 static void pidgin_add_chat_dialog_input_changed_cb(GtkEditable *editable, gpointer data);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 /******************************************************************************
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 * Helpers
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 *****************************************************************************/
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 pidgin_add_chat_dialog_validate_input(gpointer data, gpointer user_data) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 gboolean *valid = user_data;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 if(!g_object_get_data(data, "integer")) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 gboolean required = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 required = GPOINTER_TO_INT(g_object_get_data(data, "required"));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 if(required) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 const gchar *value = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
70 value = gtk_editable_get_text(GTK_EDITABLE(data));
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 if(value == NULL || *value == '\0') {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 *valid = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 pidgin_add_chat_dialog_validate(PidginAddChatDialog *dialog) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 gboolean valid = TRUE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 /* The callback should only set valid to FALSE if a field is invalid and
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 * not set valid if the field is valid.
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 */
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 g_list_foreach(dialog->inputs,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 pidgin_add_chat_dialog_validate_input,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 &valid);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 valid);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 pidgin_add_chat_dialog_update_components(PidginAddChatDialog *dialog) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 PurpleAccount *account = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 PurpleConnection *connection = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 PurpleProtocol *protocol = NULL;
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
98 GtkWidget *child = NULL;
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 GList *info = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 GHashTable *defaults = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 gboolean focus_set = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(dialog->account));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 connection = purple_account_get_connection(account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 protocol = purple_account_get_protocol(account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 /* Clean up the dynamic box and our list of entires. */
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
108 while((child = gtk_widget_get_first_child(dialog->dynamic_box)) != NULL) {
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
109 gtk_box_remove(GTK_BOX(dialog->dynamic_box), child);
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
110 }
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 g_clear_pointer(&dialog->inputs, g_list_free);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 info = purple_protocol_chat_info(PURPLE_PROTOCOL_CHAT(protocol),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 connection);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 defaults = purple_protocol_chat_info_defaults(PURPLE_PROTOCOL_CHAT(protocol),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 connection,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 dialog->default_name);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 while(info != NULL) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 GtkWidget *box = NULL, *label = NULL, *input = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 PurpleProtocolChatEntry *pce = info->data;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 if(pce->is_int) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 GtkAdjustment *adjustment = gtk_adjustment_new(pce->min, pce->min,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 pce->max, 1, 10, 10);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 input = gtk_spin_button_new(adjustment, 1, 0);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 } else {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 gchar *value = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 input = gtk_entry_new();
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 g_signal_connect(input, "changed",
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 G_CALLBACK(pidgin_add_chat_dialog_input_changed_cb),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 value = g_hash_table_lookup(defaults, pce->identifier);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 if(value != NULL) {
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
137 gtk_editable_set_text(GTK_EDITABLE(input), value);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 if(pce->secret) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 gtk_entry_set_visibility(GTK_ENTRY(input), FALSE);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 gtk_entry_set_input_purpose(GTK_ENTRY(input),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 GTK_INPUT_PURPOSE_PASSWORD);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
148 gtk_box_append(GTK_BOX(dialog->dynamic_box), box);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 label = gtk_label_new_with_mnemonic(pce->label);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 gtk_label_set_xalign(GTK_LABEL(label), 0.0f);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 gtk_label_set_yalign(GTK_LABEL(label), 0.0f);
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
153 gtk_box_append(GTK_BOX(box), label);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 gtk_size_group_add_widget(dialog->sg, label);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
156 gtk_widget_set_hexpand(input, TRUE);
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
157 gtk_box_append(GTK_BOX(box), input);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 if(!focus_set) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 gtk_widget_grab_focus(input);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 focus_set = TRUE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 g_object_set_data(G_OBJECT(input), "identifier",
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 (gpointer)pce->identifier);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 g_object_set_data(G_OBJECT(input), "integer",
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 GINT_TO_POINTER(pce->is_int));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 g_object_set_data(G_OBJECT(input), "required",
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 GINT_TO_POINTER(pce->required));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 dialog->inputs = g_list_append(dialog->inputs, input);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 g_free(pce);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 info = g_list_delete_link(info, info);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 g_hash_table_destroy(defaults);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 pidgin_add_chat_dialog_validate(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 static gboolean
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 pidgin_add_chat_dialog_filter_accounts(GtkTreeModel *model, GtkTreeIter *iter,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 gpointer data)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 PurpleAccount *account = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 PurpleProtocol *protocol = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 gboolean ret = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 g_return_val_if_fail(GTK_IS_TREE_MODEL(model), FALSE);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 g_return_val_if_fail(iter != NULL, FALSE);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 gtk_tree_model_get(model, iter, PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 &account, -1);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 if(!PURPLE_IS_ACCOUNT(account)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 return FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 protocol = purple_account_get_protocol(account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 if(PURPLE_IS_PROTOCOL(protocol)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 ret = PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, info);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 g_object_unref(G_OBJECT(account));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 return ret;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 pidgin_add_chat_dialog_add_input_to_components(gpointer data,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 gpointer user_data)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 GHashTable *components = user_data;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 gchar *identifier = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 gchar *value = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 identifier = g_strdup(g_object_get_data(data, "identifier"));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 if(g_object_get_data(data, "integer")) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 gint int_value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 value = g_strdup_printf("%d", int_value);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 } else {
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
225 const gchar *str_value = gtk_editable_get_text(GTK_EDITABLE(data));
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 if(*str_value != '\0') {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 value = g_strdup(str_value);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 /* If the value was changed to an empty string, we should remove it from the
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 * components.
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 */
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 if(value == NULL) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 g_hash_table_remove(components, identifier);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 g_free(identifier);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 } else {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 g_hash_table_replace(components, identifier, value);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 /******************************************************************************
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 * Callbacks
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 *****************************************************************************/
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 pidgin_add_chat_dialog_input_changed_cb(G_GNUC_UNUSED GtkEditable *editable,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 gpointer data)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 pidgin_add_chat_dialog_validate(data);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 pidgin_add_chat_dialog_response_cb(GtkDialog *dialog, gint response_id,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 G_GNUC_UNUSED gpointer data)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 PurpleAccount *account = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 PidginAddChatDialog *acdialog = PIDGIN_ADD_CHAT_DIALOG(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 gboolean close = TRUE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(acdialog->account));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 if(response_id == 1) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 pidgin_roomlist_dialog_show_with_account(account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 close = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 } else if(response_id == GTK_RESPONSE_OK) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 PurpleChat *chat = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 GHashTable *components = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 const gchar *alias = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 g_free);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 g_list_foreach(acdialog->inputs,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 pidgin_add_chat_dialog_add_input_to_components,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 components);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
278 alias = gtk_editable_get_text(GTK_EDITABLE(acdialog->alias));
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 chat = purple_chat_new(account, alias, components);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 if(PURPLE_IS_CHAT(chat)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 PurpleGroup *group = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 gchar *group_name = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 group_name = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(acdialog->group));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 if(group_name != NULL && *group_name != '\0') {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 group = purple_blist_find_group(group_name);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 if(!PURPLE_IS_GROUP(group)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 group = purple_group_new(group_name);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 purple_blist_add_group(group, NULL);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 purple_blist_add_chat(chat, group, NULL);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(acdialog->autojoin))) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 "gtk-autojoin", TRUE);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(acdialog->persistent))) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 "gtk-persistent", TRUE);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 g_free(group_name);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 } else {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 g_warning("failed to create chat");
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 if(close) {
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
314 gtk_window_destroy(GTK_WINDOW(dialog));
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 pidgin_add_chat_dialog_account_changed_cb(GtkComboBox *widget, gpointer data) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 PidginAddChatDialog *dialog = data;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 PurpleAccount *account = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(widget));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 if(PURPLE_IS_ACCOUNT(account)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 PurpleProtocol *protocol = purple_account_get_protocol(account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 if(PURPLE_IS_PROTOCOL(protocol)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 gboolean roomlist = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331 roomlist = PURPLE_PROTOCOL_IMPLEMENTS(protocol, ROOMLIST, get_list);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 1, roomlist);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 pidgin_add_chat_dialog_update_components(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 pidgin_add_chat_dialog_validate(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 pidgin_add_chat_dialog_username_changed_cb(G_GNUC_UNUSED GtkEditable *editable,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 gpointer data)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 pidgin_add_chat_dialog_validate(data);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 pidgin_add_chat_dialog_group_cb(PurpleBlistNode *node, gpointer data) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 PidginAddChatDialog *dialog = data;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 PurpleGroup *group = PURPLE_GROUP(node);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(dialog->group),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 purple_group_get_name(group));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 /******************************************************************************
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359 * GObject Implementation
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 *****************************************************************************/
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 pidgin_add_chat_dialog_finalize(GObject *obj) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 PidginAddChatDialog *dialog = PIDGIN_ADD_CHAT_DIALOG(obj);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 g_list_free(dialog->inputs);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 G_OBJECT_CLASS(pidgin_add_chat_dialog_parent_class)->finalize(obj);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 pidgin_add_chat_dialog_init(PidginAddChatDialog *dialog) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 gtk_widget_init_template(GTK_WIDGET(dialog));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(dialog->filter),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 pidgin_add_chat_dialog_filter_accounts,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 NULL, NULL);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(dialog->filter));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->account), 0);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 purple_blist_walk(pidgin_add_chat_dialog_group_cb, NULL, NULL, NULL,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388 pidgin_add_chat_dialog_class_init(PidginAddChatDialogClass *klass) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 obj_class->finalize = pidgin_add_chat_dialog_finalize;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 gtk_widget_class_set_template_from_resource(
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 widget_class,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 "/im/pidgin/Pidgin3/Dialogs/addchat.ui"
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 );
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400 filter);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
401
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403 account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
405 dynamic_box);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 alias);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 group);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411 autojoin);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413 persistent);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 sg);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
416
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
417 gtk_widget_class_bind_template_callback(widget_class,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418 pidgin_add_chat_dialog_response_cb);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
419 gtk_widget_class_bind_template_callback(widget_class,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420 pidgin_add_chat_dialog_account_changed_cb);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421 gtk_widget_class_bind_template_callback(widget_class,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
422 pidgin_add_chat_dialog_username_changed_cb);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
423 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
424
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
425 /******************************************************************************
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
426 * Public API
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
427 *****************************************************************************/
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428 GtkWidget *
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429 pidgin_add_chat_dialog_new(PurpleAccount *account, PurpleGroup *group,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430 const gchar *alias, const gchar *name)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
431 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
432 GtkWidget *dialog = g_object_new(PIDGIN_TYPE_ADD_CHAT_DIALOG, NULL);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 PidginAddChatDialog *acdialog = PIDGIN_ADD_CHAT_DIALOG(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
434
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
435 if(PURPLE_IS_ACCOUNT(account)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
436 pidgin_account_chooser_set_selected(PIDGIN_ACCOUNT_CHOOSER(acdialog->account),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437 account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
439
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
440 if(alias != NULL) {
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
441 gtk_editable_set_text(GTK_EDITABLE(acdialog->alias), alias);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444 if(PURPLE_IS_GROUP(group)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
445 GtkWidget *entry = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
446
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
447 entry = gtk_combo_box_get_child(GTK_COMBO_BOX(acdialog->group));
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
448 gtk_editable_set_text(GTK_EDITABLE(entry),
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
449 purple_group_get_name(group));
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
450 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
451
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
452 acdialog->default_name = name;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
453
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
454 pidgin_add_chat_dialog_update_components(acdialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
455
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456 return dialog;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457 }

mercurial