Fri, 09 Aug 2019 01:51:47 -0400
Rename pidgin_account_option_menu_* to pidgin_account_chooser_*.
Also, try to clean up documentation a bit.
|
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 | |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33120
diff
changeset
|
35 | #include "gtk3compat.h" |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33120
diff
changeset
|
36 | |
| 6371 | 37 | typedef struct |
| 38 | { | |
| 39 | GtkWidget *win; | |
| 40 | ||
| 41 | GtkWidget *type_menu; | |
| 42 | ||
| 43 | GtkWidget *add_button; | |
| 44 | GtkWidget *remove_button; | |
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
45 | 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
|
46 | GtkWidget *close_button; |
| 6371 | 47 | |
| 48 | GtkWidget *button_box; | |
| 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 | ||
| 15884 | 60 | PurpleAccount *account; |
| 6371 | 61 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
62 | } PidginPrivacyDialog; |
| 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 GtkWidget * | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
125 | build_list(PidginPrivacyDialog *dialog, GtkListStore *model, |
| 6371 | 126 | GtkWidget **ret_treeview) |
| 127 | { | |
| 128 | GtkWidget *sw; | |
| 129 | GtkWidget *treeview; | |
| 130 | GtkCellRenderer *rend; | |
| 131 | GtkTreeViewColumn *column; | |
| 132 | GtkTreeSelection *sel; | |
| 133 | ||
| 134 | treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
| 135 | *ret_treeview = treeview; | |
| 136 | ||
| 137 | rend = gtk_cell_renderer_text_new(); | |
| 138 | ||
| 139 | column = gtk_tree_view_column_new_with_attributes(NULL, rend, | |
| 140 | "text", 0, | |
| 141 | NULL); | |
| 142 | gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
| 143 | gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); | |
| 144 | gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
|
31321
1fef3832cfa2
Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents:
29742
diff
changeset
|
145 | sw = pidgin_make_scrollable(treeview, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, 200); |
|
6374
0bbc59035c89
[gaim-migrate @ 6879]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
146 | |
| 6371 | 147 | gtk_widget_show(treeview); |
| 148 | ||
| 149 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); | |
| 150 | ||
| 151 | g_signal_connect(G_OBJECT(sel), "changed", | |
| 152 | G_CALLBACK(user_selected_cb), dialog); | |
| 153 | ||
| 154 | return sw; | |
| 155 | } | |
| 156 | ||
| 157 | static GtkWidget * | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
158 | build_allow_list(PidginPrivacyDialog *dialog) |
| 6371 | 159 | { |
| 160 | GtkWidget *widget; | |
| 161 | GtkWidget *list; | |
| 162 | ||
| 163 | dialog->allow_store = gtk_list_store_new(1, G_TYPE_STRING); | |
| 164 | ||
|
11047
1b0452e2f2a9
[gaim-migrate @ 12972]
Richard Laager <rlaager@pidgin.im>
parents:
10704
diff
changeset
|
165 | gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(dialog->allow_store), 0, GTK_SORT_ASCENDING); |
|
1b0452e2f2a9
[gaim-migrate @ 12972]
Richard Laager <rlaager@pidgin.im>
parents:
10704
diff
changeset
|
166 | |
| 6371 | 167 | widget = build_list(dialog, dialog->allow_store, &list); |
| 168 | ||
| 169 | dialog->allow_list = list; | |
| 170 | ||
| 171 | rebuild_allow_list(dialog); | |
| 172 | ||
| 173 | return widget; | |
| 174 | } | |
| 175 | ||
| 176 | static GtkWidget * | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
177 | build_block_list(PidginPrivacyDialog *dialog) |
| 6371 | 178 | { |
| 179 | GtkWidget *widget; | |
| 180 | GtkWidget *list; | |
| 181 | ||
| 182 | dialog->block_store = gtk_list_store_new(1, G_TYPE_STRING); | |
| 183 | ||
|
11047
1b0452e2f2a9
[gaim-migrate @ 12972]
Richard Laager <rlaager@pidgin.im>
parents:
10704
diff
changeset
|
184 | gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(dialog->block_store), 0, GTK_SORT_ASCENDING); |
|
1b0452e2f2a9
[gaim-migrate @ 12972]
Richard Laager <rlaager@pidgin.im>
parents:
10704
diff
changeset
|
185 | |
| 6371 | 186 | widget = build_list(dialog, dialog->block_store, &list); |
| 187 | ||
| 188 | dialog->block_list = list; | |
| 189 | ||
| 190 | rebuild_block_list(dialog); | |
| 191 | ||
| 192 | return widget; | |
| 193 | } | |
| 194 | ||
| 195 | static gint | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
196 | destroy_cb(GtkWidget *w, GdkEvent *event, PidginPrivacyDialog *dialog) |
| 6371 | 197 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
198 | pidgin_privacy_dialog_hide(); |
| 6371 | 199 | |
| 200 | return 0; | |
| 201 | } | |
| 202 | ||
| 203 | static void | |
| 15884 | 204 | select_account_cb(GtkWidget *dropdown, PurpleAccount *account, |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
205 | PidginPrivacyDialog *dialog) |
| 6371 | 206 | { |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
207 | gsize i; |
| 6371 | 208 | |
| 209 | dialog->account = account; | |
| 210 | ||
| 211 | 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
|
212 | 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
|
213 | gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), i); |
| 6371 | 214 | break; |
| 215 | } | |
| 216 | } | |
| 217 | ||
| 218 | rebuild_allow_list(dialog); | |
| 219 | rebuild_block_list(dialog); | |
| 220 | } | |
| 221 | ||
|
10704
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
222 | /* |
|
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
223 | * 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
|
224 | * Even better: the privacy API needs to not suck. |
|
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
225 | */ |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
226 | 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
|
227 | 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
|
228 | { |
| 34892 | 229 | 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
|
230 | menu_entries[gtk_combo_box_get_active(combo)].type; |
| 6371 | 231 | |
|
32624
f957ad287bcc
Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31321
diff
changeset
|
232 | 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
|
233 | purple_serv_set_permit_deny(purple_account_get_connection(dialog->account)); |
| 6371 | 234 | |
| 235 | gtk_widget_hide(dialog->allow_widget); | |
| 236 | gtk_widget_hide(dialog->block_widget); | |
|
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
|
237 | gtk_widget_hide(dialog->button_box); |
| 6371 | 238 | |
|
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
|
239 | if (new_type == PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS) { |
| 6371 | 240 | gtk_widget_show(dialog->allow_widget); |
|
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
|
241 | gtk_widget_show_all(dialog->button_box); |
| 6371 | 242 | dialog->in_allow_list = TRUE; |
| 243 | } | |
|
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
|
244 | else if (new_type == PURPLE_ACCOUNT_PRIVACY_DENY_USERS) { |
| 6371 | 245 | gtk_widget_show(dialog->block_widget); |
|
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
|
246 | gtk_widget_show_all(dialog->button_box); |
| 6371 | 247 | dialog->in_allow_list = FALSE; |
| 248 | } | |
|
10147
a4897a5bcf8d
[gaim-migrate @ 11224]
Peter Lawler <pidgin@bleeter.id.au>
parents:
9791
diff
changeset
|
249 | |
|
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
|
250 | 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
|
251 | gtk_widget_show(dialog->button_box); |
|
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
|
252 | |
| 15884 | 253 | purple_blist_schedule_save(); |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38007
diff
changeset
|
254 | pidgin_blist_refresh(purple_blist_get_default()); |
| 6371 | 255 | } |
| 256 | ||
| 257 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
258 | add_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 259 | { |
| 260 | if (dialog->in_allow_list) | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
261 | pidgin_request_add_permit(dialog->account, NULL); |
| 6371 | 262 | else |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
263 | pidgin_request_add_block(dialog->account, NULL); |
| 6371 | 264 | } |
| 265 | ||
| 266 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
267 | remove_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 268 | { |
| 269 | GtkTreeIter iter; | |
| 270 | GtkTreeModel *model; | |
| 271 | GtkTreeSelection *sel; | |
| 272 | char *name; | |
| 273 | ||
| 274 | if (dialog->in_allow_list && dialog->allow_store == NULL) | |
| 275 | return; | |
| 276 | ||
| 277 | if (!dialog->in_allow_list && dialog->block_store == NULL) | |
| 278 | return; | |
| 279 | ||
| 280 | if (dialog->in_allow_list) { | |
| 281 | model = GTK_TREE_MODEL(dialog->allow_store); | |
| 282 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->allow_list)); | |
| 283 | } | |
| 284 | else { | |
| 285 | model = GTK_TREE_MODEL(dialog->block_store); | |
| 286 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->block_list)); | |
| 287 | } | |
| 288 | ||
| 289 | if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
| 290 | gtk_tree_model_get(model, &iter, 0, &name, -1); | |
| 291 | else | |
| 292 | return; | |
| 293 | ||
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
294 | 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
|
295 | 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
|
296 | 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
|
297 | 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
|
298 | |
|
13149
895f0495b7db
[gaim-migrate @ 15511]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12852
diff
changeset
|
299 | g_free(name); |
| 6371 | 300 | } |
| 301 | ||
| 302 | static void | |
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
303 | removeall_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 304 | { |
| 8556 | 305 | GSList *l; |
| 306 | 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
|
307 | l = purple_account_privacy_get_permitted(dialog->account); |
| 8556 | 308 | else |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
309 | l = purple_account_privacy_get_denied(dialog->account); |
| 8556 | 310 | while (l) { |
| 311 | char *user; | |
| 312 | user = l->data; | |
| 313 | l = l->next; | |
| 314 | 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
|
315 | purple_account_privacy_permit_remove(dialog->account, user, FALSE); |
| 8556 | 316 | 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
|
317 | purple_account_privacy_deny_remove(dialog->account, user, FALSE); |
| 8556 | 318 | } |
| 6371 | 319 | } |
| 320 | ||
| 321 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
322 | close_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 323 | { |
|
7165
6547d94b0725
[gaim-migrate @ 7732]
Mark Doliner <markdoliner@pidgin.im>
parents:
6646
diff
changeset
|
324 | gtk_widget_destroy(dialog->win); |
|
6547d94b0725
[gaim-migrate @ 7732]
Mark Doliner <markdoliner@pidgin.im>
parents:
6646
diff
changeset
|
325 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
326 | pidgin_privacy_dialog_hide(); |
| 6371 | 327 | } |
| 328 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
329 | static PidginPrivacyDialog * |
| 6371 | 330 | privacy_dialog_new(void) |
| 331 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
332 | PidginPrivacyDialog *dialog; |
| 6371 | 333 | GtkWidget *vbox; |
| 334 | GtkWidget *button; | |
| 335 | GtkWidget *dropdown; | |
| 336 | GtkWidget *label; | |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
337 | gssize selected = -1; |
|
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
338 | gsize i; |
| 6371 | 339 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
340 | dialog = g_new0(PidginPrivacyDialog, 1); |
| 6371 | 341 | |
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
342 | dialog->win = pidgin_create_dialog(_("Privacy"), PIDGIN_HIG_BORDER, "privacy", TRUE); |
| 6371 | 343 | |
| 344 | g_signal_connect(G_OBJECT(dialog->win), "delete_event", | |
| 345 | G_CALLBACK(destroy_cb), dialog); | |
| 346 | ||
| 347 | /* Main vbox */ | |
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
348 | vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(dialog->win), FALSE, PIDGIN_HIG_BORDER); |
| 6371 | 349 | |
| 350 | /* Description label */ | |
| 351 | label = gtk_label_new( | |
| 352 | _("Changes to privacy settings take effect immediately.")); | |
| 353 | ||
| 354 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
|
38007
3b971d2ecae1
Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37990
diff
changeset
|
355 | gtk_label_set_xalign(GTK_LABEL(label), 0); |
| 6371 | 356 | gtk_widget_show(label); |
| 357 | ||
| 358 | /* Accounts drop-down */ | |
|
39786
7800f52d0ae6
Rename pidgin_account_option_menu_* to pidgin_account_chooser_*.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39785
diff
changeset
|
359 | dropdown = pidgin_account_chooser_new( |
|
7800f52d0ae6
Rename pidgin_account_option_menu_* to pidgin_account_chooser_*.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39785
diff
changeset
|
360 | NULL, FALSE, G_CALLBACK(select_account_cb), NULL, dialog); |
|
22131
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
361 | pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Set privacy for:"), NULL, dropdown, TRUE, NULL); |
|
39786
7800f52d0ae6
Rename pidgin_account_option_menu_* to pidgin_account_chooser_*.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39785
diff
changeset
|
362 | dialog->account = pidgin_account_chooser_get_selected(dropdown); |
| 6371 | 363 | |
| 364 | /* Add the drop-down list with the allow/block types. */ | |
|
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
|
365 | dialog->type_menu = gtk_combo_box_text_new(); |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
366 | gtk_box_pack_start(GTK_BOX(vbox), dialog->type_menu, FALSE, FALSE, 0); |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
367 | gtk_widget_show(dialog->type_menu); |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
368 | |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
369 | 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
|
370 | 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
|
371 | _(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
|
372 | |
|
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
|
373 | 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
|
374 | 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
|
375 | } |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
376 | |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
377 | 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
|
378 | |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
379 | g_signal_connect(G_OBJECT(dialog->type_menu), "changed", |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
380 | G_CALLBACK(type_changed_cb), dialog); |
| 6371 | 381 | |
| 382 | /* Build the treeview for the allow list. */ | |
| 383 | dialog->allow_widget = build_allow_list(dialog); | |
| 384 | gtk_box_pack_start(GTK_BOX(vbox), dialog->allow_widget, TRUE, TRUE, 0); | |
| 385 | ||
| 386 | /* Build the treeview for the block list. */ | |
| 387 | dialog->block_widget = build_block_list(dialog); | |
| 388 | gtk_box_pack_start(GTK_BOX(vbox), dialog->block_widget, TRUE, TRUE, 0); | |
| 389 | ||
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
390 | /* Add the button box for Add, Remove, Remove All */ |
|
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
|
391 | dialog->button_box = pidgin_dialog_get_action_area(GTK_DIALOG(dialog->win)); |
| 6371 | 392 | |
| 393 | /* Add 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
|
394 | button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_ADD, G_CALLBACK(add_cb), dialog); |
| 6371 | 395 | dialog->add_button = button; |
| 396 | ||
| 397 | /* Remove 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
|
398 | button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_REMOVE, G_CALLBACK(remove_cb), dialog); |
| 6371 | 399 | dialog->remove_button = button; |
|
22389
21650aee2a19
Remove the privacy prpl callbacks in Zephyr since they're basically a
Mark Doliner <markdoliner@pidgin.im>
parents:
22372
diff
changeset
|
400 | /* TODO: This button should be sensitive/invisitive more cleverly */ |
| 6371 | 401 | gtk_widget_set_sensitive(button, FALSE); |
| 402 | ||
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
403 | /* Remove All button */ |
|
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
404 | button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), _("Remove Al_l"), G_CALLBACK(removeall_cb), dialog); |
|
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
405 | dialog->removeall_button = button; |
| 6371 | 406 | |
| 407 | /* Close 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
|
408 | button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_CLOSE, G_CALLBACK(close_cb), dialog); |
|
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
|
409 | dialog->close_button = button; |
| 6371 | 410 | |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
411 | type_changed_cb(GTK_COMBO_BOX(dialog->type_menu), dialog); |
|
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
|
412 | #if 0 |
|
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
|
413 | if (purple_account_get_privacy_type(dialog->account) == PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS) { |
| 6371 | 414 | gtk_widget_show(dialog->allow_widget); |
| 415 | gtk_widget_show(dialog->button_box); | |
| 416 | dialog->in_allow_list = TRUE; | |
| 417 | } | |
|
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
|
418 | else if (purple_account_get_privacy_type(dialog->account) == PURPLE_ACCOUNT_PRIVACY_DENY_USERS) { |
| 6371 | 419 | gtk_widget_show(dialog->block_widget); |
| 420 | gtk_widget_show(dialog->button_box); | |
| 421 | dialog->in_allow_list = FALSE; | |
| 422 | } | |
|
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
|
423 | #endif |
| 6371 | 424 | return dialog; |
| 425 | } | |
| 426 | ||
| 427 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
428 | pidgin_privacy_dialog_show(void) |
| 6371 | 429 | { |
| 15884 | 430 | g_return_if_fail(purple_connections_get_all() != NULL); |
|
10352
802e7ab5b838
[gaim-migrate @ 11569]
Mark Doliner <markdoliner@pidgin.im>
parents:
10148
diff
changeset
|
431 | |
| 6371 | 432 | if (privacy_dialog == NULL) |
| 433 | privacy_dialog = privacy_dialog_new(); | |
| 434 | ||
| 435 | gtk_widget_show(privacy_dialog->win); | |
|
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
|
436 | gdk_window_raise(gtk_widget_get_window(privacy_dialog->win)); |
| 6371 | 437 | } |
| 438 | ||
| 439 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
440 | pidgin_privacy_dialog_hide(void) |
| 6371 | 441 | { |
| 442 | if (privacy_dialog == NULL) | |
| 443 | return; | |
| 444 | ||
|
22214
e8a9916cb99e
It turns out the tree-models need to be unref'ed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22131
diff
changeset
|
445 | g_object_unref(G_OBJECT(privacy_dialog->allow_store)); |
|
e8a9916cb99e
It turns out the tree-models need to be unref'ed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22131
diff
changeset
|
446 | g_object_unref(G_OBJECT(privacy_dialog->block_store)); |
|
7165
6547d94b0725
[gaim-migrate @ 7732]
Mark Doliner <markdoliner@pidgin.im>
parents:
6646
diff
changeset
|
447 | g_free(privacy_dialog); |
| 6371 | 448 | privacy_dialog = NULL; |
| 449 | } | |
| 450 | ||
| 451 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
452 | destroy_request_data(PidginPrivacyRequestData *data) |
| 6371 | 453 | { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13775
diff
changeset
|
454 | g_free(data->name); |
| 6371 | 455 | g_free(data); |
| 456 | } | |
| 457 | ||
| 458 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
459 | confirm_permit_block_cb(PidginPrivacyRequestData *data, int option) |
| 6371 | 460 | { |
| 461 | if (data->block) | |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
462 | purple_account_privacy_deny(data->account, data->name); |
| 6371 | 463 | else |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
464 | purple_account_privacy_allow(data->account, data->name); |
| 6371 | 465 | |
| 466 | destroy_request_data(data); | |
| 467 | } | |
| 468 | ||
| 469 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
470 | add_permit_block_cb(PidginPrivacyRequestData *data, const char *name) |
| 6371 | 471 | { |
| 472 | data->name = g_strdup(name); | |
| 473 | ||
| 474 | confirm_permit_block_cb(data, 0); | |
| 475 | } | |
| 476 | ||
| 477 | void | |
| 15884 | 478 | pidgin_request_add_permit(PurpleAccount *account, const char *name) |
| 6371 | 479 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
480 | PidginPrivacyRequestData *data; |
| 6371 | 481 | |
| 482 | g_return_if_fail(account != NULL); | |
| 483 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
484 | data = g_new0(PidginPrivacyRequestData, 1); |
| 6371 | 485 | data->account = account; |
| 486 | data->name = g_strdup(name); | |
| 487 | data->block = FALSE; | |
| 488 | ||
| 489 | if (name == NULL) { | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
490 | purple_request_input(account, _("Permit User"), |
| 6371 | 491 | _("Type a user you permit to contact you."), |
| 492 | _("Please enter the name of the user you wish to be " | |
| 493 | "able to contact you."), | |
| 8697 | 494 | NULL, FALSE, FALSE, NULL, |
| 12603 | 495 | _("_Permit"), G_CALLBACK(add_permit_block_cb), |
| 6371 | 496 | _("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
|
497 | purple_request_cpar_from_account(account), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
498 | data); |
| 6371 | 499 | } |
| 500 | else { | |
| 501 | char *primary = g_strdup_printf(_("Allow %s to contact you?"), name); | |
| 502 | char *secondary = | |
| 503 | g_strdup_printf(_("Are you sure you wish to allow " | |
| 504 | "%s to contact you?"), name); | |
| 505 | ||
| 506 | ||
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
507 | 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
|
508 | 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
|
509 | data, 2, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
510 | _("_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
|
511 | _("Cancel"), G_CALLBACK(destroy_request_data)); |
| 6371 | 512 | |
| 513 | g_free(primary); | |
| 514 | g_free(secondary); | |
| 515 | } | |
| 516 | } | |
| 517 | ||
| 518 | void | |
| 15884 | 519 | pidgin_request_add_block(PurpleAccount *account, const char *name) |
| 6371 | 520 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
521 | PidginPrivacyRequestData *data; |
| 6371 | 522 | |
| 523 | g_return_if_fail(account != NULL); | |
| 524 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
525 | data = g_new0(PidginPrivacyRequestData, 1); |
| 6371 | 526 | data->account = account; |
| 527 | data->name = g_strdup(name); | |
| 528 | data->block = TRUE; | |
| 529 | ||
| 530 | if (name == NULL) { | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
531 | purple_request_input(account, _("Block User"), |
| 6371 | 532 | _("Type a user to block."), |
| 533 | _("Please enter the name of the user you wish to block."), | |
| 8697 | 534 | NULL, FALSE, FALSE, NULL, |
| 12603 | 535 | _("_Block"), G_CALLBACK(add_permit_block_cb), |
| 6371 | 536 | _("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
|
537 | purple_request_cpar_from_account(account), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
538 | data); |
| 6371 | 539 | } |
| 540 | else { | |
| 541 | char *primary = g_strdup_printf(_("Block %s?"), name); | |
| 542 | char *secondary = | |
| 543 | g_strdup_printf(_("Are you sure you want to block %s?"), name); | |
| 544 | ||
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
545 | 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
|
546 | 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
|
547 | data, 2, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
548 | _("_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
|
549 | _("Cancel"), G_CALLBACK(destroy_request_data)); |
| 6371 | 550 | |
| 551 | g_free(primary); | |
| 552 | g_free(secondary); | |
| 553 | } | |
| 554 | } | |
| 555 | ||
| 556 | static void | |
| 15884 | 557 | pidgin_permit_added_removed(PurpleAccount *account, const char *name) |
| 6371 | 558 | { |
| 559 | if (privacy_dialog != NULL) | |
| 560 | rebuild_allow_list(privacy_dialog); | |
| 561 | } | |
| 562 | ||
| 563 | static void | |
| 15884 | 564 | pidgin_deny_added_removed(PurpleAccount *account, const char *name) |
| 6371 | 565 | { |
| 566 | if (privacy_dialog != NULL) | |
| 567 | rebuild_block_list(privacy_dialog); | |
| 568 | } | |
| 569 | ||
| 570 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
571 | pidgin_privacy_init(void) |
| 6371 | 572 | { |
|
35040
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
573 | PurpleAccountUiOps *ops = pidgin_accounts_get_ui_ops(); |
|
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
574 | |
|
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
575 | 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
|
576 | ops->deny_added = ops->deny_removed = pidgin_deny_added_removed; |
| 6371 | 577 | } |