Fri, 19 Aug 2022 02:27:18 -0500
Port gtkaccount to GTK4
We should still port to `GtkBuilder`, but this seems small enough to fix now.
Testing Done:
Compile only.
Reviewed at https://reviews.imfreedom.org/r/1611/
|
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 | */ |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
21 | |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
22 | #include <glib/gi18n-lib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
23 | |
|
40360
e21f3bbcc2a5
Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents:
40252
diff
changeset
|
24 | #include <purple.h> |
| 6371 | 25 | |
|
35040
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
26 | #include "gtkaccount.h" |
|
11111
4621d9b973a4
[gaim-migrate @ 13163]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11047
diff
changeset
|
27 | #include "gtkblist.h" |
| 6371 | 28 | #include "gtkprivacy.h" |
| 29 | #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
|
30 | #include "pidginaccountchooser.h" |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
31 | #include "pidginaccountstore.h" |
| 6371 | 32 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
33 | #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
|
34 | 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
|
35 | PRIVACY_DIALOG, GtkDialog) |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
36 | |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
37 | struct _PidginPrivacyDialog { |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
38 | GtkDialog parent; |
| 6371 | 39 | |
| 40 | GtkWidget *type_menu; | |
| 41 | ||
| 42 | GtkWidget *add_button; | |
| 43 | GtkWidget *remove_button; | |
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
44 | 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
|
45 | GtkWidget *close_button; |
| 6371 | 46 | |
| 47 | GtkWidget *allow_widget; | |
| 48 | GtkWidget *block_widget; | |
| 49 | ||
| 50 | GtkListStore *allow_store; | |
| 51 | GtkListStore *block_store; | |
| 52 | ||
| 53 | GtkWidget *allow_list; | |
| 54 | GtkWidget *block_list; | |
| 55 | ||
| 56 | gboolean in_allow_list; | |
| 57 | ||
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
58 | GtkWidget *account_chooser; |
| 15884 | 59 | PurpleAccount *account; |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
60 | }; |
| 6371 | 61 | |
| 62 | typedef struct | |
| 63 | { | |
| 15884 | 64 | PurpleAccount *account; |
| 6371 | 65 | char *name; |
| 66 | gboolean block; | |
| 67 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
68 | } PidginPrivacyRequestData; |
| 6371 | 69 | |
| 70 | static struct | |
| 71 | { | |
| 72 | const char *text; | |
| 34892 | 73 | PurpleAccountPrivacyType type; |
| 6371 | 74 | |
|
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
|
75 | } const menu_entries[] = |
| 6371 | 76 | { |
|
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
|
77 | { 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
|
78 | { 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
|
79 | { 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
|
80 | { 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
|
81 | { N_("Block only the users below"), PURPLE_ACCOUNT_PRIVACY_DENY_USERS } |
| 6371 | 82 | }; |
| 83 | ||
|
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
|
84 | static const size_t menu_entry_count = sizeof(menu_entries) / sizeof(*menu_entries); |
| 6371 | 85 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
86 | static PidginPrivacyDialog *privacy_dialog = NULL; |
| 6371 | 87 | |
| 88 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
89 | rebuild_allow_list(PidginPrivacyDialog *dialog) |
| 6371 | 90 | { |
| 91 | GSList *l; | |
| 92 | GtkTreeIter iter; | |
| 93 | ||
| 94 | gtk_list_store_clear(dialog->allow_store); | |
| 95 | ||
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
96 | for (l = purple_account_privacy_get_permitted(dialog->account); l != NULL; l = l->next) { |
| 6371 | 97 | gtk_list_store_append(dialog->allow_store, &iter); |
| 98 | gtk_list_store_set(dialog->allow_store, &iter, 0, l->data, -1); | |
| 99 | } | |
| 100 | } | |
| 101 | ||
| 102 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
103 | rebuild_block_list(PidginPrivacyDialog *dialog) |
| 6371 | 104 | { |
| 105 | GSList *l; | |
| 106 | GtkTreeIter iter; | |
| 107 | ||
| 108 | gtk_list_store_clear(dialog->block_store); | |
| 109 | ||
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
110 | for (l = purple_account_privacy_get_denied(dialog->account); l != NULL; l = l->next) { |
| 6371 | 111 | gtk_list_store_append(dialog->block_store, &iter); |
| 112 | gtk_list_store_set(dialog->block_store, &iter, 0, l->data, -1); | |
| 113 | } | |
| 114 | } | |
| 115 | ||
| 116 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
117 | user_selected_cb(GtkTreeSelection *sel, PidginPrivacyDialog *dialog) |
| 6371 | 118 | { |
| 119 | gtk_widget_set_sensitive(dialog->remove_button, TRUE); | |
| 120 | } | |
| 121 | ||
| 122 | static void | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
123 | select_account_cb(GtkWidget *w, PidginPrivacyDialog *dialog) { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
124 | PidginAccountChooser *chooser = PIDGIN_ACCOUNT_CHOOSER(w); |
|
39787
af7ae86ee287
Remove callback from account chooser constructor.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39786
diff
changeset
|
125 | 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
|
126 | gsize i; |
| 6371 | 127 | |
| 128 | dialog->account = account; | |
| 129 | ||
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
130 | if (account) { |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
131 | 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
|
132 | 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
|
133 | /* 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
|
134 | 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
|
135 | } else { |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
136 | 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
|
137 | 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
|
138 | 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
|
139 | 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
|
140 | gtk_list_store_clear(dialog->allow_store); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
141 | gtk_list_store_clear(dialog->block_store); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
142 | return; |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
143 | } |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
144 | |
| 6371 | 145 | 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
|
146 | 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
|
147 | gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), i); |
| 6371 | 148 | break; |
| 149 | } | |
| 150 | } | |
| 151 | ||
| 152 | rebuild_allow_list(dialog); | |
| 153 | rebuild_block_list(dialog); | |
| 154 | } | |
| 155 | ||
|
10704
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
156 | /* |
|
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
157 | * 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
|
158 | * Even better: the privacy API needs to not suck. |
|
99a466f384d2
[gaim-migrate @ 12288]
Mark Doliner <markdoliner@pidgin.im>
parents:
10535
diff
changeset
|
159 | */ |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
160 | 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
|
161 | 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
|
162 | { |
| 34892 | 163 | 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
|
164 | 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
|
165 | gboolean buttons_sensitive; |
| 6371 | 166 | |
|
32624
f957ad287bcc
Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31321
diff
changeset
|
167 | 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
|
168 | purple_serv_set_permit_deny(purple_account_get_connection(dialog->account)); |
| 6371 | 169 | |
| 170 | gtk_widget_hide(dialog->allow_widget); | |
| 171 | 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
|
172 | buttons_sensitive = FALSE; |
| 6371 | 173 | |
|
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
|
174 | if (new_type == PURPLE_ACCOUNT_PRIVACY_ALLOW_USERS) { |
| 6371 | 175 | 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
|
176 | buttons_sensitive = TRUE; |
| 6371 | 177 | dialog->in_allow_list = TRUE; |
| 178 | } | |
|
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
|
179 | else if (new_type == PURPLE_ACCOUNT_PRIVACY_DENY_USERS) { |
| 6371 | 180 | 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
|
181 | buttons_sensitive = TRUE; |
| 6371 | 182 | dialog->in_allow_list = FALSE; |
| 183 | } | |
|
10147
a4897a5bcf8d
[gaim-migrate @ 11224]
Peter Lawler <pidgin@bleeter.id.au>
parents:
9791
diff
changeset
|
184 | |
|
40252
18fd5c5c4625
Don't hide button box in privacy dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40251
diff
changeset
|
185 | 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
|
186 | /* 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
|
187 | 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
|
188 | 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
|
189 | |
| 15884 | 190 | purple_blist_schedule_save(); |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38007
diff
changeset
|
191 | pidgin_blist_refresh(purple_blist_get_default()); |
| 6371 | 192 | } |
| 193 | ||
| 194 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
195 | add_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 196 | { |
| 197 | if (dialog->in_allow_list) | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
198 | pidgin_request_add_permit(dialog->account, NULL); |
| 6371 | 199 | else |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
200 | pidgin_request_add_block(dialog->account, NULL); |
| 6371 | 201 | } |
| 202 | ||
| 203 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
204 | remove_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 205 | { |
| 206 | GtkTreeIter iter; | |
| 207 | GtkTreeModel *model; | |
| 208 | GtkTreeSelection *sel; | |
| 209 | char *name; | |
| 210 | ||
| 211 | if (dialog->in_allow_list && dialog->allow_store == NULL) | |
| 212 | return; | |
| 213 | ||
| 214 | if (!dialog->in_allow_list && dialog->block_store == NULL) | |
| 215 | return; | |
| 216 | ||
| 217 | if (dialog->in_allow_list) { | |
| 218 | model = GTK_TREE_MODEL(dialog->allow_store); | |
| 219 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->allow_list)); | |
| 220 | } | |
| 221 | else { | |
| 222 | model = GTK_TREE_MODEL(dialog->block_store); | |
| 223 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->block_list)); | |
| 224 | } | |
| 225 | ||
| 226 | if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
| 227 | gtk_tree_model_get(model, &iter, 0, &name, -1); | |
| 228 | else | |
| 229 | return; | |
| 230 | ||
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
231 | 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
|
232 | 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
|
233 | 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
|
234 | 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
|
235 | |
|
13149
895f0495b7db
[gaim-migrate @ 15511]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12852
diff
changeset
|
236 | g_free(name); |
| 6371 | 237 | } |
| 238 | ||
| 239 | static void | |
|
22372
2b2d10362583
In Pidgin's privacy dialog:
Mark Doliner <markdoliner@pidgin.im>
parents:
22214
diff
changeset
|
240 | removeall_cb(GtkWidget *button, PidginPrivacyDialog *dialog) |
| 6371 | 241 | { |
| 8556 | 242 | GSList *l; |
| 243 | 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
|
244 | l = purple_account_privacy_get_permitted(dialog->account); |
| 8556 | 245 | else |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
246 | l = purple_account_privacy_get_denied(dialog->account); |
| 8556 | 247 | while (l) { |
| 248 | char *user; | |
| 249 | user = l->data; | |
| 250 | l = l->next; | |
| 251 | 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
|
252 | purple_account_privacy_permit_remove(dialog->account, user, FALSE); |
| 8556 | 253 | 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
|
254 | purple_account_privacy_deny_remove(dialog->account, user, FALSE); |
| 8556 | 255 | } |
| 6371 | 256 | } |
| 257 | ||
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
258 | 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
|
259 | |
| 6371 | 260 | static void |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
261 | pidgin_privacy_dialog_class_init(PidginPrivacyDialogClass *klass) |
| 6371 | 262 | { |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
263 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
264 | |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
265 | gtk_widget_class_set_template_from_resource( |
|
41030
ec8b76f3bf0a
Fix the resource path so we can use the automatic stuff that GtkApplication supports
Gary Kramlich <grim@reaperworld.com>
parents:
40534
diff
changeset
|
266 | widget_class, "/im/pidgin/Pidgin3/Privacy/dialog.ui"); |
|
7165
6547d94b0725
[gaim-migrate @ 7732]
Mark Doliner <markdoliner@pidgin.im>
parents:
6646
diff
changeset
|
267 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
268 | 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
|
269 | account_chooser); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
270 | 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
|
271 | add_button); |
|
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 | allow_list); |
|
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 | allow_store); |
|
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_widget); |
|
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 | block_list); |
|
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 | block_store); |
|
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_widget); |
|
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 | close_button); |
|
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 | remove_button); |
|
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 | removeall_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 | type_menu); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
292 | |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
293 | 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
|
294 | 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
|
295 | 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
|
296 | 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
|
297 | 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
|
298 | gtk_widget_class_bind_template_callback(widget_class, user_selected_cb); |
| 6371 | 299 | } |
| 300 | ||
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
301 | static void |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
302 | pidgin_privacy_dialog_init(PidginPrivacyDialog *dialog) { |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
303 | PidginAccountChooser *chooser = NULL; |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
304 | gssize selected = -1; |
|
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31321
diff
changeset
|
305 | gsize i; |
| 6371 | 306 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
307 | gtk_widget_init_template(GTK_WIDGET(dialog)); |
| 6371 | 308 | |
|
40534
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
309 | chooser = PIDGIN_ACCOUNT_CHOOSER(dialog->account_chooser); |
|
8dad2981fb86
Separate the AccountChooser from its model and move options to filters
Gary Kramlich <grim@reaperworld.com>
parents:
40496
diff
changeset
|
310 | dialog->account = pidgin_account_chooser_get_selected(chooser); |
| 6371 | 311 | |
| 312 | /* 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
|
313 | 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
|
314 | 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
|
315 | _(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
|
316 | |
|
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
|
317 | 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
|
318 | 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
|
319 | } |
|
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
320 | 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
|
321 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
322 | /* Rebuild the allow and block lists views. */ |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
323 | rebuild_allow_list(dialog); |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
324 | rebuild_block_list(dialog); |
| 6371 | 325 | |
|
26931
57f05d09b5b7
Replace the GtkOptionMenu with a GtkComboBox for the privacy options list
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22389
diff
changeset
|
326 | type_changed_cb(GTK_COMBO_BOX(dialog->type_menu), dialog); |
| 6371 | 327 | } |
| 328 | ||
| 329 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
330 | pidgin_privacy_dialog_show(void) |
| 6371 | 331 | { |
| 15884 | 332 | g_return_if_fail(purple_connections_get_all() != NULL); |
|
10352
802e7ab5b838
[gaim-migrate @ 11569]
Mark Doliner <markdoliner@pidgin.im>
parents:
10148
diff
changeset
|
333 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
334 | if (privacy_dialog == NULL) { |
|
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
335 | privacy_dialog = g_object_new(PIDGIN_TYPE_PRIVACY_DIALOG, NULL); |
|
41528
4160c570866d
Convert gtkprivacy.c to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
336 | g_object_add_weak_pointer(G_OBJECT(privacy_dialog), |
|
4160c570866d
Convert gtkprivacy.c to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
337 | (gpointer)&privacy_dialog); |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
338 | } |
| 6371 | 339 | |
|
40251
41e9424fc96f
Convert Privacy dialog to Glade.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40197
diff
changeset
|
340 | gtk_widget_show(GTK_WIDGET(privacy_dialog)); |
| 6371 | 341 | } |
| 342 | ||
| 343 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
344 | pidgin_privacy_dialog_hide(void) |
| 6371 | 345 | { |
|
41528
4160c570866d
Convert gtkprivacy.c to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
346 | if(GTK_IS_WIDGET(privacy_dialog)) { |
|
4160c570866d
Convert gtkprivacy.c to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
347 | gtk_window_destroy(GTK_WINDOW(privacy_dialog)); |
|
4160c570866d
Convert gtkprivacy.c to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
348 | } |
| 6371 | 349 | } |
| 350 | ||
| 351 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
352 | destroy_request_data(PidginPrivacyRequestData *data) |
| 6371 | 353 | { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13775
diff
changeset
|
354 | g_free(data->name); |
| 6371 | 355 | g_free(data); |
| 356 | } | |
| 357 | ||
| 358 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
359 | confirm_permit_block_cb(PidginPrivacyRequestData *data, int option) |
| 6371 | 360 | { |
| 361 | if (data->block) | |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
362 | purple_account_privacy_deny(data->account, data->name); |
| 6371 | 363 | else |
|
34587
a3bc28bb4ef5
Refactored pidgin to use the GObject-based PurpleAccount API
Ankit Vani <a@nevitus.org>
parents:
34586
diff
changeset
|
364 | purple_account_privacy_allow(data->account, data->name); |
| 6371 | 365 | |
| 366 | destroy_request_data(data); | |
| 367 | } | |
| 368 | ||
| 369 | static void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
370 | add_permit_block_cb(PidginPrivacyRequestData *data, const char *name) |
| 6371 | 371 | { |
| 372 | data->name = g_strdup(name); | |
| 373 | ||
| 374 | confirm_permit_block_cb(data, 0); | |
| 375 | } | |
| 376 | ||
| 377 | void | |
| 15884 | 378 | pidgin_request_add_permit(PurpleAccount *account, const char *name) |
| 6371 | 379 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
380 | PidginPrivacyRequestData *data; |
| 6371 | 381 | |
| 382 | g_return_if_fail(account != NULL); | |
| 383 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
384 | data = g_new0(PidginPrivacyRequestData, 1); |
| 6371 | 385 | data->account = account; |
| 386 | data->name = g_strdup(name); | |
| 387 | data->block = FALSE; | |
| 388 | ||
| 389 | if (name == NULL) { | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
390 | purple_request_input(account, _("Permit User"), |
| 6371 | 391 | _("Type a user you permit to contact you."), |
| 392 | _("Please enter the name of the user you wish to be " | |
| 393 | "able to contact you."), | |
| 8697 | 394 | NULL, FALSE, FALSE, NULL, |
| 12603 | 395 | _("_Permit"), G_CALLBACK(add_permit_block_cb), |
| 6371 | 396 | _("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
|
397 | purple_request_cpar_from_account(account), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
398 | data); |
| 6371 | 399 | } |
| 400 | else { | |
| 401 | char *primary = g_strdup_printf(_("Allow %s to contact you?"), name); | |
| 402 | char *secondary = | |
| 403 | g_strdup_printf(_("Are you sure you wish to allow " | |
| 404 | "%s to contact you?"), name); | |
| 405 | ||
| 406 | ||
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
407 | 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
|
408 | 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
|
409 | data, 2, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
410 | _("_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
|
411 | _("Cancel"), G_CALLBACK(destroy_request_data)); |
| 6371 | 412 | |
| 413 | g_free(primary); | |
| 414 | g_free(secondary); | |
| 415 | } | |
| 416 | } | |
| 417 | ||
| 418 | void | |
| 15884 | 419 | pidgin_request_add_block(PurpleAccount *account, const char *name) |
| 6371 | 420 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
421 | PidginPrivacyRequestData *data; |
| 6371 | 422 | |
| 423 | g_return_if_fail(account != NULL); | |
| 424 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
425 | data = g_new0(PidginPrivacyRequestData, 1); |
| 6371 | 426 | data->account = account; |
| 427 | data->name = g_strdup(name); | |
| 428 | data->block = TRUE; | |
| 429 | ||
| 430 | if (name == NULL) { | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
431 | purple_request_input(account, _("Block User"), |
| 6371 | 432 | _("Type a user to block."), |
| 433 | _("Please enter the name of the user you wish to block."), | |
| 8697 | 434 | NULL, FALSE, FALSE, NULL, |
| 12603 | 435 | _("_Block"), G_CALLBACK(add_permit_block_cb), |
| 6371 | 436 | _("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
|
437 | purple_request_cpar_from_account(account), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
438 | data); |
| 6371 | 439 | } |
| 440 | else { | |
| 441 | char *primary = g_strdup_printf(_("Block %s?"), name); | |
| 442 | char *secondary = | |
| 443 | g_strdup_printf(_("Are you sure you want to block %s?"), name); | |
| 444 | ||
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
445 | 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
|
446 | 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
|
447 | data, 2, |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
448 | _("_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
|
449 | _("Cancel"), G_CALLBACK(destroy_request_data)); |
| 6371 | 450 | |
| 451 | g_free(primary); | |
| 452 | g_free(secondary); | |
| 453 | } | |
| 454 | } | |
| 455 | ||
| 456 | static void | |
| 15884 | 457 | pidgin_permit_added_removed(PurpleAccount *account, const char *name) |
| 6371 | 458 | { |
| 459 | if (privacy_dialog != NULL) | |
| 460 | rebuild_allow_list(privacy_dialog); | |
| 461 | } | |
| 462 | ||
| 463 | static void | |
| 15884 | 464 | pidgin_deny_added_removed(PurpleAccount *account, const char *name) |
| 6371 | 465 | { |
| 466 | if (privacy_dialog != NULL) | |
| 467 | rebuild_block_list(privacy_dialog); | |
| 468 | } | |
| 469 | ||
| 470 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15486
diff
changeset
|
471 | pidgin_privacy_init(void) |
| 6371 | 472 | { |
|
35040
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
473 | PurpleAccountUiOps *ops = pidgin_accounts_get_ui_ops(); |
|
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
474 | |
|
f80a806325a4
Made pidgin_{permit|deny}_{added|removed} static
Ankit Vani <a@nevitus.org>
parents:
34940
diff
changeset
|
475 | 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
|
476 | ops->deny_added = ops->deny_removed = pidgin_deny_added_removed; |
| 6371 | 477 | } |