pidgin/gtkutils.c

Thu, 21 Jul 2022 20:47:58 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 21 Jul 2022 20:47:58 -0500
branch
gtk4
changeset 41557
479fdb903b82
parent 41531
2b86501d13fe
child 41567
517ac516af27
permissions
-rw-r--r--

Convert the conversations status page to adwaita

Testing Done:
Compiled.

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

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
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
22 #ifdef HAVE_CONFIG_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 # include <config.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
24 #endif
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
25
40462
24ed25d87550 Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
26 #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
27
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
28 #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
29 #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
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
4359
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 #include <gdk/gdkkeysyms.h>
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
39
39690
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
40 #include <talkatu.h>
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
41
24674
36bf974a7d78 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24672
diff changeset
42 #include "gtkaccount.h"
36bf974a7d78 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24672
diff changeset
43
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
44 #include "gtkconv.h"
9709
2e73f176cc80 [gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents: 9706
diff changeset
45 #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
46 #include "gtkrequest.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
47 #include "gtkutils.h"
40496
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40490
diff changeset
48 #include "pidgincore.h"
4359
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
50 /******************************************************************************
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
51 * Enums
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
52 *****************************************************************************/
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
53
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
54 enum {
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
55 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
56 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
57 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
58 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
59 };
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
60
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
61 enum {
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
62 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
63 COMPLETION_BUDDY_COLUMN, /* buddy name */
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
64 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
65 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
66 COMPLETION_ACCOUNT_COLUMN, /* account */
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
67 COMPLETION_COLUMN_COUNT
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
68 };
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 /******************************************************************************
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
71 * Structs
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
17118
4fbaa628dd8e Formatting changes.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17117
diff changeset
74 typedef struct {
32388
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
75 GtkTreeModel *model;
17234
6e430db9b926 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents: 17233
diff changeset
76 gint default_item;
17375
0d9082502e58 Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17238
diff changeset
77 } AopMenu;
17117
d256023d5312 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17116
diff changeset
78
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
79 typedef struct
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
80 {
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
81 GtkWidget *entry;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
82 GtkWidget *accountopt;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
83
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
84 PidginFilterBuddyCompletionEntryFunc filter_func;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
85 gpointer filter_func_user_data;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
86
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
87 GtkListStore *store;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
88 } PidginCompletionData;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
89
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
90 struct _icon_chooser {
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
91 GtkFileChooserNative *icon_filesel;
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
92
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
93 void (*callback)(const char*,gpointer);
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
94 gpointer data;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
95 };
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
96
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
97 /******************************************************************************
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
98 * Code
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
99 *****************************************************************************/
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
100
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
101 GtkWidget *
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
102 pidgin_make_frame(GtkWidget *parent, const char *title)
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
103 {
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
104 GtkWidget *vbox, *vbox2, *hbox;
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
105 GtkLabel *label;
13100
56bf8002ddc6 [gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents: 13092
diff changeset
106 char *labeltitle;
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
107
40490
fb6e46c4c63c Remove PIDGIN_HIG_* constants
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
108 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
109 gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0);
5641
a9d1f7917dd4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
110 gtk_widget_show(vbox);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
111
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
112 label = GTK_LABEL(gtk_label_new(NULL));
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
113
13100
56bf8002ddc6 [gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents: 13092
diff changeset
114 labeltitle = g_strdup_printf("<span weight=\"bold\">%s</span>", title);
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
115 gtk_label_set_markup(label, labeltitle);
13100
56bf8002ddc6 [gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents: 13092
diff changeset
116 g_free(labeltitle);
56bf8002ddc6 [gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents: 13092
diff changeset
117
38007
3b971d2ecae1 Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37997
diff changeset
118 gtk_label_set_xalign(GTK_LABEL(label), 0);
3b971d2ecae1 Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37997
diff changeset
119 gtk_label_set_yalign(GTK_LABEL(label), 0);
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
120 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(label), FALSE, FALSE, 0);
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
121 gtk_widget_show(GTK_WIDGET(label));
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
122 pidgin_set_accessible_label(vbox, label);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
123
40490
fb6e46c4c63c Remove PIDGIN_HIG_* constants
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
124 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
125 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
5641
a9d1f7917dd4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
126 gtk_widget_show(hbox);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
127
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
128 label = GTK_LABEL(gtk_label_new(" "));
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
129 gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), FALSE, FALSE, 0);
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
130 gtk_widget_show(GTK_WIDGET(label));
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
131
40490
fb6e46c4c63c Remove PIDGIN_HIG_* constants
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
132 vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
34186
1d9ea89d4934 Group and string support for keyring settings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
133 gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 0);
1d9ea89d4934 Group and string support for keyring settings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
134 gtk_widget_show(vbox2);
1d9ea89d4934 Group and string support for keyring settings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
135
1d9ea89d4934 Group and string support for keyring settings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
136 g_object_set_data(G_OBJECT(vbox2), "main-vbox", vbox);
1d9ea89d4934 Group and string support for keyring settings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
137
1d9ea89d4934 Group and string support for keyring settings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
138 return vbox2;
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
139 }
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
140
40297
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents: 40278
diff changeset
141 GdkPixbuf *
41037
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
142 pidgin_create_icon_from_protocol(PurpleProtocol *protocol,
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
143 PidginProtocolIconSize size,
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
144 PurpleAccount *account)
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
145 {
41037
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
146 GdkPixbuf *pixbuf;
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
147 const char *protoname = NULL;
41037
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
148 const gchar *icon_name = NULL;
18216
f34603f4631e Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@pidgin.im>
parents: 18193
diff changeset
149 char *tmp;
41067
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
150 GtkIconTheme *theme = NULL;
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
151 gint dimensions = 0;
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
152
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
153 theme = gtk_icon_theme_get_default();
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
154 if(size == PIDGIN_PROTOCOL_ICON_SMALL) {
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
155 dimensions = 16;
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
156 } else if(size == PIDGIN_PROTOCOL_ICON_MEDIUM) {
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
157 dimensions = 22;
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
158 } else {
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
159 dimensions = 48;
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
160 }
41037
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
161
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
162 /* If the protocol specified an icon-name try to load it from the icon
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
163 * theme.
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
164 */
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
165 icon_name = purple_protocol_get_icon_name(protocol);
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
166 if(icon_name != NULL) {
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
167 pixbuf = gtk_icon_theme_load_icon(theme, icon_name, dimensions,
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
168 GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
169
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
170 if(GDK_IS_PIXBUF(pixbuf)) {
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
171 return pixbuf;
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
172 }
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
173
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
174 }
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
175
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
176 protoname = purple_protocol_get_list_icon(protocol, account, NULL);
41067
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
177 if (protoname == NULL) {
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
178 return NULL;
41067
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
179 }
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
180
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
181 /*
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
182 * Status icons will be themeable too, and then it will look up
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
183 * protoname from the theme
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
184 */
41067
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
185 tmp = g_strconcat("im-", protoname, NULL);
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
186 pixbuf = gtk_icon_theme_load_icon(theme, tmp, dimensions,
3d135d1f8b6e Make pidgin_create_icon_from_protocol use icon theme lookup for protocol icons
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41058
diff changeset
187 GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
18216
f34603f4631e Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@pidgin.im>
parents: 18193
diff changeset
188 g_free(tmp);
f34603f4631e Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@pidgin.im>
parents: 18193
diff changeset
189
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
190 return pixbuf;
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
191 }
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
192
17117
d256023d5312 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17116
diff changeset
193 static void
17118
4fbaa628dd8e Formatting changes.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17117
diff changeset
194 aop_option_menu_select_by_data(GtkWidget *optmenu, gpointer data)
17014
1e90cfae53dd disapproval of revision '41be962a27d1633445fef2055c4a0db183f104dc'
Richard Laager <rlaager@pidgin.im>
parents: 17013
diff changeset
195 {
32388
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
196 GtkTreeModel *model;
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
197 GtkTreeIter iter;
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
198 gpointer iter_data;
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
199 model = gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu));
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
200 if (gtk_tree_model_get_iter_first(model, &iter)) {
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
201 do {
32936
03b440305f19 Looks like I missed a number.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32935
diff changeset
202 gtk_tree_model_get(model, &iter, AOP_DATA_COLUMN, &iter_data, -1);
32388
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
203 if (iter_data == data) {
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
204 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(optmenu), &iter);
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
205 return;
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
206 }
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
207 } while (gtk_tree_model_iter_next(model, &iter));
17235
f04fc9bbb90b Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents: 17234
diff changeset
208 }
17014
1e90cfae53dd disapproval of revision '41be962a27d1633445fef2055c4a0db183f104dc'
Richard Laager <rlaager@pidgin.im>
parents: 17013
diff changeset
209 }
1e90cfae53dd disapproval of revision '41be962a27d1633445fef2055c4a0db183f104dc'
Richard Laager <rlaager@pidgin.im>
parents: 17013
diff changeset
210
18281
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
211 static void
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
212 show_retrieveing_info(PurpleConnection *conn, const char *name)
17387
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
213 {
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
214 PurpleNotifyUserInfo *info = purple_notify_user_info_new();
32188
cb9cad610bc6 I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents: 32149
diff changeset
215 purple_notify_user_info_add_pair_plaintext(info, _("Information"), _("Retrieving..."));
17387
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
216 purple_notify_userinfo(conn, name, info, NULL, NULL);
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
217 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
218 }
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
219
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
220 void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name)
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
221 {
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
222 show_retrieveing_info(conn, name);
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35455
diff changeset
223 purple_serv_get_info(conn, name);
17387
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
224 }
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
225
18281
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
226 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
227 {
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
228 char *who = NULL;
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
229 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
230
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
231 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
232 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
233 return;
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
234 }
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
235
36623
caaadef03507 Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents: 36608
diff changeset
236 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
237 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
238 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
239
2dcb81a189bd Refactored pidgin to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36626
diff changeset
240 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
241 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
242 }
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
243
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
244 void
35720
863f87bfc06e Smiley manager: cleanup
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35713
diff changeset
245 pidgin_set_accessible_label(GtkWidget *w, GtkLabel *l)
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
246 {
19547
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
247 AtkObject *acc;
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
248 const gchar *label_text;
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
249 const gchar *existing_name;
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
250
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
251 acc = gtk_widget_get_accessible (w);
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
252
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
253 /* If this object has no name, set it's name with the label text */
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
254 existing_name = atk_object_get_name (acc);
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
255 if (!existing_name) {
35720
863f87bfc06e Smiley manager: cleanup
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35713
diff changeset
256 label_text = gtk_label_get_text(l);
19547
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
257 if (label_text)
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
258 atk_object_set_name (acc, label_text);
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
259 }
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
260
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
261 pidgin_set_accessible_relations(w, l);
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
262 }
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
263
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
264 void
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
265 pidgin_set_accessible_relations (GtkWidget *w, GtkLabel *l)
19547
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
266 {
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
267 AtkObject *acc, *label;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
268 AtkObject *rel_obj[1];
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
269 AtkRelationSet *set;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
270 AtkRelation *relation;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
271
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
272 acc = gtk_widget_get_accessible (w);
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
273 label = gtk_widget_get_accessible(GTK_WIDGET(l));
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
274
18351
b881759cda28 Call gtk_label_set_mnemonic_widget() in pidgin_make_accessible_label. Closes #589
Sean Egan <seanegan@pidgin.im>
parents: 18281
diff changeset
275 /* Make sure mnemonics work */
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
276 gtk_label_set_mnemonic_widget(l, w);
20241
36b8b9235ff3 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20234
diff changeset
277
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
278 /* Create the labeled-by relation */
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
279 set = atk_object_ref_relation_set (acc);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
280 rel_obj[0] = label;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
281 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
282 atk_relation_set_add (set, relation);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
283 g_object_unref (relation);
20241
36b8b9235ff3 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20234
diff changeset
284 g_object_unref(set);
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
285
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
286 /* Create the label-for relation */
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
287 set = atk_object_ref_relation_set (label);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
288 rel_obj[0] = acc;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
289 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
290 atk_relation_set_add (set, relation);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
291 g_object_unref (relation);
20241
36b8b9235ff3 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20234
diff changeset
292 g_object_unref(set);
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
293 }
8143
ce4b6383777b [gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents: 8137
diff changeset
294
37406
98ec68212b1f Move PurpleIconScaleRules to BuddyIcon API
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37200
diff changeset
295 void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleBuddyIconScaleFlags rules, int *width, int *height)
10483
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
296 {
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
297 *width = gdk_pixbuf_get_width(buf);
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
298 *height = gdk_pixbuf_get_height(buf);
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
299
15301
26153c5f156a [gaim-migrate @ 18029]
Mark Doliner <markdoliner@pidgin.im>
parents: 15289
diff changeset
300 if ((spec == NULL) || !(spec->scale_rules & rules))
26153c5f156a [gaim-migrate @ 18029]
Mark Doliner <markdoliner@pidgin.im>
parents: 15289
diff changeset
301 return;
26153c5f156a [gaim-migrate @ 18029]
Mark Doliner <markdoliner@pidgin.im>
parents: 15289
diff changeset
302
36625
e6febbd8cbec Renamed purple_buddy_icon_get_scale_size to purple_buddy_icon_spec_get_scaled_size
Ankit Vani <a@nevitus.org>
parents: 36623
diff changeset
303 purple_buddy_icon_spec_get_scaled_size(spec, width, height);
10483
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
304
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
305 /* and now for some arbitrary sanity checks */
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
306 if(*width > 100)
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
307 *width = 100;
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
308 if(*height > 100)
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
309 *height = 100;
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
310 }
12080
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
311
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
312 GdkPixbuf *
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36633
diff changeset
313 pidgin_create_protocol_icon(PurpleAccount *account, PidginProtocolIconSize size)
12080
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
314 {
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
315 PurpleProtocol *protocol;
12080
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
316
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
317 g_return_val_if_fail(account != NULL, NULL);
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
318
40803
0e11ce1049b2 Port Pidgin from purple_protocols to PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents: 40784
diff changeset
319 protocol = purple_account_get_protocol(account);
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
320 if (protocol == NULL)
13091
b5ed878998dd [gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents: 13081
diff changeset
321 return NULL;
36659
fbaa6f248ebc Free the list returned by purple_protocols_get_all()
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
322 return pidgin_create_icon_from_protocol(protocol, size, account);
13091
b5ed878998dd [gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents: 13081
diff changeset
323 }
b5ed878998dd [gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents: 13081
diff changeset
324
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
325 static gboolean buddyname_completion_match_func(GtkEntryCompletion *completion,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
326 const gchar *key, GtkTreeIter *iter, gpointer user_data)
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
327 {
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
328 GtkTreeModel *model;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
329 GValue val1;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
330 GValue val2;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
331 const char *tmp;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
332
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
333 model = gtk_entry_completion_get_model(completion);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
334
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
335 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
336 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
337 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
338 if (tmp != NULL && g_str_has_prefix(tmp, key)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
339 g_value_unset(&val1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
340 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
341 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
342 g_value_unset(&val1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
343
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
344 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
345 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
346 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
347 if (tmp != NULL && g_str_has_prefix(tmp, key)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
348 g_value_unset(&val2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
349 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
350 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
351 g_value_unset(&val2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
352
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
353 return FALSE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
354 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
355
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
356 static gboolean buddyname_completion_match_selected_cb(GtkEntryCompletion *completion,
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
357 GtkTreeModel *model, GtkTreeIter *iter, PidginCompletionData *data)
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
358 {
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
359 GValue val;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
360 GtkWidget *optmenu = data->accountopt;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
361 PurpleAccount *account;
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
362
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
363 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
364 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
365 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
366 g_value_unset(&val);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
367
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
368 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
369 account = g_value_get_pointer(&val);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
370 g_value_unset(&val);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
371
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
372 if (account == NULL)
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
373 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
374
17117
d256023d5312 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17116
diff changeset
375 if (optmenu != NULL)
17385
bf46968ab031 Casting things to gpointer isn't useful, unless they were previously const.
Richard Laager <rlaager@pidgin.im>
parents: 17377
diff changeset
376 aop_option_menu_select_by_data(optmenu, account);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
377
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
378 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
379 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
380
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
381 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
382 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
383 const PurpleAccount *account, const char *buddyname)
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
384 {
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
385 GtkTreeIter iter;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
386 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
387 gchar *normalized_buddyname;
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
388 gchar *tmp;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
389
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
390 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
391 normalized_buddyname = g_utf8_casefold(tmp, -1);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
392 g_free(tmp);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
393
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
394 /* 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
395 when the name and buddy alias match. */
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
396 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
397 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
398 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
399
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
400 tmp = g_utf8_casefold(tmp2, -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
401 g_free(tmp2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
402
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
403 gtk_list_store_append(store, &iter);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
404 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
405 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
406 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
407 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
408 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
409 COMPLETION_ACCOUNT_COLUMN, account,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
410 -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
411 g_free(completion_entry);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
412 g_free(tmp);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
413 completion_added = TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
414 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
415
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
416 /* 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
417 when the name and contact alias match. */
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
418 if (contact_alias && !purple_strequal(contact_alias, buddyname)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
419 /* 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
420 if (!purple_strequal(contact_alias, buddy_alias)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
421 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
422 buddyname, contact_alias);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
423 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
424
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
425 tmp = g_utf8_casefold(tmp2, -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
426 g_free(tmp2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
427
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
428 gtk_list_store_append(store, &iter);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
429 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
430 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
431 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
432 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
433 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
434 COMPLETION_ACCOUNT_COLUMN, account,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
435 -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
436 g_free(completion_entry);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
437 g_free(tmp);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
438 completion_added = TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
439 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
440 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
441
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
442 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
443 /* Add the buddy's name. */
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
444 gtk_list_store_append(store, &iter);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
445 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
446 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
447 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
448 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
449 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
450 COMPLETION_ACCOUNT_COLUMN, account,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
451 -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
452 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
453
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
454 g_free(normalized_buddyname);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
455 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
456
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
457 static void
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
458 add_completion_list(PidginCompletionData *data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
459 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
460 PurpleBlistNode *gnode, *cnode, *bnode;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
461 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
462 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
463 gchar *alias;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
464
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
465 gtk_list_store_clear(data->store);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
466
39665
2172e3b8eeef Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39568
diff changeset
467 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
468 gnode = gnode->next) {
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 34662
diff changeset
469 if (!PURPLE_IS_GROUP(gnode))
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
470 continue;
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
471
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
472 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
473 {
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 34662
diff changeset
474 if (!PURPLE_IS_CONTACT(cnode))
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
475 continue;
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
476
34769
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
477 g_object_get(cnode, "alias", &alias, NULL);
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
478
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
479 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
480 {
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
481 PidginBuddyCompletionEntry entry;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
482 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
483 entry.buddy = (PurpleBuddy *) bnode;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
484
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
485 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
486 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
487 alias,
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41097
diff changeset
488 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
489 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
490 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
491 );
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
492 }
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
493 }
34769
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
494
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
495 g_free(alias);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
496 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
497 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
498 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
499
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
500 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
501 buddyname_autocomplete_destroyed_cb(GtkWidget *widget, gpointer data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
502 {
17707
b5f042209c68 Unleak a few bytes in the screenname completion code
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 17605
diff changeset
503 g_free(data);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
504 purple_signals_disconnect_by_handle(widget);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
505 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
506
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
507 static void
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
508 repopulate_autocomplete(gpointer something, gpointer data)
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
509 {
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
510 add_completion_list(data);
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
511 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
512
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
513 void
39796
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
514 pidgin_setup_screenname_autocomplete(
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
515 GtkWidget *entry, GtkWidget *chooser,
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
516 PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
517 {
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
518 PidginCompletionData *data;
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
519
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
520 /*
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
521 * 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
522 * 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
523 * 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
524 */
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
525 GtkListStore *store;
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
526
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
527 GtkEntryCompletion *completion;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
528
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
529 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
530 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
531 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
532 G_TYPE_POINTER);
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
533
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
534 data->entry = entry;
39796
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
535 data->accountopt = chooser;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
536 if (filter_func == NULL) {
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
537 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
538 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
539 } else {
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
540 data->filter_func = filter_func;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
541 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
542 }
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
543 data->store = store;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
544
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
545 add_completion_list(data);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
546
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
547 /* Sort the completion list by buddy name */
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
548 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
549 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
550 GTK_SORT_ASCENDING);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
551
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
552 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
553 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
554
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
555 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
556 G_CALLBACK(buddyname_completion_match_selected_cb), data);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
557
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
558 gtk_entry_set_completion(GTK_ENTRY(entry), completion);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
559 g_object_unref(completion);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
560
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
561 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store));
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
562 g_object_unref(store);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
563
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
564 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
565
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
566 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
567 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
568 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
569 G_CALLBACK(repopulate_autocomplete), data);
13366
e01cf252b407 [gaim-migrate @ 15738]
Richard Laager <rlaager@pidgin.im>
parents: 13365
diff changeset
570
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
571 purple_signal_connect(purple_accounts_get_handle(), "account-added", entry,
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41312
diff changeset
572 G_CALLBACK(repopulate_autocomplete), data);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
573 purple_signal_connect(purple_accounts_get_handle(), "account-removed", entry,
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41312
diff changeset
574 G_CALLBACK(repopulate_autocomplete), data);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
575
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
576 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
577 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
578
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
579 gboolean
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
580 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
581 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
582
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41097
diff changeset
583 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
584 }
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
585
35455
216a37403c5b Fix a bunch of gtk-doc warnings in pidgin
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
586 /*
216a37403c5b Fix a bunch of gtk-doc warnings in pidgin
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
587 * str_array_match:
216a37403c5b Fix a bunch of gtk-doc warnings in pidgin
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
588 *
216a37403c5b Fix a bunch of gtk-doc warnings in pidgin
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
589 * Returns: %TRUE if any string from array @a exists in array @b.
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
590 */
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
591 static gboolean
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
592 str_array_match(char **a, char **b)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
593 {
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
594 int i, j;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
595
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
596 if (!a || !b)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
597 return FALSE;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
598 for (i = 0; a[i] != NULL; i++)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
599 for (j = 0; b[j] != NULL; j++)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
600 if (!g_ascii_strcasecmp(a[i], b[j]))
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
601 return TRUE;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
602 return FALSE;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
603 }
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
604
16446
3a6ed6c3400e Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents: 16437
diff changeset
605 gpointer
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
606 pidgin_convert_buddy_icon(PurpleProtocol *protocol, const char *path, size_t *len)
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
607 {
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
608 PurpleBuddyIconSpec *spec;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
609 int orig_width, orig_height, new_width, new_height;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
610 GdkPixbufFormat *format;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
611 char **pixbuf_formats;
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
612 char **protocol_formats;
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
613 GError *error = NULL;
15284
98e8f9912107 [gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents: 15254
diff changeset
614 gchar *contents;
98e8f9912107 [gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents: 15254
diff changeset
615 gsize length;
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
616 GdkPixbuf *pixbuf, *original;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
617 float scale_factor;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
618 int i;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
619 gchar *tmp;
14203
f3a50c328ddc [gaim-migrate @ 16783]
Mark Doliner <markdoliner@pidgin.im>
parents: 14196
diff changeset
620
36608
bb8dbeba5bed Changed icon spec member of a protocol to a pointer. Use purple_buddy_icon_spec_new() to create an icon spec instance
Ankit Vani <a@nevitus.org>
parents: 36607
diff changeset
621 spec = purple_protocol_get_icon_spec(protocol);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
622 if(spec->format == NULL) {
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
623 purple_buddy_icon_spec_free(spec);
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
624
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
625 return NULL;
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
626 }
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
627
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
628 format = gdk_pixbuf_get_file_info(path, &orig_width, &orig_height);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
629 if (format == NULL) {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
630 purple_debug_warning("buddyicon", "Could not get file info of %s\n", path);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
631
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
632 purple_buddy_icon_spec_free(spec);
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
633
14206
5a17eb1a2c3e [gaim-migrate @ 16786]
Mark Doliner <markdoliner@pidgin.im>
parents: 14203
diff changeset
634 return NULL;
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
635 }
15289
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
636
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
637 pixbuf_formats = gdk_pixbuf_format_get_extensions(format);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
638 protocol_formats = g_strsplit(spec->format, ",", 0);
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
639
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
640 if (str_array_match(pixbuf_formats, protocol_formats) && /* This is an acceptable format AND */
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36633
diff changeset
641 (!(spec->scale_rules & PURPLE_ICON_SCALE_SEND) || /* The protocol doesn't scale before it sends OR */
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
642 (spec->min_width <= orig_width && spec->max_width >= orig_width &&
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
643 spec->min_height <= orig_height && spec->max_height >= orig_height))) /* The icon is the correct size */
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
644 {
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
645 g_strfreev(pixbuf_formats);
29496
8807ee3e55c5 Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 28234
diff changeset
646
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
647 if (!g_file_get_contents(path, &contents, &length, &error)) {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
648 purple_debug_warning("buddyicon", "Could not get file contents "
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
649 "of %s: %s\n", path, error->message);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
650 g_strfreev(protocol_formats);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
651 purple_buddy_icon_spec_free(spec);
15289
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
652 return NULL;
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
653 }
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
654
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
655 if (spec->max_filesize == 0 || length < spec->max_filesize) {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
656 /* The supplied image fits the file size, dimensions and type
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
657 constraints. Great! Return it without making any changes. */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
658 if (len)
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
659 *len = length;
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
660 g_strfreev(protocol_formats);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
661 purple_buddy_icon_spec_free(spec);
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
662 return contents;
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
663 }
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
664
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
665 /* The image was too big. Fall-through and try scaling it down. */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
666 g_free(contents);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
667 } else {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
668 g_strfreev(pixbuf_formats);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
669 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
670
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
671 /* The original image wasn't compatible. Scale it or convert file type. */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
672 pixbuf = gdk_pixbuf_new_from_file(path, &error);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
673 if (error) {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
674 purple_debug_warning("buddyicon", "Could not open icon '%s' for "
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
675 "conversion: %s\n", path, error->message);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
676 g_error_free(error);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
677 g_strfreev(protocol_formats);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
678 purple_buddy_icon_spec_free(spec);
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
679 return NULL;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
680 }
39274
7acdb1d9797c pidgin: Fix various -Wincompatible-pointer-types warnings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39273
diff changeset
681 original = g_object_ref(pixbuf);
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
682
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
683 new_width = orig_width;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
684 new_height = orig_height;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
685
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
686 /* Make sure the image is the correct dimensions */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
687 if (spec->scale_rules & PURPLE_ICON_SCALE_SEND &&
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
688 (orig_width < spec->min_width || orig_width > spec->max_width ||
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
689 orig_height < spec->min_height || orig_height > spec->max_height))
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
690 {
36625
e6febbd8cbec Renamed purple_buddy_icon_get_scale_size to purple_buddy_icon_spec_get_scaled_size
Ankit Vani <a@nevitus.org>
parents: 36623
diff changeset
691 purple_buddy_icon_spec_get_scaled_size(spec, &new_width, &new_height);
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
692
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
693 g_object_unref(G_OBJECT(pixbuf));
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
694 pixbuf = gdk_pixbuf_scale_simple(original, new_width, new_height, GDK_INTERP_HYPER);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
695 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
696
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
697 scale_factor = 1;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
698 do {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
699 for (i = 0; protocol_formats[i]; i++) {
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
700 int quality = 100;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
701 do {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
702 const char *key = NULL;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
703 const char *value = NULL;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
704 gchar tmp_buf[4];
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
705
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
706 purple_debug_info("buddyicon", "Converting buddy icon to %s\n", protocol_formats[i]);
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
707
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38299 38260
diff changeset
708 if (purple_strequal(protocol_formats[i], "png")) {
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
709 key = "compression";
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
710 value = "9";
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38299 38260
diff changeset
711 } else if (purple_strequal(protocol_formats[i], "jpeg")) {
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
712 sprintf(tmp_buf, "%u", quality);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
713 key = "quality";
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
714 value = tmp_buf;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
715 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
716
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
717 if (!gdk_pixbuf_save_to_buffer(pixbuf, &contents, &length,
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
718 protocol_formats[i], &error, key, value, NULL))
29927
80855a5471ed Use gdk_pixbuf_save_to_buffer() instead of gdk_pixbuf_save() to avoid saving
Mark Doliner <markdoliner@pidgin.im>
parents: 29898
diff changeset
719 {
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
720 /* The NULL checking of error is necessary due to this bug:
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
721 * http://bugzilla.gnome.org/show_bug.cgi?id=405539 */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
722 purple_debug_warning("buddyicon",
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
723 "Could not convert to %s: %s\n", protocol_formats[i],
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
724 (error && error->message) ? error->message : "Unknown error");
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
725 g_error_free(error);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
726 error = NULL;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
727
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
728 /* We couldn't convert to this image type. Try the next
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
729 image type. */
15645
db8c01fc8637 Work around gdk-pixbuf brokenness when dealing with unrecognized parameters. Also, improve the error handling so we don't get a confusing error message.
Daniel Atallah <datallah@pidgin.im>
parents: 15635
diff changeset
730 break;
db8c01fc8637 Work around gdk-pixbuf brokenness when dealing with unrecognized parameters. Also, improve the error handling so we don't get a confusing error message.
Daniel Atallah <datallah@pidgin.im>
parents: 15635
diff changeset
731 }
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
732
30054
82871fde0aac Allow icons to be exactly the max file size
Mark Doliner <markdoliner@pidgin.im>
parents: 30053
diff changeset
733 if (spec->max_filesize == 0 || length <= spec->max_filesize) {
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
734 /* We were able to save the image as this image type and
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
735 have it be within the size constraints. Great! Return
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
736 the image. */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
737 purple_debug_info("buddyicon", "Converted image from "
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
738 "%dx%d to %dx%d, format=%s, quality=%u, "
32749
a152b1950ea6 Use correct format for printing gsize types.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32709
diff changeset
739 "filesize=%" G_GSIZE_FORMAT "\n",
a152b1950ea6 Use correct format for printing gsize types.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32709
diff changeset
740 orig_width, orig_height, new_width, new_height,
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
741 protocol_formats[i], quality, length);
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
742 if (len)
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
743 *len = length;
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
744 g_strfreev(protocol_formats);
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
745 g_object_unref(G_OBJECT(pixbuf));
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
746 g_object_unref(G_OBJECT(original));
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
747 purple_buddy_icon_spec_free(spec);
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
748 return contents;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
749 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
750
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
751 g_free(contents);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
752
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38299 38260
diff changeset
753 if (!purple_strequal(protocol_formats[i], "jpeg")) {
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
754 /* File size was too big and we can't lower the quality,
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
755 so skip to the next image type. */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
756 break;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
757 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
758
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
759 /* File size was too big, but we're dealing with jpeg so try
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
760 lowering the quality. */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
761 quality -= 5;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
762 } while (quality >= 70);
16446
3a6ed6c3400e Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents: 16437
diff changeset
763 }
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
764
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
765 /* We couldn't save the image in any format that was below the max
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
766 file size. Maybe we can reduce the image dimensions? */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
767 scale_factor *= 0.8;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
768 new_width = orig_width * scale_factor;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
769 new_height = orig_height * scale_factor;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
770 g_object_unref(G_OBJECT(pixbuf));
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
771 pixbuf = gdk_pixbuf_scale_simple(original, new_width, new_height, GDK_INTERP_HYPER);
30053
223f898b44b2 Oh! When setting a buddy icon, when we reduce the dimension in order to
Mark Doliner <markdoliner@pidgin.im>
parents: 30002
diff changeset
772 } while ((new_width > 10 || new_height > 10) && new_width > spec->min_width && new_height > spec->min_height);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
773 g_strfreev(protocol_formats);
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
774 g_object_unref(G_OBJECT(pixbuf));
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
775 g_object_unref(G_OBJECT(original));
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
776
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
777 tmp = g_strdup_printf(_("The file '%s' is too large for %s. Please try a smaller image.\n"),
36607
7ad7681dcfd8 Use purple_protocol_get_* API instead of protocol->member
Ankit Vani <a@nevitus.org>
parents: 36606
diff changeset
778 path, purple_protocol_get_name(protocol));
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34447
diff changeset
779 purple_notify_error(NULL, _("Icon Error"), _("Could not set icon"), tmp, NULL);
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
780 g_free(tmp);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
781
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
782 purple_buddy_icon_spec_free(spec);
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
783
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
784 return NULL;
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
785 }
14290
f20819ff8d86 [gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 14253
diff changeset
786
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
787 /*
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
788 * "This is so dead sexy."
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
789 * "Two thumbs up."
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
790 * "Best movie of the year."
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
791 *
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
792 * This is the function that handles CTRL+F searching in the buddy list.
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
793 * It finds the top-most buddy/group/chat/whatever containing the
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
794 * entered string.
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
795 *
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
796 * It's somewhat ineffecient, because we strip all the HTML from the
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
797 * "name" column of the buddy list (because the GtkTreeModel does not
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
798 * contain the screen name in a non-markedup format). But the alternative
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
799 * is to add an extra column to the GtkTreeModel. And this function is
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
800 * used rarely, so it shouldn't matter TOO much.
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
801 */
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
802 gboolean pidgin_tree_view_search_equal_func(GtkTreeModel *model, gint column,
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
803 const gchar *key, GtkTreeIter *iter, gpointer data)
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
804 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
805 gchar *enteredstring;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
806 gchar *tmp;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
807 gchar *withmarkup;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
808 gchar *nomarkup;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
809 gchar *normalized;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
810 gboolean result;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
811 size_t i;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
812 size_t len;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
813 PangoLogAttr *log_attrs;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
814 gchar *word;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
815
17155
143ff2796376 Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents: 17116
diff changeset
816 if (g_ascii_strcasecmp(key, "Global Thermonuclear War") == 0)
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
817 {
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34447
diff changeset
818 purple_notify_info(NULL, "WOPR", "Wouldn't you prefer a nice "
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34447
diff changeset
819 "game of chess?", NULL, NULL);
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
820 return FALSE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
821 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
822
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
823 gtk_tree_model_get(model, iter, column, &withmarkup, -1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
824 if (withmarkup == NULL) /* This is probably a separator */
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
825 return TRUE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
826
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
827 tmp = g_utf8_normalize(key, -1, G_NORMALIZE_DEFAULT);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
828 enteredstring = g_utf8_casefold(tmp, -1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
829 g_free(tmp);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
830
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
831 nomarkup = purple_markup_strip_html(withmarkup);
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
832 tmp = g_utf8_normalize(nomarkup, -1, G_NORMALIZE_DEFAULT);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
833 g_free(nomarkup);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
834 normalized = g_utf8_casefold(tmp, -1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
835 g_free(tmp);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
836
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
837 if (g_str_has_prefix(normalized, enteredstring)) {
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
838 g_free(withmarkup);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
839 g_free(enteredstring);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
840 g_free(normalized);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
841 return FALSE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
842 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
843
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
844 /* Use Pango to separate by words. */
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
845 len = g_utf8_strlen(normalized, -1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
846 log_attrs = g_new(PangoLogAttr, len + 1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
847
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
848 pango_get_log_attrs(normalized, strlen(normalized), -1, NULL, log_attrs, len + 1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
849
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
850 word = normalized;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
851 result = TRUE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
852 for (i = 0; i < (len - 1) ; i++)
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
853 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
854 if (log_attrs[i].is_word_start &&
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
855 g_str_has_prefix(word, enteredstring)) {
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
856 result = FALSE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
857 break;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
858 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
859 word = g_utf8_next_char(word);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
860 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
861 g_free(log_attrs);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
862
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
863 /* The non-Pango version. */
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
864 #if 0
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
865 word = normalized;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
866 result = TRUE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
867 while (word[0] != '\0')
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
868 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
869 gunichar c = g_utf8_get_char(word);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
870 if (!g_unichar_isalnum(c))
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
871 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
872 word = g_utf8_find_next_char(word, NULL);
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
873 if (g_str_has_prefix(word, enteredstring))
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
874 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
875 result = FALSE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
876 break;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
877 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
878 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
879 else
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
880 word = g_utf8_find_next_char(word, NULL);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
881 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
882 #endif
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
883
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
884 g_free(withmarkup);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
885 g_free(enteredstring);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
886 g_free(normalized);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
887
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
888 return result;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
889 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
890
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
891 static void
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
892 combo_box_changed_cb(GtkComboBoxText *combo_box, GtkEntry *entry)
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
893 {
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
894 char *text = gtk_combo_box_text_get_active_text(combo_box);
41531
2b86501d13fe Replace gtk_entry_[gs]et_text with gtk_editable_[gs]et_text
Gary Kramlich <grim@reaperworld.com>
parents: 41526
diff changeset
895 gtk_editable_set_text(GTK_EDITABLE(entry), text ? text : "");
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
896 g_free(text);
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
897 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
898
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
899 static gboolean
41180
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
900 entry_key_pressed_cb(G_GNUC_UNUSED GtkEventControllerKey *controller,
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
901 guint keyval, G_GNUC_UNUSED guint keycode,
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
902 G_GNUC_UNUSED GdkModifierType state,
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
903 gpointer data)
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
904 {
41180
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
905 GtkComboBoxText *combo = data;
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
906
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
907 if (keyval == GDK_KEY_Down || keyval == GDK_KEY_Up) {
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
908 gtk_combo_box_popup(GTK_COMBO_BOX(combo));
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
909 return TRUE;
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
910 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
911 return FALSE;
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
912 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
913
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
914 GtkWidget *
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
915 pidgin_text_combo_box_entry_new(const char *default_item, GList *items)
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
916 {
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
917 GtkComboBoxText *ret = NULL;
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
918 GtkWidget *the_entry = NULL;
41180
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
919 GtkEventController *controller = NULL;
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
920
32415
59d345017c9b propagate from branch 'im.pidgin.pidgin' (head 8a277be95a4940cd20c64326a70624c4e0449cb7)
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414 31398
diff changeset
921 ret = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new_with_entry());
33170
ce4447562d64 Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 33149
diff changeset
922 the_entry = gtk_bin_get_child(GTK_BIN(ret));
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
923
41531
2b86501d13fe Replace gtk_entry_[gs]et_text with gtk_editable_[gs]et_text
Gary Kramlich <grim@reaperworld.com>
parents: 41526
diff changeset
924 if(default_item) {
2b86501d13fe Replace gtk_entry_[gs]et_text with gtk_editable_[gs]et_text
Gary Kramlich <grim@reaperworld.com>
parents: 41526
diff changeset
925 gtk_editable_set_text(GTK_EDITABLE(the_entry), default_item);
2b86501d13fe Replace gtk_entry_[gs]et_text with gtk_editable_[gs]et_text
Gary Kramlich <grim@reaperworld.com>
parents: 41526
diff changeset
926 }
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
927
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
928 for (; items != NULL ; items = items->next) {
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
929 char *text = items->data;
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
930 if (text && *text)
32394
f883709bdba4 compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents: 32391
diff changeset
931 gtk_combo_box_text_append_text(ret, text);
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
932 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
933
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
934 g_signal_connect(G_OBJECT(ret), "changed", (GCallback)combo_box_changed_cb, the_entry);
41180
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
935
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
936 controller = gtk_event_controller_key_new(the_entry);
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
937 g_object_set_data_full(G_OBJECT(the_entry), "pidgin-event-controller",
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
938 controller, g_object_unref);
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
939 g_signal_connect_after(G_OBJECT(controller), "key-pressed",
fb686c1483bf Make pidgin_text_combo_box_entry_new use GtkEventControllerKey
Gary Kramlich <grim@reaperworld.com>
parents: 41144
diff changeset
940 G_CALLBACK(entry_key_pressed_cb), ret);
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
941
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
942 return GTK_WIDGET(ret);
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
943 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
944
41531
2b86501d13fe Replace gtk_entry_[gs]et_text with gtk_editable_[gs]et_text
Gary Kramlich <grim@reaperworld.com>
parents: 41526
diff changeset
945 const char *
2b86501d13fe Replace gtk_entry_[gs]et_text with gtk_editable_[gs]et_text
Gary Kramlich <grim@reaperworld.com>
parents: 41526
diff changeset
946 pidgin_text_combo_box_entry_get_text(GtkWidget *widget) {
2b86501d13fe Replace gtk_entry_[gs]et_text with gtk_editable_[gs]et_text
Gary Kramlich <grim@reaperworld.com>
parents: 41526
diff changeset
947 return gtk_editable_get_text(GTK_EDITABLE(gtk_bin_get_child(GTK_BIN((widget)))));
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
948 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
949
22131
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
950 GtkWidget *
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
951 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
952 {
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
953 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
954 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
955
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
956 if (widget_label) {
35527
707c3c2b2c8a Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35506
diff changeset
957 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
22131
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
958 gtk_widget_show(hbox);
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
959 gtk_box_pack_start(vbox, hbox, FALSE, FALSE, 0);
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
960
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
961 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
962 gtk_widget_show(label);
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
963 if (sg) {
38007
3b971d2ecae1 Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37997
diff changeset
964 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
965 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
966 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
967 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
968 } else {
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
969 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
970 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
971
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
972 gtk_widget_show(widget);
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
973 gtk_box_pack_start(GTK_BOX(hbox), widget, expand, TRUE, 0);
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
974 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
975 gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget);
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
976 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
977 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
978
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
979 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
980 (*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
981 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
982 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
983
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
984 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
985 {
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
986 #if 0
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
987 /* This looks at the most recent window that received focus, and makes
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
988 * 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
989 #ifndef _WIN32
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
990 static GdkAtom _WindowTime = GDK_NONE;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
991 static GdkAtom _Cardinal = GDK_NONE;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
992 GList *windows = NULL;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
993 GtkWidget *parent = NULL;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
994 time_t window_time = 0;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
995
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
996 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
997
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
998 if (_WindowTime == GDK_NONE) {
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
999 _WindowTime = gdk_x11_xatom_to_atom(gdk_x11_get_xatom_by_name("_NET_WM_USER_TIME"));
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1000 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1001 if (_Cardinal == GDK_NONE) {
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1002 _Cardinal = gdk_atom_intern("CARDINAL", 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
1003 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1004
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1005 while (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
1006 GtkWidget *window = windows->data;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1007 guchar *data = NULL;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1008 int al = 0;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1009 time_t value;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1010
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1011 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
1012
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1013 if (window == widget ||
32913
af2c726febce Fix all deprecated GTK_WIDGET_* macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32900
diff changeset
1014 !gtk_widget_get_visible(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
1015 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
1016
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1017 if (!gdk_property_get(window->window, _WindowTime, _Cardinal, 0, sizeof(time_t), 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
1018 NULL, NULL, &al, &data))
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1019 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
1020 value = *(time_t *)data;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1021 if (window_time < value) {
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1022 window_time = value;
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1023 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
1024 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1025 g_free(data);
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1026 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1027 if (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
1028 g_list_free(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
1029 if (parent) {
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1030 if (!gtk_get_current_event() && gtk_window_has_toplevel_focus(GTK_WINDOW(parent))) {
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1031 /* The window is in focus, and the new window was not triggered by a keypress/click
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1032 * event. So do not set it transient, to avoid focus stealing and all that.
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1033 */
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1034 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
1035 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1036 gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(parent));
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1037 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
1038 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1039 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
1040 #endif
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1041 #else
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1042 /* 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
1043 GList *windows = NULL;
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1044 GtkWindow *parent = 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
1045 GdkEvent *event = gtk_get_current_event();
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1046 GdkWindow *menu = 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
1047 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
1048 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
1049
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
1050 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
1051 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
1052
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
1053 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
1054 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
1055 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
1056 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
1057 }
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
1058 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
1059 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
1060 {
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
1061 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
1062 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
1063 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
1064 }
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
1065
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1066 if (event == NULL)
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1067 /* The window was not triggered by a user action. */
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1068 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
1069
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1070 /* We need to special case events from a popup menu. */
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1071 if (event->type == GDK_BUTTON_RELEASE) {
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1072 /* XXX: Neither of the following works:
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1073 menu = event->button.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
1074 menu = gdk_window_get_parent(event->button.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
1075 menu = gdk_window_get_toplevel(event->button.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
1076 */
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1077 } else if (event->type == GDK_KEY_PRESS)
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1078 menu = event->key.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
1079
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1080 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
1081 while (windows) {
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1082 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
1083 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
1084
34447
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1085 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
1086 "pidgin-window-is-closing")))
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1087 {
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1088 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
1089 break;
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1090 }
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1091
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1092 if (GTK_WIDGET(window) == widget ||
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1093 !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
1094 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
1095 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1096
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1097 if (gtk_window_has_toplevel_focus(window) ||
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1098 (menu && menu == gtk_widget_get_window(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
1099 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
1100 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
1101 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1102 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1103 if (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
1104 g_list_free(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
1105 if (parent) {
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1106 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
1107 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
1108 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1109 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
1110 #endif
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1111 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1112
31321
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1113 GtkWidget *
41526
ad8654c2e758 Remove the GtkShadowType parameter from pidgin_make_scrollable as that enum was removed.
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
1114 pidgin_make_scrollable(GtkWidget *child, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, int width, int height)
31321
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1115 {
41526
ad8654c2e758 Remove the GtkShadowType parameter from pidgin_make_scrollable as that enum was removed.
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
1116 GtkWidget *sw = gtk_scrolled_window_new();
31321
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1117
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1118 if (G_LIKELY(sw)) {
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1119 gtk_widget_show(sw);
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1120 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), hscrollbar_policy, vscrollbar_policy);
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1121 if (width != -1 || height != -1)
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1122 gtk_widget_set_size_request(sw, width, height);
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1123 if (child) {
35541
12bd3807140b Fix some GTK 3.8 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35533
diff changeset
1124 gtk_container_add(GTK_CONTAINER(sw), child);
31321
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1125 }
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1126 return sw;
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1127 }
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1128
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1129 return child;
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1130 }
1fef3832cfa2 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31217
diff changeset
1131

mercurial