Mon, 06 Apr 2020 23:35:44 -0500
Toggle the enabled status of chat actions based on connected accounts that implement that interface
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* pidgin |
| 6371 | 2 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
3 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 5 | * source distribution. | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13775
diff
changeset
|
6 | * |
| 6371 | 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18327
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 6371 | 20 | */ |
| 9791 | 21 | #include "internal.h" |
| 15577 | 22 | #include "pidgin.h" |
| 6371 | 23 | |
| 24 | #include "connection.h" | |
| 25 | #include "debug.h" | |
| 26 | #include "request.h" | |
| 27 | #include "util.h" | |
| 28 | ||
|
35040
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
29 | #include "gtkaccount.h" |
|
11111
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11047
diff
changeset
|
30 | #include "gtkblist.h" |
| 6371 | 31 | #include "gtkprivacy.h" |
| 32 | #include "gtkutils.h" | |
|
39785
aa7e3b71802d
Split pidgin_account_option_menu into its own files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39665
diff
changeset
|
33 | #include "pidginaccountchooser.h" |
| 6371 | 34 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
35 | #define PIDGIN_TYPE_PRIVACY_DIALOG (pidgin_privacy_dialog_get_type()) |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
36 | G_DECLARE_FINAL_TYPE(PidginPrivacyDialog, pidgin_privacy_dialog, PIDGIN, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
37 | PRIVACY_DIALOG, GtkDialog) |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
38 | |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
39 | struct _PidginPrivacyDialog { |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
40 | GtkDialog parent; |
| 6371 | 41 | |
| 42 | GtkWidget *type_menu; | |
| 43 | ||
| 44 | GtkWidget *add_button; | |
| 45 | GtkWidget *remove_button; | |
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
46 | GtkWidget *removeall_button; |
|
22005
0183020ba2cc
Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22000
diff
changeset
|
47 | GtkWidget *close_button; |
| 6371 | 48 | |
| 49 | GtkWidget *allow_widget; | |
| 50 | GtkWidget *block_widget; | |
| 51 | ||
| 52 | GtkListStore *allow_store; | |
| 53 | GtkListStore *block_store; | |
| 54 | ||
| 55 | GtkWidget *allow_list; | |
| 56 | GtkWidget *block_list; | |
| 57 | ||
| 58 | gboolean in_allow_list; | |
| 59 | ||
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
60 | GtkWidget *account_chooser; |
| 15884 | 61 | PurpleAccount *account; |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
62 | }; |
| 6371 | 63 | |
| 64 | typedef struct | |
| 65 | { | |
| 15884 | 66 | PurpleAccount *account; |
| 6371 | 67 | char *name; |
| 68 | gboolean block; | |
| 69 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
70 | } PidginPrivacyRequestData; |
| 6371 | 71 | |
| 72 | static struct | |
| 73 | { | |
| 74 | const char *text; | |
| 34892 | 75 | PurpleAccountPrivacyType type; |
| 6371 | 76 | |
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
20147
diff
changeset
|
77 | } const menu_entries[] = |
| 6371 | 78 | { |
|
34586
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
79 | { N_("Allow all users to contact me"), PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL }, |
|
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
80 | { N_("Allow only the users on my buddy list"), PURPLE_ACCOUNT_PRIVACY_ALLOW_BUDDYLIST }, |
|
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
81 | { N_("Allow only the users below"), PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS }, |
|
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
82 | { N_("Block all users"), PURPLE_ACCOUNT_PRIVACY_DENY_ALL }, |
|
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
83 | { N_("Block only the users below"), PURPLE_ACCOUNT_PRIVACY_DENY_USERS } |
| 6371 | 84 | }; |
| 85 | ||
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
20147
diff
changeset
|
86 | static const size_t menu_entry_count = sizeof(menu_entries) / sizeof(*menu_entries); |
| 6371 | 87 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
88 | static PidginPrivacyDialog *privacy_dialog = NULL; |
| 6371 | 89 | |
| 90 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
91 | rebuild_allow_list(PidginPrivacyDialog *dialog) |
| 6371 | 92 | { |
| 93 | GSList *l; | |
| 94 | GtkTreeIter iter; | |
| 95 | ||
| 96 | gtk_list_store_clear(dialog->allow_store); | |
| 97 | ||
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
98 | for (l = purple_account_privacy_get_permitted(dialog->account); l != NULL; l = l->next) { |
| 6371 | 99 | gtk_list_store_append(dialog->allow_store, &iter); |
| 100 | gtk_list_store_set(dialog->allow_store, &iter, 0, l->data, -1); | |
| 101 | } | |
| 102 | } | |
| 103 | ||
| 104 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
105 | rebuild_block_list(PidginPrivacyDialog *dialog) |
| 6371 | 106 | { |
| 107 | GSList *l; | |
| 108 | GtkTreeIter iter; | |
| 109 | ||
| 110 | gtk_list_store_clear(dialog->block_store); | |
| 111 | ||
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
112 | for (l = purple_account_privacy_get_denied(dialog->account); l != NULL; l = l->next) { |
| 6371 | 113 | gtk_list_store_append(dialog->block_store, &iter); |
| 114 | gtk_list_store_set(dialog->block_store, &iter, 0, l->data, -1); | |
| 115 | } | |
| 116 | } | |
| 117 | ||
| 118 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
119 | user_selected_cb(GtkTreeSelection *sel, PidginPrivacyDialog *dialog) |
| 6371 | 120 | { |
| 121 | gtk_widget_set_sensitive(dialog->remove_button, TRUE); | |
| 122 | } | |
| 123 | ||
| 124 | static void | |
|
39787
af7ae86ee287
Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39786
diff
changeset
|
125 | select_account_cb(GtkWidget *chooser, PidginPrivacyDialog *dialog) |
| 6371 | 126 | { |
|
39787
af7ae86ee287
Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39786
diff
changeset
|
127 | PurpleAccount *account = pidgin_account_chooser_get_selected(chooser); |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
128 | gsize i; |
| 6371 | 129 | |
| 130 | dialog->account = account; | |
| 131 | ||
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
132 | if (account) { |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
133 | gtk_widget_set_sensitive(dialog->type_menu, TRUE); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
134 | gtk_widget_set_sensitive(dialog->add_button, TRUE); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
135 | /* dialog->remove_button is enabled when a user is selected. */ |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
136 | gtk_widget_set_sensitive(dialog->removeall_button, TRUE); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
137 | } else { |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
138 | gtk_widget_set_sensitive(dialog->type_menu, FALSE); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
139 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
140 | gtk_widget_set_sensitive(dialog->remove_button, FALSE); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
141 | gtk_widget_set_sensitive(dialog->removeall_button, FALSE); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
142 | gtk_list_store_clear(dialog->allow_store); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
143 | gtk_list_store_clear(dialog->block_store); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
144 | return; |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
145 | } |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
146 | |
| 6371 | 147 | for (i = 0; i < menu_entry_count; i++) { |
|
34308
cdb187c27360
Fix the rest of Pidgin's warnings about -Wsign-compare; remove -Wno-sign-compare from cflags
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
148 | if (menu_entries[i].type == purple_account_get_privacy_type(account)) { |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
149 | gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), i); |
| 6371 | 150 | break; |
| 151 | } | |
| 152 | } | |
| 153 | ||
| 154 | rebuild_allow_list(dialog); | |
| 155 | rebuild_block_list(dialog); | |
| 156 | } | |
| 157 | ||
|
10704
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
158 | /* |
|
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
159 | * TODO: Setting the permit/deny setting needs to go through privacy.c |
|
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
160 | * Even better: the privacy API needs to not suck. |
|
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
161 | */ |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
162 | static void |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
163 | type_changed_cb(GtkComboBox *combo, PidginPrivacyDialog *dialog) |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
164 | { |
| 34892 | 165 | PurpleAccountPrivacyType new_type = |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
166 | menu_entries[gtk_combo_box_get_active(combo)].type; |
|
40252
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
167 | gboolean buttons_sensitive; |
| 6371 | 168 | |
|
32624
f957ad287bcc
Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31321
diff
changeset
|
169 | purple_account_set_privacy_type(dialog->account, new_type); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
170 | purple_serv_set_permit_deny(purple_account_get_connection(dialog->account)); |
| 6371 | 171 | |
| 172 | gtk_widget_hide(dialog->allow_widget); | |
| 173 | gtk_widget_hide(dialog->block_widget); | |
|
40252
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
174 | buttons_sensitive = FALSE; |
| 6371 | 175 | |
|
34586
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
176 | if (new_type == PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS) { |
| 6371 | 177 | gtk_widget_show(dialog->allow_widget); |
|
40252
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
178 | buttons_sensitive = TRUE; |
| 6371 | 179 | dialog->in_allow_list = TRUE; |
| 180 | } | |
|
34586
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
181 | else if (new_type == PURPLE_ACCOUNT_PRIVACY_DENY_USERS) { |
| 6371 | 182 | gtk_widget_show(dialog->block_widget); |
|
40252
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
183 | buttons_sensitive = TRUE; |
| 6371 | 184 | dialog->in_allow_list = FALSE; |
| 185 | } | |
|
10147
a4897a5bcf8d
[gaim-migrate @ 11224]
Peter Lawler <pidgin@bleeter.id.au>
parents:
9791
diff
changeset
|
186 | |
|
40252
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
187 | gtk_widget_set_sensitive(dialog->add_button, buttons_sensitive); |
|
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
188 | /* dialog->remove_button is enabled when a user is selected. */ |
|
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
189 | gtk_widget_set_sensitive(dialog->remove_button, FALSE); |
|
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
190 | gtk_widget_set_sensitive(dialog->removeall_button, buttons_sensitive); |
|
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
191 | |
|
22005
0183020ba2cc
Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22000
diff
changeset
|
192 | gtk_widget_show_all(dialog->close_button); |
|
0183020ba2cc
Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22000
diff
changeset
|
193 | |
| 15884 | 194 | purple_blist_schedule_save(); |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38007
diff
changeset
|
195 | pidgin_blist_refresh(purple_blist_get_default()); |
| 6371 | 196 | } |
| 197 | ||
| 198 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
199 | add_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 200 | { |
| 201 | if (dialog->in_allow_list) | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
202 | pidgin_request_add_permit(dialog->account, NULL); |
| 6371 | 203 | else |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
204 | pidgin_request_add_block(dialog->account, NULL); |
| 6371 | 205 | } |
| 206 | ||
| 207 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
208 | remove_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 209 | { |
| 210 | GtkTreeIter iter; | |
| 211 | GtkTreeModel *model; | |
| 212 | GtkTreeSelection *sel; | |
| 213 | char *name; | |
| 214 | ||
| 215 | if (dialog->in_allow_list && dialog->allow_store == NULL) | |
| 216 | return; | |
| 217 | ||
| 218 | if (!dialog->in_allow_list && dialog->block_store == NULL) | |
| 219 | return; | |
| 220 | ||
| 221 | if (dialog->in_allow_list) { | |
| 222 | model = GTK_TREE_MODEL(dialog->allow_store); | |
| 223 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->allow_list)); | |
| 224 | } | |
| 225 | else { | |
| 226 | model = GTK_TREE_MODEL(dialog->block_store); | |
| 227 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->block_list)); | |
| 228 | } | |
| 229 | ||
| 230 | if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
| 231 | gtk_tree_model_get(model, &iter, 0, &name, -1); | |
| 232 | else | |
| 233 | return; | |
| 234 | ||
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
235 | if (dialog->in_allow_list) |
|
34586
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
236 | purple_account_privacy_permit_remove(dialog->account, name, FALSE); |
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
237 | else |
|
34586
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
238 | purple_account_privacy_deny_remove(dialog->account, name, FALSE); |
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
239 | |
|
13149
895f0495b7db
[gaim-migrate @ 15511]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12852
diff
changeset
|
240 | g_free(name); |
| 6371 | 241 | } |
| 242 | ||
| 243 | static void | |
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
244 | removeall_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 245 | { |
| 8556 | 246 | GSList *l; |
| 247 | if (dialog->in_allow_list) | |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
248 | l = purple_account_privacy_get_permitted(dialog->account); |
| 8556 | 249 | else |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
250 | l = purple_account_privacy_get_denied(dialog->account); |
| 8556 | 251 | while (l) { |
| 252 | char *user; | |
| 253 | user = l->data; | |
| 254 | l = l->next; | |
| 255 | if (dialog->in_allow_list) | |
|
34586
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
256 | purple_account_privacy_permit_remove(dialog->account, user, FALSE); |
| 8556 | 257 | else |
|
34586
9ed4700451cc
Refactored gtkprivacy to use the new API. Added (moved) gtkprivacy's UI ops to gtkaccount's UI ops.
Ankit Vani <a@nevitus.org>
parents:
33170
diff
changeset
|
258 | purple_account_privacy_deny_remove(dialog->account, user, FALSE); |
| 8556 | 259 | } |
| 6371 | 260 | } |
| 261 | ||
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
262 | G_DEFINE_TYPE(PidginPrivacyDialog, pidgin_privacy_dialog, GTK_TYPE_DIALOG) |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
263 | |
| 6371 | 264 | static void |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
265 | pidgin_privacy_dialog_class_init(PidginPrivacyDialogClass *klass) |
| 6371 | 266 | { |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
267 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
268 | |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
269 | gtk_widget_class_set_template_from_resource( |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
270 | widget_class, "/im/pidgin/Pidgin/Privacy/dialog.ui"); |
|
7165
6547d94b0725
[gaim-migrate @ 7732]
Mark Doliner <markdoliner@pidgin.im>
parents:
6646
diff
changeset
|
271 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
272 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
273 | account_chooser); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
274 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
275 | add_button); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
276 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
277 | allow_list); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
278 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
279 | allow_store); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
280 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
281 | allow_widget); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
282 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
283 | block_list); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
284 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
285 | block_store); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
286 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
287 | block_widget); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
288 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
289 | close_button); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
290 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
291 | remove_button); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
292 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
293 | removeall_button); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
294 | gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
295 | type_menu); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
296 | |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
297 | gtk_widget_class_bind_template_callback(widget_class, add_cb); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
298 | gtk_widget_class_bind_template_callback(widget_class, remove_cb); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
299 | gtk_widget_class_bind_template_callback(widget_class, removeall_cb); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
300 | gtk_widget_class_bind_template_callback(widget_class, select_account_cb); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
301 | gtk_widget_class_bind_template_callback(widget_class, type_changed_cb); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
302 | gtk_widget_class_bind_template_callback(widget_class, user_selected_cb); |
| 6371 | 303 | } |
| 304 | ||
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
305 | static void |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
306 | pidgin_privacy_dialog_init(PidginPrivacyDialog *dialog) |
| 6371 | 307 | { |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
308 | gssize selected = -1; |
|
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
309 | gsize i; |
| 6371 | 310 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
311 | gtk_widget_init_template(GTK_WIDGET(dialog)); |
| 6371 | 312 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
313 | dialog->account = |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
314 | pidgin_account_chooser_get_selected(dialog->account_chooser); |
| 6371 | 315 | |
| 316 | /* Add the drop-down list with the allow/block types. */ | |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
317 | for (i = 0; i < menu_entry_count; i++) { |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
29742
diff
changeset
|
318 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(dialog->type_menu), |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
319 | _(menu_entries[i].text)); |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
320 | |
|
34308
cdb187c27360
Fix the rest of Pidgin's warnings about -Wsign-compare; remove -Wno-sign-compare from cflags
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33170
diff
changeset
|
321 | if (menu_entries[i].type == purple_account_get_privacy_type(dialog->account)) |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
322 | selected = (gssize)i; |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
323 | } |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
324 | gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), selected); |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
325 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
326 | /* Rebuild the allow and block lists views. */ |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
327 | rebuild_allow_list(dialog); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
328 | rebuild_block_list(dialog); |
| 6371 | 329 | |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
330 | type_changed_cb(GTK_COMBO_BOX(dialog->type_menu), dialog); |
| 6371 | 331 | } |
| 332 | ||
| 333 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
334 | pidgin_privacy_dialog_show(void) |
| 6371 | 335 | { |
| 15884 | 336 | g_return_if_fail(purple_connections_get_all() != NULL); |
|
10352
802e7ab5b838
[gaim-migrate @ 11569]
Mark Doliner <markdoliner@pidgin.im>
parents:
10148
diff
changeset
|
337 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
338 | if (privacy_dialog == NULL) { |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
339 | privacy_dialog = g_object_new(PIDGIN_TYPE_PRIVACY_DIALOG, NULL); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
340 | g_signal_connect(privacy_dialog, "destroy", |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
341 | G_CALLBACK(gtk_widget_destroyed), &privacy_dialog); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
342 | } |
| 6371 | 343 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
344 | gtk_widget_show(GTK_WIDGET(privacy_dialog)); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
345 | gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(privacy_dialog))); |
| 6371 | 346 | } |
| 347 | ||
| 348 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
349 | pidgin_privacy_dialog_hide(void) |
| 6371 | 350 | { |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
351 | gtk_widget_destroy(GTK_WIDGET(privacy_dialog)); |
| 6371 | 352 | } |
| 353 | ||
| 354 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
355 | destroy_request_data(PidginPrivacyRequestData *data) |
| 6371 | 356 | { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13775
diff
changeset
|
357 | g_free(data->name); |
| 6371 | 358 | g_free(data); |
| 359 | } | |
| 360 | ||
| 361 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
362 | confirm_permit_block_cb(PidginPrivacyRequestData *data, int option) |
| 6371 | 363 | { |
| 364 | if (data->block) | |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
365 | purple_account_privacy_deny(data->account, data->name); |
| 6371 | 366 | else |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
367 | purple_account_privacy_allow(data->account, data->name); |
| 6371 | 368 | |
| 369 | destroy_request_data(data); | |
| 370 | } | |
| 371 | ||
| 372 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
373 | add_permit_block_cb(PidginPrivacyRequestData *data, const char *name) |
| 6371 | 374 | { |
| 375 | data->name = g_strdup(name); | |
| 376 | ||
| 377 | confirm_permit_block_cb(data, 0); | |
| 378 | } | |
| 379 | ||
| 380 | void | |
| 15884 | 381 | pidgin_request_add_permit(PurpleAccount *account, const char *name) |
| 6371 | 382 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
383 | PidginPrivacyRequestData *data; |
| 6371 | 384 | |
| 385 | g_return_if_fail(account != NULL); | |
| 386 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
387 | data = g_new0(PidginPrivacyRequestData, 1); |
| 6371 | 388 | data->account = account; |
| 389 | data->name = g_strdup(name); | |
| 390 | data->block = FALSE; | |
| 391 | ||
| 392 | if (name == NULL) { | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
393 | purple_request_input(account, _("Permit User"), |
| 6371 | 394 | _("Type a user you permit to contact you."), |
| 395 | _("Please enter the name of the user you wish to be " | |
| 396 | "able to contact you."), | |
| 8697 | 397 | NULL, FALSE, FALSE, NULL, |
| 12603 | 398 | _("_Permit"), G_CALLBACK(add_permit_block_cb), |
| 6371 | 399 | _("Cancel"), G_CALLBACK(destroy_request_data), |
|
34329
ddbc1337332c
Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34308
diff
changeset
|
400 | purple_request_cpar_from_account(account), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
401 | data); |
| 6371 | 402 | } |
| 403 | else { | |
| 404 | char *primary = g_strdup_printf(_("Allow %s to contact you?"), name); | |
| 405 | char *secondary = | |
| 406 | g_strdup_printf(_("Are you sure you wish to allow " | |
| 407 | "%s to contact you?"), name); | |
| 408 | ||
| 409 | ||
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
410 | purple_request_action(account, _("Permit User"), primary, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
411 | secondary, 0, purple_request_cpar_from_account(account), |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
412 | data, 2, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
413 | _("_Permit"), G_CALLBACK(confirm_permit_block_cb), |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
414 | _("Cancel"), G_CALLBACK(destroy_request_data)); |
| 6371 | 415 | |
| 416 | g_free(primary); | |
| 417 | g_free(secondary); | |
| 418 | } | |
| 419 | } | |
| 420 | ||
| 421 | void | |
| 15884 | 422 | pidgin_request_add_block(PurpleAccount *account, const char *name) |
| 6371 | 423 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
424 | PidginPrivacyRequestData *data; |
| 6371 | 425 | |
| 426 | g_return_if_fail(account != NULL); | |
| 427 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
428 | data = g_new0(PidginPrivacyRequestData, 1); |
| 6371 | 429 | data->account = account; |
| 430 | data->name = g_strdup(name); | |
| 431 | data->block = TRUE; | |
| 432 | ||
| 433 | if (name == NULL) { | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
434 | purple_request_input(account, _("Block User"), |
| 6371 | 435 | _("Type a user to block."), |
| 436 | _("Please enter the name of the user you wish to block."), | |
| 8697 | 437 | NULL, FALSE, FALSE, NULL, |
| 12603 | 438 | _("_Block"), G_CALLBACK(add_permit_block_cb), |
| 6371 | 439 | _("Cancel"), G_CALLBACK(destroy_request_data), |
|
34329
ddbc1337332c
Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34308
diff
changeset
|
440 | purple_request_cpar_from_account(account), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
441 | data); |
| 6371 | 442 | } |
| 443 | else { | |
| 444 | char *primary = g_strdup_printf(_("Block %s?"), name); | |
| 445 | char *secondary = | |
| 446 | g_strdup_printf(_("Are you sure you want to block %s?"), name); | |
| 447 | ||
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
448 | purple_request_action(account, _("Block User"), primary, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
449 | secondary, 0, purple_request_cpar_from_account(account), |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
450 | data, 2, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
451 | _("_Block"), G_CALLBACK(confirm_permit_block_cb), |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
452 | _("Cancel"), G_CALLBACK(destroy_request_data)); |
| 6371 | 453 | |
| 454 | g_free(primary); | |
| 455 | g_free(secondary); | |
| 456 | } | |
| 457 | } | |
| 458 | ||
| 459 | static void | |
| 15884 | 460 | pidgin_permit_added_removed(PurpleAccount *account, const char *name) |
| 6371 | 461 | { |
| 462 | if (privacy_dialog != NULL) | |
| 463 | rebuild_allow_list(privacy_dialog); | |
| 464 | } | |
| 465 | ||
| 466 | static void | |
| 15884 | 467 | pidgin_deny_added_removed(PurpleAccount *account, const char *name) |
| 6371 | 468 | { |
| 469 | if (privacy_dialog != NULL) | |
| 470 | rebuild_block_list(privacy_dialog); | |
| 471 | } | |
| 472 | ||
| 473 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
474 | pidgin_privacy_init(void) |
| 6371 | 475 | { |
|
35040
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
476 | PurpleAccountUiOps *ops = pidgin_accounts_get_ui_ops(); |
|
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
477 | |
|
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
478 | ops->permit_added = ops->permit_removed = pidgin_permit_added_removed; |
|
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
479 | ops->deny_added = ops->deny_removed = pidgin_deny_added_removed; |
| 6371 | 480 | } |