pidgin/gtkutils.c

Thu, 11 Nov 2021 21:39:44 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 11 Nov 2021 21:39:44 -0600
changeset 41167
e2c60e7de2b1
parent 41144
910bdda75c74
child 41180
fb686c1483bf
permissions
-rw-r--r--

Make sure the path for a buddy icon isn't an empty string before we attempt to load it as a pixbuf

Testing Done:
Ran with `G_DEBUG=fatal-warnings gdb pidgin3` in a `devenv` and verified it no longer stopped at startup.

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

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 "minidialog.h"
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40490
diff changeset
49 #include "pidgincore.h"
41144
910bdda75c74 Move the pidgin_pixbuf stuff to pidgingdkpixbuf.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
50 #include "pidgingdkpixbuf.h"
4359
cf899ee07d1d [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51
35565
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 * Enums
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
54 *****************************************************************************/
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
55
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
56 enum {
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_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
58 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
59 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
60 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
61 };
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
62
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
63 enum {
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
64 DND_FILE_TRANSFER,
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
65 DND_IM_IMAGE,
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
66 DND_BUDDY_ICON
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
67 };
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
68
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
69 enum {
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
70 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
71 COMPLETION_BUDDY_COLUMN, /* buddy name */
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
72 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
73 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
74 COMPLETION_ACCOUNT_COLUMN, /* account */
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
75 COMPLETION_COLUMN_COUNT
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
76 };
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
77
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
78 /******************************************************************************
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
79 * Structs
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
17118
4fbaa628dd8e Formatting changes.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17117
diff changeset
82 typedef struct {
32388
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
83 GtkTreeModel *model;
17234
6e430db9b926 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents: 17233
diff changeset
84 gint default_item;
17375
0d9082502e58 Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17238
diff changeset
85 } AopMenu;
17117
d256023d5312 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17116
diff changeset
86
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
87 typedef struct {
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
88 char *filename;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
89 PurpleAccount *account;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
90 char *who;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
91 } _DndData;
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 typedef struct
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
94 {
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
95 GtkWidget *entry;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
96 GtkWidget *accountopt;
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 PidginFilterBuddyCompletionEntryFunc filter_func;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
99 gpointer filter_func_user_data;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
100
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
101 GtkListStore *store;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
102 } PidginCompletionData;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
103
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
104 struct _icon_chooser {
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
105 GtkFileChooserNative *icon_filesel;
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
106 GtkWidget *icon_preview;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
107 GtkWidget *icon_text;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
108
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
109 void (*callback)(const char*,gpointer);
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
110 gpointer data;
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
111 };
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
112
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
113 /******************************************************************************
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
114 * Globals
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
115 *****************************************************************************/
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
116
10850
6889f793b918 [gaim-migrate @ 12522]
Mark Doliner <markdoliner@pidgin.im>
parents: 10681
diff changeset
117 static guint accels_save_timer = 0;
35565
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
118
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
119 /******************************************************************************
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
120 * Code
f774eda0a91e Move globals and types together in gtkutils.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 35541
diff changeset
121 *****************************************************************************/
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
122
17359
6dd3b7730470 Change pidgin_separator to return the separator added to the menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17155
diff changeset
123 GtkWidget *pidgin_separator(GtkWidget *menu)
4687
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4398
diff changeset
124 {
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4398
diff changeset
125 GtkWidget *menuitem;
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4398
diff changeset
126
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4398
diff changeset
127 menuitem = gtk_separator_menu_item_new();
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4398
diff changeset
128 gtk_widget_show(menuitem);
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4398
diff changeset
129 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
17359
6dd3b7730470 Change pidgin_separator to return the separator added to the menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17155
diff changeset
130 return menuitem;
4687
91ad36873636 [gaim-migrate @ 4998]
Sean Egan <seanegan@pidgin.im>
parents: 4398
diff changeset
131 }
5160
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
132
15568
cd19bb5a51b8 gtkutils changes
Sean Egan <seanegan@pidgin.im>
parents: 15562
diff changeset
133 GtkWidget *pidgin_new_check_item(GtkWidget *menu, const char *str,
26821
ad2ea323d0f2 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26820
diff changeset
134 GCallback cb, gpointer data, gboolean checked)
5906
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
135 {
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
136 GtkWidget *menuitem;
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
137 menuitem = gtk_check_menu_item_new_with_mnemonic(str);
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
138
6372
27c3152351ce [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
139 if (menu)
5906
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
140 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
141
7299
4c804d9a52f1 [gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents: 7118
diff changeset
142 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), checked);
4c804d9a52f1 [gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents: 7118
diff changeset
143
26821
ad2ea323d0f2 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26820
diff changeset
144 if (cb)
ad2ea323d0f2 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26820
diff changeset
145 g_signal_connect(G_OBJECT(menuitem), "activate", cb, data);
5906
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
146
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
147 gtk_widget_show_all(menuitem);
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
148
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
149 return menuitem;
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
150 }
b9e4aaf4ae51 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
151
37879
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
152 GtkWidget *pidgin_new_menu_item(GtkWidget *menu, const char *mnemonic,
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
153 const char *icon, GCallback cb, gpointer data)
5160
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
154 {
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
155 GtkWidget *menuitem;
37879
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
156 GtkWidget *box;
5160
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
157 GtkWidget *label;
37879
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
158
40490
fb6e46c4c63c Remove PIDGIN_HIG_* constants
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
159 box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
37879
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
160
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
161 menuitem = gtk_menu_item_new();
5160
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
162
26821
ad2ea323d0f2 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26820
diff changeset
163 if (cb)
ad2ea323d0f2 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26820
diff changeset
164 g_signal_connect(G_OBJECT(menuitem), "activate", cb, data);
5160
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
165
37879
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
166 if (icon) {
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
167 GtkWidget *image;
41080
e315e317c2de Replace gtk_image_new_from_stock with gtk_image_new_from_icon_name
Gary Kramlich <grim@reaperworld.com>
parents: 41067
diff changeset
168 image = gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_MENU);
37879
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
169 gtk_container_add(GTK_CONTAINER(box), image);
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
170 }
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
171
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
172 label = gtk_label_new_with_mnemonic(mnemonic);
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
173 gtk_container_add(GTK_CONTAINER(box), label);
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
174
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
175 gtk_container_add(GTK_CONTAINER(menuitem), box);
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
176
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
177 if (menu)
38eebb7c9019 Simplify our menuitem creation util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37590
diff changeset
178 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
5160
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
179
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
180 gtk_widget_show_all(menuitem);
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
181
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
182 return menuitem;
bcc3e2b2ed56 [gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents: 4859
diff changeset
183 }
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
184
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
185 GtkWidget *
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
186 pidgin_make_frame(GtkWidget *parent, const char *title)
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
187 {
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
188 GtkWidget *vbox, *vbox2, *hbox;
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
189 GtkLabel *label;
13100
56bf8002ddc6 [gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents: 13092
diff changeset
190 char *labeltitle;
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
191
40490
fb6e46c4c63c Remove PIDGIN_HIG_* constants
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
192 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
193 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
194 gtk_widget_show(vbox);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
195
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
196 label = GTK_LABEL(gtk_label_new(NULL));
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
197
13100
56bf8002ddc6 [gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents: 13092
diff changeset
198 labeltitle = g_strdup_printf("<span weight=\"bold\">%s</span>", title);
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
199 gtk_label_set_markup(label, labeltitle);
13100
56bf8002ddc6 [gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents: 13092
diff changeset
200 g_free(labeltitle);
56bf8002ddc6 [gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents: 13092
diff changeset
201
38007
3b971d2ecae1 Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37997
diff changeset
202 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
203 gtk_label_set_yalign(GTK_LABEL(label), 0);
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
204 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
205 gtk_widget_show(GTK_WIDGET(label));
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
206 pidgin_set_accessible_label(vbox, label);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
207
40490
fb6e46c4c63c Remove PIDGIN_HIG_* constants
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
208 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
209 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
210 gtk_widget_show(hbox);
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
211
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
212 label = GTK_LABEL(gtk_label_new(" "));
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
213 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
214 gtk_widget_show(GTK_WIDGET(label));
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
215
40490
fb6e46c4c63c Remove PIDGIN_HIG_* constants
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
216 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
217 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
218 gtk_widget_show(vbox2);
1d9ea89d4934 Group and string support for keyring settings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
219
1d9ea89d4934 Group and string support for keyring settings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
220 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
221
1d9ea89d4934 Group and string support for keyring settings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
222 return vbox2;
5530
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
223 }
ba1ad464b56f [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
224
40297
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents: 40278
diff changeset
225 GdkPixbuf *
41037
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
226 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
227 PidginProtocolIconSize size,
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
228 PurpleAccount *account)
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
229 {
41037
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
230 GdkPixbuf *pixbuf;
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
231 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
232 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
233 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
234 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
235 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
236
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
237 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
238 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
239 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
240 } 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
241 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
242 } 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
243 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
244 }
41037
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
245
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
246 /* 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
247 * theme.
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
248 */
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
249 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
250 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
251 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
252 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
253
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
254 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
255 return pixbuf;
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
256 }
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
257
c2043b9692f6 Add icon-name, icon-search-path, and icon-resource-path to PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 41020
diff changeset
258 }
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
259
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
260 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
261 if (protoname == NULL) {
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
262 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
263 }
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
264
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
265 /*
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
266 * 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
267 * protoname from the theme
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
268 */
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
269 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
270 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
271 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
272 g_free(tmp);
f34603f4631e Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@pidgin.im>
parents: 18193
diff changeset
273
17368
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
274 return pixbuf;
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
275 }
e2c6cb39043c Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17363
diff changeset
276
17117
d256023d5312 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17116
diff changeset
277 static void
17118
4fbaa628dd8e Formatting changes.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17117
diff changeset
278 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
279 {
32388
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
280 GtkTreeModel *model;
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
281 GtkTreeIter iter;
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
282 gpointer iter_data;
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
283 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
284 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
285 do {
32936
03b440305f19 Looks like I missed a number.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32935
diff changeset
286 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
287 if (iter_data == data) {
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
288 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
289 return;
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
290 }
9fc7219b95cc Apply final changes from nix_nix's patch.
Gabriel Schulhof <nix@go-nix.ca>
parents: 32386
diff changeset
291 } while (gtk_tree_model_iter_next(model, &iter));
17235
f04fc9bbb90b Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents: 17234
diff changeset
292 }
17014
1e90cfae53dd disapproval of revision '41be962a27d1633445fef2055c4a0db183f104dc'
Richard Laager <rlaager@pidgin.im>
parents: 17013
diff changeset
293 }
1e90cfae53dd disapproval of revision '41be962a27d1633445fef2055c4a0db183f104dc'
Richard Laager <rlaager@pidgin.im>
parents: 17013
diff changeset
294
7538
b20dbe9222e2 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
295 void
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
296 pidgin_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
14781
3733727a022a [gaim-migrate @ 17473]
Etan Reisner <deryni@pidgin.im>
parents: 14720
diff changeset
297 GdkModifierType arg2, GClosure *arg3,
3733727a022a [gaim-migrate @ 17473]
Etan Reisner <deryni@pidgin.im>
parents: 14720
diff changeset
298 gpointer data)
7420
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
299 {
40765
a5381c20e802 Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40704
diff changeset
300 purple_debug_misc("accels", "accel changed, scheduling save.");
7420
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
301
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
302 if (!accels_save_timer)
38433
361c801c4536 Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents: 38358
diff changeset
303 accels_save_timer = g_timeout_add_seconds(5, pidgin_save_accels,
14781
3733727a022a [gaim-migrate @ 17473]
Etan Reisner <deryni@pidgin.im>
parents: 14720
diff changeset
304 NULL);
7420
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
305 }
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
306
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
307 gboolean
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
308 pidgin_save_accels(gpointer data)
7420
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
309 {
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
310 char *filename = NULL;
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
311
39953
10db0a477198 Move some Pidgin things to XDG directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39932
diff changeset
312 filename = g_build_filename(purple_config_dir(), "accels", NULL);
40765
a5381c20e802 Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40704
diff changeset
313 purple_debug_misc("accels", "saving accels to %s", filename);
7420
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
314 gtk_accel_map_save(filename);
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
315 g_free(filename);
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
316
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
317 accels_save_timer = 0;
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
318 return FALSE;
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
319 }
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
320
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
321 void
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
322 pidgin_load_accels()
7420
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
323 {
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
324 char *filename = NULL;
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
325
39953
10db0a477198 Move some Pidgin things to XDG directories.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39932
diff changeset
326 filename = g_build_filename(purple_config_dir(), "accels", NULL);
7420
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
327 gtk_accel_map_load(filename);
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
328 g_free(filename);
af45f3aa95c9 [gaim-migrate @ 8022]
Etan Reisner <deryni@pidgin.im>
parents: 7299
diff changeset
329 }
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
330
18281
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
331 static void
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
332 show_retrieveing_info(PurpleConnection *conn, const char *name)
17387
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
333 {
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
334 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
335 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
336 purple_notify_userinfo(conn, name, info, NULL, NULL);
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
337 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
338 }
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
339
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
340 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
341 {
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
342 show_retrieveing_info(conn, name);
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35455
diff changeset
343 purple_serv_get_info(conn, name);
17387
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
344 }
db83104d06f2 Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17386
diff changeset
345
18281
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
346 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
347 {
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
348 char *who = NULL;
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
349 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
350
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
351 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
352 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
353 return;
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
354 }
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
355
36623
caaadef03507 Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents: 36608
diff changeset
356 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
357 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
358 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
359
2dcb81a189bd Refactored pidgin to use the new protocol API
Ankit Vani <a@nevitus.org>
parents: 36626
diff changeset
360 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
361 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
362 }
f7dd07e1e434 Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18278
diff changeset
363
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
364 gboolean
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
365 pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
366 PurpleAccount **ret_account, char **ret_protocol,
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
367 char **ret_username, char **ret_alias)
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
368 {
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
369 char *protocol = NULL;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
370 char *username = NULL;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
371 char *alias = NULL;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
372 char *str;
30626
bec413ce77c7 Fix some "Dead nested assignment"s and then kill off some useless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30054
diff changeset
373 char *s;
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
374 gboolean valid;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
375
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
376 g_return_val_if_fail(msg != NULL, FALSE);
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
377 g_return_val_if_fail(ret_protocol != NULL, FALSE);
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
378 g_return_val_if_fail(ret_username != NULL, FALSE);
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
379
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
380 s = str = g_strdup(msg);
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
381
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
382 while (*s != '\r' && *s != '\n' && *s != '\0')
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
383 {
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
384 char *key, *value;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
385
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
386 key = s;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
387
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
388 /* Grab the key */
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
389 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ')
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
390 s++;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
391
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
392 if (*s == '\r') s++;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
393
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
394 if (*s == '\n')
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
395 {
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
396 s++;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
397 continue;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
398 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
399
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
400 if (*s != '\0') *s++ = '\0';
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
401
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
402 /* Clear past any whitespace */
40133
b86418d6eb94 Remove redundant comparisons in conditions
qarkai <qarkai@gmail.com>
parents: 40094
diff changeset
403 while (*s == ' ')
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
404 s++;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
405
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
406 /* Now let's grab until the end of the line. */
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
407 value = s;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
408
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
409 while (*s != '\r' && *s != '\n' && *s != '\0')
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
410 s++;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
411
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
412 if (*s == '\r') *s++ = '\0';
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
413 if (*s == '\n') *s++ = '\0';
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
414
30626
bec413ce77c7 Fix some "Dead nested assignment"s and then kill off some useless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30054
diff changeset
415 if (strchr(key, ':') != NULL)
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
416 {
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
417 if (!g_ascii_strcasecmp(key, "X-IM-Username:"))
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
418 username = g_strdup(value);
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
419 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:"))
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
420 protocol = g_strdup(value);
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
421 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:"))
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
422 alias = g_strdup(value);
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
423 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
424 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
425
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
426 if (username != NULL && protocol != NULL)
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
427 {
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
428 valid = TRUE;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
429
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
430 *ret_username = username;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
431 *ret_protocol = protocol;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
432
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
433 if (ret_alias != NULL)
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
434 *ret_alias = alias;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
435
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
436 /* Check for a compatible account. */
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
437 if (ret_account != NULL)
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
438 {
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
439 GList *list;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
440 PurpleAccount *account = NULL;
18122
9bf9970c1b6a disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents: 18121
diff changeset
441 GList *l;
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
442 const char *protoname;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
443
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
444 if (all_accounts)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
445 list = purple_accounts_get_all();
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
446 else
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
447 list = purple_connections_get_all();
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
448
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
449 for (l = list; l != NULL; l = l->next)
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
450 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
451 PurpleConnection *gc;
37006
5fecec4fe589 Fix misleading variable name
Ankit Vani <a@nevitus.org>
parents: 36959
diff changeset
452 PurpleProtocol *proto = NULL;
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
453
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
454 if (all_accounts)
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
455 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
456 account = (PurpleAccount *)l->data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
457
40803
0e11ce1049b2 Port Pidgin from purple_protocols to PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents: 40784
diff changeset
458 proto = purple_account_get_protocol(account);
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
459
37006
5fecec4fe589 Fix misleading variable name
Ankit Vani <a@nevitus.org>
parents: 36959
diff changeset
460 if (proto == NULL)
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
461 {
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
462 account = NULL;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
463
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
464 continue;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
465 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
466 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
467 else
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
468 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
469 gc = (PurpleConnection *)l->data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
470 account = purple_connection_get_account(gc);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
471
37006
5fecec4fe589 Fix misleading variable name
Ankit Vani <a@nevitus.org>
parents: 36959
diff changeset
472 proto = purple_connection_get_protocol(gc);
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
473 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
474
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
475 protoname = purple_protocol_get_list_icon(proto, account, NULL);
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
476
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38257
diff changeset
477 if (purple_strequal(protoname, protocol))
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
478 break;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
479
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
480 account = NULL;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
481 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
482
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
483 *ret_account = account;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
484 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
485 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
486 else
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
487 {
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
488 valid = FALSE;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
489
14097
0c340861ab79 [gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents: 13783
diff changeset
490 g_free(username);
0c340861ab79 [gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents: 13783
diff changeset
491 g_free(protocol);
0c340861ab79 [gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents: 13783
diff changeset
492 g_free(alias);
7712
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
493 }
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
494
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
495 g_free(str);
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
496
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
497 return valid;
74af9358b808 [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
498 }
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
499
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
500 void
35720
863f87bfc06e Smiley manager: cleanup
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35713
diff changeset
501 pidgin_set_accessible_label(GtkWidget *w, GtkLabel *l)
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
502 {
19547
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
503 AtkObject *acc;
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
504 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
505 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
506
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
507 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
508
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
509 /* 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
510 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
511 if (!existing_name) {
35720
863f87bfc06e Smiley manager: cleanup
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35713
diff changeset
512 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
513 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
514 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
515 }
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
516
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
517 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
518 }
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
519
0c3fcdc6a025 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 19123
diff changeset
520 void
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
521 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
522 {
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
523 AtkObject *acc, *label;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
524 AtkObject *rel_obj[1];
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
525 AtkRelationSet *set;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
526 AtkRelation *relation;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
527
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
528 acc = gtk_widget_get_accessible (w);
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
529 label = gtk_widget_get_accessible(GTK_WIDGET(l));
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
530
18351
b881759cda28 Call gtk_label_set_mnemonic_widget() in pidgin_make_accessible_label. Closes #589
Sean Egan <seanegan@pidgin.im>
parents: 18281
diff changeset
531 /* Make sure mnemonics work */
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
532 gtk_label_set_mnemonic_widget(l, w);
20241
36b8b9235ff3 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20234
diff changeset
533
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
534 /* Create the labeled-by relation */
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
535 set = atk_object_ref_relation_set (acc);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
536 rel_obj[0] = label;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
537 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
538 atk_relation_set_add (set, relation);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
539 g_object_unref (relation);
20241
36b8b9235ff3 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20234
diff changeset
540 g_object_unref(set);
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
541
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
542 /* Create the label-for relation */
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
543 set = atk_object_ref_relation_set (label);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
544 rel_obj[0] = acc;
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
545 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
546 atk_relation_set_add (set, relation);
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
547 g_object_unref (relation);
20241
36b8b9235ff3 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20234
diff changeset
548 g_object_unref(set);
8137
ca2132ad085e [gaim-migrate @ 8842]
Marc Mulcahy
parents: 8134
diff changeset
549 }
8143
ce4b6383777b [gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents: 8137
diff changeset
550
18238
b38c33d2d71e Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 18216
diff changeset
551 void
38709
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
552 pidgin_menu_popup_at_treeview_selection(GtkWidget *menu, GtkWidget *treeview)
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
553 {
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
554 GtkTreePath *path;
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
555 GtkTreeViewColumn *column;
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
556 GdkWindow *bin_window;
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
557 GdkRectangle rect;
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
558
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
559 gtk_tree_view_get_cursor(GTK_TREE_VIEW(treeview), &path, &column);
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
560 g_return_if_fail(path != NULL);
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
561 if (column == NULL)
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
562 column = gtk_tree_view_get_column(GTK_TREE_VIEW(treeview), 0);
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
563 bin_window = gtk_tree_view_get_bin_window(GTK_TREE_VIEW(treeview));
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
564 gtk_tree_view_get_cell_area(GTK_TREE_VIEW(treeview), path, column, &rect);
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
565 gtk_menu_popup_at_rect(GTK_MENU(menu), bin_window, &rect,
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
566 GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST,
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
567 NULL);
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
568
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
569 gtk_tree_path_free(path);
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
570 }
6c80734ca3b4 Add pidgin_menu_popup_at_treeview_selection.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38650
diff changeset
571
10061
2833056ea11c [gaim-migrate @ 11033]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 9910
diff changeset
572
10850
6889f793b918 [gaim-migrate @ 12522]
Mark Doliner <markdoliner@pidgin.im>
parents: 10681
diff changeset
573 static void dnd_image_ok_callback(_DndData *data, int choice)
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
574 {
31372
743be8e50f23 When drag-dropping an image into an IM window and sending as an inline
Mark Doliner <markdoliner@pidgin.im>
parents: 31217
diff changeset
575 const gchar *shortname;
23287
4b4f5e80e324 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents: 23286
diff changeset
576 gchar *filedata;
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
577 size_t size;
33940
b44d15793c83 Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
578 GStatBuf st;
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
579 GError *err = NULL;
23287
4b4f5e80e324 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents: 23286
diff changeset
580 PurpleBuddy *buddy;
4b4f5e80e324 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents: 23286
diff changeset
581 PurpleContact *contact;
35812
48c6ee645ca1 Imgstore vs PurpleImage: rip and fix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35742
diff changeset
582 PurpleImage *img;
48c6ee645ca1 Imgstore vs PurpleImage: rip and fix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35742
diff changeset
583
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
584 switch (choice) {
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
585 case DND_BUDDY_ICON:
14914
290eb2170f38 [gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14781
diff changeset
586 if (g_stat(data->filename, &st)) {
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
587 char *str;
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
588
14914
290eb2170f38 [gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14781
diff changeset
589 str = g_strdup_printf(_("The following error has occurred loading %s: %s"),
21975
721ddc236ce5 Use g_sterror instead of strerror in two more places.
Mark Doliner <markdoliner@pidgin.im>
parents: 21890
diff changeset
590 data->filename, g_strerror(errno));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
591 purple_notify_error(NULL, NULL,
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34447
diff changeset
592 _("Failed to load image"), str, NULL);
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
593 g_free(str);
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
594
26846
d5546da39e44 Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26821
diff changeset
595 break;
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
596 }
10335
cf53f16ad85d [gaim-migrate @ 11542]
Kevin Stange <kstange@pidgin.im>
parents: 10240
diff changeset
597
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34726
diff changeset
598 buddy = purple_blist_find_buddy(data->account, data->who);
23287
4b4f5e80e324 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents: 23286
diff changeset
599 if (!buddy) {
4b4f5e80e324 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents: 23286
diff changeset
600 purple_debug_info("custom-icon", "You can only set custom icons for people on your buddylist.\n");
4b4f5e80e324 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents: 23286
diff changeset
601 break;
4b4f5e80e324 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents: 23286
diff changeset
602 }
4b4f5e80e324 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents: 23286
diff changeset
603 contact = purple_buddy_get_contact(buddy);
4b4f5e80e324 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents: 23286
diff changeset
604 purple_buddy_icons_node_set_custom_icon_from_file((PurpleBlistNode*)contact, data->filename);
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
605 break;
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
606 case DND_FILE_TRANSFER:
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35455
diff changeset
607 purple_serv_send_file(purple_account_get_connection(data->account), data->who, data->filename);
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
608 break;
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
609 case DND_IM_IMAGE:
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
610 if (!g_file_get_contents(data->filename, &filedata, &size,
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
611 &err)) {
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
612 char *str;
10335
cf53f16ad85d [gaim-migrate @ 11542]
Kevin Stange <kstange@pidgin.im>
parents: 10240
diff changeset
613
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
614 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
615 purple_notify_error(NULL, NULL,
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34447
diff changeset
616 _("Failed to load image"), str, NULL);
10335
cf53f16ad85d [gaim-migrate @ 11542]
Kevin Stange <kstange@pidgin.im>
parents: 10240
diff changeset
617
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
618 g_error_free(err);
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
619 g_free(str);
10335
cf53f16ad85d [gaim-migrate @ 11542]
Kevin Stange <kstange@pidgin.im>
parents: 10240
diff changeset
620
26846
d5546da39e44 Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 26821
diff changeset
621 break;
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
622 }
31372
743be8e50f23 When drag-dropping an image into an IM window and sending as an inline
Mark Doliner <markdoliner@pidgin.im>
parents: 31217
diff changeset
623 shortname = strrchr(data->filename, G_DIR_SEPARATOR);
743be8e50f23 When drag-dropping an image into an IM window and sending as an inline
Mark Doliner <markdoliner@pidgin.im>
parents: 31217
diff changeset
624 shortname = shortname ? shortname + 1 : data->filename;
39273
820a44d3d618 pidgin: Fix -Wpointer-sign warning expected 'const guint8 *' vs 'gchar *'
Mike Ruprecht <cmaiku@gmail.com>
parents: 39175
diff changeset
625 img = purple_image_new_from_data((guint8 *)filedata, size);
35825
4c1e8623b7c7 Fix warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35815
diff changeset
626 purple_image_set_friendly_filename(img, shortname);
35812
48c6ee645ca1 Imgstore vs PurpleImage: rip and fix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35742
diff changeset
627
39688
2b1c2b6e9993 Additional cleanups for the entry webkit removal
Gary Kramlich <grim@reaperworld.com>
parents: 39665
diff changeset
628 # warning fix this when talkatu has a way to programmatically insert an image
2b1c2b6e9993 Additional cleanups for the entry webkit removal
Gary Kramlich <grim@reaperworld.com>
parents: 39665
diff changeset
629 // pidgin_webview_insert_image(PIDGIN_WEBVIEW(gtkconv->entry), img);
35812
48c6ee645ca1 Imgstore vs PurpleImage: rip and fix
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35742
diff changeset
630 g_object_unref(img);
10335
cf53f16ad85d [gaim-migrate @ 11542]
Kevin Stange <kstange@pidgin.im>
parents: 10240
diff changeset
631
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
632 break;
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
633 }
25152
128b99dfb286 Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents: 24860
diff changeset
634 g_free(data->filename);
128b99dfb286 Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents: 24860
diff changeset
635 g_free(data->who);
128b99dfb286 Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents: 24860
diff changeset
636 g_free(data);
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
637 }
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
638
10850
6889f793b918 [gaim-migrate @ 12522]
Mark Doliner <markdoliner@pidgin.im>
parents: 10681
diff changeset
639 static void dnd_image_cancel_callback(_DndData *data, int choice)
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
640 {
25152
128b99dfb286 Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents: 24860
diff changeset
641 g_free(data->filename);
128b99dfb286 Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents: 24860
diff changeset
642 g_free(data->who);
128b99dfb286 Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents: 24860
diff changeset
643 g_free(data);
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
644 }
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
645
11110
acc4e51cb91a [gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents: 11017
diff changeset
646 static void dnd_set_icon_ok_cb(_DndData *data)
acc4e51cb91a [gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents: 11017
diff changeset
647 {
acc4e51cb91a [gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents: 11017
diff changeset
648 dnd_image_ok_callback(data, DND_BUDDY_ICON);
acc4e51cb91a [gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents: 11017
diff changeset
649 }
acc4e51cb91a [gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents: 11017
diff changeset
650
acc4e51cb91a [gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents: 11017
diff changeset
651 static void dnd_set_icon_cancel_cb(_DndData *data)
acc4e51cb91a [gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents: 11017
diff changeset
652 {
25152
128b99dfb286 Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents: 24860
diff changeset
653 g_free(data->filename);
128b99dfb286 Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents: 24860
diff changeset
654 g_free(data->who);
128b99dfb286 Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents: 24860
diff changeset
655 g_free(data);
11110
acc4e51cb91a [gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents: 11017
diff changeset
656 }
acc4e51cb91a [gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents: 11017
diff changeset
657
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
658 static void
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
659 pidgin_dnd_file_send_image(PurpleAccount *account, const gchar *who,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
660 const gchar *filename)
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
661 {
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
662 PurpleConnection *gc = purple_account_get_connection(account);
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
663 PurpleProtocol *protocol = NULL;
39922
113b93e2bd2a Replace malloc(sizeof(...)) with g_new0(..., 1).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39919
diff changeset
664 _DndData *data = g_new0(_DndData, 1);
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
665 gboolean ft = FALSE, im = FALSE;
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
666
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
667 data->who = g_strdup(who);
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
668 data->filename = g_strdup(filename);
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
669 data->account = account;
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
670
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
671 if (gc)
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
672 protocol = purple_connection_get_protocol(gc);
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
673
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
674 if (!(purple_connection_get_flags(gc) & PURPLE_CONNECTION_FLAG_NO_IMAGES))
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
675 im = TRUE;
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
676
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38433
diff changeset
677 if (protocol && PURPLE_IS_PROTOCOL_XFER(protocol)) {
39274
7acdb1d9797c pidgin: Fix various -Wincompatible-pointer-types warnings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39273
diff changeset
678 PurpleProtocolXferInterface *iface =
7acdb1d9797c pidgin: Fix various -Wincompatible-pointer-types warnings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39273
diff changeset
679 PURPLE_PROTOCOL_XFER_GET_IFACE(protocol);
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38433
diff changeset
680
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38433
diff changeset
681 if(iface->can_receive) {
39274
7acdb1d9797c pidgin: Fix various -Wincompatible-pointer-types warnings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39273
diff changeset
682 ft = purple_protocol_xfer_can_receive(
7acdb1d9797c pidgin: Fix various -Wincompatible-pointer-types warnings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39273
diff changeset
683 PURPLE_PROTOCOL_XFER(protocol),
7acdb1d9797c pidgin: Fix various -Wincompatible-pointer-types warnings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39273
diff changeset
684 gc, who);
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38433
diff changeset
685 } else {
39005
6a56e1366809 xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents: 38993
diff changeset
686 ft = (iface->send_file) ? TRUE : FALSE;
38827
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38433
diff changeset
687 }
3573c82d32d8 Initial attempt at removing the magic around PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents: 38433
diff changeset
688 }
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
689
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
690 if (im && ft) {
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
691 purple_request_choice(NULL, NULL,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
692 _("You have dragged an image"),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
693 _("You can send this image as a file "
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
694 "transfer, embed it into this message, "
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
695 "or use it as the buddy icon for this user."),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
696 (gpointer)DND_FILE_TRANSFER, _("OK"),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
697 (GCallback)dnd_image_ok_callback, _("Cancel"),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
698 (GCallback)dnd_image_cancel_callback,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
699 purple_request_cpar_from_account(account), data,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
700 _("Set as buddy icon"), DND_BUDDY_ICON,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
701 _("Send image file"), DND_FILE_TRANSFER,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
702 _("Insert in message"), DND_IM_IMAGE,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
703 NULL);
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
704 } else if (!(im || ft)) {
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
705 purple_request_yes_no(NULL, NULL, _("You have dragged an image"),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
706 _("Would you like to set it as the buddy icon for this user?"),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
707 PURPLE_DEFAULT_ACTION_NONE,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
708 purple_request_cpar_from_account(account),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
709 data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb);
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
710 } else {
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
711 purple_request_choice(NULL, NULL,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
712 _("You have dragged an image"),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
713 (ft ? _("You can send this image as a file transfer, or use it as the buddy icon for this user.") :
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
714 _("You can insert this image into this message, or use it as the buddy icon for this user")),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
715 GINT_TO_POINTER(ft ? DND_FILE_TRANSFER : DND_IM_IMAGE),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
716 _("OK"), (GCallback)dnd_image_ok_callback,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
717 _("Cancel"), (GCallback)dnd_image_cancel_callback,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
718 purple_request_cpar_from_account(account),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
719 data,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
720 _("Set as buddy icon"), DND_BUDDY_ICON,
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
721 (ft ? _("Send image file") : _("Insert in message")), (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
722 NULL);
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
723 }
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
724
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
725 }
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
726
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
727 #ifndef _WIN32
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
728 static void
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
729 pidgin_dnd_file_send_desktop(PurpleAccount *account, const gchar *who,
37541
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
730 const gchar *filename)
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
731 {
37541
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
732 gchar *name;
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
733 gchar *type;
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
734 gchar *url;
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
735 GKeyFile *desktop_file;
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
736 PurpleConversation *conv;
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
737 PidginConversation *gtkconv;
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
738 GError *error = NULL;
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
739
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
740 desktop_file = g_key_file_new();
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
741
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
742 if (!g_key_file_load_from_file(desktop_file, filename, G_KEY_FILE_NONE, &error)) {
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
743 if (error) {
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
744 purple_debug_warning("D&D", "Failed to load %s: %s\n",
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
745 filename, error->message);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
746 g_error_free(error);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
747 }
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
748 return;
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
749 }
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
750
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
751 name = g_key_file_get_string(desktop_file, G_KEY_FILE_DESKTOP_GROUP,
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
752 G_KEY_FILE_DESKTOP_KEY_NAME, &error);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
753 if (error) {
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
754 purple_debug_warning("D&D", "Failed to read the Name from a desktop file: %s\n",
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
755 error->message);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
756 g_error_free(error);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
757
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
758 }
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
759
37541
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
760 type = g_key_file_get_string(desktop_file, G_KEY_FILE_DESKTOP_GROUP,
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
761 G_KEY_FILE_DESKTOP_KEY_TYPE, &error);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
762 if (error) {
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
763 purple_debug_warning("D&D", "Failed to read the Type from a desktop file: %s\n",
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
764 error->message);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
765 g_error_free(error);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
766
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
767 }
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
768
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
769 url = g_key_file_get_string(desktop_file, G_KEY_FILE_DESKTOP_GROUP,
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
770 G_KEY_FILE_DESKTOP_KEY_URL, &error);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
771 if (error) {
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
772 purple_debug_warning("D&D", "Failed to read the Type from a desktop file: %s\n",
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
773 error->message);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
774 g_error_free(error);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
775
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
776 }
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
777
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
778
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
779 /* If any of this is null, do nothing. */
39919
1d0ce288ca30 Fix possible use-of-NULL warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39913
diff changeset
780 if (!name || !type || !url) {
37541
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
781 g_free(type);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
782 g_free(name);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
783 g_free(url);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
784
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
785 return;
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
786 }
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
787
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
788 /* I don't know if we really want to do anything here. Most of
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
789 * the desktop item types are crap like "MIME Type" (I have no
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
790 * clue how that would be a desktop item) and "Comment"...
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
791 * nothing we can really send. The only logical one is
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
792 * "Application," but do we really want to send a binary and
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
793 * nothing else? Probably not. I'll just give an error and
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
794 * return. */
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
795 /* The original patch sent the icon used by the launcher. That's probably wrong */
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38299 38260
diff changeset
796 if (purple_strequal(type, "Link")) {
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
797 purple_notify_error(NULL, NULL, _("Cannot send launcher"),
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
798 _("You dragged a desktop launcher. Most "
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
799 "likely you wanted to send the target "
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
800 "of this launcher instead of this "
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
801 "launcher itself."), NULL);
37541
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
802
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
803 } else {
39690
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
804 GtkTextBuffer *buffer = NULL;
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
805 GtkTextMark *mark = NULL;
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
806 GtkTextIter iter;
37541
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
807
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
808 conv = PURPLE_CONVERSATION(purple_im_conversation_new(account, who));
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
809 gtkconv = PIDGIN_CONVERSATION(conv);
39690
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
810
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
811 buffer = talkatu_editor_get_buffer(TALKATU_EDITOR(gtkconv->editor));
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
812 mark = gtk_text_buffer_get_insert(buffer);
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
813
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
814 gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
815
173fe0644961 Fix some issues found in review and default to an TalkatuHTMLBuffer
Gary Kramlich <grim@reaperworld.com>
parents: 39688
diff changeset
816 talkatu_buffer_insert_link(TALKATU_BUFFER(buffer), &iter, name, url);
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
817 }
37541
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
818
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
819 g_free(type);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
820 g_free(name);
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
821 g_free(url);
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
822 }
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
823 #endif /* _WIN32 */
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
824
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
825 void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
826 pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who)
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
827 {
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
828 GdkPixbuf *pb;
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
829 GList *files = purple_uri_list_extract_filenames((const gchar *) gtk_selection_data_get_data(sd));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
830 PurpleConnection *gc = purple_account_get_connection(account);
28458
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
831 gchar *filename = NULL;
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
832 gchar *basename = NULL;
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
833
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
834 g_return_if_fail(account != NULL);
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
835 g_return_if_fail(who != NULL);
10335
cf53f16ad85d [gaim-migrate @ 11542]
Kevin Stange <kstange@pidgin.im>
parents: 10240
diff changeset
836
28458
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
837 for ( ; files; files = g_list_delete_link(files, files)) {
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
838 g_free(filename);
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
839 g_free(basename);
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
840
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
841 filename = files->data;
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
842 basename = g_path_get_basename(filename);
10335
cf53f16ad85d [gaim-migrate @ 11542]
Kevin Stange <kstange@pidgin.im>
parents: 10240
diff changeset
843
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
844 /* XXX - Make ft API support creating a transfer with more than one file */
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
845 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
846 continue;
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
847 }
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
848
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
849 /* XXX - make ft api suupport sending a directory */
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
850 /* Are we dealing with a directory? */
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
851 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) {
16071
044392e01c96 make things cleaner for translators
Nathan Walp <nwalp@pidgin.im>
parents: 15987
diff changeset
852 char *str, *str2;
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
853
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
854 str = g_strdup_printf(_("Cannot send folder %s."), basename);
16977
c9cb49bea66d Change the PIDGIN_NAME stuff to allow translators to transliterate the
Richard Laager <rlaager@pidgin.im>
parents: 16692
diff changeset
855 str2 = g_strdup_printf(_("%s cannot transfer a folder. You will need to send the files within individually."), PIDGIN_NAME);
16071
044392e01c96 make things cleaner for translators
Nathan Walp <nwalp@pidgin.im>
parents: 15987
diff changeset
856
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34447
diff changeset
857 purple_notify_error(NULL, NULL, str, str2,
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34447
diff changeset
858 purple_request_cpar_from_connection(gc));
10335
cf53f16ad85d [gaim-migrate @ 11542]
Kevin Stange <kstange@pidgin.im>
parents: 10240
diff changeset
859
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
860 g_free(str);
16071
044392e01c96 make things cleaner for translators
Nathan Walp <nwalp@pidgin.im>
parents: 15987
diff changeset
861 g_free(str2);
10335
cf53f16ad85d [gaim-migrate @ 11542]
Kevin Stange <kstange@pidgin.im>
parents: 10240
diff changeset
862 continue;
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
863 }
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
864
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
865 /* Are we dealing with an image? */
31889
96183796df0c Start looking at the GError parameter every time we call these functions:
Mark Doliner <markdoliner@pidgin.im>
parents: 31565
diff changeset
866 pb = pidgin_pixbuf_new_from_file(filename);
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
867 if (pb) {
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
868 pidgin_dnd_file_send_image(account, who, filename);
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
869
26820
76f90ca8f6f2 Use g_object_ref/unref instead of the deprecated versions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26753
diff changeset
870 g_object_unref(G_OBJECT(pb));
28458
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
871
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
872 continue;
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
873 }
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
874
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
875 #ifndef _WIN32
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
876 /* Are we trying to send a .desktop file? */
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
877 else if (g_str_has_suffix(basename, ".desktop")) {
37541
5b8d92fdcaa3 Use glib's Desktop file utilities instead of our own
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37540
diff changeset
878 pidgin_dnd_file_send_desktop(account, who, filename);
37540
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
879
b59120d66fdd Refactor a painfully long Drag&Drop util function
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37422
diff changeset
880 continue;
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
881 }
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
882 #endif /* _WIN32 */
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
883
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
884 /* Everything is fine, let's send */
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 35455
diff changeset
885 purple_serv_send_file(gc, who, filename);
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
886 }
28458
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
887
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
888 g_free(filename);
850dc251c138 Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <darkrain42@pidgin.im>
parents: 28234
diff changeset
889 g_free(basename);
10229
39ffee70c286 [gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents: 10209
diff changeset
890 }
10483
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
891
37406
98ec68212b1f Move PurpleIconScaleRules to BuddyIcon API
Jorge Villaseñor <salinasv@pidgin.im>
parents: 37200
diff changeset
892 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
893 {
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
894 *width = gdk_pixbuf_get_width(buf);
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
895 *height = gdk_pixbuf_get_height(buf);
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
896
15301
26153c5f156a [gaim-migrate @ 18029]
Mark Doliner <markdoliner@pidgin.im>
parents: 15289
diff changeset
897 if ((spec == NULL) || !(spec->scale_rules & rules))
26153c5f156a [gaim-migrate @ 18029]
Mark Doliner <markdoliner@pidgin.im>
parents: 15289
diff changeset
898 return;
26153c5f156a [gaim-migrate @ 18029]
Mark Doliner <markdoliner@pidgin.im>
parents: 15289
diff changeset
899
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
900 purple_buddy_icon_spec_get_scaled_size(spec, width, height);
10483
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
901
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
902 /* and now for some arbitrary sanity checks */
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
903 if(*width > 100)
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
904 *width = 100;
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
905 if(*height > 100)
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
906 *height = 100;
e7b09a8b1f52 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
907 }
12080
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
908
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
909 GdkPixbuf *
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36633
diff changeset
910 pidgin_create_protocol_icon(PurpleAccount *account, PidginProtocolIconSize size)
12080
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
911 {
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
912 PurpleProtocol *protocol;
12080
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
913
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
914 g_return_val_if_fail(account != NULL, NULL);
2aaca2265a51 [gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12067
diff changeset
915
40803
0e11ce1049b2 Port Pidgin from purple_protocols to PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents: 40784
diff changeset
916 protocol = purple_account_get_protocol(account);
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
917 if (protocol == NULL)
13091
b5ed878998dd [gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents: 13081
diff changeset
918 return NULL;
36659
fbaa6f248ebc Free the list returned by purple_protocols_get_all()
Ankit Vani <a@nevitus.org>
parents: 36637
diff changeset
919 return pidgin_create_icon_from_protocol(protocol, size, account);
13091
b5ed878998dd [gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents: 13081
diff changeset
920 }
b5ed878998dd [gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents: 13081
diff changeset
921
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
922 static void
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
923 menu_action_cb(GtkMenuItem *item, gpointer object)
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
924 {
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
925 gpointer data;
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
926 void (*callback)(gpointer, gpointer);
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
927
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
928 callback = g_object_get_data(G_OBJECT(item), "purplecallback");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
929 data = g_object_get_data(G_OBJECT(item), "purplecallbackdata");
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
930
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
931 if (callback)
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
932 callback(object, data);
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
933 }
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
934
40278
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
935 static GtkWidget *
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
936 do_pidgin_append_menu_action(GtkWidget *menu, PurpleActionMenu *act,
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
937 gpointer object)
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
938 {
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
939 GtkWidget *menuitem;
32287
c8cf9b704a49 Hide-a-PurpleMenuAction.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32229
diff changeset
940 GList *list;
17386
f68ba6199d79 merge of 'de0c8e6287f1090343edb9c43e0d8d681e58df07'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17368 17385
diff changeset
941
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
942 if (act == NULL) {
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
943 return pidgin_separator(menu);
17386
f68ba6199d79 merge of 'de0c8e6287f1090343edb9c43e0d8d681e58df07'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17368 17385
diff changeset
944 }
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
945
39742
bed2cb40d222 Remove purple_action_menu_get_stock_icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39703
diff changeset
946 menuitem = gtk_menu_item_new_with_mnemonic(
bed2cb40d222 Remove purple_action_menu_get_stock_icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39703
diff changeset
947 purple_action_menu_get_label(act));
34485
2574bedf42f5 E2EE: make it possible to attach stock icon to PurpleMenuAction
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34451
diff changeset
948
39483
ab4728087d87 Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents: 39481
diff changeset
949 list = purple_action_menu_get_children(act);
32287
c8cf9b704a49 Hide-a-PurpleMenuAction.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32229
diff changeset
950
c8cf9b704a49 Hide-a-PurpleMenuAction.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32229
diff changeset
951 if (list == NULL) {
c8cf9b704a49 Hide-a-PurpleMenuAction.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32229
diff changeset
952 PurpleCallback callback;
c8cf9b704a49 Hide-a-PurpleMenuAction.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32229
diff changeset
953
39483
ab4728087d87 Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents: 39481
diff changeset
954 callback = purple_action_menu_get_callback(act);
32287
c8cf9b704a49 Hide-a-PurpleMenuAction.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32229
diff changeset
955
c8cf9b704a49 Hide-a-PurpleMenuAction.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32229
diff changeset
956 if (callback != NULL) {
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
957 g_object_set_data(G_OBJECT(menuitem),
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
958 "purplecallback",
32287
c8cf9b704a49 Hide-a-PurpleMenuAction.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32229
diff changeset
959 callback);
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
960 g_object_set_data(G_OBJECT(menuitem),
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
961 "purplecallbackdata",
39483
ab4728087d87 Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents: 39481
diff changeset
962 purple_action_menu_get_data(act));
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
963 g_signal_connect(G_OBJECT(menuitem), "activate",
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
964 G_CALLBACK(menu_action_cb),
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
965 object);
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
966 } else {
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
967 gtk_widget_set_sensitive(menuitem, FALSE);
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
968 }
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
969
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
970 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
971 } else {
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
972 GList *l = NULL;
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
973 GtkWidget *submenu = NULL;
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
974 GtkAccelGroup *group;
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
975
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
976 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
977
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
978 submenu = gtk_menu_new();
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
979 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
980
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
981 group = gtk_menu_get_accel_group(GTK_MENU(menu));
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
982 if (group) {
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
983 char *path = g_strdup_printf("%s/%s",
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32415
diff changeset
984 gtk_menu_item_get_accel_path(GTK_MENU_ITEM(menuitem)),
39483
ab4728087d87 Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents: 39481
diff changeset
985 purple_action_menu_get_label(act));
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
986 gtk_menu_set_accel_path(GTK_MENU(submenu), path);
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
987 g_free(path);
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
988 gtk_menu_set_accel_group(GTK_MENU(submenu), group);
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
989 }
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
990
32287
c8cf9b704a49 Hide-a-PurpleMenuAction.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents: 32229
diff changeset
991 for (l = list; l; l = l->next) {
39481
4db28449567d Rename PurpleMenuAction to PurpleActionMenu
Gary Kramlich <grim@reaperworld.com>
parents: 39466
diff changeset
992 PurpleActionMenu *act = (PurpleActionMenu *)l->data;
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
993
40278
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
994 do_pidgin_append_menu_action(submenu, act, object);
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
995 }
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
996 }
40278
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
997 return menuitem;
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
998 }
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
999
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
1000 GtkWidget *
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
1001 pidgin_append_menu_action(GtkWidget *menu, PurpleActionMenu *act,
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
1002 gpointer object)
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
1003 {
e3d3676df758 gtk: fix a PurpleActionMenu use after free
Fabrice Bellet <fabrice@bellet.info>
parents: 40197
diff changeset
1004 GtkWidget *menuitem = do_pidgin_append_menu_action(menu, act, object);
39483
ab4728087d87 Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents: 39481
diff changeset
1005 purple_action_menu_free(act);
17363
f16ea1b259e2 Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 17360
diff changeset
1006 return menuitem;
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12905
diff changeset
1007 }
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1008
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
1009 static gboolean buddyname_completion_match_func(GtkEntryCompletion *completion,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1010 const gchar *key, GtkTreeIter *iter, gpointer user_data)
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1011 {
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1012 GtkTreeModel *model;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1013 GValue val1;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1014 GValue val2;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1015 const char *tmp;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1016
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
1017 model = gtk_entry_completion_get_model(completion);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1018
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1019 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
1020 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
1021 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
1022 if (tmp != NULL && g_str_has_prefix(tmp, key)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1023 g_value_unset(&val1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1024 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1025 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1026 g_value_unset(&val1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1027
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1028 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
1029 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
1030 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
1031 if (tmp != NULL && g_str_has_prefix(tmp, key)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1032 g_value_unset(&val2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1033 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1034 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1035 g_value_unset(&val2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1036
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1037 return FALSE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1038 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1039
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
1040 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
1041 GtkTreeModel *model, GtkTreeIter *iter, PidginCompletionData *data)
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1042 {
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1043 GValue val;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1044 GtkWidget *optmenu = data->accountopt;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
1045 PurpleAccount *account;
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1046
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1047 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
1048 gtk_tree_model_get_value(model, iter, COMPLETION_BUDDY_COLUMN, &val);
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1049 gtk_entry_set_text(GTK_ENTRY(data->entry), g_value_get_string(&val));
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1050 g_value_unset(&val);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1051
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
1052 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
1053 account = g_value_get_pointer(&val);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1054 g_value_unset(&val);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1055
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1056 if (account == NULL)
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1057 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1058
17117
d256023d5312 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17116
diff changeset
1059 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
1060 aop_option_menu_select_by_data(optmenu, account);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1061
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1062 return TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1063 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1064
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1065 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
1066 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
1067 const PurpleAccount *account, const char *buddyname)
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1068 {
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1069 GtkTreeIter iter;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1070 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
1071 gchar *normalized_buddyname;
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1072 gchar *tmp;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1073
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
1074 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
1075 normalized_buddyname = g_utf8_casefold(tmp, -1);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1076 g_free(tmp);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1077
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1078 /* 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
1079 when the name and buddy alias match. */
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
1080 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
1081 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
1082 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
1083
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1084 tmp = g_utf8_casefold(tmp2, -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1085 g_free(tmp2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1086
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1087 gtk_list_store_append(store, &iter);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1088 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
1089 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
1090 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
1091 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
1092 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
1093 COMPLETION_ACCOUNT_COLUMN, account,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1094 -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1095 g_free(completion_entry);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1096 g_free(tmp);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1097 completion_added = TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1098 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1099
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1100 /* 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
1101 when the name and contact alias match. */
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
1102 if (contact_alias && !purple_strequal(contact_alias, buddyname)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1103 /* 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
1104 if (!purple_strequal(contact_alias, buddy_alias)) {
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1105 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
1106 buddyname, contact_alias);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1107 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
1108
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1109 tmp = g_utf8_casefold(tmp2, -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1110 g_free(tmp2);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1111
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1112 gtk_list_store_append(store, &iter);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1113 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
1114 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
1115 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
1116 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
1117 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
1118 COMPLETION_ACCOUNT_COLUMN, account,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1119 -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1120 g_free(completion_entry);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1121 g_free(tmp);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1122 completion_added = TRUE;
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1123 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1124 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1125
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1126 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
1127 /* Add the buddy's name. */
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1128 gtk_list_store_append(store, &iter);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1129 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
1130 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
1131 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
1132 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
1133 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
1134 COMPLETION_ACCOUNT_COLUMN, account,
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1135 -1);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1136 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1137
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
1138 g_free(normalized_buddyname);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1139 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1140
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1141 static void
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
1142 add_completion_list(PidginCompletionData *data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1143 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
1144 PurpleBlistNode *gnode, *cnode, *bnode;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1145 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
1146 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
1147 gchar *alias;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1148
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1149 gtk_list_store_clear(data->store);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1150
39665
2172e3b8eeef Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39568
diff changeset
1151 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
1152 gnode = gnode->next) {
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 34662
diff changeset
1153 if (!PURPLE_IS_GROUP(gnode))
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1154 continue;
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1155
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1156 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1157 {
34696
6e0d13978666 Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents: 34662
diff changeset
1158 if (!PURPLE_IS_CONTACT(cnode))
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1159 continue;
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1160
34769
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
1161 g_object_get(cnode, "alias", &alias, NULL);
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
1162
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1163 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1164 {
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1165 PidginBuddyCompletionEntry entry;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1166 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
1167 entry.buddy = (PurpleBuddy *) bnode;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1168
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1169 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
1170 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
1171 alias,
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41097
diff changeset
1172 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
1173 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
1174 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
1175 );
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1176 }
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1177 }
34769
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
1178
427725f8ed54 Free strings received from g_object_get
Ankit Vani <a@nevitus.org>
parents: 34739
diff changeset
1179 g_free(alias);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1180 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1181 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1182 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1183
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1184 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
1185 buddyname_autocomplete_destroyed_cb(GtkWidget *widget, gpointer data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1186 {
17707
b5f042209c68 Unleak a few bytes in the screenname completion code
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 17605
diff changeset
1187 g_free(data);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
1188 purple_signals_disconnect_by_handle(widget);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1189 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1190
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1191 static void
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1192 repopulate_autocomplete(gpointer something, gpointer data)
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1193 {
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1194 add_completion_list(data);
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1195 }
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1196
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1197 void
39796
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
1198 pidgin_setup_screenname_autocomplete(
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
1199 GtkWidget *entry, GtkWidget *chooser,
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
1200 PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data)
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1201 {
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1202 PidginCompletionData *data;
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1203
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
1204 /*
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
1205 * 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
1206 * 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
1207 * 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
1208 */
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1209 GtkListStore *store;
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1210
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1211 GtkEntryCompletion *completion;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1212
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1213 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
1214 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
1215 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
1216 G_TYPE_POINTER);
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1217
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1218 data->entry = entry;
39796
b42070e4ea6e Rename optmenu -> chooser in other files.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39785
diff changeset
1219 data->accountopt = chooser;
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1220 if (filter_func == NULL) {
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1221 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
1222 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
1223 } else {
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1224 data->filter_func = filter_func;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1225 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
1226 }
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1227 data->store = store;
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1228
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1229 add_completion_list(data);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1230
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
1231 /* Sort the completion list by buddy name */
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1232 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
1233 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
1234 GTK_SORT_ASCENDING);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1235
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1236 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
1237 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
1238
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1239 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
1240 G_CALLBACK(buddyname_completion_match_selected_cb), data);
13361
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1241
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1242 gtk_entry_set_completion(GTK_ENTRY(entry), completion);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1243 g_object_unref(completion);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1244
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1245 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store));
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1246 g_object_unref(store);
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1247
32933
956eb215f6c6 Make code a bit more verbose, and remove some "magic numbers".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32927
diff changeset
1248 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
1249
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1250 purple_signal_connect(purple_connections_get_handle(), "signed-on", entry,
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1251 PURPLE_CALLBACK(repopulate_autocomplete), data);
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1252 purple_signal_connect(purple_connections_get_handle(), "signed-off", entry,
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1253 PURPLE_CALLBACK(repopulate_autocomplete), data);
13366
e01cf252b407 [gaim-migrate @ 15738]
Richard Laager <rlaager@pidgin.im>
parents: 13365
diff changeset
1254
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
1255 purple_signal_connect(purple_accounts_get_handle(), "account-added", entry,
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1256 PURPLE_CALLBACK(repopulate_autocomplete), data);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
1257 purple_signal_connect(purple_accounts_get_handle(), "account-removed", entry,
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1258 PURPLE_CALLBACK(repopulate_autocomplete), data);
13365
8e6ae65497ef [gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13361
diff changeset
1259
25889
26d9ca30335c Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents: 25888
diff changeset
1260 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
1261 }
bb2f64cf6721 [gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 13281
diff changeset
1262
18966
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1263 gboolean
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1264 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
1265 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
1266
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41097
diff changeset
1267 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
1268 }
6a0715b72b6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents: 18941
diff changeset
1269
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
1270 void pidgin_set_cursor(GtkWidget *widget, GdkCursorType cursor_type)
13435
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1271 {
37997
7b62a2153898 Use gdk_cursor_new_for_display over gdk_cursor_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37996
diff changeset
1272 GdkDisplay *display;
13435
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1273 GdkCursor *cursor;
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1274
13470
5550131ec50b [gaim-migrate @ 15845]
Richard Laager <rlaager@pidgin.im>
parents: 13435
diff changeset
1275 g_return_if_fail(widget != NULL);
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
1276 if (gtk_widget_get_window(widget) == NULL)
13435
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1277 return;
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1278
37997
7b62a2153898 Use gdk_cursor_new_for_display over gdk_cursor_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37996
diff changeset
1279 display = gtk_widget_get_display(widget);
7b62a2153898 Use gdk_cursor_new_for_display over gdk_cursor_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37996
diff changeset
1280 cursor = gdk_cursor_new_for_display(display, cursor_type);
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
1281 gdk_window_set_cursor(gtk_widget_get_window(widget), cursor);
35533
8ca83abbc248 Fix some crashes and bugs introduced by recent deprecation fixes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35532
diff changeset
1282
35532
2c802bb77720 Fix most of warnings for gtk 3.4
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35528
diff changeset
1283 g_object_unref(cursor);
13435
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1284
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
1285 gdk_display_flush(gdk_window_get_display(gtk_widget_get_window(widget)));
13435
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1286 }
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1287
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
1288 void pidgin_clear_cursor(GtkWidget *widget)
13435
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1289 {
13470
5550131ec50b [gaim-migrate @ 15845]
Richard Laager <rlaager@pidgin.im>
parents: 13435
diff changeset
1290 g_return_if_fail(widget != NULL);
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
1291 if (gtk_widget_get_window(widget) == NULL)
13435
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1292 return;
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1293
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
1294 gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
13435
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1295 }
4c22eed6e0a6 [gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents: 13372
diff changeset
1296
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1297 static void
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1298 icon_filesel_choose_cb(GtkWidget *widget, gint response, struct _icon_chooser *dialog)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1299 {
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1300 char *filename, *current_folder;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1301
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1302 if (response != GTK_RESPONSE_ACCEPT) {
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1303 if (dialog->callback)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1304 dialog->callback(NULL, dialog->data);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1305 g_free(dialog);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1306 return;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1307 }
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1308
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1309 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel));
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1310 current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel));
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1311 if (current_folder != NULL) {
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16071
diff changeset
1312 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder", current_folder);
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1313 g_free(current_folder);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1314 }
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1315
29496
8807ee3e55c5 Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 28234
diff changeset
1316
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1317 if (dialog->callback)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1318 dialog->callback(filename, dialog->data);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1319 g_free(filename);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1320 g_free(dialog);
32422
c215bc5d85e4 Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32415
diff changeset
1321 }
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1322
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1323
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1324 static void
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1325 icon_preview_change_cb(GtkFileChooser *widget, struct _icon_chooser *dialog)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1326 {
33359
aba982dbb801 Fix sizing for the file-chooser image preview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32043
diff changeset
1327 GdkPixbuf *pixbuf;
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1328 int height, width;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1329 char *basename, *markup, *size;
33940
b44d15793c83 Use GStatBuf instead of struct stat
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33796
diff changeset
1330 GStatBuf st;
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1331 char *filename;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1332
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1333 filename = gtk_file_chooser_get_preview_filename(
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1334 GTK_FILE_CHOOSER(dialog->icon_filesel));
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1335
33359
aba982dbb801 Fix sizing for the file-chooser image preview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32043
diff changeset
1336 if (!filename || g_stat(filename, &st) || !(pixbuf = pidgin_pixbuf_new_from_file_at_size(filename, 128, 128)))
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1337 {
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1338 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1339 gtk_label_set_markup(GTK_LABEL(dialog->icon_text), "");
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1340 g_free(filename);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1341 return;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1342 }
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1343
33359
aba982dbb801 Fix sizing for the file-chooser image preview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32043
diff changeset
1344 gdk_pixbuf_get_file_info(filename, &width, &height);
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1345 basename = g_path_get_basename(filename);
39824
aefdb7ab2475 Replace purple_str_size_to_units by g_format_size.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39814
diff changeset
1346 size = g_format_size(st.st_size);
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1347 markup = g_strdup_printf(_("<b>File:</b> %s\n"
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1348 "<b>File size:</b> %s\n"
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1349 "<b>Image size:</b> %dx%d"),
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1350 basename, size, width, height);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1351
33359
aba982dbb801 Fix sizing for the file-chooser image preview.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32043
diff changeset
1352 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), pixbuf);
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1353 gtk_label_set_markup(GTK_LABEL(dialog->icon_text), markup);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1354
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1355 g_object_unref(G_OBJECT(pixbuf));
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1356 g_free(filename);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1357 g_free(basename);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1358 g_free(size);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1359 g_free(markup);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1360 }
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1361
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1362 GtkFileChooserNative *
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1363 pidgin_buddy_icon_chooser_new(GtkWindow *parent,
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1364 void (*callback)(const char *, gpointer),
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1365 gpointer data)
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1366 {
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1367 struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1368
17046
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1369 GtkWidget *vbox;
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1370 const char *current_folder;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1371
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1372 dialog->callback = callback;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1373 dialog->data = data;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1374
16123
8b98683319e7 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 16071
diff changeset
1375 current_folder = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder");
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1376
39930
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1377 dialog->icon_filesel = gtk_file_chooser_native_new(
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1378 _("Buddy Icon"), parent, GTK_FILE_CHOOSER_ACTION_OPEN, _("_Open"),
411f3df51bcd Convert to GtkFileChooserNative.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39858
diff changeset
1379 _("_Cancel"));
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1380 if ((current_folder != NULL) && (*current_folder != '\0'))
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1381 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel),
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1382 current_folder);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1383
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1384 dialog->icon_preview = gtk_image_new();
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1385 dialog->icon_text = gtk_label_new(NULL);
17046
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1386
40490
fb6e46c4c63c Remove PIDGIN_HIG_* constants
Gary Kramlich <grim@reaperworld.com>
parents: 40474
diff changeset
1387 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
17046
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1388 gtk_widget_set_size_request(GTK_WIDGET(vbox), -1, 50);
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1389 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(dialog->icon_preview), TRUE, FALSE, 0);
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1390 gtk_box_pack_end(GTK_BOX(vbox), GTK_WIDGET(dialog->icon_text), FALSE, FALSE, 0);
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1391 gtk_widget_show_all(vbox);
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1392
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1393 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel), vbox);
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1394 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(dialog->icon_filesel), TRUE);
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1395 gtk_file_chooser_set_use_preview_label(GTK_FILE_CHOOSER(dialog->icon_filesel), FALSE);
e1fcb4c68dab Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <datallah@pidgin.im>
parents: 17038
diff changeset
1396
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1397 g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview",
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1398 G_CALLBACK(icon_preview_change_cb), dialog);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1399 g_signal_connect(G_OBJECT(dialog->icon_filesel), "response",
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1400 G_CALLBACK(icon_filesel_choose_cb), dialog);
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1401 icon_preview_change_cb(NULL, dialog);
21729
a06176e84f3a applied changes from 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Daniel Atallah <datallah@pidgin.im>
parents: 21630
diff changeset
1402
a06176e84f3a applied changes from 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Daniel Atallah <datallah@pidgin.im>
parents: 21630
diff changeset
1403 return dialog->icon_filesel;
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1404 }
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1405
35455
216a37403c5b Fix a bunch of gtk-doc warnings in pidgin
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1406 /*
216a37403c5b Fix a bunch of gtk-doc warnings in pidgin
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1407 * str_array_match:
216a37403c5b Fix a bunch of gtk-doc warnings in pidgin
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1408 *
216a37403c5b Fix a bunch of gtk-doc warnings in pidgin
Ankit Vani <a@nevitus.org>
parents: 35454
diff changeset
1409 * 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
1410 */
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1411 static gboolean
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1412 str_array_match(char **a, char **b)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1413 {
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1414 int i, j;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1415
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1416 if (!a || !b)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1417 return FALSE;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1418 for (i = 0; a[i] != NULL; i++)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1419 for (j = 0; b[j] != NULL; j++)
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1420 if (!g_ascii_strcasecmp(a[i], b[j]))
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1421 return TRUE;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1422 return FALSE;
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1423 }
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1424
16446
3a6ed6c3400e Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents: 16437
diff changeset
1425 gpointer
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
1426 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
1427 {
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1428 PurpleBuddyIconSpec *spec;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1429 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
1430 GdkPixbufFormat *format;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1431 char **pixbuf_formats;
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1432 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
1433 GError *error = NULL;
15284
98e8f9912107 [gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents: 15254
diff changeset
1434 gchar *contents;
98e8f9912107 [gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents: 15254
diff changeset
1435 gsize length;
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1436 GdkPixbuf *pixbuf, *original;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1437 float scale_factor;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1438 int i;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1439 gchar *tmp;
14203
f3a50c328ddc [gaim-migrate @ 16783]
Mark Doliner <markdoliner@pidgin.im>
parents: 14196
diff changeset
1440
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
1441 spec = purple_protocol_get_icon_spec(protocol);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1442 if(spec->format == NULL) {
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1443 purple_buddy_icon_spec_free(spec);
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1444
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1445 return NULL;
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1446 }
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1447
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1448 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
1449 if (format == NULL) {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1450 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
1451
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1452 purple_buddy_icon_spec_free(spec);
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1453
14206
5a17eb1a2c3e [gaim-migrate @ 16786]
Mark Doliner <markdoliner@pidgin.im>
parents: 14203
diff changeset
1454 return NULL;
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1455 }
15289
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
1456
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
1457 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
1458 protocol_formats = g_strsplit(spec->format, ",", 0);
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1459
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1460 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
1461 (!(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
1462 (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
1463 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
1464 {
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1465 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
1466
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1467 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
1468 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
1469 "of %s: %s\n", path, error->message);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1470 g_strfreev(protocol_formats);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1471 purple_buddy_icon_spec_free(spec);
15289
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
1472 return NULL;
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
1473 }
2b90dc4e1483 [gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents: 15284
diff changeset
1474
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1475 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
1476 /* 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
1477 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
1478 if (len)
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1479 *len = length;
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1480 g_strfreev(protocol_formats);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1481 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
1482 return contents;
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1483 }
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1484
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1485 /* 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
1486 g_free(contents);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1487 } else {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1488 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
1489 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1490
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1491 /* 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
1492 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
1493 if (error) {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1494 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
1495 "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
1496 g_error_free(error);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1497 g_strfreev(protocol_formats);
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1498 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
1499 return NULL;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1500 }
39274
7acdb1d9797c pidgin: Fix various -Wincompatible-pointer-types warnings
Mike Ruprecht <cmaiku@gmail.com>
parents: 39273
diff changeset
1501 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
1502
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1503 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
1504 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
1505
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1506 /* 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
1507 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
1508 (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
1509 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
1510 {
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
1511 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
1512
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1513 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
1514 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
1515 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1516
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1517 scale_factor = 1;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1518 do {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1519 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
1520 int quality = 100;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1521 do {
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1522 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
1523 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
1524 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
1525
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1526 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
1527
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38299 38260
diff changeset
1528 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
1529 key = "compression";
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1530 value = "9";
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38299 38260
diff changeset
1531 } 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
1532 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
1533 key = "quality";
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1534 value = tmp_buf;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1535 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1536
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1537 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
1538 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
1539 {
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1540 /* 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
1541 * 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
1542 purple_debug_warning("buddyicon",
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1543 "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
1544 (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
1545 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
1546 error = NULL;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1547
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1548 /* 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
1549 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
1550 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
1551 }
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1552
30054
82871fde0aac Allow icons to be exactly the max file size
Mark Doliner <markdoliner@pidgin.im>
parents: 30053
diff changeset
1553 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
1554 /* 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
1555 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
1556 the image. */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1557 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
1558 "%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
1559 "filesize=%" G_GSIZE_FORMAT "\n",
a152b1950ea6 Use correct format for printing gsize types.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32709
diff changeset
1560 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
1561 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
1562 if (len)
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1563 *len = length;
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
1564 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
1565 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
1566 g_object_unref(G_OBJECT(original));
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1567 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
1568 return contents;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1569 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1570
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1571 g_free(contents);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1572
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 38299 38260
diff changeset
1573 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
1574 /* 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
1575 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
1576 break;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1577 }
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1578
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1579 /* 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
1580 lowering the quality. */
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1581 quality -= 5;
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1582 } 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
1583 }
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1584
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1585 /* 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
1586 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
1587 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
1588 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
1589 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
1590 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
1591 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
1592 } 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
1593 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
1594 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
1595 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
1596
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1597 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
1598 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
1599 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
1600 g_free(tmp);
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1601
40813
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1602 purple_buddy_icon_spec_free(spec);
71305a7d7423 Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents: 40803
diff changeset
1603
29931
1d21766368d2 Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <markdoliner@pidgin.im>
parents: 29928
diff changeset
1604 return NULL;
14195
0f7cb3b272b2 [gaim-migrate @ 16775]
Sean Egan <seanegan@pidgin.im>
parents: 14097
diff changeset
1605 }
14290
f20819ff8d86 [gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 14253
diff changeset
1606
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1607 /*
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1608 * "This is so dead sexy."
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1609 * "Two thumbs up."
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1610 * "Best movie of the year."
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1611 *
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1612 * 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
1613 * 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
1614 * entered string.
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1615 *
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1616 * 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
1617 * "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
1618 * 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
1619 * 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
1620 * used rarely, so it shouldn't matter TOO much.
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1621 */
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15506
diff changeset
1622 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
1623 const gchar *key, GtkTreeIter *iter, gpointer data)
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1624 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1625 gchar *enteredstring;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1626 gchar *tmp;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1627 gchar *withmarkup;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1628 gchar *nomarkup;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1629 gchar *normalized;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1630 gboolean result;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1631 size_t i;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1632 size_t len;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1633 PangoLogAttr *log_attrs;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1634 gchar *word;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1635
17155
143ff2796376 Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents: 17116
diff changeset
1636 if (g_ascii_strcasecmp(key, "Global Thermonuclear War") == 0)
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1637 {
34449
bbcb198650b7 Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34447
diff changeset
1638 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
1639 "game of chess?", NULL, NULL);
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1640 return FALSE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1641 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1642
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1643 gtk_tree_model_get(model, iter, column, &withmarkup, -1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1644 if (withmarkup == NULL) /* This is probably a separator */
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1645 return TRUE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1646
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1647 tmp = g_utf8_normalize(key, -1, G_NORMALIZE_DEFAULT);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1648 enteredstring = g_utf8_casefold(tmp, -1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1649 g_free(tmp);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1650
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
1651 nomarkup = purple_markup_strip_html(withmarkup);
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1652 tmp = g_utf8_normalize(nomarkup, -1, G_NORMALIZE_DEFAULT);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1653 g_free(nomarkup);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1654 normalized = g_utf8_casefold(tmp, -1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1655 g_free(tmp);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1656
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
1657 if (g_str_has_prefix(normalized, enteredstring)) {
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1658 g_free(withmarkup);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1659 g_free(enteredstring);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1660 g_free(normalized);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1661 return FALSE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1662 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1663
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1664 /* Use Pango to separate by words. */
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1665 len = g_utf8_strlen(normalized, -1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1666 log_attrs = g_new(PangoLogAttr, len + 1);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1667
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1668 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
1669
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1670 word = normalized;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1671 result = TRUE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1672 for (i = 0; i < (len - 1) ; i++)
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1673 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1674 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
1675 g_str_has_prefix(word, enteredstring)) {
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1676 result = FALSE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1677 break;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1678 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1679 word = g_utf8_next_char(word);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1680 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1681 g_free(log_attrs);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1682
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1683 /* The non-Pango version. */
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1684 #if 0
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1685 word = normalized;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1686 result = TRUE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1687 while (word[0] != '\0')
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1688 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1689 gunichar c = g_utf8_get_char(word);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1690 if (!g_unichar_isalnum(c))
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1691 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1692 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
1693 if (g_str_has_prefix(word, enteredstring))
15177
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1694 {
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1695 result = FALSE;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1696 break;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1697 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1698 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1699 else
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1700 word = g_utf8_find_next_char(word, NULL);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1701 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1702 #endif
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1703
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1704 g_free(withmarkup);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1705 g_free(enteredstring);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1706 g_free(normalized);
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1707
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1708 return result;
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1709 }
8b6c66e09388 [gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15114
diff changeset
1710
18278
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1711 const char *pidgin_get_dim_grey_string(GtkWidget *widget) {
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1712 static char dim_grey_string[8] = "";
37996
6c9cb1e8b2d9 Replace GtkStyle with GtkStyleContext.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37990
diff changeset
1713 GtkStyleContext *context;
6c9cb1e8b2d9 Replace GtkStyle with GtkStyleContext.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37990
diff changeset
1714 GdkRGBA fg, bg;
18278
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1715
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1716 if (!widget)
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1717 return "dim grey";
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1718
37996
6c9cb1e8b2d9 Replace GtkStyle with GtkStyleContext.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37990
diff changeset
1719 context = gtk_widget_get_style_context(widget);
6c9cb1e8b2d9 Replace GtkStyle with GtkStyleContext.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37990
diff changeset
1720 if (!context)
18278
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1721 return "dim grey";
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 25173
diff changeset
1722
37996
6c9cb1e8b2d9 Replace GtkStyle with GtkStyleContext.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37990
diff changeset
1723 gtk_style_context_get_color(context, gtk_style_context_get_state(context),
6c9cb1e8b2d9 Replace GtkStyle with GtkStyleContext.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37990
diff changeset
1724 &fg);
6c9cb1e8b2d9 Replace GtkStyle with GtkStyleContext.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37990
diff changeset
1725 gtk_style_context_get_background_color(context,
6c9cb1e8b2d9 Replace GtkStyle with GtkStyleContext.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37990
diff changeset
1726 gtk_style_context_get_state(context),
6c9cb1e8b2d9 Replace GtkStyle with GtkStyleContext.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37990
diff changeset
1727 &bg);
40094
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40062
diff changeset
1728 g_snprintf(dim_grey_string, sizeof(dim_grey_string), "#%02x%02x%02x",
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40062
diff changeset
1729 (unsigned int)((fg.red + bg.red) * 0.5 * 255),
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40062
diff changeset
1730 (unsigned int)((fg.green + bg.green) * 0.5 * 255),
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 40062
diff changeset
1731 (unsigned int)((fg.blue + bg.blue) * 0.5 * 255));
18278
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1732 return dim_grey_string;
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1733 }
06bf54cee797 Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents: 18275
diff changeset
1734
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1735 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
1736 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
1737 {
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
1738 char *text = gtk_combo_box_text_get_active_text(combo_box);
20036
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1739 gtk_entry_set_text(entry, text ? text : "");
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1740 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
1741 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1742
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1743 static gboolean
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
1744 entry_key_pressed_cb(GtkWidget *entry, GdkEventKey *key, GtkComboBoxText *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
1745 {
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
1746 if (key->keyval == GDK_KEY_Down || key->keyval == GDK_KEY_Up) {
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
1747 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
1748 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
1749 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1750 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
1751 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1752
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1753 GtkWidget *
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1754 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
1755 {
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
1756 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
1757 GtkWidget *the_entry = NULL;
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1758
32415
59d345017c9b propagate from branch 'im.pidgin.pidgin' (head 8a277be95a4940cd20c64326a70624c4e0449cb7)
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32414 31398
diff changeset
1759 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
1760 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
1761
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1762 if (default_item)
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1763 gtk_entry_set_text(GTK_ENTRY(the_entry), default_item);
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1764
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1765 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
1766 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
1767 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
1768 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
1769 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1770
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1771 g_signal_connect(G_OBJECT(ret), "changed", (GCallback)combo_box_changed_cb, the_entry);
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1772 g_signal_connect_after(G_OBJECT(the_entry), "key-press-event", G_CALLBACK(entry_key_pressed_cb), ret);
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1773
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1774 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
1775 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1776
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1777 const char *pidgin_text_combo_box_entry_get_text(GtkWidget *widget)
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1778 {
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
1779 return gtk_entry_get_text(GTK_ENTRY(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
1780 }
3bdbea94ad0c Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19859
diff changeset
1781
22131
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1782 GtkWidget *
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1783 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
1784 {
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1785 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
1786 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
1787
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1788 if (widget_label) {
35527
707c3c2b2c8a Fix more gtk_[hv]box_new gtk3 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35506
diff changeset
1789 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
1790 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
1791 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
1792
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1793 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
1794 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
1795 if (sg) {
38007
3b971d2ecae1 Simplify gtk_label_set_[xy]align calls.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37997
diff changeset
1796 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
1797 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
1798 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1799 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
1800 } else {
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1801 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
1802 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1803
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1804 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
1805 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
1806 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
1807 gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget);
35721
abae078d0525 Fix some warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35720
diff changeset
1808 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
1809 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1810
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1811 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
1812 (*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
1813 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
1814 }
12b395dc8c59 Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22013
diff changeset
1815
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
1816 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
1817 {
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1818 #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
1819 /* 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
1820 * 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
1821 #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
1822 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
1823 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
1824 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
1825 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
1826 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
1827
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1828 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
1829
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1830 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
1831 _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
1832 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1833 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
1834 _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
1835 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1836
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1837 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
1838 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
1839 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
1840 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
1841 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
1842
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1843 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
1844
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1845 if (window == widget ||
32913
af2c726febce Fix all deprecated GTK_WIDGET_* macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32900
diff changeset
1846 !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
1847 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
1848
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1849 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
1850 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
1851 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
1852 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
1853 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
1854 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
1855 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
1856 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1857 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
1858 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1859 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
1860 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
1861 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
1862 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
1863 /* 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
1864 * 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
1865 */
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1866 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
1867 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1868 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
1869 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
1870 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1871 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
1872 #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
1873 #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
1874 /* 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
1875 GList *windows = NULL;
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1876 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
1877 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
1878 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
1879 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
1880 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
1881
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
1882 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
1883 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
1884
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
1885 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
1886 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
1887 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
1888 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
1889 }
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
1890 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
1891 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
1892 {
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
1893 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
1894 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
1895 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
1896 }
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
1897
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1898 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
1899 /* 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
1900 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
1901
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1902 /* 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
1903 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
1904 /* 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
1905 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
1906 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
1907 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
1908 */
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1909 } 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
1910 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
1911
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1912 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
1913 while (windows) {
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1914 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
1915 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
1916
34447
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1917 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
1918 "pidgin-window-is-closing")))
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1919 {
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1920 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
1921 break;
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1922 }
be84e0a7e68d GTK Request: don't loose focus when switching request dialogs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34345
diff changeset
1923
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1924 if (GTK_WIDGET(window) == widget ||
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1925 !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
1926 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
1927 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1928
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1929 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
1930 (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
1931 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
1932 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
1933 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1934 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1935 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
1936 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
1937 if (parent) {
34345
be0d28873c0b Pidgin: don't parent on windows being destroyed
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34338
diff changeset
1938 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
1939 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
1940 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1941 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
1942 #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
1943 }
386062b58867 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 22005
diff changeset
1944
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
1945 GtkWidget *
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
1946 pidgin_make_scrollable(GtkWidget *child, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, GtkShadowType shadow_type, int width, int 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
1947 {
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
1948 GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL);
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
1949
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
1950 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
1951 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
1952 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
1953 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), shadow_type);
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
1954 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
1955 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
1956 if (child) {
35541
12bd3807140b Fix some GTK 3.8 deprecation warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35533
diff changeset
1957 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
1958 }
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
1959 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
1960 }
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
1961
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
1962 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
1963 }
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
1964

mercurial