pidgin/gtkutils.c

Wed, 15 Nov 2023 16:07:26 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Wed, 15 Nov 2023 16:07:26 -0600
changeset 42501
d1f17ab61ecf
parent 42410
563e7a17c220
child 42550
d745bb34f491
permissions
-rw-r--r--

Remove a few gtk utility functions

Testing Done:
Compiled

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

20147
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 20036
diff changeset
1 /* pidgin
4359
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7988
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7988
diff changeset
5 * source distribution.
7060
717cbeb22b6d [gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents: 6846
diff changeset
6 *
4359
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * (at your option) any later version.
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 *
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * GNU General Public License for more details.
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 *
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
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: 19547
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
4359
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 */
24569
5dbd0617a27d Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents: 23501
diff changeset
21
42410
563e7a17c220 Fix possible clash of config headers
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42347
diff changeset
22 #include <purpleconfig.h>
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
23
40462
24ed25d87550 Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
24 #include <errno.h>
24ed25d87550 Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
25
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
26 #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
27 #include <glib/gstdio.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
28
42347
d768e30362a4 Fix some random include issues
Gary Kramlich <grim@reaperworld.com>
parents: 42342
diff changeset
29 #include <gdk/gdkkeysyms.h>
d768e30362a4 Fix some random include issues
Gary Kramlich <grim@reaperworld.com>
parents: 42342
diff changeset
30
40474
1341be8e3402 Make it so only libpurple can directly include libpurple header files.
Gary Kramlich <grim@reaperworld.com>
parents: 40462
diff changeset
31 #include <purple.h>
1341be8e3402 Make it so only libpurple can directly include libpurple header files.
Gary Kramlich <grim@reaperworld.com>
parents: 40462
diff changeset
32
33477
ed01a53b8afc These changes were what I needed to be able to build on a Macbook Pro with OS
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 33359
diff changeset
33 #ifdef _WIN32
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
34 # undef small
35892
02bf3200b9cb cross-win32: make use of WIN32_LEAN_AND_MEAN define
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35856
diff changeset
35 # include <shellapi.h>
4359
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 #endif /*_WIN32*/
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
37
9709
2e73f176cc80 [gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents: 9706
diff changeset
38 #include "gtkdialogs.h"
34451
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
39 #include "gtkrequest.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
40 #include "gtkutils.h"
42161
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
41 #include "pidginaccountchooser.h"
40496
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40490
diff changeset
42 #include "pidgincore.h"
4359
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
44 /******************************************************************************
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
45 * Enums
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
46 *****************************************************************************/
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
47
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
48 enum {
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
49 AOP_ICON_COLUMN,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
50 AOP_NAME_COLUMN,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
51 AOP_DATA_COLUMN,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
52 AOP_COLUMN_COUNT
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
53 };
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
54
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
55 enum {
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
56 COMPLETION_DISPLAYED_COLUMN, /* displayed completion value */
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
57 COMPLETION_BUDDY_COLUMN, /* buddy name */
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
58 COMPLETION_NORMALIZED_COLUMN, /* UTF-8 normalized & casefolded buddy name */
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
59 COMPLETION_COMPARISON_COLUMN, /* UTF-8 normalized & casefolded value for comparison */
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
60 COMPLETION_ACCOUNT_COLUMN, /* account */
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
61 COMPLETION_COLUMN_COUNT
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
62 };
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
63
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
64 /******************************************************************************
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
65 * Structs
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
66 *****************************************************************************/
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
67
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
68 typedef struct
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
69 {
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
70 GtkWidget *entry;
42161
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
71 GtkWidget *chooser;
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
72
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
73 PidginFilterBuddyCompletionEntryFunc filter_func;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
74 gpointer filter_func_user_data;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
75
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
76 GtkListStore *store;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
77 } PidginCompletionData;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
78
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
79 /******************************************************************************
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
80 * Code
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
81 *****************************************************************************/
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
82
41924
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
83 void
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
84 pidgin_retrieve_user_info(PurpleConnection *conn, const char *name) {
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
85 PurpleNotifyUserInfo *info = NULL;
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
86 PurpleProtocol *protocol = NULL;
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
87
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
88 protocol = purple_connection_get_protocol(conn);
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
89 if(!PURPLE_IS_PROTOCOL_SERVER(protocol)) {
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
90 return;
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
91 }
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
92
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
93 purple_protocol_server_get_info(PURPLE_PROTOCOL_SERVER(protocol), conn,
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
94 name);
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
95
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
96 info = purple_notify_user_info_new();
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
97 purple_notify_user_info_add_pair_plaintext(info, _("Information"),
7646d24a31be Inline purple_serv_get_info and purple_serv_set_info
Gary Kramlich <grim@reaperworld.com>
parents: 41797
diff changeset
98 _("Retrieving..."));
17387
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
99 purple_notify_userinfo(conn, name, info, NULL, NULL);
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
100 purple_notify_user_info_destroy(info);
18281
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
101 }
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
102
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
103 void pidgin_retrieve_user_info_in_chat(PurpleConnection *conn, const char *name, int chat)
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
104 {
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
105 char *who = NULL;
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
106 PurpleProtocol *protocol = NULL;
18281
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
107
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
108 if (chat < 0) {
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
109 pidgin_retrieve_user_info(conn, name);
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
110 return;
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
111 }
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
112
36623
caaadef03507 Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents: 36608
diff changeset
113 protocol = purple_connection_get_protocol(conn);
36633
2dcb81a189bd Refactored pidgin to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36626
diff changeset
114 if (protocol != NULL)
40697
81f81f5d2f39 Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents: 40693
diff changeset
115 who = purple_protocol_chat_get_user_real_name(PURPLE_PROTOCOL_CHAT(protocol), conn, chat, name);
36633
2dcb81a189bd Refactored pidgin to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36626
diff changeset
116
2dcb81a189bd Refactored pidgin to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36626
diff changeset
117 pidgin_retrieve_user_info(conn, who ? who : name);
18281
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
118 g_free(who);
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
119 }
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
120
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
121 void
35720
863f87bfc06e Smiley manager: cleanup
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35713
diff changeset
122 pidgin_set_accessible_label(GtkWidget *w, GtkLabel *l)
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
123 {
41568
8effab29be30 Make a11y utility functions work on GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41567
diff changeset
124 GtkAccessible *acc, *label;
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
125
41568
8effab29be30 Make a11y utility functions work on GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41567
diff changeset
126 acc = GTK_ACCESSIBLE(w);
8effab29be30 Make a11y utility functions work on GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41567
diff changeset
127 label = GTK_ACCESSIBLE(l);
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
128
18351
b881759cda28 Call gtk_label_set_mnemonic_widget() in pidgin_make_accessible_label. Closes #589
Sean Egan <seanegan@pidgin.im>
parents: 18281
diff changeset
129 /* Make sure mnemonics work */
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
130 gtk_label_set_mnemonic_widget(l, w);
20241
36b8b9235ff3 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20234
diff changeset
131
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
132 /* Create the labeled-by relation */
41568
8effab29be30 Make a11y utility functions work on GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41567
diff changeset
133 gtk_accessible_update_relation(acc, GTK_ACCESSIBLE_RELATION_LABELLED_BY,
8effab29be30 Make a11y utility functions work on GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41567
diff changeset
134 label, NULL, -1);
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
135 }
8143
ce4b6383777b [gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents: 8137
diff changeset
136
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41924
diff changeset
137 static gboolean
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41924
diff changeset
138 buddyname_completion_match_func(GtkEntryCompletion *completion,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41924
diff changeset
139 const char *key, GtkTreeIter *iter,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41924
diff changeset
140 G_GNUC_UNUSED gpointer user_data)
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
141 {
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
142 GtkTreeModel *model;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
143 GValue val1;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
144 GValue val2;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
145 const char *tmp;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
146
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
147 model = gtk_entry_completion_get_model(completion);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
148
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
149 val1.g_type = 0;
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
150 gtk_tree_model_get_value(model, iter, COMPLETION_NORMALIZED_COLUMN, &val1);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
151 tmp = g_value_get_string(&val1);
40125
a7acc7b00d79 Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40094
diff changeset
152 if (tmp != NULL && g_str_has_prefix(tmp, key)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
153 g_value_unset(&val1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
154 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
155 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
156 g_value_unset(&val1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
157
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
158 val2.g_type = 0;
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
159 gtk_tree_model_get_value(model, iter, COMPLETION_COMPARISON_COLUMN, &val2);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
160 tmp = g_value_get_string(&val2);
40125
a7acc7b00d79 Replace purple_str_has_{prefix,suffix} by g_str_has_{prefix,suffix}.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40094
diff changeset
161 if (tmp != NULL && g_str_has_prefix(tmp, key)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
162 g_value_unset(&val2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
163 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
164 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
165 g_value_unset(&val2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
166
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
167 return FALSE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
168 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
169
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41924
diff changeset
170 static gboolean
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41924
diff changeset
171 buddyname_completion_match_selected_cb(G_GNUC_UNUSED GtkEntryCompletion *completion,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41924
diff changeset
172 GtkTreeModel *model, GtkTreeIter *iter,
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41924
diff changeset
173 PidginCompletionData *data)
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
174 {
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
175 GValue val;
42161
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
176 PurpleAccount *account = NULL;
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
177
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
178 val.g_type = 0;
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
179 gtk_tree_model_get_value(model, iter, COMPLETION_BUDDY_COLUMN, &val);
41531
2b86501d13fe Replace gtk_entry_[gs]et_text with gtk_editable_[gs]et_text
Gary Kramlich <grim@reaperworld.com>
parents: 41526
diff changeset
180 gtk_editable_set_text(GTK_EDITABLE(data->entry), g_value_get_string(&val));
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
181 g_value_unset(&val);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
182
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
183 gtk_tree_model_get_value(model, iter, COMPLETION_ACCOUNT_COLUMN, &val);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
184 account = g_value_get_pointer(&val);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
185 g_value_unset(&val);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
186
42161
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
187 if(!PURPLE_IS_ACCOUNT(account)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
188 return TRUE;
42161
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
189 }
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
190
42161
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
191 if(PIDGIN_IS_ACCOUNT_CHOOSER(data->chooser)) {
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
192 pidgin_account_chooser_set_selected(PIDGIN_ACCOUNT_CHOOSER(data->chooser),
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
193 account);
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
194 }
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
195
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
196 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
197 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
198
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
199 static void
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
200 add_buddyname_autocomplete_entry(GtkListStore *store, const char *buddy_alias, const char *contact_alias,
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
201 const PurpleAccount *account, const char *buddyname)
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
202 {
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
203 GtkTreeIter iter;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
204 gboolean completion_added = FALSE;
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
205 gchar *normalized_buddyname;
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
206 gchar *tmp;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
207
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
208 tmp = g_utf8_normalize(buddyname, -1, G_NORMALIZE_DEFAULT);
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
209 normalized_buddyname = g_utf8_casefold(tmp, -1);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
210 g_free(tmp);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
211
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
212 /* There's no sense listing things like: 'xxx "xxx"'
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
213 when the name and buddy alias match. */
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
214 if (buddy_alias && !purple_strequal(buddy_alias, buddyname)) {
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
215 char *completion_entry = g_strdup_printf("%s \"%s\"", buddyname, buddy_alias);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
216 char *tmp2 = g_utf8_normalize(buddy_alias, -1, G_NORMALIZE_DEFAULT);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
217
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
218 tmp = g_utf8_casefold(tmp2, -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
219 g_free(tmp2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
220
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
221 gtk_list_store_append(store, &iter);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
222 gtk_list_store_set(store, &iter,
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
223 COMPLETION_DISPLAYED_COLUMN, completion_entry,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
224 COMPLETION_BUDDY_COLUMN, buddyname,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
225 COMPLETION_NORMALIZED_COLUMN, normalized_buddyname,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
226 COMPLETION_COMPARISON_COLUMN, tmp,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
227 COMPLETION_ACCOUNT_COLUMN, account,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
228 -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
229 g_free(completion_entry);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
230 g_free(tmp);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
231 completion_added = TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
232 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
233
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
234 /* There's no sense listing things like: 'xxx "xxx"'
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
235 when the name and contact alias match. */
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
236 if (contact_alias && !purple_strequal(contact_alias, buddyname)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
237 /* We don't want duplicates when the contact and buddy alias match. */
38260
dcada91c0912 Remove redundant NULL checks
qarkai <qarkai@gmail.com>
parents: 38259
diff changeset
238 if (!purple_strequal(contact_alias, buddy_alias)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
239 char *completion_entry = g_strdup_printf("%s \"%s\"",
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
240 buddyname, contact_alias);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
241 char *tmp2 = g_utf8_normalize(contact_alias, -1, G_NORMALIZE_DEFAULT);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
242
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
243 tmp = g_utf8_casefold(tmp2, -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
244 g_free(tmp2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
245
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
246 gtk_list_store_append(store, &iter);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
247 gtk_list_store_set(store, &iter,
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
248 COMPLETION_DISPLAYED_COLUMN, completion_entry,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
249 COMPLETION_BUDDY_COLUMN, buddyname,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
250 COMPLETION_NORMALIZED_COLUMN, normalized_buddyname,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
251 COMPLETION_COMPARISON_COLUMN, tmp,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
252 COMPLETION_ACCOUNT_COLUMN, account,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
253 -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
254 g_free(completion_entry);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
255 g_free(tmp);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
256 completion_added = TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
257 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
258 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
259
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
260 if (completion_added == FALSE) {
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
261 /* Add the buddy's name. */
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
262 gtk_list_store_append(store, &iter);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
263 gtk_list_store_set(store, &iter,
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
264 COMPLETION_DISPLAYED_COLUMN, buddyname,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
265 COMPLETION_BUDDY_COLUMN, buddyname,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
266 COMPLETION_NORMALIZED_COLUMN, normalized_buddyname,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
267 COMPLETION_COMPARISON_COLUMN, NULL,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
268 COMPLETION_ACCOUNT_COLUMN, account,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
269 -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
270 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
271
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
272 g_free(normalized_buddyname);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
273 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
274
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
275 static void
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
276 add_completion_list(PidginCompletionData *data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
277 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
278 PurpleBlistNode *gnode, *cnode, *bnode;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
279 PidginFilterBuddyCompletionEntryFunc filter_func = data->filter_func;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
280 gpointer user_data = data->filter_func_user_data;
34739
7d507b8b9f92 Refactored pidgin to use the GObject BList API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
281 gchar *alias;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
282
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
283 gtk_list_store_clear(data->store);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
284
39665
2172e3b8eeef Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39568
diff changeset
285 for (gnode = purple_blist_get_default_root(); gnode != NULL;
2172e3b8eeef Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39568
diff changeset
286 gnode = gnode->next) {
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 34662
diff changeset
287 if (!PURPLE_IS_GROUP(gnode))
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
288 continue;
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
289
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
290 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
291 {
41733
a9085b52de8b Rename PurpleContact to PurpleMetaContact.
Gary Kramlich <grim@reaperworld.com>
parents: 41629
diff changeset
292 if (!PURPLE_IS_META_CONTACT(cnode))
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
293 continue;
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
294
34769
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
295 g_object_get(cnode, "alias", &alias, NULL);
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
296
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
297 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
298 {
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
299 PidginBuddyCompletionEntry entry;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
300 entry.is_buddy = TRUE;
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41097
diff changeset
301 entry.buddy = (PurpleBuddy *) bnode;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
302
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
303 if (filter_func(&entry, user_data)) {
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
304 add_buddyname_autocomplete_entry(data->store,
34739
7d507b8b9f92 Refactored pidgin to use the GObject BList API
Ankit Vani <a@nevitus.org>
parents: 34728
diff changeset
305 alias,
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41097
diff changeset
306 purple_buddy_get_contact_alias(entry.buddy),
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41097
diff changeset
307 purple_buddy_get_account(entry.buddy),
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41097
diff changeset
308 purple_buddy_get_name(entry.buddy)
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
309 );
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
310 }
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
311 }
34769
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
312
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
313 g_free(alias);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
314 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
315 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
316 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
317
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
318 static void
41947
7b3312d0760c Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41924
diff changeset
319 repopulate_autocomplete(G_GNUC_UNUSED gpointer something, gpointer data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
320 {
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
321 add_completion_list(data);
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
322 }
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
323
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
324 static void
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
325 autocomplete_account_added_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
326 G_GNUC_UNUSED PurpleAccount *account,
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
327 gpointer data)
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
328 {
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
329 add_completion_list(data);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
330 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
331
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
332 static void
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
333 autocomplete_account_removed_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
334 G_GNUC_UNUSED PurpleAccount *account,
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
335 gpointer data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
336 {
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
337 add_completion_list(data);
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
338 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
339
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
340 static void
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
341 buddyname_autocomplete_destroyed_cb(GtkWidget *widget, gpointer data)
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
342 {
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
343 PurpleAccountManager *manager = purple_account_manager_get_default();
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
344
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
345 purple_signals_disconnect_by_handle(widget);
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
346
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
347 g_signal_handlers_disconnect_by_func(manager,
42246
3230f1a1fb8f Remove unnecessary casting from g_signal_handlers_disconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42231
diff changeset
348 autocomplete_account_added_cb, data);
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
349 g_signal_handlers_disconnect_by_func(manager,
42246
3230f1a1fb8f Remove unnecessary casting from g_signal_handlers_disconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42231
diff changeset
350 autocomplete_account_removed_cb,
3230f1a1fb8f Remove unnecessary casting from g_signal_handlers_disconnect
Gary Kramlich <grim@reaperworld.com>
parents: 42231
diff changeset
351 data);
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
352
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
353 g_free(data);
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
354 }
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
355
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
356 void
39796
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
357 pidgin_setup_screenname_autocomplete(
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
358 GtkWidget *entry, GtkWidget *chooser,
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
359 PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
360 {
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
361 PidginCompletionData *data;
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
362 PurpleAccountManager *manager = NULL;
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
363
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
364 /*
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
365 * Store the displayed completion value, the buddy name, the UTF-8
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
366 * normalized & casefolded buddy name, the UTF-8 normalized &
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
367 * casefolded value for comparison, and the account.
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
368 */
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
369 GtkListStore *store;
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
370
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
371 GtkEntryCompletion *completion;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
372
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
373 data = g_new0(PidginCompletionData, 1);
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
374 store = gtk_list_store_new(COMPLETION_COLUMN_COUNT, G_TYPE_STRING,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
375 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
376 G_TYPE_POINTER);
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
377
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
378 data->entry = entry;
42161
152522734e16 Fix username autocompletion
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41947
diff changeset
379 data->chooser = chooser;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
380 if (filter_func == NULL) {
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
381 data->filter_func = pidgin_screenname_autocomplete_default_filter;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
382 data->filter_func_user_data = NULL;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
383 } else {
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
384 data->filter_func = filter_func;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
385 data->filter_func_user_data = user_data;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
386 }
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
387 data->store = store;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
388
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
389 add_completion_list(data);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
390
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
391 /* Sort the completion list by buddy name */
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
392 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
393 COMPLETION_BUDDY_COLUMN,
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
394 GTK_SORT_ASCENDING);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
395
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
396 completion = gtk_entry_completion_new();
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
397 gtk_entry_completion_set_match_func(completion, buddyname_completion_match_func, NULL, NULL);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
398
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
399 g_signal_connect(G_OBJECT(completion), "match-selected",
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
400 G_CALLBACK(buddyname_completion_match_selected_cb), data);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
401
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
402 gtk_entry_set_completion(GTK_ENTRY(entry), completion);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
403 g_object_unref(completion);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
404
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
405 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store));
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
406 g_object_unref(store);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
407
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
408 gtk_entry_completion_set_text_column(completion, COMPLETION_DISPLAYED_COLUMN);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
409
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
410 purple_signal_connect(purple_connections_get_handle(), "signed-on", entry,
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41312
diff changeset
411 G_CALLBACK(repopulate_autocomplete), data);
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
412 purple_signal_connect(purple_connections_get_handle(), "signed-off", entry,
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41312
diff changeset
413 G_CALLBACK(repopulate_autocomplete), data);
13366
e01cf252b407 [gaim-migrate @ 15738]
Richard Laager <rlaager@pidgin.im>
parents: 13365
diff changeset
414
41797
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
415 manager = purple_account_manager_get_default();
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
416 g_signal_connect(manager, "added",
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
417 G_CALLBACK(autocomplete_account_added_cb), data);
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
418 g_signal_connect(manager, "removed",
3bc9948e9f3c Use PurpleAccountManager added/removed signals
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41766
diff changeset
419 G_CALLBACK(autocomplete_account_removed_cb), data);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
420
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
421 g_signal_connect(G_OBJECT(entry), "destroy", G_CALLBACK(buddyname_autocomplete_destroyed_cb), data);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
422 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
423
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
424 gboolean
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
425 pidgin_screenname_autocomplete_default_filter(const PidginBuddyCompletionEntry *completion_entry, gpointer all_accounts) {
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
426 gboolean all = GPOINTER_TO_INT(all_accounts);
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
427
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41097
diff changeset
428 return all || purple_account_is_connected(purple_buddy_get_account(completion_entry->buddy));
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
429 }
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
430
22131
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
431 GtkWidget *
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
432 pidgin_add_widget_to_vbox(GtkBox *vbox, const char *widget_label, GtkSizeGroup *sg, GtkWidget *widget, gboolean expand, GtkWidget **p_label)
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
433 {
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
434 GtkWidget *hbox;
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
435 GtkWidget *label = NULL;
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
436
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
437 if (widget_label) {
35527
707c3c2b2c8a Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35506
diff changeset
438 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
41572
218b27397c2b Port gtkutils to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41569
diff changeset
439 gtk_box_append(vbox, hbox);
22131
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
440
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
441 label = gtk_label_new_with_mnemonic(widget_label);
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
442 if (sg) {
38007
3b971d2ecae1 Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37997
diff changeset
443 gtk_label_set_xalign(GTK_LABEL(label), 0);
22131
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
444 gtk_size_group_add_widget(sg, label);
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
445 }
41572
218b27397c2b Port gtkutils to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41569
diff changeset
446 gtk_box_append(GTK_BOX(hbox), label);
218b27397c2b Port gtkutils to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41569
diff changeset
447
218b27397c2b Port gtkutils to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41569
diff changeset
448 gtk_widget_set_hexpand(widget, expand);
218b27397c2b Port gtkutils to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41569
diff changeset
449 gtk_box_append(GTK_BOX(hbox), widget);
22131
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
450 } else {
41572
218b27397c2b Port gtkutils to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41569
diff changeset
451 gtk_widget_set_vexpand(widget, expand);
218b27397c2b Port gtkutils to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41569
diff changeset
452 gtk_box_append(vbox, widget);
218b27397c2b Port gtkutils to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41569
diff changeset
453
22131
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
454 hbox = GTK_WIDGET(vbox);
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
455 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
456
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
457 if (label) {
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
458 gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget);
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
459 pidgin_set_accessible_label(widget, GTK_LABEL(label));
22131
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
460 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
461
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
462 if (p_label)
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
463 (*p_label) = label;
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
464 return hbox;
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
465 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
466
22007
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
467 gboolean pidgin_auto_parent_window(GtkWidget *widget)
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
468 {
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
469 /* This finds the currently active window and makes that the parent window. */
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
470 GList *windows = NULL;
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
471 GtkWindow *parent = NULL;
34451
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
472 gpointer parent_from;
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
473 PurpleNotifyType notify_type;
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
474
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
475 parent_from = g_object_get_data(G_OBJECT(widget), "pidgin-parent-from");
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
476 if (purple_request_is_valid_ui_handle(parent_from, NULL)) {
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
477
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
478 gtk_window_set_transient_for(GTK_WINDOW(widget),
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
479 gtk_window_get_transient_for(
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
480 pidgin_request_get_dialog_window(parent_from)));
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
481 return TRUE;
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
482 }
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
483 if (purple_notify_is_valid_ui_handle(parent_from, &notify_type) &&
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
484 notify_type == PURPLE_NOTIFY_MESSAGE)
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
485 {
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
486 gtk_window_set_transient_for(GTK_WINDOW(widget),
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
487 gtk_window_get_transient_for(GTK_WINDOW(parent_from)));
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
488 return TRUE;
b7165d4e1d73 Implement purple_*_is_valid_ui_handle, purple_request_cpar_*et_parent_from, pidgin_request_get_dialog_window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34449
diff changeset
489 }
22007
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
490
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
491 windows = gtk_window_list_toplevels();
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
492 while (windows) {
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
493 GtkWindow *window = GTK_WINDOW(windows->data);
22007
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
494 windows = g_list_delete_link(windows, windows);
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
495
34447
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
496 if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(window),
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
497 "pidgin-window-is-closing")))
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
498 {
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
499 parent = gtk_window_get_transient_for(window);
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
500 break;
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
501 }
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
502
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
503 if (GTK_WIDGET(window) == widget ||
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
504 !gtk_widget_get_visible(GTK_WIDGET(window))) {
22007
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
505 continue;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
506 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
507
41572
218b27397c2b Port gtkutils to GTK4
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41569
diff changeset
508 if (gtk_window_is_active(window)) {
22007
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
509 parent = window;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
510 break;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
511 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
512 }
42172
7c2d151b410d Use g_clear_* helpers where useful
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42161
diff changeset
513 g_clear_list(&windows, NULL);
22007
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
514 if (parent) {
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
515 gtk_window_set_transient_for(GTK_WINDOW(widget), parent);
22007
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
516 return TRUE;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
517 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
518 return FALSE;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
519 }

mercurial