pidgin/pidginaddchatdialog.c

Mon, 05 Dec 2022 05:31:22 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 05 Dec 2022 05:31:22 -0600
changeset 41958
76d1633b8ec0
parent 41901
55a099a1e619
child 42231
e322f1f3f5c7
permissions
-rw-r--r--

Remove the privacy api

This API has been needing a rewrite for as long as I've been working on Gaim /
Pidgin and nothing has come of it. Therefore, I'm am removing it for a much
more simplified approach in the future.

Testing Done:
Sent some messages with the demo protocol plugin.

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

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 "pidgincore.h"
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 struct _PidginAddChatDialog {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 GtkDialog parent;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
35 GtkCustomFilter *filter;
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 const gchar *default_name;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 GtkWidget *account;
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
40 GtkWidget *dynamic_group;
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 GtkWidget *alias;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 GtkWidget *group;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 GtkWidget *autojoin;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 GtkWidget *persistent;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
46 GList *rows;
41508
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
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 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
50
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 /* ugh, prototypes... */
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 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
53
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 /******************************************************************************
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 * Helpers
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 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 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
59 gboolean *valid = user_data;
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
60 gboolean required = FALSE;
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
62 required = GPOINTER_TO_INT(g_object_get_data(data, "required"));
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
63 if(required) {
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
64 const gchar *value = gtk_editable_get_text(GTK_EDITABLE(data));
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
66 if(value == NULL || *value == '\0') {
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
67 *valid = FALSE;
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
68 } else if(g_object_get_data(data, "integer")) {
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
69 gint int_value = atoi(value);
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
70 char *str_value = g_strdup_printf("%d", int_value);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
72 if(!purple_strequal(value, str_value)) {
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 *valid = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
75
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
76 g_free(str_value);
41508
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 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 pidgin_add_chat_dialog_validate(PidginAddChatDialog *dialog) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 gboolean valid = TRUE;
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 /* 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
86 * not set valid if the field is valid.
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 */
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
88 g_list_foreach(dialog->rows,
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 pidgin_add_chat_dialog_validate_input,
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 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
93 valid);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 pidgin_add_chat_dialog_update_components(PidginAddChatDialog *dialog) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 PurpleAccount *account = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 PurpleConnection *connection = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 PurpleProtocol *protocol = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 GList *info = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 GHashTable *defaults = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 gboolean focus_set = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
105 /* Clean up the dynamic group and our list of rows. */
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
106 while(dialog->rows != NULL) {
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
107 adw_preferences_group_remove(ADW_PREFERENCES_GROUP(dialog->dynamic_group),
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
108 dialog->rows->data);
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
109 dialog->rows = g_list_delete_link(dialog->rows, dialog->rows);
41563
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
41860
9315e7772780 Fix criticals when opening Add a Chat dialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
112 account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(dialog->account));
9315e7772780 Fix criticals when opening Add a Chat dialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
113 if(!PURPLE_IS_ACCOUNT(account)) {
9315e7772780 Fix criticals when opening Add a Chat dialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
114 return;
9315e7772780 Fix criticals when opening Add a Chat dialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
115 }
9315e7772780 Fix criticals when opening Add a Chat dialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
116
9315e7772780 Fix criticals when opening Add a Chat dialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
117 connection = purple_account_get_connection(account);
9315e7772780 Fix criticals when opening Add a Chat dialog
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41854
diff changeset
118 protocol = purple_account_get_protocol(account);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 info = purple_protocol_chat_info(PURPLE_PROTOCOL_CHAT(protocol),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 connection);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 defaults = purple_protocol_chat_info_defaults(PURPLE_PROTOCOL_CHAT(protocol),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 connection,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 dialog->default_name);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 while(info != NULL) {
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
126 GtkWidget *row = NULL;
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 PurpleProtocolChatEntry *pce = info->data;
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
128 char *value = NULL;
41508
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 if(pce->is_int) {
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
131 row = adw_entry_row_new();
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
132 adw_entry_row_set_input_purpose(ADW_ENTRY_ROW(row),
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
133 GTK_INPUT_PURPOSE_NUMBER);
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
134 } else if(pce->secret) {
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
135 row = adw_password_entry_row_new();
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 } else {
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
137 row = adw_entry_row_new();
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
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
140 value = g_hash_table_lookup(defaults, pce->identifier);
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
141 if(value != NULL) {
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
142 gtk_editable_set_text(GTK_EDITABLE(row), value);
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
143 }
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
144
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
145 g_signal_connect(row, "changed",
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
146 G_CALLBACK(pidgin_add_chat_dialog_input_changed_cb),
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
147 dialog);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
149 adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), pce->label);
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
150 adw_preferences_row_set_use_underline(ADW_PREFERENCES_ROW(row), TRUE);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
152 adw_preferences_group_add(ADW_PREFERENCES_GROUP(dialog->dynamic_group),
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
153 row);
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
154
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 if(!focus_set) {
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
156 gtk_widget_grab_focus(row);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 focus_set = TRUE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
160 g_object_set_data(G_OBJECT(row), "identifier",
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 (gpointer)pce->identifier);
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
162 g_object_set_data(G_OBJECT(row), "integer",
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 GINT_TO_POINTER(pce->is_int));
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
164 g_object_set_data(G_OBJECT(row), "required",
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 GINT_TO_POINTER(pce->required));
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
167 dialog->rows = g_list_append(dialog->rows, row);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 g_free(pce);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 info = g_list_delete_link(info, info);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 }
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 g_hash_table_destroy(defaults);
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 pidgin_add_chat_dialog_validate(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 }
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 static gboolean
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
180 pidgin_add_chat_dialog_filter_accounts(gpointer item,
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
181 G_GNUC_UNUSED gpointer data)
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 gboolean ret = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
185 if(PURPLE_IS_ACCOUNT(item)) {
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
186 PurpleAccount *account = PURPLE_ACCOUNT(item);
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
187 PurpleProtocol *protocol = purple_account_get_protocol(account);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
189 if(PURPLE_IS_PROTOCOL(protocol)) {
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
190 ret = PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, info);
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
191 }
41508
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
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 return ret;
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
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 pidgin_add_chat_dialog_add_input_to_components(gpointer data,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 gpointer user_data)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 GHashTable *components = user_data;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 gchar *identifier = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 gchar *value = NULL;
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 identifier = g_strdup(g_object_get_data(data, "identifier"));
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 if(g_object_get_data(data, "integer")) {
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
208 const char *str_value = gtk_editable_get_text(GTK_EDITABLE(data));
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
209 gint int_value = atoi(str_value);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 value = g_strdup_printf("%d", int_value);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 } else {
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
213 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
214
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 if(*str_value != '\0') {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 value = g_strdup(str_value);
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 }
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 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
221 * components.
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 if(value == NULL) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 g_hash_table_remove(components, identifier);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 g_free(identifier);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 } else {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 g_hash_table_replace(components, identifier, value);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 }
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 * Callbacks
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 *****************************************************************************/
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 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
236 gpointer data)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 pidgin_add_chat_dialog_validate(data);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 }
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 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 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
243 G_GNUC_UNUSED gpointer data)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 PurpleAccount *account = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 PidginAddChatDialog *acdialog = PIDGIN_ADD_CHAT_DIALOG(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 gboolean close = TRUE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 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
250
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 if(response_id == 1) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 pidgin_roomlist_dialog_show_with_account(account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 close = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 } else if(response_id == GTK_RESPONSE_OK) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 PurpleChat *chat = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 GHashTable *components = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 const gchar *alias = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 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
261 g_free);
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
262 g_list_foreach(acdialog->rows,
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 pidgin_add_chat_dialog_add_input_to_components,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 components);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
266 alias = gtk_editable_get_text(GTK_EDITABLE(acdialog->alias));
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 chat = purple_chat_new(account, alias, components);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 if(PURPLE_IS_CHAT(chat)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 PurpleGroup *group = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 gchar *group_name = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 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
275 if(group_name != NULL && *group_name != '\0') {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 group = purple_blist_find_group(group_name);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 if(!PURPLE_IS_GROUP(group)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 group = purple_group_new(group_name);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 purple_blist_add_group(group, NULL);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 purple_blist_add_chat(chat, group, NULL);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
286 if(gtk_switch_get_active(GTK_SWITCH(acdialog->autojoin))) {
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 "gtk-autojoin", TRUE);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 }
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
290 if(gtk_switch_get_active(GTK_SWITCH(acdialog->persistent))) {
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 purple_blist_node_set_bool(PURPLE_BLIST_NODE(chat),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 "gtk-persistent", TRUE);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 }
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 g_free(group_name);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 } else {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 g_warning("failed to create chat");
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 if(close) {
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
302 gtk_window_destroy(GTK_WINDOW(dialog));
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 }
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 static void
41854
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41629
diff changeset
307 pidgin_add_chat_dialog_account_changed_cb(GObject *obj,
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41629
diff changeset
308 G_GNUC_UNUSED GParamSpec *pspec,
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41629
diff changeset
309 gpointer data)
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41629
diff changeset
310 {
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 PidginAddChatDialog *dialog = data;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 PurpleAccount *account = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313
41854
c1d7e7445b0f Avoid GtkComboBox-isms with PidginAccountChooser
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41629
diff changeset
314 account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(obj));
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 if(PURPLE_IS_ACCOUNT(account)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 PurpleProtocol *protocol = purple_account_get_protocol(account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 if(PURPLE_IS_PROTOCOL(protocol)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 gboolean roomlist = FALSE;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 roomlist = PURPLE_PROTOCOL_IMPLEMENTS(protocol, ROOMLIST, get_list);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), 1, roomlist);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 }
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 pidgin_add_chat_dialog_update_components(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 pidgin_add_chat_dialog_validate(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331 }
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 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 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
335 gpointer data)
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_validate(data);
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
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 pidgin_add_chat_dialog_group_cb(PurpleBlistNode *node, gpointer data) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 PidginAddChatDialog *dialog = data;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 PurpleGroup *group = PURPLE_GROUP(node);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 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
346 purple_group_get_name(group));
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 /******************************************************************************
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 * GObject Implementation
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 *****************************************************************************/
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 pidgin_add_chat_dialog_finalize(GObject *obj) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 PidginAddChatDialog *dialog = PIDGIN_ADD_CHAT_DIALOG(obj);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
356 g_list_free(dialog->rows);
41508
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 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
359 }
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_init(PidginAddChatDialog *dialog) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 gtk_widget_init_template(GTK_WIDGET(dialog));
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 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
366
41864
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
367 gtk_custom_filter_set_filter_func(dialog->filter,
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
368 pidgin_add_chat_dialog_filter_accounts,
6f490dec468f Move PidginAccountChooser to GtkDropDown
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41860
diff changeset
369 NULL, NULL);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 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
372 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
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 static void
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 pidgin_add_chat_dialog_class_init(PidginAddChatDialogClass *klass) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380 obj_class->finalize = pidgin_add_chat_dialog_finalize;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 gtk_widget_class_set_template_from_resource(
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 widget_class,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 "/im/pidgin/Pidgin3/Dialogs/addchat.ui"
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 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388 filter);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391 account);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
41901
55a099a1e619 Modernize add buddy/chat dialogs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41864
diff changeset
393 dynamic_group);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 alias);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 group);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399 autojoin);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400 gtk_widget_class_bind_template_child(widget_class, PidginAddChatDialog,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
401 persistent);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403 gtk_widget_class_bind_template_callback(widget_class,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404 pidgin_add_chat_dialog_response_cb);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
405 gtk_widget_class_bind_template_callback(widget_class,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 pidgin_add_chat_dialog_account_changed_cb);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 gtk_widget_class_bind_template_callback(widget_class,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408 pidgin_add_chat_dialog_username_changed_cb);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411 /******************************************************************************
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 * Public API
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413 *****************************************************************************/
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414 GtkWidget *
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 pidgin_add_chat_dialog_new(PurpleAccount *account, PurpleGroup *group,
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
416 const gchar *alias, const gchar *name)
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
417 {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418 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
419 PidginAddChatDialog *acdialog = PIDGIN_ADD_CHAT_DIALOG(dialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421 if(PURPLE_IS_ACCOUNT(account)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
422 pidgin_account_chooser_set_selected(PIDGIN_ACCOUNT_CHOOSER(acdialog->account),
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
423 account);
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 if(alias != NULL) {
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
427 gtk_editable_set_text(GTK_EDITABLE(acdialog->alias), alias);
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430 if(PURPLE_IS_GROUP(group)) {
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
431 GtkWidget *entry = NULL;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
432
41563
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
433 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
434 gtk_editable_set_text(GTK_EDITABLE(entry),
17c8c3d42aa0 Port PidginAddChatDialog to GTK4
Gary Kramlich <grim@reaperworld.com>
parents: 41508
diff changeset
435 purple_group_get_name(group));
41508
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
436 }
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438 acdialog->default_name = name;
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 pidgin_add_chat_dialog_update_components(acdialog);
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442 return dialog;
b248346ee70b Create a new PidginAddChatDialog widget.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443 }

mercurial