Sat, 27 Jun 2009 17:56:04 +0000
We're releasing Pidgin 2.5.8 today, not yesterday.
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1 | /** |
|
14914
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
2 | * @file gtkutils.c GTK+ utility functions |
|
16254
eeb2bba4dc94
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents:
16123
diff
changeset
|
3 | * @ingroup pidgin |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
20036
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
20036
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
20036
diff
changeset
|
6 | /* pidgin |
| 4359 | 7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
8 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
|
7060
717cbeb22b6d
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
11 | * |
| 4359 | 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * 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
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 4359 | 25 | */ |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
23501
diff
changeset
|
26 | #define _PIDGIN_GTKUTILS_C_ |
|
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
23501
diff
changeset
|
27 | |
| 9791 | 28 | #include "internal.h" |
| 15577 | 29 | #include "pidgin.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
30 | |
| 4359 | 31 | #ifndef _WIN32 |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
32 | # include <X11/Xlib.h> |
| 4359 | 33 | #else |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
34 | # ifdef small |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
35 | # undef small |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
36 | # endif |
| 4359 | 37 | #endif /*_WIN32*/ |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
38 | |
|
7538
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
39 | #ifdef USE_GTKSPELL |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
40 | # include <gtkspell/gtkspell.h> |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
41 | # ifdef _WIN32 |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
42 | # include "wspell.h" |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
43 | # endif |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
44 | #endif |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
45 | |
| 4359 | 46 | #include <gdk/gdkkeysyms.h> |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
47 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
48 | #include "conversation.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
49 | #include "debug.h" |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
50 | #include "desktopitem.h" |
| 7078 | 51 | #include "imgstore.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
52 | #include "notify.h" |
| 5548 | 53 | #include "prefs.h" |
| 4359 | 54 | #include "prpl.h" |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
55 | #include "request.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
56 | #include "signals.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
57 | #include "util.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
58 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
59 | #include "gtkconv.h" |
|
9709
2e73f176cc80
[gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents:
9706
diff
changeset
|
60 | #include "gtkdialogs.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
61 | #include "gtkimhtml.h" |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
62 | #include "gtkimhtmltoolbar.h" |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15882
diff
changeset
|
63 | #include "pidginstock.h" |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
64 | #include "gtkthemes.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
65 | #include "gtkutils.h" |
|
21323
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
66 | #include "pidgin/minidialog.h" |
| 4359 | 67 | |
| 17118 | 68 | typedef struct { |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
69 | GtkWidget *menu; |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
70 | gint default_item; |
| 17375 | 71 | } AopMenu; |
| 17117 | 72 | |
|
10850
6889f793b918
[gaim-migrate @ 12522]
Mark Doliner <markdoliner@pidgin.im>
parents:
10681
diff
changeset
|
73 | static guint accels_save_timer = 0; |
| 7420 | 74 | |
| 8913 | 75 | static gboolean |
| 76 | url_clicked_idle_cb(gpointer data) | |
| 77 | { | |
| 15884 | 78 | purple_notify_uri(NULL, data); |
| 8913 | 79 | g_free(data); |
| 80 | return FALSE; | |
| 81 | } | |
| 82 | ||
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
83 | static void |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
84 | url_clicked_cb(GtkWidget *w, const char *uri) |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
85 | { |
| 8913 | 86 | g_idle_add(url_clicked_idle_cb, g_strdup(uri)); |
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
87 | } |
|
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
88 | |
|
10871
c0282a4f2250
[gaim-migrate @ 12558]
Mark Doliner <markdoliner@pidgin.im>
parents:
10850
diff
changeset
|
89 | static GtkIMHtmlFuncs gtkimhtml_cbs = { |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16314
diff
changeset
|
90 | (GtkIMHtmlGetImageFunc)purple_imgstore_find_by_id, |
| 15884 | 91 | (GtkIMHtmlGetImageDataFunc)purple_imgstore_get_data, |
| 92 | (GtkIMHtmlGetImageSizeFunc)purple_imgstore_get_size, | |
| 93 | (GtkIMHtmlGetImageFilenameFunc)purple_imgstore_get_filename, | |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16314
diff
changeset
|
94 | purple_imgstore_ref_by_id, |
|
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16314
diff
changeset
|
95 | purple_imgstore_unref_by_id, |
| 8962 | 96 | }; |
| 97 | ||
| 4359 | 98 | void |
| 15568 | 99 | pidgin_setup_imhtml(GtkWidget *imhtml) |
| 4359 | 100 | { |
|
17487
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
101 | PangoFontDescription *desc = NULL; |
| 4359 | 102 | g_return_if_fail(imhtml != NULL); |
| 103 | g_return_if_fail(GTK_IS_IMHTML(imhtml)); | |
| 104 | ||
| 105 | g_signal_connect(G_OBJECT(imhtml), "url_clicked", | |
|
6465
bd201d637ff4
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
106 | G_CALLBACK(url_clicked_cb), NULL); |
| 4359 | 107 | |
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16254
diff
changeset
|
108 | pidgin_themes_smiley_themeize(imhtml); |
| 8962 | 109 | |
| 110 | gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), >kimhtml_cbs); | |
|
15506
03be1365a163
GNOME has a 'document font' setting that we should use when running on GNOME. This does the gconftool-2 spawning trick to get it
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
111 | |
|
17487
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
112 | if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font")) { |
|
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
113 | const char *font = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font"); |
|
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
114 | desc = pango_font_description_from_string(font); |
|
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
115 | } else if (purple_running_gnome()) { |
|
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
116 | /* Use the GNOME "document" font, if applicable */ |
| 20895 | 117 | char *path; |
|
17030
2685caae6d1f
Fix #459 - Choose buddy icon UI doesn't list the current directory. The "update-preview" signal cb must call gtk_file_chooser_set_preview_widget_active().
Daniel Atallah <datallah@pidgin.im>
parents:
17013
diff
changeset
|
118 | |
|
15506
03be1365a163
GNOME has a 'document font' setting that we should use when running on GNOME. This does the gconftool-2 spawning trick to get it
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
119 | if ((path = g_find_program_in_path("gconftool-2"))) { |
| 20895 | 120 | char *font = NULL; |
|
23029
8232af5ae3f0
Quiet the output from gconftool-2 when there is no document font name in
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22787
diff
changeset
|
121 | char *err = NULL; |
|
15506
03be1365a163
GNOME has a 'document font' setting that we should use when running on GNOME. This does the gconftool-2 spawning trick to get it
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
122 | g_free(path); |
| 20895 | 123 | if (g_spawn_command_line_sync( |
|
17030
2685caae6d1f
Fix #459 - Choose buddy icon UI doesn't list the current directory. The "update-preview" signal cb must call gtk_file_chooser_set_preview_widget_active().
Daniel Atallah <datallah@pidgin.im>
parents:
17013
diff
changeset
|
124 | "gconftool-2 -g /desktop/gnome/interface/document_font_name", |
|
23029
8232af5ae3f0
Quiet the output from gconftool-2 when there is no document font name in
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22787
diff
changeset
|
125 | &font, &err, NULL, NULL)) { |
| 20895 | 126 | desc = pango_font_description_from_string(font); |
| 127 | } | |
|
23029
8232af5ae3f0
Quiet the output from gconftool-2 when there is no document font name in
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22787
diff
changeset
|
128 | g_free(err); |
| 20895 | 129 | g_free(font); |
|
15506
03be1365a163
GNOME has a 'document font' setting that we should use when running on GNOME. This does the gconftool-2 spawning trick to get it
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
130 | } |
|
17487
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
131 | } |
| 20895 | 132 | |
|
17487
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
133 | if (desc) { |
|
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
134 | gtk_widget_modify_font(imhtml, desc); |
|
2d9c6631e922
Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@pidgin.im>
parents:
17385
diff
changeset
|
135 | pango_font_description_free(desc); |
|
15506
03be1365a163
GNOME has a 'document font' setting that we should use when running on GNOME. This does the gconftool-2 spawning trick to get it
Sean Egan <seanegan@pidgin.im>
parents:
15497
diff
changeset
|
136 | } |
| 4359 | 137 | } |
| 138 | ||
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
139 | static |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
140 | void pidgin_window_init(GtkWindow *wnd, const char *title, guint border_width, const char *role, gboolean resizable) |
| 17213 | 141 | { |
| 142 | if (title) | |
| 143 | gtk_window_set_title(wnd, title); | |
|
18941
995cf072aa9b
Prevent some more window titles from being "pidgin.exe" on Windows. Fixes #1767
Daniel Atallah <datallah@pidgin.im>
parents:
18672
diff
changeset
|
144 | #ifdef _WIN32 |
|
995cf072aa9b
Prevent some more window titles from being "pidgin.exe" on Windows. Fixes #1767
Daniel Atallah <datallah@pidgin.im>
parents:
18672
diff
changeset
|
145 | else |
|
995cf072aa9b
Prevent some more window titles from being "pidgin.exe" on Windows. Fixes #1767
Daniel Atallah <datallah@pidgin.im>
parents:
18672
diff
changeset
|
146 | gtk_window_set_title(wnd, PIDGIN_ALERT_TITLE); |
|
995cf072aa9b
Prevent some more window titles from being "pidgin.exe" on Windows. Fixes #1767
Daniel Atallah <datallah@pidgin.im>
parents:
18672
diff
changeset
|
147 | #endif |
| 17213 | 148 | gtk_container_set_border_width(GTK_CONTAINER(wnd), border_width); |
| 149 | if (role) | |
| 150 | gtk_window_set_role(wnd, role); | |
| 151 | gtk_window_set_resizable(wnd, resizable); | |
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
152 | } |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
153 | |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
154 | GtkWidget * |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
155 | pidgin_create_window(const char *title, guint border_width, const char *role, gboolean resizable) |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
156 | { |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
157 | GtkWindow *wnd = NULL; |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
158 | |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
159 | wnd = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
160 | pidgin_window_init(wnd, title, border_width, role, resizable); |
| 17213 | 161 | |
| 162 | return GTK_WIDGET(wnd); | |
| 163 | } | |
| 164 | ||
| 165 | GtkWidget * | |
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
166 | pidgin_create_dialog(const char *title, guint border_width, const char *role, gboolean resizable) |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
167 | { |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
168 | GtkWindow *wnd = NULL; |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
169 | |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
170 | wnd = GTK_WINDOW(gtk_dialog_new()); |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
171 | pidgin_window_init(wnd, title, border_width, role, resizable); |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
172 | g_object_set(G_OBJECT(wnd), "has-separator", FALSE, NULL); |
| 17213 | 173 | |
| 174 | return GTK_WIDGET(wnd); | |
| 175 | } | |
| 176 | ||
| 177 | GtkWidget * | |
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
178 | pidgin_dialog_get_vbox_with_properties(GtkDialog *dialog, gboolean homogeneous, gint spacing) |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
179 | { |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
180 | GtkBox *vbox = GTK_BOX(GTK_DIALOG(dialog)->vbox); |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
181 | gtk_box_set_homogeneous(vbox, homogeneous); |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
182 | gtk_box_set_spacing(vbox, spacing); |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
183 | return GTK_WIDGET(vbox); |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
184 | } |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
185 | |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
186 | GtkWidget *pidgin_dialog_get_vbox(GtkDialog *dialog) |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
187 | { |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
188 | return GTK_DIALOG(dialog)->vbox; |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
189 | } |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
190 | |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
191 | GtkWidget *pidgin_dialog_get_action_area(GtkDialog *dialog) |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
192 | { |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
193 | return GTK_DIALOG(dialog)->action_area; |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
194 | } |
|
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
195 | |
|
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
|
196 | GtkWidget *pidgin_dialog_add_button(GtkDialog *dialog, const char *label, |
|
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
|
197 | GCallback callback, gpointer callbackdata) |
|
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
|
198 | { |
|
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
|
199 | GtkWidget *button = gtk_button_new_from_stock(label); |
|
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
|
200 | GtkWidget *bbox = pidgin_dialog_get_action_area(dialog); |
|
0183020ba2cc
Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22000
diff
changeset
|
201 | gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
|
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
|
202 | if (callback) |
|
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
|
203 | g_signal_connect(G_OBJECT(button), "clicked", callback, callbackdata); |
|
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
|
204 | gtk_widget_show(button); |
|
0183020ba2cc
Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22000
diff
changeset
|
205 | return button; |
|
0183020ba2cc
Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22000
diff
changeset
|
206 | } |
|
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
|
207 | |
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21630
diff
changeset
|
208 | GtkWidget * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
209 | pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret) |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
210 | { |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
211 | GtkWidget *frame; |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
212 | GtkWidget *imhtml; |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
213 | GtkWidget *sep; |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
214 | GtkWidget *sw; |
|
10177
9471d38bd527
[gaim-migrate @ 11292]
Christian Hammond <chipx86@chipx86.com>
parents:
10175
diff
changeset
|
215 | GtkWidget *toolbar = NULL; |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
216 | GtkWidget *vbox; |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
217 | |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
218 | frame = gtk_frame_new(NULL); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
219 | gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
220 | |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
221 | vbox = gtk_vbox_new(FALSE, 0); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
222 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
223 | gtk_widget_show(vbox); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
224 | |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
225 | if (editable) { |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
226 | toolbar = gtk_imhtmltoolbar_new(); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
227 | gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
228 | gtk_widget_show(toolbar); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
229 | |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
230 | sep = gtk_hseparator_new(); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
231 | gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); |
| 14607 | 232 | g_signal_connect_swapped(G_OBJECT(toolbar), "show", G_CALLBACK(gtk_widget_show), sep); |
| 233 | g_signal_connect_swapped(G_OBJECT(toolbar), "hide", G_CALLBACK(gtk_widget_hide), sep); | |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
234 | gtk_widget_show(sep); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
235 | } |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
236 | |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
237 | sw = gtk_scrolled_window_new(NULL, NULL); |
|
13203
bdb98c8e5b56
[gaim-migrate @ 15565]
Mark Doliner <markdoliner@pidgin.im>
parents:
13114
diff
changeset
|
238 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
|
18417
88a1c65eaad3
When the scrolled window is set to GTK_POLICY_NEVER, the scrolledwindow will increase its size request when there's enough text in the imhtml to warrent it. Turning the policy to AUTOMATIC makes the text wordwrap the way we want
Sean Egan <seanegan@pidgin.im>
parents:
18351
diff
changeset
|
239 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
240 | gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
241 | gtk_widget_show(sw); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
242 | |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
243 | imhtml = gtk_imhtml_new(NULL, NULL); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
244 | gtk_imhtml_set_editable(GTK_IMHTML(imhtml), editable); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
245 | gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
246 | gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); |
|
12651
be8208c28eaa
[gaim-migrate @ 14992]
Mark Doliner <markdoliner@pidgin.im>
parents:
12595
diff
changeset
|
247 | #ifdef USE_GTKSPELL |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16071
diff
changeset
|
248 | if (editable && purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck")) |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
249 | pidgin_setup_gtkspell(GTK_TEXT_VIEW(imhtml)); |
|
12651
be8208c28eaa
[gaim-migrate @ 14992]
Mark Doliner <markdoliner@pidgin.im>
parents:
12595
diff
changeset
|
250 | #endif |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
251 | gtk_widget_show(imhtml); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
252 | |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
253 | if (editable) { |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
254 | gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), imhtml); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
255 | gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(toolbar), "default"); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
256 | } |
| 15568 | 257 | pidgin_setup_imhtml(imhtml); |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
258 | |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
259 | gtk_container_add(GTK_CONTAINER(sw), imhtml); |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
260 | |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
261 | if (imhtml_ret != NULL) |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
262 | *imhtml_ret = imhtml; |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
263 | |
|
10181
2425c3773266
[gaim-migrate @ 11296]
Mark Doliner <markdoliner@pidgin.im>
parents:
10177
diff
changeset
|
264 | if (editable && (toolbar_ret != NULL)) |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
265 | *toolbar_ret = toolbar; |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
266 | |
|
13281
3558cb15ebb9
[gaim-migrate @ 15646]
Richard Laager <rlaager@pidgin.im>
parents:
13203
diff
changeset
|
267 | if (sw_ret != NULL) |
|
3558cb15ebb9
[gaim-migrate @ 15646]
Richard Laager <rlaager@pidgin.im>
parents:
13203
diff
changeset
|
268 | *sw_ret = sw; |
|
3558cb15ebb9
[gaim-migrate @ 15646]
Richard Laager <rlaager@pidgin.im>
parents:
13203
diff
changeset
|
269 | |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
270 | return frame; |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
271 | } |
|
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
272 | |
| 4359 | 273 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
274 | pidgin_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog) |
|
7751
e0dc18b50181
[gaim-migrate @ 8396]
Mark Doliner <markdoliner@pidgin.im>
parents:
7717
diff
changeset
|
275 | { |
|
e0dc18b50181
[gaim-migrate @ 8396]
Mark Doliner <markdoliner@pidgin.im>
parents:
7717
diff
changeset
|
276 | const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); |
|
e0dc18b50181
[gaim-migrate @ 8396]
Mark Doliner <markdoliner@pidgin.im>
parents:
7717
diff
changeset
|
277 | gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, |
|
e0dc18b50181
[gaim-migrate @ 8396]
Mark Doliner <markdoliner@pidgin.im>
parents:
7717
diff
changeset
|
278 | (*text != '\0')); |
|
e0dc18b50181
[gaim-migrate @ 8396]
Mark Doliner <markdoliner@pidgin.im>
parents:
7717
diff
changeset
|
279 | } |
|
e0dc18b50181
[gaim-migrate @ 8396]
Mark Doliner <markdoliner@pidgin.im>
parents:
7717
diff
changeset
|
280 | |
| 4359 | 281 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
282 | pidgin_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) |
| 4359 | 283 | { |
| 284 | gboolean sensitivity; | |
| 285 | ||
| 286 | if (to_toggle == NULL) | |
| 287 | return; | |
| 288 | ||
| 289 | sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
| 290 | ||
| 291 | gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
| 292 | } | |
| 293 | ||
|
5314
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
294 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
295 | pidgin_toggle_sensitive_array(GtkWidget *w, GPtrArray *data) |
|
5314
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
296 | { |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
297 | gboolean sensitivity; |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
298 | gpointer element; |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
299 | int i; |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
300 | |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
301 | for (i=0; i < data->len; i++) { |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
302 | element = g_ptr_array_index(data,i); |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
303 | if (element == NULL) |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
304 | continue; |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
305 | |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
306 | sensitivity = GTK_WIDGET_IS_SENSITIVE(element); |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
307 | |
|
10175
2bf5ed145e8a
[gaim-migrate @ 11290]
Mark Doliner <markdoliner@pidgin.im>
parents:
10061
diff
changeset
|
308 | gtk_widget_set_sensitive(element, !sensitivity); |
|
5314
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
309 | } |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
310 | } |
|
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
311 | |
|
8901
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
312 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
313 | pidgin_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle) |
|
8901
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
314 | { |
|
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
315 | if (to_toggle == NULL) |
|
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
316 | return; |
|
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
317 | |
|
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
318 | if (GTK_WIDGET_VISIBLE(to_toggle)) |
|
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
319 | gtk_widget_hide(to_toggle); |
|
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
320 | else |
|
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
321 | gtk_widget_show(to_toggle); |
|
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
322 | } |
|
0a8334a14c2d
[gaim-migrate @ 9670]
Mark Doliner <markdoliner@pidgin.im>
parents:
8881
diff
changeset
|
323 | |
|
17359
6dd3b7730470
Change pidgin_separator to return the separator added to the menu.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17155
diff
changeset
|
324 | GtkWidget *pidgin_separator(GtkWidget *menu) |
| 4687 | 325 | { |
| 326 | GtkWidget *menuitem; | |
| 327 | ||
| 328 | menuitem = gtk_separator_menu_item_new(); | |
| 329 | gtk_widget_show(menuitem); | |
| 330 | 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
|
331 | return menuitem; |
| 4687 | 332 | } |
|
5160
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
333 | |
| 15568 | 334 | GtkWidget *pidgin_new_item(GtkWidget *menu, const char *str) |
|
5162
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
335 | { |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
336 | GtkWidget *menuitem; |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
337 | GtkWidget *label; |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
338 | |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
339 | menuitem = gtk_menu_item_new(); |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
340 | if (menu) |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
341 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
342 | gtk_widget_show(menuitem); |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
343 | |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
344 | label = gtk_label_new(str); |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6236
diff
changeset
|
345 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
|
5162
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
346 | gtk_label_set_pattern(GTK_LABEL(label), "_"); |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
347 | gtk_container_add(GTK_CONTAINER(menuitem), label); |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
348 | gtk_widget_show(label); |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
349 | /* FIXME: Go back and fix this |
|
5162
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
350 | gtk_widget_add_accelerator(menuitem, "activate", accel, str[0], |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
351 | GDK_MOD1_MASK, GTK_ACCEL_LOCKED); |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
352 | */ |
| 15568 | 353 | pidgin_set_accessible_label (menuitem, label); |
|
5162
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
354 | return menuitem; |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
355 | } |
|
f8293b913629
[gaim-migrate @ 5526]
Mark Doliner <markdoliner@pidgin.im>
parents:
5160
diff
changeset
|
356 | |
| 15568 | 357 | GtkWidget *pidgin_new_check_item(GtkWidget *menu, const char *str, |
| 5906 | 358 | GtkSignalFunc sf, gpointer data, gboolean checked) |
| 359 | { | |
| 360 | GtkWidget *menuitem; | |
| 361 | menuitem = gtk_check_menu_item_new_with_mnemonic(str); | |
| 362 | ||
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
363 | if (menu) |
| 5906 | 364 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
| 365 | ||
|
7299
4c804d9a52f1
[gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
366 | 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
|
367 | |
| 5906 | 368 | if (sf) |
| 369 | g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); | |
| 370 | ||
| 371 | gtk_widget_show_all(menuitem); | |
| 372 | ||
| 373 | return menuitem; | |
| 374 | } | |
| 375 | ||
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
376 | GtkWidget * |
| 15568 | 377 | pidgin_pixbuf_toolbar_button_from_stock(const char *icon) |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
378 | { |
|
9706
d5b657fe9cff
[gaim-migrate @ 10567]
Mark Doliner <markdoliner@pidgin.im>
parents:
9534
diff
changeset
|
379 | GtkWidget *button, *image, *bbox; |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
380 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
381 | button = gtk_toggle_button_new(); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
382 | gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
383 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
384 | bbox = gtk_vbox_new(FALSE, 0); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
385 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
386 | gtk_container_add (GTK_CONTAINER(button), bbox); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
387 | |
|
15623
bf485c598199
toolbar/menu icons. reduce the imhtmltoolbar spacing. more gaimstock pruning
Sean Egan <seanegan@pidgin.im>
parents:
15578
diff
changeset
|
388 | image = gtk_image_new_from_stock(icon, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)); |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
389 | gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
390 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
391 | gtk_widget_show_all(bbox); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
392 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
393 | return button; |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
394 | } |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
395 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
396 | GtkWidget * |
| 15568 | 397 | pidgin_pixbuf_button_from_stock(const char *text, const char *icon, |
| 398 | PidginButtonOrientation style) | |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
399 | { |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
400 | GtkWidget *button, *image, *label, *bbox, *ibox, *lbox = NULL; |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
401 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
402 | button = gtk_button_new(); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
403 | |
| 15568 | 404 | if (style == PIDGIN_BUTTON_HORIZONTAL) { |
|
9750
dfb5cf70295f
[gaim-migrate @ 10617]
Mark Doliner <markdoliner@pidgin.im>
parents:
9749
diff
changeset
|
405 | bbox = gtk_hbox_new(FALSE, 0); |
|
dfb5cf70295f
[gaim-migrate @ 10617]
Mark Doliner <markdoliner@pidgin.im>
parents:
9749
diff
changeset
|
406 | ibox = gtk_hbox_new(FALSE, 0); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
407 | if (text) |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
408 | lbox = gtk_hbox_new(FALSE, 0); |
|
9750
dfb5cf70295f
[gaim-migrate @ 10617]
Mark Doliner <markdoliner@pidgin.im>
parents:
9749
diff
changeset
|
409 | } else { |
|
dfb5cf70295f
[gaim-migrate @ 10617]
Mark Doliner <markdoliner@pidgin.im>
parents:
9749
diff
changeset
|
410 | bbox = gtk_vbox_new(FALSE, 0); |
|
dfb5cf70295f
[gaim-migrate @ 10617]
Mark Doliner <markdoliner@pidgin.im>
parents:
9749
diff
changeset
|
411 | ibox = gtk_vbox_new(FALSE, 0); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
412 | if (text) |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10483
diff
changeset
|
413 | lbox = gtk_vbox_new(FALSE, 0); |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
414 | } |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
415 | |
|
9750
dfb5cf70295f
[gaim-migrate @ 10617]
Mark Doliner <markdoliner@pidgin.im>
parents:
9749
diff
changeset
|
416 | gtk_container_add(GTK_CONTAINER(button), bbox); |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
417 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
418 | if (icon) { |
|
9750
dfb5cf70295f
[gaim-migrate @ 10617]
Mark Doliner <markdoliner@pidgin.im>
parents:
9749
diff
changeset
|
419 | gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox); |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
420 | image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON); |
|
9767
c68cfe03deec
[gaim-migrate @ 10635]
Mark Doliner <markdoliner@pidgin.im>
parents:
9750
diff
changeset
|
421 | gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, TRUE, 0); |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
422 | } |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
423 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
424 | if (text) { |
|
9750
dfb5cf70295f
[gaim-migrate @ 10617]
Mark Doliner <markdoliner@pidgin.im>
parents:
9749
diff
changeset
|
425 | gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox); |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
426 | label = gtk_label_new(NULL); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
427 | gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
428 | gtk_label_set_mnemonic_widget(GTK_LABEL(label), button); |
|
9767
c68cfe03deec
[gaim-migrate @ 10635]
Mark Doliner <markdoliner@pidgin.im>
parents:
9750
diff
changeset
|
429 | gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, TRUE, 0); |
| 15568 | 430 | pidgin_set_accessible_label (button, label); |
|
6372
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
431 | } |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
432 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
433 | gtk_widget_show_all(bbox); |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
434 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
435 | return button; |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
436 | } |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
437 | |
|
27c3152351ce
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
438 | |
| 15568 | 439 | GtkWidget *pidgin_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod) |
|
5160
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
440 | { |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
441 | GtkWidget *menuitem; |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
442 | /* |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
443 | GtkWidget *hbox; |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
444 | GtkWidget *label; |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
445 | */ |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
446 | GtkWidget *image; |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
447 | |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
448 | if (icon == NULL) |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
449 | menuitem = gtk_menu_item_new_with_mnemonic(str); |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
450 | else |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
451 | menuitem = gtk_image_menu_item_new_with_mnemonic(str); |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
452 | |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
453 | if (menu) |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
454 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
455 | |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
456 | if (sf) |
|
5314
56ef6a09fb99
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
457 | g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); |
|
5160
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
458 | |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
459 | if (icon != NULL) { |
|
15623
bf485c598199
toolbar/menu icons. reduce the imhtmltoolbar spacing. more gaimstock pruning
Sean Egan <seanegan@pidgin.im>
parents:
15578
diff
changeset
|
460 | image = gtk_image_new_from_stock(icon, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)); |
|
5160
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
461 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
462 | } |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
463 | /* FIXME: this isn't right |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
464 | if (mod) { |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
465 | label = gtk_label_new(mod); |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
466 | gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2); |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
467 | gtk_widget_show(label); |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
468 | } |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
469 | */ |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
470 | /* |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
471 | if (accel_key) { |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
472 | gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key, |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
473 | accel_mods, GTK_ACCEL_LOCKED); |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
474 | } |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
475 | */ |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
476 | |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
477 | gtk_widget_show_all(menuitem); |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
478 | |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
479 | return menuitem; |
|
bcc3e2b2ed56
[gaim-migrate @ 5524]
Mark Doliner <markdoliner@pidgin.im>
parents:
4859
diff
changeset
|
480 | } |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
481 | |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
482 | GtkWidget * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
483 | pidgin_make_frame(GtkWidget *parent, const char *title) |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
484 | { |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
485 | GtkWidget *vbox, *label, *hbox; |
|
13100
56bf8002ddc6
[gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents:
13092
diff
changeset
|
486 | char *labeltitle; |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
487 | |
| 15882 | 488 | vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
489 | 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
|
490 | gtk_widget_show(vbox); |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
491 | |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
492 | label = gtk_label_new(NULL); |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
493 | |
|
13100
56bf8002ddc6
[gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents:
13092
diff
changeset
|
494 | labeltitle = g_strdup_printf("<span weight=\"bold\">%s</span>", title); |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
495 | gtk_label_set_markup(GTK_LABEL(label), labeltitle); |
|
13100
56bf8002ddc6
[gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents:
13092
diff
changeset
|
496 | g_free(labeltitle); |
|
56bf8002ddc6
[gaim-migrate @ 15461]
Richard Laager <rlaager@pidgin.im>
parents:
13092
diff
changeset
|
497 | |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
498 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
499 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
|
5641
a9d1f7917dd4
[gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
500 | gtk_widget_show(label); |
| 15568 | 501 | pidgin_set_accessible_label (vbox, label); |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
502 | |
| 15882 | 503 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
504 | 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
|
505 | gtk_widget_show(hbox); |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
506 | |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
507 | label = gtk_label_new(" "); |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
508 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
|
5641
a9d1f7917dd4
[gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
509 | gtk_widget_show(label); |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
510 | |
| 15882 | 511 | vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
512 | gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
|
5641
a9d1f7917dd4
[gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
513 | gtk_widget_show(vbox); |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
514 | |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
515 | return vbox; |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
516 | } |
|
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
517 | |
| 17117 | 518 | static gpointer |
| 17118 | 519 | aop_option_menu_get_selected(GtkWidget *optmenu, GtkWidget **p_item) |
| 17117 | 520 | { |
| 521 | GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); | |
| 522 | GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu)); | |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
523 | if (p_item) |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
524 | (*p_item) = item; |
| 17117 | 525 | return g_object_get_data(G_OBJECT(item), "aop_per_item_data"); |
| 526 | } | |
| 527 | ||
|
5647
7ffa3264c9be
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
528 | static void |
| 17117 | 529 | aop_menu_cb(GtkWidget *optmenu, GCallback cb) |
|
5647
7ffa3264c9be
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
530 | { |
|
7ffa3264c9be
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
531 | GtkWidget *item; |
| 17117 | 532 | gpointer per_item_data; |
| 533 | ||
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
534 | per_item_data = aop_option_menu_get_selected(optmenu, &item); |
|
5647
7ffa3264c9be
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
535 | |
| 17375 | 536 | if (cb != NULL) { |
| 537 | ((void (*)(GtkWidget *, gpointer, gpointer))cb)(item, per_item_data, g_object_get_data(G_OBJECT(optmenu), "user_data")); | |
|
17237
77ee6a7263dc
Add some braces and clean up indentation.
Richard Laager <rlaager@pidgin.im>
parents:
17236
diff
changeset
|
538 | } |
| 17117 | 539 | } |
| 540 | ||
| 541 | static GtkWidget * | |
|
17851
02fbbecd95f5
Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17387
diff
changeset
|
542 | aop_menu_item_new(GtkSizeGroup *sg, GdkPixbuf *pixbuf, const char *lbl, gpointer per_item_data, const char *data) |
| 17117 | 543 | { |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
544 | GtkWidget *item; |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
545 | GtkWidget *hbox; |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
546 | GtkWidget *image; |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
547 | GtkWidget *label; |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
548 | |
| 17375 | 549 | item = gtk_menu_item_new(); |
| 550 | gtk_widget_show(item); | |
| 551 | ||
| 552 | hbox = gtk_hbox_new(FALSE, 4); | |
| 553 | gtk_widget_show(hbox); | |
| 17117 | 554 | |
| 555 | /* Create the image */ | |
|
17238
22c1b67b96d4
Fix a logic mistake I introduced during a cleanup.
Richard Laager <rlaager@pidgin.im>
parents:
17237
diff
changeset
|
556 | if (pixbuf == NULL) |
| 17375 | 557 | image = gtk_image_new(); |
| 17117 | 558 | else |
| 17375 | 559 | image = gtk_image_new_from_pixbuf(pixbuf); |
| 560 | gtk_widget_show(image); | |
| 17117 | 561 | |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
562 | if (sg) |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
563 | gtk_size_group_add_widget(sg, image); |
| 17117 | 564 | |
| 565 | /* Create the label */ | |
| 17375 | 566 | label = gtk_label_new (lbl); |
|
17377
136e8a8b76da
Forgot an instance of g_object_new and some other changes are necessary, too.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17375
diff
changeset
|
567 | gtk_widget_show (label); |
| 17375 | 568 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
|
17377
136e8a8b76da
Forgot an instance of g_object_new and some other changes are necessary, too.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17375
diff
changeset
|
569 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); |
| 17117 | 570 | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
571 | gtk_container_add(GTK_CONTAINER(item), hbox); |
| 17375 | 572 | gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
| 573 | gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
574 | |
|
17851
02fbbecd95f5
Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17387
diff
changeset
|
575 | g_object_set_data(G_OBJECT (item), data, per_item_data); |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
576 | g_object_set_data(G_OBJECT (item), "aop_per_item_data", per_item_data); |
| 17118 | 577 | |
| 578 | pidgin_set_accessible_label(item, label); | |
| 17117 | 579 | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
580 | return item; |
|
5647
7ffa3264c9be
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
581 | } |
|
7ffa3264c9be
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
582 | |
|
17368
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
583 | static GdkPixbuf * |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
584 | pidgin_create_prpl_icon_from_prpl(PurplePlugin *prpl, PidginPrplIconSize size, PurpleAccount *account) |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
585 | { |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
586 | PurplePluginProtocolInfo *prpl_info; |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
587 | const char *protoname = NULL; |
|
18216
f34603f4631e
Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@pidgin.im>
parents:
18193
diff
changeset
|
588 | char *tmp; |
|
17368
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
589 | char *filename = NULL; |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
590 | GdkPixbuf *pixbuf; |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
591 | |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
592 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
593 | if (prpl_info->list_icon == NULL) |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
594 | return NULL; |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
595 | |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
596 | protoname = prpl_info->list_icon(account, NULL); |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
597 | if (protoname == NULL) |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
598 | return NULL; |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
599 | |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
600 | /* |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
601 | * 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
|
602 | * protoname from the theme |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
603 | */ |
|
18216
f34603f4631e
Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@pidgin.im>
parents:
18193
diff
changeset
|
604 | tmp = g_strconcat(protoname, ".png", NULL); |
|
17368
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
605 | |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
606 | filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
607 | size == PIDGIN_PRPL_ICON_SMALL ? "16" : |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
608 | size == PIDGIN_PRPL_ICON_MEDIUM ? "22" : "48", |
|
18216
f34603f4631e
Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@pidgin.im>
parents:
18193
diff
changeset
|
609 | tmp, NULL); |
|
f34603f4631e
Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@pidgin.im>
parents:
18193
diff
changeset
|
610 | g_free(tmp); |
|
f34603f4631e
Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@pidgin.im>
parents:
18193
diff
changeset
|
611 | |
|
17368
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
612 | pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
613 | g_free(filename); |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
614 | |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
615 | return pixbuf; |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
616 | } |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
617 | |
|
17014
1e90cfae53dd
disapproval of revision '41be962a27d1633445fef2055c4a0db183f104dc'
Richard Laager <rlaager@pidgin.im>
parents:
17013
diff
changeset
|
618 | static GtkWidget * |
| 17375 | 619 | aop_option_menu_new(AopMenu *aop_menu, GCallback cb, gpointer user_data) |
| 17117 | 620 | { |
| 621 | GtkWidget *optmenu; | |
| 622 | ||
| 17375 | 623 | optmenu = gtk_option_menu_new(); |
| 624 | gtk_widget_show(optmenu); | |
| 625 | gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), aop_menu->menu); | |
| 626 | ||
| 17117 | 627 | if (aop_menu->default_item != -1) |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
628 | gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), aop_menu->default_item); |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
629 | |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
630 | g_object_set_data_full(G_OBJECT(optmenu), "aop_menu", aop_menu, (GDestroyNotify)g_free); |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
631 | g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
632 | |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
633 | g_signal_connect(G_OBJECT(optmenu), "changed", G_CALLBACK(aop_menu_cb), cb); |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
634 | |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
635 | return optmenu; |
| 17117 | 636 | } |
| 637 | ||
| 638 | static void | |
| 17375 | 639 | aop_option_menu_replace_menu(GtkWidget *optmenu, AopMenu *new_aop_menu) |
| 17117 | 640 | { |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
641 | if (gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu))) |
| 17117 | 642 | gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); |
| 17375 | 643 | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
644 | gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), new_aop_menu->menu); |
| 17375 | 645 | |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
646 | if (new_aop_menu->default_item != -1) |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
647 | gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), new_aop_menu->default_item); |
| 17375 | 648 | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
649 | g_object_set_data_full(G_OBJECT(optmenu), "aop_menu", new_aop_menu, (GDestroyNotify)g_free); |
| 17117 | 650 | } |
| 651 | ||
| 652 | static void | |
| 17118 | 653 | 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
|
654 | { |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
655 | guint idx; |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
656 | GList *llItr = NULL; |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
657 | |
| 17375 | 658 | for (idx = 0, llItr = GTK_MENU_SHELL(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)))->children; |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
659 | llItr != NULL; |
| 17375 | 660 | llItr = llItr->next, idx++) { |
| 661 | if (data == g_object_get_data(G_OBJECT(llItr->data), "aop_per_item_data")) { | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
662 | gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), idx); |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
663 | break; |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
664 | } |
|
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
665 | } |
|
17014
1e90cfae53dd
disapproval of revision '41be962a27d1633445fef2055c4a0db183f104dc'
Richard Laager <rlaager@pidgin.im>
parents:
17013
diff
changeset
|
666 | } |
|
1e90cfae53dd
disapproval of revision '41be962a27d1633445fef2055c4a0db183f104dc'
Richard Laager <rlaager@pidgin.im>
parents:
17013
diff
changeset
|
667 | |
| 17375 | 668 | static AopMenu * |
| 669 | create_protocols_menu(const char *default_proto_id) | |
| 17117 | 670 | { |
| 17375 | 671 | AopMenu *aop_menu = NULL; |
| 15884 | 672 | PurplePluginProtocolInfo *prpl_info; |
| 673 | PurplePlugin *plugin; | |
| 17117 | 674 | GdkPixbuf *pixbuf = NULL; |
|
5649
e31ce53da5a0
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
675 | GtkSizeGroup *sg; |
| 17117 | 676 | GList *p; |
|
17236
4bd0f7e562e7
Apply some constification.
Richard Laager <rlaager@pidgin.im>
parents:
17235
diff
changeset
|
677 | const char *gtalk_name = NULL; |
| 17117 | 678 | int i; |
| 679 | ||
| 17375 | 680 | aop_menu = g_malloc0(sizeof(AopMenu)); |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
681 | aop_menu->default_item = -1; |
| 17375 | 682 | aop_menu->menu = gtk_menu_new(); |
| 683 | gtk_widget_show(aop_menu->menu); | |
| 684 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
|
17098
3e4159d270d3
Only include Google Talk if we have XMPP.
Richard Laager <rlaager@pidgin.im>
parents:
17092
diff
changeset
|
685 | |
|
3e4159d270d3
Only include Google Talk if we have XMPP.
Richard Laager <rlaager@pidgin.im>
parents:
17092
diff
changeset
|
686 | if (purple_find_prpl("prpl-jabber")) |
|
17116
122d4dcce40e
Patch from Gabriel Schulhof to fix the Google-Talk selection.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17098
diff
changeset
|
687 | gtalk_name = _("Google Talk"); |
|
5644
bc4c2f9f2bf8
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
688 | |
| 15884 | 689 | for (p = purple_plugins_get_protocols(), i = 0; |
|
5644
bc4c2f9f2bf8
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
690 | p != NULL; |
| 17375 | 691 | p = p->next, i++) { |
|
5644
bc4c2f9f2bf8
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
692 | |
| 15884 | 693 | plugin = (PurplePlugin *)p->data; |
| 694 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); | |
|
5644
bc4c2f9f2bf8
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
695 | |
| 17375 | 696 | if (gtalk_name && strcmp(gtalk_name, plugin->info->name) < 0) { |
| 17117 | 697 | char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols", |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
698 | "16", "google-talk.png", NULL); |
|
17851
02fbbecd95f5
Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17387
diff
changeset
|
699 | GtkWidget *item; |
|
02fbbecd95f5
Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17387
diff
changeset
|
700 | |
|
17092
11d23a81eabd
Sort Google Talk appropriately.
Richard Laager <rlaager@pidgin.im>
parents:
17046
diff
changeset
|
701 | pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
|
11d23a81eabd
Sort Google Talk appropriately.
Richard Laager <rlaager@pidgin.im>
parents:
17046
diff
changeset
|
702 | g_free(filename); |
|
11d23a81eabd
Sort Google Talk appropriately.
Richard Laager <rlaager@pidgin.im>
parents:
17046
diff
changeset
|
703 | |
| 17117 | 704 | gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu), |
|
17851
02fbbecd95f5
Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17387
diff
changeset
|
705 | item = aop_menu_item_new(sg, pixbuf, gtalk_name, "prpl-jabber", "protocol")); |
|
02fbbecd95f5
Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17387
diff
changeset
|
706 | g_object_set_data(G_OBJECT(item), "fake", GINT_TO_POINTER(1)); |
| 17117 | 707 | |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
708 | if (pixbuf) |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
709 | g_object_unref(pixbuf); |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
710 | |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
711 | gtalk_name = NULL; |
|
17527
52201c2338cf
Fix for the protocol type being off by one in modify account dialog
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17497
diff
changeset
|
712 | i++; |
|
17092
11d23a81eabd
Sort Google Talk appropriately.
Richard Laager <rlaager@pidgin.im>
parents:
17046
diff
changeset
|
713 | } |
|
11d23a81eabd
Sort Google Talk appropriately.
Richard Laager <rlaager@pidgin.im>
parents:
17046
diff
changeset
|
714 | |
|
17368
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
715 | pixbuf = pidgin_create_prpl_icon_from_prpl(plugin, PIDGIN_PRPL_ICON_SMALL, NULL); |
| 17117 | 716 | |
| 717 | gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu), | |
|
17851
02fbbecd95f5
Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17387
diff
changeset
|
718 | aop_menu_item_new(sg, pixbuf, plugin->info->name, plugin->info->id, "protocol")); |
| 17375 | 719 | |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
720 | if (pixbuf) |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
721 | g_object_unref(pixbuf); |
| 17117 | 722 | |
| 723 | if (default_proto_id != NULL && !strcmp(plugin->info->id, default_proto_id)) | |
| 724 | aop_menu->default_item = i; | |
|
5644
bc4c2f9f2bf8
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
725 | } |
|
bc4c2f9f2bf8
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
726 | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
727 | g_object_unref(sg); |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
728 | |
|
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
729 | return aop_menu; |
| 17117 | 730 | } |
| 731 | ||
| 732 | GtkWidget * | |
| 733 | pidgin_protocol_option_menu_new(const char *id, GCallback cb, | |
| 734 | gpointer user_data) | |
| 735 | { | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
736 | return aop_option_menu_new(create_protocols_menu(id), cb, user_data); |
|
5644
bc4c2f9f2bf8
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
737 | } |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
738 | |
|
18672
da4db1be5d98
Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@pidgin.im>
parents:
18417
diff
changeset
|
739 | const char * |
|
da4db1be5d98
Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@pidgin.im>
parents:
18417
diff
changeset
|
740 | pidgin_protocol_option_menu_get_selected(GtkWidget *optmenu) |
|
da4db1be5d98
Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@pidgin.im>
parents:
18417
diff
changeset
|
741 | { |
|
da4db1be5d98
Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@pidgin.im>
parents:
18417
diff
changeset
|
742 | return (const char *)aop_option_menu_get_selected(optmenu, NULL); |
|
da4db1be5d98
Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@pidgin.im>
parents:
18417
diff
changeset
|
743 | } |
|
da4db1be5d98
Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@pidgin.im>
parents:
18417
diff
changeset
|
744 | |
| 15884 | 745 | PurpleAccount * |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
746 | pidgin_account_option_menu_get_selected(GtkWidget *optmenu) |
|
8940
3e22cf150db0
[gaim-migrate @ 9710]
Mark Doliner <markdoliner@pidgin.im>
parents:
8913
diff
changeset
|
747 | { |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
748 | return (PurpleAccount *)aop_option_menu_get_selected(optmenu, NULL); |
|
8940
3e22cf150db0
[gaim-migrate @ 9710]
Mark Doliner <markdoliner@pidgin.im>
parents:
8913
diff
changeset
|
749 | } |
|
3e22cf150db0
[gaim-migrate @ 9710]
Mark Doliner <markdoliner@pidgin.im>
parents:
8913
diff
changeset
|
750 | |
| 17375 | 751 | static AopMenu * |
| 17117 | 752 | create_account_menu(PurpleAccount *default_account, |
| 15884 | 753 | PurpleFilterAccountFunc filter_func, gboolean show_all) |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
754 | { |
| 17375 | 755 | AopMenu *aop_menu = NULL; |
| 15884 | 756 | PurpleAccount *account; |
| 17117 | 757 | GdkPixbuf *pixbuf = NULL; |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
758 | GList *list; |
|
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
759 | GList *p; |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
760 | GtkSizeGroup *sg; |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
761 | int i; |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
762 | char buf[256]; |
|
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
763 | |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
764 | if (show_all) |
| 15884 | 765 | list = purple_accounts_get_all(); |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
766 | else |
| 15884 | 767 | list = purple_connections_get_all(); |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
768 | |
| 17375 | 769 | aop_menu = g_malloc0(sizeof(AopMenu)); |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
770 | aop_menu->default_item = -1; |
|
17377
136e8a8b76da
Forgot an instance of g_object_new and some other changes are necessary, too.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17375
diff
changeset
|
771 | aop_menu->menu = gtk_menu_new(); |
|
136e8a8b76da
Forgot an instance of g_object_new and some other changes are necessary, too.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17375
diff
changeset
|
772 | gtk_widget_show(aop_menu->menu); |
|
5880
f5335e81bb6c
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
773 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
774 | |
|
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
775 | for (p = list, i = 0; p != NULL; p = p->next, i++) { |
| 15884 | 776 | PurplePlugin *plugin; |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
777 | |
|
5879
a2757f3f2dda
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
778 | if (show_all) |
| 15884 | 779 | account = (PurpleAccount *)p->data; |
|
5879
a2757f3f2dda
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
780 | else { |
| 15884 | 781 | PurpleConnection *gc = (PurpleConnection *)p->data; |
| 782 | ||
| 783 | account = purple_connection_get_account(gc); | |
|
5879
a2757f3f2dda
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
784 | } |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
785 | |
|
8289
234429bac6b5
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
786 | if (filter_func && !filter_func(account)) { |
| 8215 | 787 | i--; |
|
6646
b9a0b5eb74e6
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
788 | continue; |
| 8215 | 789 | } |
|
6646
b9a0b5eb74e6
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
790 | |
| 15884 | 791 | plugin = purple_find_prpl(purple_account_get_protocol_id(account)); |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
792 | |
|
17368
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
793 | pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
794 | |
|
17386
f68ba6199d79
merge of 'de0c8e6287f1090343edb9c43e0d8d681e58df07'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
795 | if (pixbuf) { |
|
17368
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
796 | if (purple_account_is_disconnected(account) && show_all && |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
797 | purple_connections_get_all()) |
|
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
798 | gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE); |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
799 | } |
|
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
800 | |
| 15884 | 801 | if (purple_account_get_alias(account)) { |
| 11017 | 802 | g_snprintf(buf, sizeof(buf), "%s (%s) (%s)", |
| 15884 | 803 | purple_account_get_username(account), |
| 804 | purple_account_get_alias(account), | |
| 805 | purple_account_get_protocol_name(account)); | |
| 11017 | 806 | } else { |
| 807 | g_snprintf(buf, sizeof(buf), "%s (%s)", | |
| 15884 | 808 | purple_account_get_username(account), |
| 809 | purple_account_get_protocol_name(account)); | |
| 11017 | 810 | } |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
811 | |
| 17117 | 812 | gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu), |
|
17851
02fbbecd95f5
Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17387
diff
changeset
|
813 | aop_menu_item_new(sg, pixbuf, buf, account, "account")); |
| 17117 | 814 | |
|
17235
f04fc9bbb90b
Style changes in if statements.
Richard Laager <rlaager@pidgin.im>
parents:
17234
diff
changeset
|
815 | if (pixbuf) |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
816 | g_object_unref(pixbuf); |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
817 | |
| 17375 | 818 | if (default_account && account == default_account) |
| 17117 | 819 | aop_menu->default_item = i; |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
820 | } |
|
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
821 | |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
822 | g_object_unref(sg); |
|
5880
f5335e81bb6c
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
823 | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
824 | return aop_menu; |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
825 | } |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
826 | |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
827 | static void |
| 8134 | 828 | regenerate_account_menu(GtkWidget *optmenu) |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
829 | { |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
830 | gboolean show_all; |
| 15884 | 831 | PurpleAccount *account; |
| 832 | PurpleFilterAccountFunc filter_func; | |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
833 | |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
834 | account = (PurpleAccount *)aop_option_menu_get_selected(optmenu, NULL); |
| 17117 | 835 | show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu), "show_all")); |
| 836 | filter_func = g_object_get_data(G_OBJECT(optmenu), "filter_func"); | |
| 837 | ||
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
838 | aop_option_menu_replace_menu(optmenu, create_account_menu(account, filter_func, show_all)); |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
839 | } |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
840 | |
| 8134 | 841 | static void |
| 15884 | 842 | account_menu_sign_on_off_cb(PurpleConnection *gc, GtkWidget *optmenu) |
| 8134 | 843 | { |
| 844 | regenerate_account_menu(optmenu); | |
| 845 | } | |
| 846 | ||
| 847 | static void | |
| 15884 | 848 | account_menu_added_removed_cb(PurpleAccount *account, GtkWidget *optmenu) |
| 8134 | 849 | { |
| 850 | regenerate_account_menu(optmenu); | |
| 851 | } | |
| 852 | ||
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
853 | static gboolean |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
854 | account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event, |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
855 | void *user_data) |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
856 | { |
| 15884 | 857 | purple_signals_disconnect_by_handle(optmenu); |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
858 | |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
859 | return FALSE; |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
860 | } |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
861 | |
|
9910
7b4465b92411
[gaim-migrate @ 10802]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9899
diff
changeset
|
862 | void |
| 15884 | 863 | pidgin_account_option_menu_set_selected(GtkWidget *optmenu, PurpleAccount *account) |
|
9910
7b4465b92411
[gaim-migrate @ 10802]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9899
diff
changeset
|
864 | { |
|
17385
bf46968ab031
Casting things to gpointer isn't useful, unless they were previously const.
Richard Laager <rlaager@pidgin.im>
parents:
17377
diff
changeset
|
865 | aop_option_menu_select_by_data(optmenu, account); |
|
9910
7b4465b92411
[gaim-migrate @ 10802]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9899
diff
changeset
|
866 | } |
|
7b4465b92411
[gaim-migrate @ 10802]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9899
diff
changeset
|
867 | |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
868 | GtkWidget * |
| 15884 | 869 | pidgin_account_option_menu_new(PurpleAccount *default_account, |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
870 | gboolean show_all, GCallback cb, |
| 15884 | 871 | PurpleFilterAccountFunc filter_func, |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
872 | gpointer user_data) |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
873 | { |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
874 | GtkWidget *optmenu; |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
875 | |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
876 | /* Create the option menu */ |
|
17234
6e430db9b926
Style change: death to spaces before semi-colons.
Richard Laager <rlaager@pidgin.im>
parents:
17233
diff
changeset
|
877 | optmenu = aop_option_menu_new(create_account_menu(default_account, filter_func, show_all), cb, user_data); |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
878 | |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
879 | g_signal_connect(G_OBJECT(optmenu), "destroy", |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
880 | G_CALLBACK(account_menu_destroyed_cb), NULL); |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
881 | |
| 15884 | 882 | /* Register the purple sign on/off event callbacks. */ |
| 883 | purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
| 884 | optmenu, PURPLE_CALLBACK(account_menu_sign_on_off_cb), | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
885 | optmenu); |
| 15884 | 886 | purple_signal_connect(purple_connections_get_handle(), "signed-off", |
| 887 | optmenu, PURPLE_CALLBACK(account_menu_sign_on_off_cb), | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
888 | optmenu); |
| 15884 | 889 | purple_signal_connect(purple_accounts_get_handle(), "account-added", |
| 890 | optmenu, PURPLE_CALLBACK(account_menu_added_removed_cb), | |
| 8134 | 891 | optmenu); |
| 15884 | 892 | purple_signal_connect(purple_accounts_get_handle(), "account-removed", |
| 893 | optmenu, PURPLE_CALLBACK(account_menu_added_removed_cb), | |
| 8134 | 894 | optmenu); |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
895 | |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
896 | /* Set some data. */ |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
897 | g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
|
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
898 | g_object_set_data(G_OBJECT(optmenu), "show_all", GINT_TO_POINTER(show_all)); |
| 17375 | 899 | g_object_set_data(G_OBJECT(optmenu), "filter_func", filter_func); |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
900 | |
|
5877
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
901 | return optmenu; |
|
37695b88b248
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
902 | } |
|
5943
8a052155157a
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
903 | |
|
6391
bd5914d9837c
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
904 | gboolean |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
905 | pidgin_check_if_dir(const char *path, GtkFileSelection *filesel) |
|
5966
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
906 | { |
|
20241
36b8b9235ff3
applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents:
20234
diff
changeset
|
907 | char *dirname = NULL; |
|
5966
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
908 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
909 | if (g_file_test(path, G_FILE_TEST_IS_DIR)) { |
|
5966
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
910 | /* append a / if needed */ |
|
9534
a85e66272b09
[gaim-migrate @ 10362]
Mark Doliner <markdoliner@pidgin.im>
parents:
9497
diff
changeset
|
911 | if (path[strlen(path) - 1] != G_DIR_SEPARATOR) { |
|
a85e66272b09
[gaim-migrate @ 10362]
Mark Doliner <markdoliner@pidgin.im>
parents:
9497
diff
changeset
|
912 | dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL); |
|
5966
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
913 | } |
|
20241
36b8b9235ff3
applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents:
20234
diff
changeset
|
914 | gtk_file_selection_set_filename(filesel, (dirname != NULL) ? dirname : path); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
915 | g_free(dirname); |
|
5966
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
916 | return TRUE; |
|
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
917 | } |
|
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
918 | |
|
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
919 | return FALSE; |
|
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
920 | } |
|
91a208b3e979
[gaim-migrate @ 6413]
Mark Doliner <markdoliner@pidgin.im>
parents:
5959
diff
changeset
|
921 | |
|
12067
11fb53722956
[gaim-migrate @ 14362]
Richard Laager <rlaager@pidgin.im>
parents:
12063
diff
changeset
|
922 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
923 | pidgin_setup_gtkspell(GtkTextView *textview) |
| 12061 | 924 | { |
|
12067
11fb53722956
[gaim-migrate @ 14362]
Richard Laager <rlaager@pidgin.im>
parents:
12063
diff
changeset
|
925 | #ifdef USE_GTKSPELL |
|
7538
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
926 | GError *error = NULL; |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
927 | char *locale = NULL; |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
928 | |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
929 | g_return_if_fail(textview != NULL); |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
930 | g_return_if_fail(GTK_IS_TEXT_VIEW(textview)); |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
931 | |
|
12067
11fb53722956
[gaim-migrate @ 14362]
Richard Laager <rlaager@pidgin.im>
parents:
12063
diff
changeset
|
932 | if (gtkspell_new_attach(textview, locale, &error) == NULL && error) |
|
7538
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
933 | { |
| 15884 | 934 | purple_debug_warning("gtkspell", "Failed to setup GtkSpell: %s\n", |
|
12067
11fb53722956
[gaim-migrate @ 14362]
Richard Laager <rlaager@pidgin.im>
parents:
12063
diff
changeset
|
935 | error->message); |
|
7538
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
936 | g_error_free(error); |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
937 | } |
|
12067
11fb53722956
[gaim-migrate @ 14362]
Richard Laager <rlaager@pidgin.im>
parents:
12063
diff
changeset
|
938 | #endif /* USE_GTKSPELL */ |
|
7538
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
939 | } |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
940 | |
|
b20dbe9222e2
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
941 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
942 | pidgin_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, |
| 14781 | 943 | GdkModifierType arg2, GClosure *arg3, |
| 944 | gpointer data) | |
| 7420 | 945 | { |
| 15884 | 946 | purple_debug(PURPLE_DEBUG_MISC, "accels", |
| 14781 | 947 | "accel changed, scheduling save.\n"); |
| 7420 | 948 | |
| 949 | if (!accels_save_timer) | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
950 | accels_save_timer = g_timeout_add(5000, pidgin_save_accels, |
| 14781 | 951 | NULL); |
| 7420 | 952 | } |
| 953 | ||
| 954 | gboolean | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
955 | pidgin_save_accels(gpointer data) |
| 7420 | 956 | { |
| 957 | char *filename = NULL; | |
| 958 | ||
| 15884 | 959 | filename = g_build_filename(purple_user_dir(), G_DIR_SEPARATOR_S, |
| 14781 | 960 | "accels", NULL); |
| 15884 | 961 | purple_debug(PURPLE_DEBUG_MISC, "accels", "saving accels to %s\n", filename); |
| 7420 | 962 | gtk_accel_map_save(filename); |
| 963 | g_free(filename); | |
| 964 | ||
| 965 | accels_save_timer = 0; | |
| 966 | return FALSE; | |
| 967 | } | |
| 968 | ||
| 969 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
970 | pidgin_load_accels() |
| 7420 | 971 | { |
| 972 | char *filename = NULL; | |
| 973 | ||
| 15884 | 974 | filename = g_build_filename(purple_user_dir(), G_DIR_SEPARATOR_S, |
| 14781 | 975 | "accels", NULL); |
| 7420 | 976 | gtk_accel_map_load(filename); |
| 977 | g_free(filename); | |
| 978 | } | |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
979 | |
|
18281
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
980 | static void |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
981 | show_retrieveing_info(PurpleConnection *conn, const char *name) |
|
17387
db83104d06f2
Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17386
diff
changeset
|
982 | { |
|
db83104d06f2
Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17386
diff
changeset
|
983 | PurpleNotifyUserInfo *info = purple_notify_user_info_new(); |
|
db83104d06f2
Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17386
diff
changeset
|
984 | purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving...")); |
|
db83104d06f2
Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17386
diff
changeset
|
985 | purple_notify_userinfo(conn, name, info, NULL, NULL); |
|
db83104d06f2
Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17386
diff
changeset
|
986 | 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
|
987 | } |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
988 | |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
989 | 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
|
990 | { |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
991 | show_retrieveing_info(conn, name); |
|
17387
db83104d06f2
Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17386
diff
changeset
|
992 | serv_get_info(conn, name); |
|
db83104d06f2
Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17386
diff
changeset
|
993 | } |
|
db83104d06f2
Fix the last merge.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17386
diff
changeset
|
994 | |
|
18281
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
995 | 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
|
996 | { |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
997 | char *who = NULL; |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
998 | PurplePluginProtocolInfo *prpl_info = NULL; |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
999 | |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1000 | 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
|
1001 | 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
|
1002 | return; |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1003 | } |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1004 | |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1005 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(conn->prpl); |
|
23501
55185be28a1b
Pass the "real" chat username to the pidgin_retrieve_user_info function.
Daniel Atallah <datallah@pidgin.im>
parents:
23333
diff
changeset
|
1006 | if (prpl_info != NULL && prpl_info->get_cb_real_name) |
|
55185be28a1b
Pass the "real" chat username to the pidgin_retrieve_user_info function.
Daniel Atallah <datallah@pidgin.im>
parents:
23333
diff
changeset
|
1007 | who = prpl_info->get_cb_real_name(conn, chat, name); |
|
18281
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1008 | if (prpl_info == NULL || prpl_info->get_cb_info == NULL) { |
|
23501
55185be28a1b
Pass the "real" chat username to the pidgin_retrieve_user_info function.
Daniel Atallah <datallah@pidgin.im>
parents:
23333
diff
changeset
|
1009 | pidgin_retrieve_user_info(conn, who ? who : name); |
|
55185be28a1b
Pass the "real" chat username to the pidgin_retrieve_user_info function.
Daniel Atallah <datallah@pidgin.im>
parents:
23333
diff
changeset
|
1010 | g_free(who); |
|
18281
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1011 | return; |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1012 | } |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1013 | |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1014 | show_retrieveing_info(conn, who ? who : name); |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1015 | prpl_info->get_cb_info(conn, chat, name); |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1016 | 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
|
1017 | } |
|
f7dd07e1e434
Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18278
diff
changeset
|
1018 | |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1019 | gboolean |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
1020 | pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts, |
| 15884 | 1021 | PurpleAccount **ret_account, char **ret_protocol, |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1022 | char **ret_username, char **ret_alias) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1023 | { |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1024 | char *protocol = NULL; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1025 | char *username = NULL; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1026 | char *alias = NULL; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1027 | char *str; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1028 | char *c, *s; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1029 | gboolean valid; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1030 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1031 | g_return_val_if_fail(msg != NULL, FALSE); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1032 | g_return_val_if_fail(ret_protocol != NULL, FALSE); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1033 | g_return_val_if_fail(ret_username != NULL, FALSE); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1034 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1035 | s = str = g_strdup(msg); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1036 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1037 | while (*s != '\r' && *s != '\n' && *s != '\0') |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1038 | { |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1039 | char *key, *value; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1040 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1041 | key = s; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1042 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1043 | /* Grab the key */ |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1044 | while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ') |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1045 | s++; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1046 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1047 | if (*s == '\r') s++; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1048 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1049 | if (*s == '\n') |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1050 | { |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1051 | s++; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1052 | continue; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1053 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1054 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1055 | if (*s != '\0') *s++ = '\0'; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1056 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1057 | /* Clear past any whitespace */ |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1058 | while (*s != '\0' && *s == ' ') |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1059 | s++; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1060 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1061 | /* Now let's grab until the end of the line. */ |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1062 | value = s; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1063 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1064 | while (*s != '\r' && *s != '\n' && *s != '\0') |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1065 | s++; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1066 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1067 | if (*s == '\r') *s++ = '\0'; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1068 | if (*s == '\n') *s++ = '\0'; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1069 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1070 | if ((c = strchr(key, ':')) != NULL) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1071 | { |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1072 | if (!g_ascii_strcasecmp(key, "X-IM-Username:")) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1073 | username = g_strdup(value); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1074 | else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:")) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1075 | protocol = g_strdup(value); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1076 | else if (!g_ascii_strcasecmp(key, "X-IM-Alias:")) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1077 | alias = g_strdup(value); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1078 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1079 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1080 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1081 | if (username != NULL && protocol != NULL) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1082 | { |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1083 | valid = TRUE; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1084 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1085 | *ret_username = username; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1086 | *ret_protocol = protocol; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1087 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1088 | if (ret_alias != NULL) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1089 | *ret_alias = alias; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1090 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1091 | /* Check for a compatible account. */ |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1092 | if (ret_account != NULL) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1093 | { |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
1094 | GList *list; |
| 15884 | 1095 | PurpleAccount *account = NULL; |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
1096 | GList *l; |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1097 | const char *protoname; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1098 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1099 | if (all_accounts) |
| 15884 | 1100 | list = purple_accounts_get_all(); |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1101 | else |
| 15884 | 1102 | list = purple_connections_get_all(); |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1103 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1104 | for (l = list; l != NULL; l = l->next) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1105 | { |
| 15884 | 1106 | PurpleConnection *gc; |
| 1107 | PurplePluginProtocolInfo *prpl_info = NULL; | |
| 1108 | PurplePlugin *plugin; | |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1109 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1110 | if (all_accounts) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1111 | { |
| 15884 | 1112 | account = (PurpleAccount *)l->data; |
| 1113 | ||
| 1114 | plugin = purple_plugins_find_with_id( | |
| 1115 | purple_account_get_protocol_id(account)); | |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1116 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1117 | if (plugin == NULL) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1118 | { |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1119 | account = NULL; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1120 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1121 | continue; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1122 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1123 | |
| 15884 | 1124 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1125 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1126 | else |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1127 | { |
| 15884 | 1128 | gc = (PurpleConnection *)l->data; |
| 1129 | account = purple_connection_get_account(gc); | |
| 1130 | ||
| 1131 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1132 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1133 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1134 | protoname = prpl_info->list_icon(account, NULL); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1135 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1136 | if (!strcmp(protoname, protocol)) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1137 | break; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1138 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1139 | account = NULL; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1140 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1141 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1142 | /* Special case for AIM and ICQ */ |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1143 | if (account == NULL && (!strcmp(protocol, "aim") || |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1144 | !strcmp(protocol, "icq"))) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1145 | { |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1146 | for (l = list; l != NULL; l = l->next) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1147 | { |
| 15884 | 1148 | PurpleConnection *gc; |
| 1149 | PurplePluginProtocolInfo *prpl_info = NULL; | |
| 1150 | PurplePlugin *plugin; | |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1151 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1152 | if (all_accounts) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1153 | { |
| 15884 | 1154 | account = (PurpleAccount *)l->data; |
| 1155 | ||
| 1156 | plugin = purple_plugins_find_with_id( | |
| 1157 | purple_account_get_protocol_id(account)); | |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1158 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1159 | if (plugin == NULL) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1160 | { |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1161 | account = NULL; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1162 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1163 | continue; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1164 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1165 | |
| 15884 | 1166 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1167 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1168 | else |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1169 | { |
| 15884 | 1170 | gc = (PurpleConnection *)l->data; |
| 1171 | account = purple_connection_get_account(gc); | |
| 1172 | ||
| 1173 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1174 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1175 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1176 | protoname = prpl_info->list_icon(account, NULL); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1177 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1178 | if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq")) |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1179 | break; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1180 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1181 | account = NULL; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1182 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1183 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1184 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1185 | *ret_account = account; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1186 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1187 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1188 | else |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1189 | { |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1190 | valid = FALSE; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1191 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13783
diff
changeset
|
1192 | g_free(username); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13783
diff
changeset
|
1193 | g_free(protocol); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13783
diff
changeset
|
1194 | g_free(alias); |
|
7712
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1195 | } |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1196 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1197 | g_free(str); |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1198 | |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1199 | return valid; |
|
74af9358b808
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1200 | } |
| 8137 | 1201 | |
| 1202 | void | |
| 15568 | 1203 | pidgin_set_accessible_label (GtkWidget *w, GtkWidget *l) |
| 8137 | 1204 | { |
|
19547
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1205 | AtkObject *acc; |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1206 | 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
|
1207 | 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
|
1208 | |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1209 | 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
|
1210 | |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1211 | /* 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
|
1212 | 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
|
1213 | if (!existing_name) { |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1214 | label_text = gtk_label_get_text (GTK_LABEL(l)); |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1215 | 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
|
1216 | 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
|
1217 | } |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1218 | |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1219 | 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
|
1220 | } |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1221 | |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1222 | void |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1223 | pidgin_set_accessible_relations (GtkWidget *w, GtkWidget *l) |
|
0c3fcdc6a025
Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents:
19123
diff
changeset
|
1224 | { |
| 8137 | 1225 | AtkObject *acc, *label; |
| 1226 | AtkObject *rel_obj[1]; | |
| 1227 | AtkRelationSet *set; | |
| 1228 | AtkRelation *relation; | |
| 1229 | ||
| 1230 | acc = gtk_widget_get_accessible (w); | |
| 1231 | label = gtk_widget_get_accessible (l); | |
| 1232 | ||
|
18351
b881759cda28
Call gtk_label_set_mnemonic_widget() in pidgin_make_accessible_label. Closes #589
Sean Egan <seanegan@pidgin.im>
parents:
18281
diff
changeset
|
1233 | /* Make sure mnemonics work */ |
|
20241
36b8b9235ff3
applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents:
20234
diff
changeset
|
1234 | gtk_label_set_mnemonic_widget(GTK_LABEL(l), w); |
|
36b8b9235ff3
applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents:
20234
diff
changeset
|
1235 | |
| 8137 | 1236 | /* Create the labeled-by relation */ |
| 1237 | set = atk_object_ref_relation_set (acc); | |
| 1238 | rel_obj[0] = label; | |
| 1239 | relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY); | |
| 1240 | atk_relation_set_add (set, relation); | |
| 1241 | g_object_unref (relation); | |
|
20241
36b8b9235ff3
applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents:
20234
diff
changeset
|
1242 | g_object_unref(set); |
| 8137 | 1243 | |
| 1244 | /* Create the label-for relation */ | |
| 1245 | set = atk_object_ref_relation_set (label); | |
| 1246 | rel_obj[0] = acc; | |
| 1247 | relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR); | |
| 1248 | atk_relation_set_add (set, relation); | |
| 1249 | g_object_unref (relation); | |
|
20241
36b8b9235ff3
applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents:
20234
diff
changeset
|
1250 | g_object_unref(set); |
| 8137 | 1251 | } |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1252 | |
|
18238
b38c33d2d71e
Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18216
diff
changeset
|
1253 | void |
|
b38c33d2d71e
Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18216
diff
changeset
|
1254 | pidgin_menu_position_func_helper(GtkMenu *menu, |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1255 | gint *x, |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1256 | gint *y, |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1257 | gboolean *push_in, |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1258 | gpointer data) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1259 | { |
|
18238
b38c33d2d71e
Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18216
diff
changeset
|
1260 | #if GTK_CHECK_VERSION(2,2,0) |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1261 | GtkWidget *widget; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1262 | GtkRequisition requisition; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1263 | GdkScreen *screen; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1264 | GdkRectangle monitor; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1265 | gint monitor_num; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1266 | gint space_left, space_right, space_above, space_below; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1267 | gint needed_width; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1268 | gint needed_height; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1269 | gint xthickness; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1270 | gint ythickness; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1271 | gboolean rtl; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1272 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1273 | g_return_if_fail(GTK_IS_MENU(menu)); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1274 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1275 | widget = GTK_WIDGET(menu); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1276 | screen = gtk_widget_get_screen(widget); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1277 | xthickness = widget->style->xthickness; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1278 | ythickness = widget->style->ythickness; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1279 | rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1280 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1281 | /* |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1282 | * We need the requisition to figure out the right place to |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1283 | * popup the menu. In fact, we always need to ask here, since |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1284 | * if a size_request was queued while we weren't popped up, |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1285 | * the requisition won't have been recomputed yet. |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1286 | */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1287 | gtk_widget_size_request (widget, &requisition); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1288 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1289 | monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1290 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1291 | push_in = FALSE; |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
1292 | |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1293 | /* |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1294 | * The placement of popup menus horizontally works like this (with |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1295 | * RTL in parentheses) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1296 | * |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1297 | * - If there is enough room to the right (left) of the mouse cursor, |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1298 | * position the menu there. |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
1299 | * |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
1300 | * - Otherwise, if if there is enough room to the left (right) of the |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1301 | * mouse cursor, position the menu there. |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
1302 | * |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1303 | * - Otherwise if the menu is smaller than the monitor, position it |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1304 | * on the side of the mouse cursor that has the most space available |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1305 | * |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1306 | * - Otherwise (if there is simply not enough room for the menu on the |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1307 | * monitor), position it as far left (right) as possible. |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1308 | * |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1309 | * Positioning in the vertical direction is similar: first try below |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1310 | * mouse cursor, then above. |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1311 | */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1312 | gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1313 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1314 | space_left = *x - monitor.x; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1315 | space_right = monitor.x + monitor.width - *x - 1; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1316 | space_above = *y - monitor.y; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1317 | space_below = monitor.y + monitor.height - *y - 1; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1318 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1319 | /* position horizontally */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1320 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1321 | /* the amount of space we need to position the menu. Note the |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
1322 | * menu is offset "xthickness" pixels |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1323 | */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1324 | needed_width = requisition.width - xthickness; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1325 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1326 | if (needed_width <= space_left || |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1327 | needed_width <= space_right) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1328 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1329 | if ((rtl && needed_width <= space_left) || |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1330 | (!rtl && needed_width > space_right)) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1331 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1332 | /* position left */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1333 | *x = *x + xthickness - requisition.width + 1; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1334 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1335 | else |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1336 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1337 | /* position right */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1338 | *x = *x - xthickness; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1339 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1340 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1341 | /* x is clamped on-screen further down */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1342 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1343 | else if (requisition.width <= monitor.width) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1344 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1345 | /* the menu is too big to fit on either side of the mouse |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1346 | * cursor, but smaller than the monitor. Position it on |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1347 | * the side that has the most space |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1348 | */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1349 | if (space_left > space_right) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1350 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1351 | /* left justify */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1352 | *x = monitor.x; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1353 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1354 | else |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1355 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1356 | /* right justify */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1357 | *x = monitor.x + monitor.width - requisition.width; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1358 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1359 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1360 | else /* menu is simply too big for the monitor */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1361 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1362 | if (rtl) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1363 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1364 | /* right justify */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1365 | *x = monitor.x + monitor.width - requisition.width; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1366 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1367 | else |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1368 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1369 | /* left justify */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1370 | *x = monitor.x; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1371 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1372 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1373 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1374 | /* Position vertically. The algorithm is the same as above, but |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1375 | * simpler because we don't have to take RTL into account. |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1376 | */ |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1377 | needed_height = requisition.height - ythickness; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1378 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1379 | if (needed_height <= space_above || |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1380 | needed_height <= space_below) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1381 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1382 | if (needed_height <= space_below) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1383 | *y = *y - ythickness; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1384 | else |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1385 | *y = *y + ythickness - requisition.height + 1; |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
1386 | |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1387 | *y = CLAMP (*y, monitor.y, |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1388 | monitor.y + monitor.height - requisition.height); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1389 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1390 | else if (needed_height > space_below && needed_height > space_above) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1391 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1392 | if (space_below >= space_above) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1393 | *y = monitor.y + monitor.height - requisition.height; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1394 | else |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1395 | *y = monitor.y; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1396 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1397 | else |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1398 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1399 | *y = monitor.y; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1400 | } |
|
18238
b38c33d2d71e
Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18216
diff
changeset
|
1401 | #endif |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1402 | } |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1403 | |
| 8247 | 1404 | |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1405 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
1406 | pidgin_treeview_popup_menu_position_func(GtkMenu *menu, |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1407 | gint *x, |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1408 | gint *y, |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1409 | gboolean *push_in, |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1410 | gpointer data) |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1411 | { |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1412 | GtkWidget *widget = GTK_WIDGET(data); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1413 | GtkTreeView *tv = GTK_TREE_VIEW(data); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1414 | GtkTreePath *path; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1415 | GtkTreeViewColumn *col; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1416 | GdkRectangle rect; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1417 | gint ythickness = GTK_WIDGET(menu)->style->ythickness; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1418 | |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1419 | gdk_window_get_origin (widget->window, x, y); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1420 | gtk_tree_view_get_cursor (tv, &path, &col); |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1421 | gtk_tree_view_get_cell_area (tv, path, col, &rect); |
|
8218
0ff223f56a67
[gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents:
8215
diff
changeset
|
1422 | |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1423 | *x += rect.x+rect.width; |
|
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1424 | *y += rect.y+rect.height+ythickness; |
|
18238
b38c33d2d71e
Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18216
diff
changeset
|
1425 | pidgin_menu_position_func_helper(menu, x, y, push_in, data); |
|
8143
ce4b6383777b
[gaim-migrate @ 8851]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8137
diff
changeset
|
1426 | } |
|
10061
2833056ea11c
[gaim-migrate @ 11033]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9910
diff
changeset
|
1427 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1428 | enum { |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1429 | DND_FILE_TRANSFER, |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1430 | DND_IM_IMAGE, |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1431 | DND_BUDDY_ICON |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1432 | }; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1433 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1434 | typedef struct { |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1435 | char *filename; |
| 15884 | 1436 | PurpleAccount *account; |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1437 | char *who; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1438 | } _DndData; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1439 | |
|
10850
6889f793b918
[gaim-migrate @ 12522]
Mark Doliner <markdoliner@pidgin.im>
parents:
10681
diff
changeset
|
1440 | 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
|
1441 | { |
|
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
|
1442 | gchar *filedata; |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1443 | size_t size; |
|
14914
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
1444 | struct stat st; |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1445 | GError *err = NULL; |
| 15884 | 1446 | PurpleConversation *conv; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
1447 | PidginConversation *gtkconv; |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1448 | GtkTextIter iter; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1449 | int id; |
|
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
|
1450 | 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
|
1451 | PurpleContact *contact; |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1452 | switch (choice) { |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1453 | case DND_BUDDY_ICON: |
|
14914
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
1454 | if (g_stat(data->filename, &st)) { |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1455 | char *str; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1456 | |
|
14914
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
1457 | 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
|
1458 | data->filename, g_strerror(errno)); |
| 15884 | 1459 | purple_notify_error(NULL, NULL, |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1460 | _("Failed to load image"), |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1461 | str); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1462 | g_free(str); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1463 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1464 | return; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1465 | } |
| 10335 | 1466 | |
| 23288 | 1467 | buddy = purple_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
|
1468 | 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
|
1469 | 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
|
1470 | 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
|
1471 | } |
|
4b4f5e80e324
Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <deryni@pidgin.im>
parents:
23286
diff
changeset
|
1472 | 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
|
1473 | 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
|
1474 | break; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1475 | case DND_FILE_TRANSFER: |
| 15884 | 1476 | 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
|
1477 | break; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1478 | case DND_IM_IMAGE: |
| 15884 | 1479 | conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, data->account, data->who); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
1480 | gtkconv = PIDGIN_CONVERSATION(conv); |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1481 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1482 | if (!g_file_get_contents(data->filename, &filedata, &size, |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1483 | &err)) { |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1484 | char *str; |
| 10335 | 1485 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1486 | str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message); |
| 15884 | 1487 | purple_notify_error(NULL, NULL, |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1488 | _("Failed to load image"), |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1489 | str); |
| 10335 | 1490 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1491 | g_error_free(err); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1492 | g_free(str); |
| 10335 | 1493 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1494 | return; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1495 | } |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16314
diff
changeset
|
1496 | id = purple_imgstore_add_with_id(filedata, size, data->filename); |
| 10335 | 1497 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1498 | gtk_text_buffer_get_iter_at_mark(GTK_IMHTML(gtkconv->entry)->text_buffer, &iter, |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1499 | gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer)); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1500 | gtk_imhtml_insert_image_at_iter(GTK_IMHTML(gtkconv->entry), id, &iter); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
16314
diff
changeset
|
1501 | purple_imgstore_unref_by_id(id); |
| 10335 | 1502 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1503 | break; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1504 | } |
|
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
|
1505 | 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
|
1506 | 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
|
1507 | g_free(data); |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1508 | } |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1509 | |
|
10850
6889f793b918
[gaim-migrate @ 12522]
Mark Doliner <markdoliner@pidgin.im>
parents:
10681
diff
changeset
|
1510 | 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
|
1511 | { |
|
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
|
1512 | 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
|
1513 | 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
|
1514 | g_free(data); |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1515 | } |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1516 | |
|
11110
acc4e51cb91a
[gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents:
11017
diff
changeset
|
1517 | static void dnd_set_icon_ok_cb(_DndData *data) |
|
acc4e51cb91a
[gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents:
11017
diff
changeset
|
1518 | { |
|
acc4e51cb91a
[gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents:
11017
diff
changeset
|
1519 | dnd_image_ok_callback(data, DND_BUDDY_ICON); |
|
acc4e51cb91a
[gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents:
11017
diff
changeset
|
1520 | } |
|
acc4e51cb91a
[gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents:
11017
diff
changeset
|
1521 | |
|
acc4e51cb91a
[gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents:
11017
diff
changeset
|
1522 | static void dnd_set_icon_cancel_cb(_DndData *data) |
|
acc4e51cb91a
[gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents:
11017
diff
changeset
|
1523 | { |
|
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
|
1524 | 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
|
1525 | 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
|
1526 | g_free(data); |
|
11110
acc4e51cb91a
[gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents:
11017
diff
changeset
|
1527 | } |
|
acc4e51cb91a
[gaim-migrate @ 13162]
Richard Laager <rlaager@pidgin.im>
parents:
11017
diff
changeset
|
1528 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1529 | void |
| 15884 | 1530 | 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
|
1531 | { |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1532 | GList *tmp; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1533 | GdkPixbuf *pb; |
| 15884 | 1534 | GList *files = purple_uri_list_extract_filenames((const gchar *)sd->data); |
| 1535 | PurpleConnection *gc = purple_account_get_connection(account); | |
| 1536 | PurplePluginProtocolInfo *prpl_info = NULL; | |
| 10335 | 1537 | gboolean file_send_ok = FALSE; |
| 1538 | #ifndef _WIN32 | |
| 15884 | 1539 | PurpleDesktopItem *item; |
| 10335 | 1540 | #endif |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1541 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1542 | g_return_if_fail(account != NULL); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1543 | g_return_if_fail(who != NULL); |
| 10335 | 1544 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1545 | for(tmp = files; tmp != NULL ; tmp = g_list_next(tmp)) { |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1546 | gchar *filename = tmp->data; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1547 | gchar *basename = g_path_get_basename(filename); |
| 10335 | 1548 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1549 | /* Set the default action: don't send anything */ |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1550 | file_send_ok = FALSE; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1551 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1552 | /* 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
|
1553 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1554 | continue; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1555 | } |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1556 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1557 | /* XXX - make ft api suupport sending a directory */ |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1558 | /* Are we dealing with a directory? */ |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1559 | 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
|
1560 | char *str, *str2; |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1561 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1562 | 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
|
1563 | 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
|
1564 | |
| 15884 | 1565 | purple_notify_error(NULL, NULL, |
|
16071
044392e01c96
make things cleaner for translators
Nathan Walp <nwalp@pidgin.im>
parents:
15987
diff
changeset
|
1566 | str, str2); |
| 10335 | 1567 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1568 | g_free(str); |
|
16071
044392e01c96
make things cleaner for translators
Nathan Walp <nwalp@pidgin.im>
parents:
15987
diff
changeset
|
1569 | g_free(str2); |
| 10335 | 1570 | |
| 1571 | continue; | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1572 | } |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1573 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1574 | /* Are we dealing with an image? */ |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1575 | pb = gdk_pixbuf_new_from_file(filename, NULL); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1576 | if (pb) { |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1577 | _DndData *data = g_malloc(sizeof(_DndData)); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1578 | gboolean ft = FALSE, im = FALSE; |
| 10335 | 1579 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1580 | data->who = g_strdup(who); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1581 | data->filename = g_strdup(filename); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1582 | data->account = account; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1583 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1584 | if (gc) |
| 15884 | 1585 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
10348
0ab5eb1a828e
[gaim-migrate @ 11562]
Mark Doliner <markdoliner@pidgin.im>
parents:
10335
diff
changeset
|
1586 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1587 | if (prpl_info && prpl_info->options & OPT_PROTO_IM_IMAGE) |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1588 | im = TRUE; |
| 10335 | 1589 | |
|
10348
0ab5eb1a828e
[gaim-migrate @ 11562]
Mark Doliner <markdoliner@pidgin.im>
parents:
10335
diff
changeset
|
1590 | if (prpl_info && prpl_info->can_receive_file) |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1591 | ft = prpl_info->can_receive_file(gc, who); |
|
20976
c5cf79b99382
When drag-dropping an image onto a conversation, include 'Send image file' as
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20895
diff
changeset
|
1592 | else if (prpl_info && prpl_info->send_file) |
|
c5cf79b99382
When drag-dropping an image onto a conversation, include 'Send image file' as
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20895
diff
changeset
|
1593 | ft = TRUE; |
| 10335 | 1594 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1595 | if (im && ft) |
| 15884 | 1596 | purple_request_choice(NULL, NULL, |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1597 | _("You have dragged an image"), |
|
10951
a81bececc6f0
[gaim-migrate @ 12751]
Richard Laager <rlaager@pidgin.im>
parents:
10871
diff
changeset
|
1598 | _("You can send this image as a file transfer, " |
|
a81bececc6f0
[gaim-migrate @ 12751]
Richard Laager <rlaager@pidgin.im>
parents:
10871
diff
changeset
|
1599 | "embed it into this message, or use it as the buddy icon for this user."), |
|
13101
55659ca43906
[gaim-migrate @ 15462]
Richard Laager <rlaager@pidgin.im>
parents:
13100
diff
changeset
|
1600 | DND_FILE_TRANSFER, "OK", (GCallback)dnd_image_ok_callback, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1601 | "Cancel", (GCallback)dnd_image_cancel_callback, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1602 | account, who, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1603 | data, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1604 | _("Set as buddy icon"), DND_BUDDY_ICON, |
| 10335 | 1605 | _("Send image file"), DND_FILE_TRANSFER, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1606 | _("Insert in message"), DND_IM_IMAGE, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1607 | NULL); |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1608 | else if (!(im || ft)) |
| 15884 | 1609 | purple_request_yes_no(NULL, NULL, _("You have dragged an image"), |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1610 | _("Would you like to set it as the buddy icon for this user?"), |
|
22269
3fdf7b13f20a
A few more of those "default_action" fixes
Mark Doliner <markdoliner@pidgin.im>
parents:
22140
diff
changeset
|
1611 | PURPLE_DEFAULT_ACTION_NONE, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1612 | account, who, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1613 | data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb); |
| 10335 | 1614 | else |
| 15884 | 1615 | purple_request_choice(NULL, NULL, |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1616 | _("You have dragged an image"), |
|
17497
6cbc2e55e878
Fix the "transfer file or embed image" message (it looks like it was copied and pasted incorrectly).
Daniel Atallah <datallah@pidgin.im>
parents:
17487
diff
changeset
|
1617 | (ft ? _("You can send this image as a file transfer, or use it as the buddy icon for this user.") : |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1618 | _("You can insert this image into this message, or use it as the buddy icon for this user")), |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1619 | (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE), |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1620 | "OK", (GCallback)dnd_image_ok_callback, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1621 | "Cancel", (GCallback)dnd_image_cancel_callback, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1622 | account, who, NULL, |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1623 | data, |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1624 | _("Set as buddy icon"), DND_BUDDY_ICON, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1625 | (ft ? _("Send image file") : _("Insert in message")), (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE), |
|
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16314
diff
changeset
|
1626 | NULL); |
|
20976
c5cf79b99382
When drag-dropping an image onto a conversation, include 'Send image file' as
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20895
diff
changeset
|
1627 | gdk_pixbuf_unref(pb); |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1628 | return; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1629 | } |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1630 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1631 | #ifndef _WIN32 |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1632 | /* Are we trying to send a .desktop file? */ |
| 15884 | 1633 | else if (purple_str_has_suffix(basename, ".desktop") && (item = purple_desktop_item_new_from_file(filename))) { |
| 1634 | PurpleDesktopItemType dtype; | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1635 | char key[64]; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1636 | const char *itemname = NULL; |
| 10335 | 1637 | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1638 | #if GTK_CHECK_VERSION(2,6,0) |
| 10679 | 1639 | const char * const *langs; |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1640 | int i; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1641 | langs = g_get_language_names(); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1642 | for (i = 0; langs[i]; i++) { |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1643 | g_snprintf(key, sizeof(key), "Name[%s]", langs[i]); |
| 15884 | 1644 | itemname = purple_desktop_item_get_string(item, key); |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1645 | break; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1646 | } |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1647 | #else |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1648 | const char *lang = g_getenv("LANG"); |
|
10681
7c56ed5f169f
[gaim-migrate @ 12227]
Richard Laager <rlaager@pidgin.im>
parents:
10679
diff
changeset
|
1649 | char *dot; |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1650 | dot = strchr(lang, '.'); |
| 10335 | 1651 | if (dot) |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1652 | *dot = '\0'; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1653 | g_snprintf(key, sizeof(key), "Name[%s]", lang); |
| 15884 | 1654 | itemname = purple_desktop_item_get_string(item, key); |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1655 | #endif |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1656 | if (!itemname) |
| 15884 | 1657 | itemname = purple_desktop_item_get_string(item, "Name"); |
| 1658 | ||
| 1659 | dtype = purple_desktop_item_get_entry_type(item); | |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1660 | switch (dtype) { |
| 15884 | 1661 | PurpleConversation *conv; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
1662 | PidginConversation *gtkconv; |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1663 | |
| 15884 | 1664 | case PURPLE_DESKTOP_ITEM_TYPE_LINK: |
| 1665 | conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, who); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
1666 | gtkconv = PIDGIN_CONVERSATION(conv); |
| 10335 | 1667 | gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), |
| 1668 | gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer), | |
| 15884 | 1669 | purple_desktop_item_get_string(item, "URL"), itemname); |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1670 | break; |
| 10335 | 1671 | default: |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1672 | /* I don't know if we really want to do anything here. Most of the desktop item types are crap like |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1673 | * "MIME Type" (I have no clue how that would be a desktop item) and "Comment"... nothing we can really |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1674 | * send. The only logical one is "Application," but do we really want to send a binary and nothing else? |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1675 | * Probably not. I'll just give an error and return. */ |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1676 | /* The original patch sent the icon used by the launcher. That's probably wrong */ |
| 15884 | 1677 | purple_notify_error(NULL, NULL, _("Cannot send launcher"), _("You dragged a desktop launcher. " |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1678 | "Most likely you wanted to send whatever this launcher points to instead of this launcher" |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1679 | " itself.")); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1680 | break; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1681 | } |
| 15884 | 1682 | purple_desktop_item_unref(item); |
|
10229
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1683 | return; |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1684 | } |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1685 | #endif /* _WIN32 */ |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1686 | |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1687 | /* Everything is fine, let's send */ |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1688 | serv_send_file(gc, who, filename); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1689 | g_free(filename); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1690 | } |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1691 | g_list_free(files); |
|
39ffee70c286
[gaim-migrate @ 11364]
Alceste Scalas <alceste.scalas@gmx.net>
parents:
10209
diff
changeset
|
1692 | } |
| 10483 | 1693 | |
| 15884 | 1694 | void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleIconScaleRules rules, int *width, int *height) |
| 10483 | 1695 | { |
| 1696 | *width = gdk_pixbuf_get_width(buf); | |
| 1697 | *height = gdk_pixbuf_get_height(buf); | |
| 1698 | ||
|
15301
26153c5f156a
[gaim-migrate @ 18029]
Mark Doliner <markdoliner@pidgin.im>
parents:
15289
diff
changeset
|
1699 | if ((spec == NULL) || !(spec->scale_rules & rules)) |
|
26153c5f156a
[gaim-migrate @ 18029]
Mark Doliner <markdoliner@pidgin.im>
parents:
15289
diff
changeset
|
1700 | return; |
|
26153c5f156a
[gaim-migrate @ 18029]
Mark Doliner <markdoliner@pidgin.im>
parents:
15289
diff
changeset
|
1701 | |
| 15884 | 1702 | purple_buddy_icon_get_scale_size(spec, width, height); |
| 10483 | 1703 | |
| 1704 | /* and now for some arbitrary sanity checks */ | |
| 1705 | if(*width > 100) | |
| 1706 | *width = 100; | |
| 1707 | if(*height > 100) | |
| 1708 | *height = 100; | |
| 1709 | } | |
|
12080
2aaca2265a51
[gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12067
diff
changeset
|
1710 | |
| 15884 | 1711 | GdkPixbuf * pidgin_create_status_icon(PurpleStatusPrimitive prim, GtkWidget *w, const char *size) |
|
15799
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15645
diff
changeset
|
1712 | { |
|
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15645
diff
changeset
|
1713 | GtkIconSize icon_size = gtk_icon_size_from_name(size); |
|
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15645
diff
changeset
|
1714 | GdkPixbuf *pixbuf = NULL; |
|
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15645
diff
changeset
|
1715 | |
| 15884 | 1716 | if (prim == PURPLE_STATUS_UNAVAILABLE) |
|
22131
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1717 | pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_BUSY, |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1718 | icon_size, "GtkWidget"); |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1719 | else if (prim == PURPLE_STATUS_AWAY) |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1720 | pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_AWAY, |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1721 | icon_size, "GtkWidget"); |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1722 | else if (prim == PURPLE_STATUS_EXTENDED_AWAY) |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1723 | pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_XA, |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1724 | icon_size, "GtkWidget"); |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1725 | else if (prim == PURPLE_STATUS_INVISIBLE) |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1726 | pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_INVISIBLE, |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1727 | icon_size, "GtkWidget"); |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1728 | else if (prim == PURPLE_STATUS_OFFLINE) |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1729 | pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_OFFLINE, |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1730 | icon_size, "GtkWidget"); |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1731 | else |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1732 | pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_AVAILABLE, |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
1733 | icon_size, "GtkWidget"); |
|
15799
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15645
diff
changeset
|
1734 | return pixbuf; |
|
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15645
diff
changeset
|
1735 | |
|
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15645
diff
changeset
|
1736 | } |
|
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15645
diff
changeset
|
1737 | |
|
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15645
diff
changeset
|
1738 | |
|
12080
2aaca2265a51
[gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12067
diff
changeset
|
1739 | GdkPixbuf * |
| 15884 | 1740 | pidgin_create_prpl_icon(PurpleAccount *account, PidginPrplIconSize size) |
|
12080
2aaca2265a51
[gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12067
diff
changeset
|
1741 | { |
| 15884 | 1742 | PurplePlugin *prpl; |
|
12080
2aaca2265a51
[gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12067
diff
changeset
|
1743 | |
|
2aaca2265a51
[gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12067
diff
changeset
|
1744 | g_return_val_if_fail(account != NULL, NULL); |
|
2aaca2265a51
[gaim-migrate @ 14377]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12067
diff
changeset
|
1745 | |
| 15884 | 1746 | prpl = purple_find_prpl(purple_account_get_protocol_id(account)); |
|
13091
b5ed878998dd
[gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents:
13081
diff
changeset
|
1747 | if (prpl == NULL) |
|
b5ed878998dd
[gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents:
13081
diff
changeset
|
1748 | return NULL; |
|
17368
e2c6cb39043c
Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17363
diff
changeset
|
1749 | return pidgin_create_prpl_icon_from_prpl(prpl, size, account); |
|
13091
b5ed878998dd
[gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents:
13081
diff
changeset
|
1750 | } |
|
b5ed878998dd
[gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents:
13081
diff
changeset
|
1751 | |
| 12919 | 1752 | static void |
| 1753 | menu_action_cb(GtkMenuItem *item, gpointer object) | |
| 1754 | { | |
| 1755 | gpointer data; | |
| 1756 | void (*callback)(gpointer, gpointer); | |
| 1757 | ||
| 15884 | 1758 | callback = g_object_get_data(G_OBJECT(item), "purplecallback"); |
| 1759 | data = g_object_get_data(G_OBJECT(item), "purplecallbackdata"); | |
| 12919 | 1760 | |
| 1761 | if (callback) | |
| 1762 | callback(object, data); | |
| 1763 | } | |
| 1764 | ||
|
17363
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1765 | GtkWidget * |
| 15884 | 1766 | pidgin_append_menu_action(GtkWidget *menu, PurpleMenuAction *act, |
| 12919 | 1767 | gpointer object) |
| 1768 | { | |
|
17363
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1769 | GtkWidget *menuitem; |
|
17386
f68ba6199d79
merge of 'de0c8e6287f1090343edb9c43e0d8d681e58df07'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
1770 | |
| 12919 | 1771 | 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
|
1772 | return pidgin_separator(menu); |
|
17386
f68ba6199d79
merge of 'de0c8e6287f1090343edb9c43e0d8d681e58df07'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
1773 | } |
|
17363
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1774 | |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1775 | if (act->children == NULL) { |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1776 | menuitem = gtk_menu_item_new_with_mnemonic(act->label); |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1777 | |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1778 | if (act->callback != NULL) { |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1779 | 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
|
1780 | "purplecallback", |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1781 | act->callback); |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1782 | 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
|
1783 | "purplecallbackdata", |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1784 | act->data); |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1785 | 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
|
1786 | 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
|
1787 | object); |
| 12919 | 1788 | } else { |
|
17363
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1789 | gtk_widget_set_sensitive(menuitem, FALSE); |
| 12919 | 1790 | } |
|
17363
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1791 | |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1792 | 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
|
1793 | } else { |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1794 | 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
|
1795 | 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
|
1796 | GtkAccelGroup *group; |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1797 | |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1798 | menuitem = gtk_menu_item_new_with_mnemonic(act->label); |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1799 | 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
|
1800 | |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1801 | 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
|
1802 | 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
|
1803 | |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1804 | 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
|
1805 | if (group) { |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1806 | char *path = g_strdup_printf("%s/%s", GTK_MENU_ITEM(menuitem)->accel_path, act->label); |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1807 | 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
|
1808 | 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
|
1809 | 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
|
1810 | } |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1811 | |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1812 | for (l = act->children; l; l = l->next) { |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1813 | PurpleMenuAction *act = (PurpleMenuAction *)l->data; |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1814 | |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1815 | pidgin_append_menu_action(submenu, act, object); |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1816 | } |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1817 | g_list_free(act->children); |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1818 | act->children = NULL; |
| 12919 | 1819 | } |
|
17363
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1820 | purple_menu_action_free(act); |
|
f16ea1b259e2
Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17360
diff
changeset
|
1821 | return menuitem; |
| 12919 | 1822 | } |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1823 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1824 | #if GTK_CHECK_VERSION(2,3,0) |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1825 | # define NEW_STYLE_COMPLETION |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1826 | #endif |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1827 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1828 | typedef struct |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1829 | { |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1830 | GtkWidget *entry; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1831 | GtkWidget *accountopt; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1832 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1833 | PidginFilterBuddyCompletionEntryFunc filter_func; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1834 | gpointer filter_func_user_data; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1835 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1836 | #ifdef NEW_STYLE_COMPLETION |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1837 | GtkListStore *store; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1838 | #else |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1839 | GCompletion *completion; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1840 | gboolean completion_started; |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1841 | GList *log_items; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1842 | #endif /* NEW_STYLE_COMPLETION */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
1843 | } PidginCompletionData; |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1844 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1845 | #ifndef NEW_STYLE_COMPLETION |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1846 | static gboolean |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1847 | completion_entry_event(GtkEditable *entry, GdkEventKey *event, |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
1848 | PidginCompletionData *data) |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1849 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1850 | int pos, end_pos; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1851 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1852 | if (event->type == GDK_KEY_PRESS && event->keyval == GDK_Tab) |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1853 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1854 | gtk_editable_get_selection_bounds(entry, &pos, &end_pos); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1855 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1856 | if (data->completion_started && |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1857 | pos != end_pos && pos > 1 && |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1858 | end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1859 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1860 | gtk_editable_select_region(entry, 0, 0); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1861 | gtk_editable_set_position(entry, -1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1862 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1863 | return TRUE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1864 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1865 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1866 | else if (event->type == GDK_KEY_PRESS && event->length > 0) |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1867 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1868 | char *prefix, *nprefix; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1869 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1870 | gtk_editable_get_selection_bounds(entry, &pos, &end_pos); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1871 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1872 | if (data->completion_started && |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1873 | pos != end_pos && pos > 1 && |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1874 | end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1875 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1876 | char *temp; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1877 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1878 | temp = gtk_editable_get_chars(entry, 0, pos); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1879 | prefix = g_strconcat(temp, event->string, NULL); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1880 | g_free(temp); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1881 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1882 | else if (pos == end_pos && pos > 1 && |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1883 | end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1884 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1885 | prefix = g_strconcat(gtk_entry_get_text(GTK_ENTRY(entry)), |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1886 | event->string, NULL); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1887 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1888 | else |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1889 | return FALSE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1890 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1891 | pos = strlen(prefix); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1892 | nprefix = NULL; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1893 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1894 | g_completion_complete(data->completion, prefix, &nprefix); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1895 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1896 | if (nprefix != NULL) |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1897 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1898 | gtk_entry_set_text(GTK_ENTRY(entry), nprefix); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1899 | gtk_editable_set_position(entry, pos); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1900 | gtk_editable_select_region(entry, pos, -1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1901 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1902 | data->completion_started = TRUE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1903 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1904 | g_free(nprefix); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1905 | g_free(prefix); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1906 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1907 | return TRUE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1908 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1909 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1910 | g_free(prefix); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1911 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1912 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1913 | return FALSE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1914 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1915 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1916 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
1917 | destroy_completion_data(GtkWidget *w, PidginCompletionData *data) |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1918 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1919 | g_list_foreach(data->completion->items, (GFunc)g_free, NULL); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1920 | g_completion_free(data->completion); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1921 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1922 | g_free(data); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1923 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1924 | #endif /* !NEW_STYLE_COMPLETION */ |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1925 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1926 | #ifdef NEW_STYLE_COMPLETION |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1927 | static gboolean screenname_completion_match_func(GtkEntryCompletion *completion, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1928 | const gchar *key, GtkTreeIter *iter, gpointer user_data) |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1929 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1930 | GtkTreeModel *model; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1931 | GValue val1; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1932 | GValue val2; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1933 | const char *tmp; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1934 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1935 | model = gtk_entry_completion_get_model (completion); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1936 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1937 | val1.g_type = 0; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1938 | gtk_tree_model_get_value(model, iter, 2, &val1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1939 | tmp = g_value_get_string(&val1); |
| 15884 | 1940 | if (tmp != NULL && purple_str_has_prefix(tmp, key)) |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1941 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1942 | g_value_unset(&val1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1943 | return TRUE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1944 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1945 | g_value_unset(&val1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1946 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1947 | val2.g_type = 0; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1948 | gtk_tree_model_get_value(model, iter, 3, &val2); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1949 | tmp = g_value_get_string(&val2); |
| 15884 | 1950 | if (tmp != NULL && purple_str_has_prefix(tmp, key)) |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1951 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1952 | g_value_unset(&val2); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1953 | return TRUE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1954 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1955 | g_value_unset(&val2); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1956 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1957 | return FALSE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1958 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1959 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1960 | static gboolean screenname_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
|
1961 | GtkTreeModel *model, GtkTreeIter *iter, PidginCompletionData *data) |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1962 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1963 | GValue val; |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1964 | GtkWidget *optmenu = data->accountopt; |
| 15884 | 1965 | PurpleAccount *account; |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1966 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1967 | val.g_type = 0; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1968 | gtk_tree_model_get_value(model, iter, 1, &val); |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
1969 | 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
|
1970 | g_value_unset(&val); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1971 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1972 | gtk_tree_model_get_value(model, iter, 4, &val); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1973 | account = g_value_get_pointer(&val); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1974 | g_value_unset(&val); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1975 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1976 | if (account == NULL) |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1977 | return TRUE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1978 | |
| 17117 | 1979 | 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
|
1980 | aop_option_menu_select_by_data(optmenu, account); |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1981 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1982 | return TRUE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1983 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1984 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1985 | static void |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1986 | add_screenname_autocomplete_entry(GtkListStore *store, const char *buddy_alias, const char *contact_alias, |
| 15884 | 1987 | const PurpleAccount *account, const char *screenname) |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1988 | { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1989 | GtkTreeIter iter; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1990 | gboolean completion_added = FALSE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1991 | gchar *normalized_screenname; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1992 | gchar *tmp; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1993 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1994 | tmp = g_utf8_normalize(screenname, -1, G_NORMALIZE_DEFAULT); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1995 | normalized_screenname = g_utf8_casefold(tmp, -1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1996 | g_free(tmp); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1997 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1998 | /* There's no sense listing things like: 'xxx "xxx"' |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
1999 | when the screenname and buddy alias match. */ |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2000 | if (buddy_alias && strcmp(buddy_alias, screenname)) { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2001 | char *completion_entry = g_strdup_printf("%s \"%s\"", screenname, buddy_alias); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2002 | 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
|
2003 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2004 | tmp = g_utf8_casefold(tmp2, -1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2005 | g_free(tmp2); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2006 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2007 | gtk_list_store_append(store, &iter); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2008 | gtk_list_store_set(store, &iter, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2009 | 0, completion_entry, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2010 | 1, screenname, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2011 | 2, normalized_screenname, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2012 | 3, tmp, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2013 | 4, account, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2014 | -1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2015 | g_free(completion_entry); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2016 | g_free(tmp); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2017 | completion_added = TRUE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2018 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2019 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2020 | /* There's no sense listing things like: 'xxx "xxx"' |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2021 | when the screenname and contact alias match. */ |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2022 | if (contact_alias && strcmp(contact_alias, screenname)) { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2023 | /* We don't want duplicates when the contact and buddy alias match. */ |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2024 | if (!buddy_alias || strcmp(contact_alias, buddy_alias)) { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2025 | char *completion_entry = g_strdup_printf("%s \"%s\"", |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2026 | screenname, contact_alias); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2027 | 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
|
2028 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2029 | tmp = g_utf8_casefold(tmp2, -1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2030 | g_free(tmp2); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2031 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2032 | gtk_list_store_append(store, &iter); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2033 | gtk_list_store_set(store, &iter, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2034 | 0, completion_entry, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2035 | 1, screenname, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2036 | 2, normalized_screenname, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2037 | 3, tmp, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2038 | 4, account, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2039 | -1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2040 | g_free(completion_entry); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2041 | g_free(tmp); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2042 | completion_added = TRUE; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2043 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2044 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2045 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2046 | if (completion_added == FALSE) { |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2047 | /* Add the buddy's screenname. */ |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2048 | gtk_list_store_append(store, &iter); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2049 | gtk_list_store_set(store, &iter, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2050 | 0, screenname, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2051 | 1, screenname, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2052 | 2, normalized_screenname, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2053 | 3, NULL, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2054 | 4, account, |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2055 | -1); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2056 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2057 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2058 | g_free(normalized_screenname); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2059 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2060 | #endif /* NEW_STYLE_COMPLETION */ |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2061 | |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2062 | static void get_log_set_name(PurpleLogSet *set, gpointer value, PidginCompletionData *data) |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2063 | { |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2064 | 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
|
2065 | gpointer user_data = data->filter_func_user_data; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2066 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2067 | /* 1. Don't show buddies because we will have gotten them already. |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2068 | * 2. The boxes that use this autocomplete code handle only IMs. */ |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2069 | if (!set->buddy && set->type == PURPLE_LOG_IM) { |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2070 | PidginBuddyCompletionEntry entry; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2071 | entry.is_buddy = FALSE; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2072 | entry.entry.logged_buddy = set; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2073 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2074 | if (filter_func(&entry, user_data)) { |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2075 | #ifdef NEW_STYLE_COMPLETION |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2076 | add_screenname_autocomplete_entry(data->store, |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2077 | NULL, NULL, set->account, set->name); |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2078 | #else |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2079 | /* Steal the name for the GCompletion. */ |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2080 | data->log_items = g_list_append(data->log_items, set->name); |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2081 | set->name = set->normalized_name = NULL; |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2082 | #endif /* NEW_STYLE_COMPLETION */ |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2083 | } |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2084 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2085 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2086 | |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2087 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
2088 | add_completion_list(PidginCompletionData *data) |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2089 | { |
| 15884 | 2090 | PurpleBlistNode *gnode, *cnode, *bnode; |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2091 | 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
|
2092 | gpointer user_data = data->filter_func_user_data; |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2093 | GHashTable *sets; |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2094 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2095 | #ifdef NEW_STYLE_COMPLETION |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2096 | gtk_list_store_clear(data->store); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2097 | #else |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2098 | GList *item = g_list_append(NULL, NULL); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2099 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2100 | g_list_foreach(data->completion->items, (GFunc)g_free, NULL); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2101 | g_completion_clear_items(data->completion); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2102 | #endif /* NEW_STYLE_COMPLETION */ |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2103 | |
| 15884 | 2104 | for (gnode = purple_get_blist()->root; gnode != NULL; gnode = gnode->next) |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2105 | { |
| 15884 | 2106 | if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2107 | continue; |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2108 | |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2109 | for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2110 | { |
| 15884 | 2111 | if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2112 | continue; |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2113 | |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2114 | for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2115 | { |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2116 | PidginBuddyCompletionEntry entry; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2117 | entry.is_buddy = TRUE; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2118 | entry.entry.buddy = (PurpleBuddy *) bnode; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2119 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2120 | if (filter_func(&entry, user_data)) { |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2121 | #ifdef NEW_STYLE_COMPLETION |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2122 | add_screenname_autocomplete_entry(data->store, |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2123 | ((PurpleContact *)cnode)->alias, |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2124 | purple_buddy_get_contact_alias(entry.entry.buddy), |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2125 | entry.entry.buddy->account, |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2126 | entry.entry.buddy->name |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2127 | ); |
|
19123
baad98c70da0
Patch from Gabriel Schulhof to compile with old versions of glib.
Mark Doliner <markdoliner@pidgin.im>
parents:
18966
diff
changeset
|
2128 | #else |
|
baad98c70da0
Patch from Gabriel Schulhof to compile with old versions of glib.
Mark Doliner <markdoliner@pidgin.im>
parents:
18966
diff
changeset
|
2129 | item->data = g_strdup(entry.entry.buddy->name); |
|
baad98c70da0
Patch from Gabriel Schulhof to compile with old versions of glib.
Mark Doliner <markdoliner@pidgin.im>
parents:
18966
diff
changeset
|
2130 | g_completion_add_items(data->completion, item); |
|
baad98c70da0
Patch from Gabriel Schulhof to compile with old versions of glib.
Mark Doliner <markdoliner@pidgin.im>
parents:
18966
diff
changeset
|
2131 | #endif /* NEW_STYLE_COMPLETION */ |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2132 | } |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2133 | } |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2134 | } |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2135 | } |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2136 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2137 | #ifndef NEW_STYLE_COMPLETION |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2138 | g_list_free(item); |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2139 | data->log_items = NULL; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2140 | #endif /* NEW_STYLE_COMPLETION */ |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2141 | |
| 15884 | 2142 | sets = purple_log_get_log_sets(); |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2143 | g_hash_table_foreach(sets, (GHFunc)get_log_set_name, data); |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2144 | g_hash_table_destroy(sets); |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2145 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2146 | #ifndef NEW_STYLE_COMPLETION |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2147 | g_completion_add_items(data->completion, data->log_items); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2148 | g_list_free(data->log_items); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2149 | #endif /* NEW_STYLE_COMPLETION */ |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2150 | } |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2151 | |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2152 | static void |
|
13367
c05a832cf9cb
[gaim-migrate @ 15739]
Richard Laager <rlaager@pidgin.im>
parents:
13366
diff
changeset
|
2153 | screenname_autocomplete_destroyed_cb(GtkWidget *widget, gpointer data) |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2154 | { |
|
17707
b5f042209c68
Unleak a few bytes in the screenname completion code
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17605
diff
changeset
|
2155 | g_free(data); |
| 15884 | 2156 | purple_signals_disconnect_by_handle(widget); |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2157 | } |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2158 | |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2159 | static void |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2160 | repopulate_autocomplete(gpointer something, gpointer data) |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2161 | { |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2162 | add_completion_list(data); |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2163 | } |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2164 | |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2165 | |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2166 | void |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2167 | pidgin_setup_screenname_autocomplete_with_filter(GtkWidget *entry, GtkWidget *accountopt, PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data) |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2168 | { |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2169 | PidginCompletionData *data; |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2170 | |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2171 | #ifdef NEW_STYLE_COMPLETION |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2172 | /* Store the displayed completion value, the screenname, the UTF-8 normalized & casefolded screenname, |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2173 | * the UTF-8 normalized & casefolded value for comparison, and the account. */ |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2174 | GtkListStore *store; |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2175 | |
|
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2176 | GtkEntryCompletion *completion; |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2177 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2178 | data = g_new0(PidginCompletionData, 1); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2179 | store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2180 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2181 | data->entry = entry; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2182 | data->accountopt = accountopt; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2183 | if (filter_func == NULL) { |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2184 | 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
|
2185 | 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
|
2186 | } else { |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2187 | data->filter_func = filter_func; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2188 | 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
|
2189 | } |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2190 | data->store = store; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2191 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2192 | add_completion_list(data); |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2193 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2194 | /* Sort the completion list by screenname. */ |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2195 | gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2196 | 1, GTK_SORT_ASCENDING); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2197 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2198 | completion = gtk_entry_completion_new(); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2199 | gtk_entry_completion_set_match_func(completion, screenname_completion_match_func, NULL, NULL); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2200 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2201 | g_signal_connect(G_OBJECT(completion), "match-selected", |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2202 | G_CALLBACK(screenname_completion_match_selected_cb), data); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2203 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2204 | gtk_entry_set_completion(GTK_ENTRY(entry), completion); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2205 | g_object_unref(completion); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2206 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2207 | gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2208 | g_object_unref(store); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2209 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2210 | gtk_entry_completion_set_text_column(completion, 0); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2211 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2212 | #else /* !NEW_STYLE_COMPLETION */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
2213 | |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
2214 | data = g_new0(PidginCompletionData, 1); |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2215 | |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2216 | data->entry = entry; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2217 | data->accountopt = accountopt; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2218 | if (filter_func == NULL) { |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2219 | 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
|
2220 | 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
|
2221 | } else { |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2222 | data->filter_func = filter_func; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2223 | 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
|
2224 | } |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2225 | data->completion = g_completion_new(NULL); |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2226 | data->completion_started = FALSE; |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2227 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2228 | add_completion_list(data); |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2229 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2230 | g_completion_set_compare(data->completion, g_ascii_strncasecmp); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2231 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2232 | g_signal_connect(G_OBJECT(entry), "event", |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2233 | G_CALLBACK(completion_entry_event), data); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2234 | g_signal_connect(G_OBJECT(entry), "destroy", |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2235 | G_CALLBACK(destroy_completion_data), data); |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2236 | |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2237 | #endif /* !NEW_STYLE_COMPLETION */ |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2238 | |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2239 | 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
|
2240 | PURPLE_CALLBACK(repopulate_autocomplete), data); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2241 | 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
|
2242 | PURPLE_CALLBACK(repopulate_autocomplete), data); |
|
13366
e01cf252b407
[gaim-migrate @ 15738]
Richard Laager <rlaager@pidgin.im>
parents:
13365
diff
changeset
|
2243 | |
| 15884 | 2244 | 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
|
2245 | PURPLE_CALLBACK(repopulate_autocomplete), data); |
| 15884 | 2246 | 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
|
2247 | PURPLE_CALLBACK(repopulate_autocomplete), data); |
|
13365
8e6ae65497ef
[gaim-migrate @ 15737]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13361
diff
changeset
|
2248 | |
|
17707
b5f042209c68
Unleak a few bytes in the screenname completion code
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17605
diff
changeset
|
2249 | g_signal_connect(G_OBJECT(entry), "destroy", G_CALLBACK(screenname_autocomplete_destroyed_cb), data); |
|
13361
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2250 | } |
|
bb2f64cf6721
[gaim-migrate @ 15733]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13281
diff
changeset
|
2251 | |
|
18966
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2252 | gboolean |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2253 | 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
|
2254 | 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
|
2255 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2256 | if (completion_entry->is_buddy) { |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2257 | return all || purple_account_is_connected(completion_entry->entry.buddy->account); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2258 | } else { |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2259 | return all || (completion_entry->entry.logged_buddy->account != NULL && purple_account_is_connected(completion_entry->entry.logged_buddy->account)); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2260 | } |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2261 | } |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2262 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2263 | void |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2264 | pidgin_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *accountopt, gboolean all) { |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2265 | pidgin_setup_screenname_autocomplete_with_filter(entry, accountopt, pidgin_screenname_autocomplete_default_filter, GINT_TO_POINTER(all)); |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2266 | } |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2267 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2268 | |
|
6a0715b72b6b
Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@pidgin.im>
parents:
18941
diff
changeset
|
2269 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
2270 | void pidgin_set_cursor(GtkWidget *widget, GdkCursorType cursor_type) |
|
13435
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2271 | { |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2272 | GdkCursor *cursor; |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2273 | |
|
13470
5550131ec50b
[gaim-migrate @ 15845]
Richard Laager <rlaager@pidgin.im>
parents:
13435
diff
changeset
|
2274 | g_return_if_fail(widget != NULL); |
|
5550131ec50b
[gaim-migrate @ 15845]
Richard Laager <rlaager@pidgin.im>
parents:
13435
diff
changeset
|
2275 | if (widget->window == NULL) |
|
13435
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2276 | return; |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2277 | |
|
22787
18842b6fda42
Use the desired cursor, instead of always using GDK_WATCH.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22702
diff
changeset
|
2278 | cursor = gdk_cursor_new(cursor_type); |
|
13435
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2279 | gdk_window_set_cursor(widget->window, cursor); |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2280 | gdk_cursor_unref(cursor); |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2281 | |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2282 | #if GTK_CHECK_VERSION(2,4,0) |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2283 | gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window))); |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2284 | #else |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2285 | gdk_flush(); |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2286 | #endif |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2287 | } |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2288 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
2289 | void pidgin_clear_cursor(GtkWidget *widget) |
|
13435
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2290 | { |
|
13470
5550131ec50b
[gaim-migrate @ 15845]
Richard Laager <rlaager@pidgin.im>
parents:
13435
diff
changeset
|
2291 | g_return_if_fail(widget != NULL); |
|
5550131ec50b
[gaim-migrate @ 15845]
Richard Laager <rlaager@pidgin.im>
parents:
13435
diff
changeset
|
2292 | if (widget->window == NULL) |
|
13435
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2293 | return; |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2294 | |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2295 | gdk_window_set_cursor(widget->window, NULL); |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2296 | } |
|
4c22eed6e0a6
[gaim-migrate @ 15809]
Richard Laager <rlaager@pidgin.im>
parents:
13372
diff
changeset
|
2297 | |
| 14195 | 2298 | struct _icon_chooser { |
| 2299 | GtkWidget *icon_filesel; | |
| 2300 | GtkWidget *icon_preview; | |
| 2301 | GtkWidget *icon_text; | |
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2302 | |
| 14195 | 2303 | void (*callback)(const char*,gpointer); |
| 2304 | gpointer data; | |
| 2305 | }; | |
| 2306 | ||
| 2307 | #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
| 2308 | static void | |
| 2309 | icon_filesel_delete_cb(GtkWidget *w, struct _icon_chooser *dialog) | |
| 2310 | { | |
| 2311 | if (dialog->icon_filesel != NULL) | |
| 2312 | gtk_widget_destroy(dialog->icon_filesel); | |
| 2313 | ||
| 2314 | if (dialog->callback) | |
|
14290
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2315 | dialog->callback(NULL, dialog->data); |
| 14195 | 2316 | |
| 2317 | g_free(dialog); | |
| 2318 | } | |
| 2319 | #endif /* FILECHOOSER */ | |
| 2320 | ||
| 2321 | ||
| 2322 | ||
| 2323 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
| 2324 | static void | |
| 2325 | icon_filesel_choose_cb(GtkWidget *widget, gint response, struct _icon_chooser *dialog) | |
| 2326 | { | |
| 2327 | char *filename, *current_folder; | |
| 2328 | ||
| 2329 | if (response != GTK_RESPONSE_ACCEPT) { | |
| 2330 | if (response == GTK_RESPONSE_CANCEL) { | |
| 2331 | gtk_widget_destroy(dialog->icon_filesel); | |
| 2332 | } | |
| 2333 | dialog->icon_filesel = NULL; | |
| 2334 | if (dialog->callback) | |
| 2335 | dialog->callback(NULL, dialog->data); | |
| 2336 | g_free(dialog); | |
| 2337 | return; | |
| 2338 | } | |
| 2339 | ||
| 2340 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel)); | |
| 2341 | current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel)); | |
| 2342 | 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
|
2343 | purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder", current_folder); |
| 14195 | 2344 | g_free(current_folder); |
| 2345 | } | |
| 2346 | ||
| 2347 | #else /* FILECHOOSER */ | |
| 2348 | static void | |
|
14290
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2349 | icon_filesel_choose_cb(GtkWidget *w, struct _icon_chooser *dialog) |
| 14195 | 2350 | { |
| 2351 | char *filename, *current_folder; | |
| 2352 | ||
| 2353 | filename = g_strdup(gtk_file_selection_get_filename( | |
| 2354 | GTK_FILE_SELECTION(dialog->icon_filesel))); | |
| 2355 | ||
| 2356 | /* If they typed in a directory, change there */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
2357 | if (pidgin_check_if_dir(filename, |
| 14195 | 2358 | GTK_FILE_SELECTION(dialog->icon_filesel))) |
| 2359 | { | |
| 2360 | g_free(filename); | |
| 2361 | return; | |
| 2362 | } | |
| 2363 | ||
| 2364 | current_folder = g_path_get_dirname(filename); | |
| 2365 | 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
|
2366 | purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder", current_folder); |
| 14195 | 2367 | g_free(current_folder); |
| 2368 | } | |
| 2369 | ||
| 2370 | #endif /* FILECHOOSER */ | |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21975
diff
changeset
|
2371 | #if 0 /* mismatched curly braces */ |
|
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21975
diff
changeset
|
2372 | } |
|
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21975
diff
changeset
|
2373 | #endif |
| 14195 | 2374 | if (dialog->callback) |
| 2375 | dialog->callback(filename, dialog->data); | |
| 2376 | gtk_widget_destroy(dialog->icon_filesel); | |
| 2377 | g_free(filename); | |
| 2378 | g_free(dialog); | |
| 2379 | } | |
| 2380 | ||
| 2381 | ||
| 2382 | static void | |
| 2383 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
| 2384 | icon_preview_change_cb(GtkFileChooser *widget, struct _icon_chooser *dialog) | |
| 2385 | #else /* FILECHOOSER */ | |
| 2386 | icon_preview_change_cb(GtkTreeSelection *sel, struct _icon_chooser *dialog) | |
| 2387 | #endif /* FILECHOOSER */ | |
| 2388 | { | |
| 2389 | GdkPixbuf *pixbuf, *scale; | |
| 2390 | int height, width; | |
| 2391 | char *basename, *markup, *size; | |
| 2392 | struct stat st; | |
| 2393 | char *filename; | |
| 2394 | ||
| 2395 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
| 2396 | filename = gtk_file_chooser_get_preview_filename( | |
| 2397 | GTK_FILE_CHOOSER(dialog->icon_filesel)); | |
| 2398 | #else /* FILECHOOSER */ | |
| 2399 | filename = g_strdup(gtk_file_selection_get_filename( | |
| 2400 | GTK_FILE_SELECTION(dialog->icon_filesel))); | |
| 2401 | #endif /* FILECHOOSER */ | |
| 2402 | ||
|
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
|
2403 | if (!filename || g_stat(filename, &st) || !(pixbuf = gdk_pixbuf_new_from_file(filename, NULL))) |
| 14195 | 2404 | { |
| 2405 | gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL); | |
| 2406 | gtk_label_set_markup(GTK_LABEL(dialog->icon_text), ""); | |
| 2407 | g_free(filename); | |
| 2408 | return; | |
| 2409 | } | |
| 2410 | ||
| 2411 | width = gdk_pixbuf_get_width(pixbuf); | |
| 2412 | height = gdk_pixbuf_get_height(pixbuf); | |
| 2413 | basename = g_path_get_basename(filename); | |
| 15884 | 2414 | size = purple_str_size_to_units(st.st_size); |
| 14195 | 2415 | markup = g_strdup_printf(_("<b>File:</b> %s\n" |
| 2416 | "<b>File size:</b> %s\n" | |
| 2417 | "<b>Image size:</b> %dx%d"), | |
| 2418 | basename, size, width, height); | |
| 2419 | ||
| 2420 | scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height, | |
| 2421 | 50, GDK_INTERP_BILINEAR); | |
| 2422 | gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), scale); | |
| 2423 | gtk_label_set_markup(GTK_LABEL(dialog->icon_text), markup); | |
| 2424 | ||
| 2425 | g_object_unref(G_OBJECT(pixbuf)); | |
| 2426 | g_object_unref(G_OBJECT(scale)); | |
| 2427 | g_free(filename); | |
| 2428 | g_free(basename); | |
| 2429 | g_free(size); | |
| 2430 | g_free(markup); | |
| 2431 | } | |
| 2432 | ||
| 2433 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
2434 | GtkWidget *pidgin_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data) { |
| 14195 | 2435 | struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1); |
| 2436 | ||
|
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
|
2437 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
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
|
2438 | GtkWidget *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
|
2439 | #else |
| 14195 | 2440 | GtkWidget *hbox; |
| 2441 | GtkWidget *tv; | |
| 2442 | GtkTreeSelection *sel; | |
| 2443 | #endif /* FILECHOOSER */ | |
| 2444 | const char *current_folder; | |
| 2445 | ||
| 2446 | dialog->callback = callback; | |
| 2447 | dialog->data = data; | |
| 2448 | ||
| 2449 | if (dialog->icon_filesel != NULL) { | |
| 2450 | gtk_window_present(GTK_WINDOW(dialog->icon_filesel)); | |
| 2451 | return NULL; | |
| 2452 | } | |
| 2453 | ||
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16071
diff
changeset
|
2454 | current_folder = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder"); |
| 14195 | 2455 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
| 2456 | ||
| 2457 | dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"), | |
| 2458 | parent, | |
| 2459 | GTK_FILE_CHOOSER_ACTION_OPEN, | |
| 2460 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
| 2461 | GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | |
| 2462 | NULL); | |
| 2463 | gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT); | |
| 2464 | if ((current_folder != NULL) && (*current_folder != '\0')) | |
| 2465 | gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel), | |
| 2466 | current_folder); | |
| 2467 | ||
| 2468 | dialog->icon_preview = gtk_image_new(); | |
| 2469 | 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
|
2470 | |
|
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
|
2471 | vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
|
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
|
2472 | 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
|
2473 | 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
|
2474 | 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
|
2475 | 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
|
2476 | |
|
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
|
2477 | 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
|
2478 | 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
|
2479 | 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
|
2480 | |
| 14195 | 2481 | g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview", |
| 2482 | G_CALLBACK(icon_preview_change_cb), dialog); | |
| 2483 | g_signal_connect(G_OBJECT(dialog->icon_filesel), "response", | |
| 2484 | G_CALLBACK(icon_filesel_choose_cb), dialog); | |
| 2485 | icon_preview_change_cb(NULL, dialog); | |
| 2486 | #else /* FILECHOOSER */ | |
| 2487 | dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon")); | |
| 2488 | dialog->icon_preview = gtk_image_new(); | |
| 2489 | dialog->icon_text = gtk_label_new(NULL); | |
| 2490 | if ((current_folder != NULL) && (*current_folder != '\0')) | |
| 2491 | gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->icon_filesel), | |
| 2492 | current_folder); | |
| 2493 | ||
|
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
|
2494 | gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview),-1, 50); |
| 15882 | 2495 | hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
| 14195 | 2496 | gtk_box_pack_start( |
| 2497 | GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox), | |
| 2498 | hbox, FALSE, FALSE, 0); | |
| 2499 | gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_preview, | |
| 2500 | FALSE, FALSE, 0); | |
| 2501 | gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_text, FALSE, FALSE, 0); | |
| 2502 | ||
| 2503 | tv = GTK_FILE_SELECTION(dialog->icon_filesel)->file_list; | |
| 2504 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
| 2505 | ||
| 2506 | g_signal_connect(G_OBJECT(sel), "changed", | |
| 2507 | G_CALLBACK(icon_preview_change_cb), dialog); | |
| 2508 | g_signal_connect( | |
| 2509 | G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->ok_button), | |
| 2510 | "clicked", | |
| 2511 | G_CALLBACK(icon_filesel_choose_cb), dialog); | |
| 2512 | g_signal_connect( | |
| 2513 | G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->cancel_button), | |
| 2514 | "clicked", | |
| 2515 | G_CALLBACK(icon_filesel_delete_cb), dialog); | |
| 2516 | g_signal_connect(G_OBJECT(dialog->icon_filesel), "destroy", | |
| 2517 | G_CALLBACK(icon_filesel_delete_cb), dialog); | |
| 2518 | #endif /* FILECHOOSER */ | |
|
21729
a06176e84f3a
applied changes from 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
2519 | |
|
a06176e84f3a
applied changes from 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
2520 | #ifdef _WIN32 |
|
a06176e84f3a
applied changes from 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
2521 | g_signal_connect(G_OBJECT(dialog->icon_filesel), "show", |
|
a06176e84f3a
applied changes from 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
2522 | G_CALLBACK(winpidgin_ensure_onscreen), dialog->icon_filesel); |
|
a06176e84f3a
applied changes from 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
2523 | #endif |
|
a06176e84f3a
applied changes from 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
2524 | |
|
a06176e84f3a
applied changes from 6546cfd72ecd9aa76fc524aaf3ac48489aeb2a90
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
2525 | return dialog->icon_filesel; |
| 14195 | 2526 | } |
| 2527 | ||
| 2528 | ||
| 2529 | #if GTK_CHECK_VERSION(2,2,0) | |
| 2530 | static gboolean | |
| 2531 | str_array_match(char **a, char **b) | |
| 2532 | { | |
| 2533 | int i, j; | |
| 2534 | ||
| 2535 | if (!a || !b) | |
| 2536 | return FALSE; | |
| 2537 | for (i = 0; a[i] != NULL; i++) | |
| 2538 | for (j = 0; b[j] != NULL; j++) | |
| 2539 | if (!g_ascii_strcasecmp(a[i], b[j])) | |
| 2540 | return TRUE; | |
| 2541 | return FALSE; | |
| 2542 | } | |
| 2543 | #endif | |
| 2544 | ||
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2545 | gpointer |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2546 | pidgin_convert_buddy_icon(PurplePlugin *plugin, const char *path, size_t *len) |
| 14195 | 2547 | { |
| 15884 | 2548 | PurplePluginProtocolInfo *prpl_info; |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2549 | #if GTK_CHECK_VERSION(2,2,0) |
|
14720
6751e3e9c5bf
[gaim-migrate @ 17404]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14717
diff
changeset
|
2550 | char **prpl_formats; |
| 14195 | 2551 | int width, height; |
| 2552 | char **pixbuf_formats = NULL; | |
| 2553 | GdkPixbufFormat *format; | |
| 2554 | GdkPixbuf *pixbuf; | |
| 2555 | #if !GTK_CHECK_VERSION(2,4,0) | |
| 2556 | GdkPixbufLoader *loader; | |
| 2557 | #endif | |
| 2558 | #endif | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15254
diff
changeset
|
2559 | gchar *contents; |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15254
diff
changeset
|
2560 | gsize length; |
|
14203
f3a50c328ddc
[gaim-migrate @ 16783]
Mark Doliner <markdoliner@pidgin.im>
parents:
14196
diff
changeset
|
2561 | |
| 15884 | 2562 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
|
14203
f3a50c328ddc
[gaim-migrate @ 16783]
Mark Doliner <markdoliner@pidgin.im>
parents:
14196
diff
changeset
|
2563 | |
|
f3a50c328ddc
[gaim-migrate @ 16783]
Mark Doliner <markdoliner@pidgin.im>
parents:
14196
diff
changeset
|
2564 | g_return_val_if_fail(prpl_info->icon_spec.format != NULL, NULL); |
|
f3a50c328ddc
[gaim-migrate @ 16783]
Mark Doliner <markdoliner@pidgin.im>
parents:
14196
diff
changeset
|
2565 | |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2566 | |
| 14195 | 2567 | #if GTK_CHECK_VERSION(2,2,0) |
| 2568 | #if GTK_CHECK_VERSION(2,4,0) | |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2569 | format = gdk_pixbuf_get_file_info(path, &width, &height); |
| 14195 | 2570 | #else |
| 2571 | loader = gdk_pixbuf_loader_new(); | |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15254
diff
changeset
|
2572 | if (g_file_get_contents(path, &contents, &length, NULL)) { |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15254
diff
changeset
|
2573 | gdk_pixbuf_loader_write(loader, contents, length, NULL); |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15254
diff
changeset
|
2574 | g_free(contents); |
| 14195 | 2575 | } |
| 2576 | gdk_pixbuf_loader_close(loader, NULL); | |
| 2577 | pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); | |
| 2578 | width = gdk_pixbuf_get_width(pixbuf); | |
| 2579 | height = gdk_pixbuf_get_height(pixbuf); | |
| 2580 | format = gdk_pixbuf_loader_get_format(loader); | |
| 2581 | g_object_unref(G_OBJECT(loader)); | |
| 2582 | #endif | |
|
14206
5a17eb1a2c3e
[gaim-migrate @ 16786]
Mark Doliner <markdoliner@pidgin.im>
parents:
14203
diff
changeset
|
2583 | if (format == NULL) |
|
5a17eb1a2c3e
[gaim-migrate @ 16786]
Mark Doliner <markdoliner@pidgin.im>
parents:
14203
diff
changeset
|
2584 | return NULL; |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2585 | |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2586 | pixbuf_formats = gdk_pixbuf_format_get_extensions(format); |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2587 | prpl_formats = g_strsplit(prpl_info->icon_spec.format,",",0); |
| 14195 | 2588 | if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */ |
| 15884 | 2589 | (!(prpl_info->icon_spec.scale_rules & PURPLE_ICON_SCALE_SEND) || /* The prpl doesn't scale before it sends OR */ |
| 14195 | 2590 | (prpl_info->icon_spec.min_width <= width && |
| 2591 | prpl_info->icon_spec.max_width >= width && | |
| 2592 | prpl_info->icon_spec.min_height <= height && | |
| 2593 | prpl_info->icon_spec.max_height >= height))) /* The icon is the correct size */ | |
| 2594 | #endif | |
| 2595 | { | |
| 2596 | #if GTK_CHECK_VERSION(2,2,0) | |
| 2597 | g_strfreev(prpl_formats); | |
| 2598 | g_strfreev(pixbuf_formats); | |
| 2599 | #endif | |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2600 | /* We don't need to scale the image. */ |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15254
diff
changeset
|
2601 | |
|
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15254
diff
changeset
|
2602 | contents = NULL; |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2603 | if (!g_file_get_contents(path, &contents, &length, NULL)) |
| 14195 | 2604 | { |
|
15284
98e8f9912107
[gaim-migrate @ 18012]
Mark Doliner <markdoliner@pidgin.im>
parents:
15254
diff
changeset
|
2605 | g_free(contents); |
| 14195 | 2606 | #if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2607 | g_object_unref(G_OBJECT(pixbuf)); |
| 14195 | 2608 | #endif |
| 2609 | return NULL; | |
| 2610 | } | |
| 2611 | } | |
| 2612 | #if GTK_CHECK_VERSION(2,2,0) | |
| 2613 | else | |
| 2614 | { | |
| 2615 | int i; | |
| 2616 | GError *error = NULL; | |
| 2617 | GdkPixbuf *scale; | |
|
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
|
2618 | gboolean success = FALSE; |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2619 | char *filename = NULL; |
|
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
|
2620 | |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2621 | g_strfreev(pixbuf_formats); |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2622 | |
| 14195 | 2623 | pixbuf = gdk_pixbuf_new_from_file(path, &error); |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2624 | if (error) { |
| 15884 | 2625 | purple_debug_error("buddyicon", "Could not open icon for conversion: %s\n", error->message); |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2626 | g_error_free(error); |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2627 | g_strfreev(prpl_formats); |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2628 | return NULL; |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2629 | } |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2630 | |
| 15884 | 2631 | if ((prpl_info->icon_spec.scale_rules & PURPLE_ICON_SCALE_SEND) && |
| 14195 | 2632 | (width < prpl_info->icon_spec.min_width || |
| 2633 | width > prpl_info->icon_spec.max_width || | |
| 2634 | height < prpl_info->icon_spec.min_height || | |
| 2635 | height > prpl_info->icon_spec.max_height)) | |
| 2636 | { | |
| 2637 | int new_width = width; | |
| 2638 | int new_height = height; | |
| 2639 | ||
| 15884 | 2640 | purple_buddy_icon_get_scale_size(&prpl_info->icon_spec, &new_width, &new_height); |
| 14195 | 2641 | |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2642 | scale = gdk_pixbuf_scale_simple(pixbuf, new_width, new_height, |
| 14195 | 2643 | GDK_INTERP_HYPER); |
| 2644 | g_object_unref(G_OBJECT(pixbuf)); | |
| 2645 | pixbuf = scale; | |
| 2646 | } | |
| 2647 | ||
| 2648 | for (i = 0; prpl_formats[i]; i++) { | |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2649 | FILE *fp; |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2650 | |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2651 | g_free(filename); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2652 | fp = purple_mkstemp(&filename, TRUE); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2653 | if (!fp) |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2654 | { |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2655 | g_free(filename); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2656 | return NULL; |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2657 | } |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2658 | fclose(fp); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2659 | |
| 15884 | 2660 | purple_debug_info("buddyicon", "Converting buddy icon to %s as %s\n", prpl_formats[i], filename); |
|
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
|
2661 | /* The "compression" param wasn't supported until gdk-pixbuf 2.8. |
|
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
|
2662 | * Using it in previous versions causes the save to fail (and an assert message). */ |
|
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
|
2663 | if ((gdk_pixbuf_major_version > 2 || (gdk_pixbuf_major_version == 2 |
|
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
|
2664 | && gdk_pixbuf_minor_version >= 8)) |
|
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
|
2665 | && strcmp(prpl_formats[i], "png") == 0) { |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2666 | if (gdk_pixbuf_save(pixbuf, filename, prpl_formats[i], |
|
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
|
2667 | &error, "compression", "9", NULL)) { |
|
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
|
2668 | success = TRUE; |
|
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
|
2669 | 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
|
2670 | } |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2671 | } else if (gdk_pixbuf_save(pixbuf, filename, prpl_formats[i], |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2672 | &error, NULL)) { |
|
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
|
2673 | success = TRUE; |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2674 | break; |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2675 | } |
|
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
|
2676 | |
|
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
|
2677 | /* The NULL checking is necessary due to this bug: |
|
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
|
2678 | * http://bugzilla.gnome.org/show_bug.cgi?id=405539 */ |
| 15884 | 2679 | purple_debug_warning("buddyicon", "Could not convert to %s: %s\n", prpl_formats[i], |
|
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
|
2680 | (error && error->message) ? error->message : "Unknown error"); |
| 14195 | 2681 | g_error_free(error); |
| 2682 | error = NULL; | |
| 2683 | } | |
| 2684 | g_strfreev(prpl_formats); | |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2685 | g_object_unref(G_OBJECT(pixbuf)); |
|
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
|
2686 | if (!success) { |
| 15884 | 2687 | purple_debug_error("buddyicon", "Could not convert icon to usable format.\n"); |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2688 | return NULL; |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2689 | } |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2690 | |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2691 | contents = NULL; |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2692 | if (!g_file_get_contents(filename, &contents, &length, NULL)) |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2693 | { |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2694 | purple_debug_error("buddyicon", |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2695 | "Could not read '%s', which we just wrote to disk.\n", |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2696 | filename); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2697 | |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2698 | g_free(contents); |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2699 | g_free(filename); |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2700 | return NULL; |
| 14195 | 2701 | } |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2702 | |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2703 | g_unlink(filename); |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2704 | g_free(filename); |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2705 | } |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2706 | |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2707 | /* Check the image size */ |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2708 | /* |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2709 | * TODO: If the file is too big, it would be cool if we checked if |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2710 | * the prpl supported jpeg, and then we could convert to that |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2711 | * and use a lower quality setting. |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2712 | */ |
|
15302
e220a1a988a3
[gaim-migrate @ 18030]
Mark Doliner <markdoliner@pidgin.im>
parents:
15301
diff
changeset
|
2713 | if ((prpl_info->icon_spec.max_filesize != 0) && |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2714 | (length > prpl_info->icon_spec.max_filesize)) |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2715 | { |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2716 | gchar *tmp; |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2717 | tmp = g_strdup_printf(_("The file '%s' is too large for %s. Please try a smaller image.\n"), |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2718 | path, plugin->info->name); |
| 15884 | 2719 | purple_notify_error(NULL, _("Icon Error"), |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2720 | _("Could not set icon"), tmp); |
| 15884 | 2721 | purple_debug_info("buddyicon", |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2722 | "'%s' was converted to an image which is %" G_GSIZE_FORMAT |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2723 | " bytes, but the maximum icon size for %s is %" G_GSIZE_FORMAT |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2724 | " bytes\n", path, length, plugin->info->name, |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2725 | prpl_info->icon_spec.max_filesize); |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2726 | g_free(tmp); |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2727 | return NULL; |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2728 | } |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2729 | |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2730 | if (len) |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2731 | *len = length; |
|
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2732 | return contents; |
|
15289
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2733 | #else |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2734 | /* |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2735 | * The chosen icon wasn't the right size, and we're using |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2736 | * GTK+ 2.0 so we can't scale it. |
|
2b90dc4e1483
[gaim-migrate @ 18017]
Mark Doliner <markdoliner@pidgin.im>
parents:
15284
diff
changeset
|
2737 | */ |
| 14195 | 2738 | return NULL; |
| 2739 | #endif | |
| 2740 | } | |
|
14290
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2741 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2742 | #if !GTK_CHECK_VERSION(2,6,0) |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2743 | static void |
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2744 | _gdk_file_scale_size_prepared_cb (GdkPixbufLoader *loader, |
|
14290
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2745 | int width, |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2746 | int height, |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2747 | gpointer data) |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2748 | { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2749 | struct { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2750 | gint width; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2751 | gint height; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2752 | gboolean preserve_aspect_ratio; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2753 | } *info = data; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2754 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2755 | g_return_if_fail (width > 0 && height > 0); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2756 | |
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2757 | if (info->preserve_aspect_ratio && |
|
14290
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2758 | (info->width > 0 || info->height > 0)) { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2759 | if (info->width < 0) |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2760 | { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2761 | width = width * (double)info->height/(double)height; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2762 | height = info->height; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2763 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2764 | else if (info->height < 0) |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2765 | { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2766 | height = height * (double)info->width/(double)width; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2767 | width = info->width; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2768 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2769 | else if ((double)height * (double)info->width > |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2770 | (double)width * (double)info->height) { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2771 | width = 0.5 + (double)width * (double)info->height / (double)height; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2772 | height = info->height; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2773 | } else { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2774 | height = 0.5 + (double)height * (double)info->width / (double)width; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2775 | width = info->width; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2776 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2777 | } else { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2778 | if (info->width > 0) |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2779 | width = info->width; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2780 | if (info->height > 0) |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2781 | height = info->height; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2782 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2783 | |
|
14720
6751e3e9c5bf
[gaim-migrate @ 17404]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14717
diff
changeset
|
2784 | #if GTK_CHECK_VERSION(2,2,0) /* 2.0 users are going to have very strangely sized things */ |
|
14290
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2785 | gdk_pixbuf_loader_set_size (loader, width, height); |
|
14720
6751e3e9c5bf
[gaim-migrate @ 17404]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14717
diff
changeset
|
2786 | #else |
|
6751e3e9c5bf
[gaim-migrate @ 17404]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14717
diff
changeset
|
2787 | #warning nosnilmot could not be bothered to fix this properly for you |
|
6751e3e9c5bf
[gaim-migrate @ 17404]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14717
diff
changeset
|
2788 | #warning ... good luck ... your images may end up strange sizes |
|
6751e3e9c5bf
[gaim-migrate @ 17404]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14717
diff
changeset
|
2789 | #endif |
|
14290
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2790 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2791 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2792 | GdkPixbuf * |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2793 | gdk_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2794 | gboolean preserve_aspect_ratio, |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2795 | GError **error) |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2796 | { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2797 | GdkPixbufLoader *loader; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2798 | GdkPixbuf *pixbuf; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2799 | guchar buffer [4096]; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2800 | int length; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2801 | FILE *f; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2802 | struct { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2803 | gint width; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2804 | gint height; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2805 | gboolean preserve_aspect_ratio; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2806 | } info; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2807 | GdkPixbufAnimation *animation; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2808 | GdkPixbufAnimationIter *iter; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2809 | gboolean has_frame; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2810 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2811 | g_return_val_if_fail (filename != NULL, NULL); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2812 | g_return_val_if_fail (width > 0 || width == -1, NULL); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2813 | g_return_val_if_fail (height > 0 || height == -1, NULL); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2814 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2815 | f = g_fopen (filename, "rb"); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2816 | if (!f) { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2817 | gint save_errno = errno; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2818 | gchar *display_name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2819 | g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (save_errno), |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2820 | _("Failed to open file '%s': %s"), |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2821 | display_name ? display_name : "(unknown)", |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2822 | g_strerror (save_errno)); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2823 | g_free (display_name); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2824 | return NULL; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2825 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2826 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2827 | loader = gdk_pixbuf_loader_new (); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2828 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2829 | info.width = width; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2830 | info.height = height; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2831 | info.preserve_aspect_ratio = preserve_aspect_ratio; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2832 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2833 | g_signal_connect (loader, "size-prepared", G_CALLBACK (_gdk_file_scale_size_prepared_cb), &info); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2834 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2835 | has_frame = FALSE; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2836 | while (!has_frame && !feof (f) && !ferror (f)) { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2837 | length = fread (buffer, 1, sizeof (buffer), f); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2838 | if (length > 0) |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2839 | if (!gdk_pixbuf_loader_write (loader, buffer, length, error)) { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2840 | gdk_pixbuf_loader_close (loader, NULL); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2841 | fclose (f); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2842 | g_object_unref (loader); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2843 | return NULL; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2844 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2845 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2846 | animation = gdk_pixbuf_loader_get_animation (loader); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2847 | if (animation) { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2848 | iter = gdk_pixbuf_animation_get_iter (animation, 0); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2849 | if (!gdk_pixbuf_animation_iter_on_currently_loading_frame (iter)) { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2850 | has_frame = TRUE; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2851 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2852 | g_object_unref (iter); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2853 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2854 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2855 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2856 | fclose (f); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2857 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2858 | if (!gdk_pixbuf_loader_close (loader, error) && !has_frame) { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2859 | g_object_unref (loader); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2860 | return NULL; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2861 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2862 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2863 | pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2864 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2865 | if (!pixbuf) { |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2866 | gchar *display_name = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2867 | g_object_unref (loader); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2868 | g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_FAILED, |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2869 | _("Failed to load image '%s': reason not known, probably a corrupt image file"), |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2870 | display_name ? display_name : "(unknown)"); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2871 | g_free (display_name); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2872 | return NULL; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2873 | } |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2874 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2875 | g_object_ref (pixbuf); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2876 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2877 | g_object_unref (loader); |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2878 | |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2879 | return pixbuf; |
|
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2880 | } |
|
15320
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
2881 | #endif /* ! Gtk 2.6.0 */ |
|
14290
f20819ff8d86
[gaim-migrate @ 16910]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14253
diff
changeset
|
2882 | |
| 15884 | 2883 | void pidgin_set_custom_buddy_icon(PurpleAccount *account, const char *who, const char *filename) |
|
14914
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
2884 | { |
| 15884 | 2885 | PurpleBuddy *buddy; |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2886 | PurpleContact *contact; |
|
14914
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
2887 | |
| 15884 | 2888 | buddy = purple_find_buddy(account, who); |
|
14914
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
2889 | if (!buddy) { |
| 15884 | 2890 | purple_debug_info("custom-icon", "You can only set custom icon for someone in your buddylist.\n"); |
|
14914
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
2891 | return; |
|
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
2892 | } |
|
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
2893 | |
|
16446
3a6ed6c3400e
Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@pidgin.im>
parents:
16437
diff
changeset
|
2894 | contact = purple_buddy_get_contact(buddy); |
|
23286
afe077628c20
Make pidgin_set_custom_buddy_icon use the
Etan Reisner <deryni@pidgin.im>
parents:
23284
diff
changeset
|
2895 | purple_buddy_icons_node_set_custom_icon_from_file((PurpleBlistNode*)contact, filename); |
|
14914
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
2896 | } |
|
290eb2170f38
[gaim-migrate @ 17621]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14781
diff
changeset
|
2897 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
2898 | char *pidgin_make_pretty_arrows(const char *str) |
| 15084 | 2899 | { |
| 2900 | char *ret; | |
| 2901 | char **split = g_strsplit(str, "->", -1); | |
| 2902 | ret = g_strjoinv("\342\207\250", split); | |
| 2903 | g_strfreev(split); | |
| 2904 | ||
| 2905 | split = g_strsplit(ret, "<-", -1); | |
| 2906 | g_free(ret); | |
| 2907 | ret = g_strjoinv("\342\207\246", split); | |
| 2908 | g_strfreev(split); | |
| 2909 | ||
| 2910 | return ret; | |
| 2911 | } | |
| 15094 | 2912 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
2913 | void pidgin_set_urgent(GtkWindow *window, gboolean urgent) |
| 15403 | 2914 | { |
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2915 | #if GTK_CHECK_VERSION(2,8,0) |
|
15410
b56fbd3662b9
[gaim-migrate @ 18141]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15409
diff
changeset
|
2916 | gtk_window_set_urgency_hint(window, urgent); |
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2917 | #elif defined _WIN32 |
|
15574
18d9d1c05994
Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents:
15568
diff
changeset
|
2918 | winpidgin_window_flash(window, urgent); |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20241
diff
changeset
|
2919 | #elif defined GDK_WINDOWING_X11 |
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2920 | GdkWindow *gdkwin; |
| 15403 | 2921 | XWMHints *hints; |
| 2922 | ||
| 2923 | g_return_if_fail(window != NULL); | |
| 2924 | ||
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2925 | gdkwin = GTK_WIDGET(window)->window; |
|
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2926 | |
|
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2927 | g_return_if_fail(gdkwin != NULL); |
|
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2928 | |
|
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2929 | hints = XGetWMHints(GDK_WINDOW_XDISPLAY(gdkwin), |
|
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2930 | GDK_WINDOW_XWINDOW(gdkwin)); |
| 15403 | 2931 | if(!hints) |
| 2932 | hints = XAllocWMHints(); | |
| 2933 | ||
| 2934 | if (urgent) | |
| 2935 | hints->flags |= XUrgencyHint; | |
| 2936 | else | |
| 2937 | hints->flags &= ~XUrgencyHint; | |
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2938 | XSetWMHints(GDK_WINDOW_XDISPLAY(gdkwin), |
|
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
2939 | GDK_WINDOW_XWINDOW(gdkwin), hints); |
| 15403 | 2940 | XFree(hints); |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20241
diff
changeset
|
2941 | #else |
|
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20241
diff
changeset
|
2942 | /* do something else? */ |
| 15403 | 2943 | #endif |
| 2944 | } | |
| 2945 | ||
| 15094 | 2946 | GSList *minidialogs = NULL; |
| 2947 | ||
| 2948 | static void * | |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
22013
diff
changeset
|
2949 | pidgin_utils_get_handle(void) |
| 15094 | 2950 | { |
| 2951 | static int handle; | |
| 2952 | ||
| 2953 | return &handle; | |
| 2954 | } | |
| 2955 | ||
| 15884 | 2956 | static void connection_signed_off_cb(PurpleConnection *gc) |
| 15094 | 2957 | { |
|
22702
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
2958 | GSList *list, *l_next; |
|
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
2959 | for (list = minidialogs; list; list = l_next) { |
|
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
2960 | l_next = list->next; |
| 15094 | 2961 | if (g_object_get_data(G_OBJECT(list->data), "gc") == gc) { |
| 2962 | gtk_widget_destroy(GTK_WIDGET(list->data)); | |
| 2963 | } | |
| 2964 | } | |
| 2965 | } | |
| 2966 | ||
| 2967 | static void alert_killed_cb(GtkWidget *widget) | |
| 2968 | { | |
| 2969 | minidialogs = g_slist_remove(minidialogs, widget); | |
| 2970 | } | |
| 2971 | ||
|
21323
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2972 | struct _old_button_clicked_cb_data |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2973 | { |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2974 | PidginUtilMiniDialogCallback cb; |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2975 | gpointer data; |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2976 | }; |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2977 | |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2978 | static void |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2979 | old_mini_dialog_button_clicked_cb(PidginMiniDialog *mini_dialog, |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2980 | GtkButton *button, |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2981 | gpointer user_data) |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2982 | { |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2983 | struct _old_button_clicked_cb_data *data = user_data; |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2984 | data->cb(data->data, button); |
|
21326
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2985 | } |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2986 | |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2987 | static void |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2988 | old_mini_dialog_destroy_cb(GtkWidget *dialog, |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2989 | GList *cb_datas) |
| 15094 | 2990 | { |
|
21326
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2991 | while (cb_datas != NULL) |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2992 | { |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2993 | g_free(cb_datas->data); |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2994 | cb_datas = g_list_delete_link(cb_datas, cb_datas); |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
2995 | } |
|
21323
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2996 | } |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
2997 | |
|
21310
de88118624f0
Fix the return type of pidgin_make_mini_dialog() to be GtkWidget * rather than
Will Thompson <resiak@pidgin.im>
parents:
21233
diff
changeset
|
2998 | GtkWidget * |
|
de88118624f0
Fix the return type of pidgin_make_mini_dialog() to be GtkWidget * rather than
Will Thompson <resiak@pidgin.im>
parents:
21233
diff
changeset
|
2999 | pidgin_make_mini_dialog(PurpleConnection *gc, |
|
de88118624f0
Fix the return type of pidgin_make_mini_dialog() to be GtkWidget * rather than
Will Thompson <resiak@pidgin.im>
parents:
21233
diff
changeset
|
3000 | const char *icon_name, |
|
de88118624f0
Fix the return type of pidgin_make_mini_dialog() to be GtkWidget * rather than
Will Thompson <resiak@pidgin.im>
parents:
21233
diff
changeset
|
3001 | const char *primary, |
|
de88118624f0
Fix the return type of pidgin_make_mini_dialog() to be GtkWidget * rather than
Will Thompson <resiak@pidgin.im>
parents:
21233
diff
changeset
|
3002 | const char *secondary, |
|
de88118624f0
Fix the return type of pidgin_make_mini_dialog() to be GtkWidget * rather than
Will Thompson <resiak@pidgin.im>
parents:
21233
diff
changeset
|
3003 | void *user_data, |
|
de88118624f0
Fix the return type of pidgin_make_mini_dialog() to be GtkWidget * rather than
Will Thompson <resiak@pidgin.im>
parents:
21233
diff
changeset
|
3004 | ...) |
| 15094 | 3005 | { |
|
21323
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3006 | PidginMiniDialog *mini_dialog; |
| 15094 | 3007 | const char *button_text; |
|
21326
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
3008 | GList *cb_datas = NULL; |
| 15094 | 3009 | va_list args; |
| 3010 | static gboolean first_call = TRUE; | |
| 3011 | ||
| 3012 | if (first_call) { | |
| 3013 | first_call = FALSE; | |
| 15884 | 3014 | purple_signal_connect(purple_connections_get_handle(), "signed-off", |
|
21323
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3015 | pidgin_utils_get_handle(), |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3016 | PURPLE_CALLBACK(connection_signed_off_cb), NULL); |
| 15094 | 3017 | } |
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
3018 | |
|
21323
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3019 | mini_dialog = pidgin_mini_dialog_new(primary, secondary, icon_name); |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3020 | g_object_set_data(G_OBJECT(mini_dialog), "gc" ,gc); |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3021 | g_signal_connect(G_OBJECT(mini_dialog), "destroy", |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3022 | G_CALLBACK(alert_killed_cb), NULL); |
|
15409
37b46bbce4cb
[gaim-migrate @ 18140]
Daniel Atallah <datallah@pidgin.im>
parents:
15405
diff
changeset
|
3023 | |
| 15094 | 3024 | va_start(args, user_data); |
| 3025 | while ((button_text = va_arg(args, char*))) { | |
|
22702
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3026 | struct _old_button_clicked_cb_data *data = NULL; |
|
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3027 | PidginMiniDialogCallback wrapper_cb = NULL; |
|
21323
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3028 | PidginUtilMiniDialogCallback callback = |
|
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3029 | va_arg(args, PidginUtilMiniDialogCallback); |
|
22702
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3030 | |
|
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3031 | if (callback != NULL) { |
|
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3032 | data = g_new0(struct _old_button_clicked_cb_data, 1); |
|
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3033 | data->cb = callback; |
|
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3034 | data->data = user_data; |
|
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3035 | wrapper_cb = old_mini_dialog_button_clicked_cb; |
|
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3036 | } |
|
21323
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3037 | pidgin_mini_dialog_add_button(mini_dialog, button_text, |
|
22702
bccd324d76c5
Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <datallah@pidgin.im>
parents:
22639
diff
changeset
|
3038 | wrapper_cb, data); |
|
21326
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
3039 | cb_datas = g_list_append(cb_datas, data); |
| 15094 | 3040 | } |
| 3041 | va_end(args); | |
| 3042 | ||
|
21326
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
3043 | g_signal_connect(G_OBJECT(mini_dialog), "destroy", |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
3044 | G_CALLBACK(old_mini_dialog_destroy_cb), cb_datas); |
|
62bb702f824a
Don't leak all bar one of the closure structs allocated by
Will Thompson <resiak@pidgin.im>
parents:
21323
diff
changeset
|
3045 | |
|
21323
0ad61638683f
Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <resiak@pidgin.im>
parents:
21320
diff
changeset
|
3046 | return GTK_WIDGET(mini_dialog); |
| 15094 | 3047 | } |
|
15177
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3048 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3049 | /* |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3050 | * "This is so dead sexy." |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3051 | * "Two thumbs up." |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3052 | * "Best movie of the year." |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3053 | * |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3054 | * 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
|
3055 | * 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
|
3056 | * entered string. |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3057 | * |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3058 | * 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
|
3059 | * "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
|
3060 | * 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
|
3061 | * 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
|
3062 | * used rarely, so it shouldn't matter TOO much. |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3063 | */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15506
diff
changeset
|
3064 | 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
|
3065 | const gchar *key, GtkTreeIter *iter, gpointer data) |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3066 | { |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3067 | gchar *enteredstring; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3068 | gchar *tmp; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3069 | gchar *withmarkup; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3070 | gchar *nomarkup; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3071 | gchar *normalized; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3072 | gboolean result; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3073 | size_t i; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3074 | size_t len; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3075 | PangoLogAttr *log_attrs; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3076 | gchar *word; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3077 | |
|
17155
143ff2796376
Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@pidgin.im>
parents:
17116
diff
changeset
|
3078 | if (g_ascii_strcasecmp(key, "Global Thermonuclear War") == 0) |
|
15177
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3079 | { |
| 15884 | 3080 | purple_notify_info(NULL, "WOPR", |
|
15177
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3081 | "Wouldn't you prefer a nice game of chess?", NULL); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3082 | return FALSE; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3083 | } |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3084 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3085 | gtk_tree_model_get(model, iter, column, &withmarkup, -1); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3086 | if (withmarkup == NULL) /* This is probably a separator */ |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3087 | return TRUE; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3088 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3089 | tmp = g_utf8_normalize(key, -1, G_NORMALIZE_DEFAULT); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3090 | enteredstring = g_utf8_casefold(tmp, -1); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3091 | g_free(tmp); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3092 | |
| 15884 | 3093 | nomarkup = purple_markup_strip_html(withmarkup); |
|
15177
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3094 | tmp = g_utf8_normalize(nomarkup, -1, G_NORMALIZE_DEFAULT); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3095 | g_free(nomarkup); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3096 | normalized = g_utf8_casefold(tmp, -1); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3097 | g_free(tmp); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3098 | |
| 15884 | 3099 | if (purple_str_has_prefix(normalized, enteredstring)) |
|
15177
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3100 | { |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3101 | g_free(withmarkup); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3102 | g_free(enteredstring); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3103 | g_free(normalized); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3104 | return FALSE; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3105 | } |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3106 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3107 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3108 | /* Use Pango to separate by words. */ |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3109 | len = g_utf8_strlen(normalized, -1); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3110 | log_attrs = g_new(PangoLogAttr, len + 1); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3111 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3112 | 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
|
3113 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3114 | word = normalized; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3115 | result = TRUE; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3116 | for (i = 0; i < (len - 1) ; i++) |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3117 | { |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3118 | if (log_attrs[i].is_word_start && |
| 15884 | 3119 | purple_str_has_prefix(word, enteredstring)) |
|
15177
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3120 | { |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3121 | result = FALSE; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3122 | break; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3123 | } |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3124 | word = g_utf8_next_char(word); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3125 | } |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3126 | g_free(log_attrs); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3127 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3128 | /* The non-Pango version. */ |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3129 | #if 0 |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3130 | word = normalized; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3131 | result = TRUE; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3132 | while (word[0] != '\0') |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3133 | { |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3134 | gunichar c = g_utf8_get_char(word); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3135 | if (!g_unichar_isalnum(c)) |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3136 | { |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3137 | word = g_utf8_find_next_char(word, NULL); |
| 15884 | 3138 | if (purple_str_has_prefix(word, enteredstring)) |
|
15177
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3139 | { |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3140 | result = FALSE; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3141 | break; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3142 | } |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3143 | } |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3144 | else |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3145 | word = g_utf8_find_next_char(word, NULL); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3146 | } |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3147 | #endif |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3148 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3149 | g_free(withmarkup); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3150 | g_free(enteredstring); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3151 | g_free(normalized); |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3152 | |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3153 | return result; |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3154 | } |
|
8b6c66e09388
[gaim-migrate @ 17901]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15114
diff
changeset
|
3155 | |
|
15320
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3156 | |
| 15568 | 3157 | gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) { |
| 15474 | 3158 | int width, height, rowstride, i; |
| 3159 | unsigned char *pixels; | |
| 3160 | unsigned char *row; | |
| 3161 | ||
| 3162 | if (!gdk_pixbuf_get_has_alpha(pixbuf)) | |
| 3163 | return TRUE; | |
| 3164 | ||
| 3165 | width = gdk_pixbuf_get_width (pixbuf); | |
| 3166 | height = gdk_pixbuf_get_height (pixbuf); | |
| 3167 | rowstride = gdk_pixbuf_get_rowstride (pixbuf); | |
| 3168 | pixels = gdk_pixbuf_get_pixels (pixbuf); | |
| 3169 | ||
| 3170 | row = pixels; | |
| 3171 | for (i = 3; i < rowstride; i+=4) { | |
|
17605
bb9b2209ae37
Fix rounding of buddy icons, it looks like when MSN Messenger converts jpgs
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17527
diff
changeset
|
3172 | if (row[i] < 0xfe) |
| 15474 | 3173 | return FALSE; |
| 3174 | } | |
| 3175 | ||
| 3176 | for (i = 1; i < height - 1; i++) { | |
| 3177 | row = pixels + (i*rowstride); | |
|
17605
bb9b2209ae37
Fix rounding of buddy icons, it looks like when MSN Messenger converts jpgs
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17527
diff
changeset
|
3178 | if (row[3] < 0xfe || row[rowstride-1] < 0xfe) { |
| 15474 | 3179 | return FALSE; |
|
17605
bb9b2209ae37
Fix rounding of buddy icons, it looks like when MSN Messenger converts jpgs
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17527
diff
changeset
|
3180 | } |
| 15474 | 3181 | } |
| 3182 | ||
| 3183 | row = pixels + ((height-1) * rowstride); | |
| 3184 | for (i = 3; i < rowstride; i+=4) { | |
|
17605
bb9b2209ae37
Fix rounding of buddy icons, it looks like when MSN Messenger converts jpgs
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17527
diff
changeset
|
3185 | if (row[i] < 0xfe) |
| 15474 | 3186 | return FALSE; |
| 3187 | } | |
| 3188 | ||
| 3189 | return TRUE; | |
| 3190 | } | |
| 3191 | ||
|
18275
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3192 | void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf) { |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3193 | int width, height, rowstride; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3194 | guchar *pixels; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3195 | if (!gdk_pixbuf_get_has_alpha(pixbuf)) |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3196 | return; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3197 | width = gdk_pixbuf_get_width(pixbuf); |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3198 | height = gdk_pixbuf_get_height(pixbuf); |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3199 | rowstride = gdk_pixbuf_get_rowstride(pixbuf); |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3200 | pixels = gdk_pixbuf_get_pixels(pixbuf); |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3201 | |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3202 | if (width < 6 || height < 6) |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3203 | return; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3204 | /* Top left */ |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3205 | pixels[3] = 0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3206 | pixels[7] = 0x80; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3207 | pixels[11] = 0xC0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3208 | pixels[rowstride + 3] = 0x80; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3209 | pixels[rowstride * 2 + 3] = 0xC0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3210 | |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3211 | /* Top right */ |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3212 | pixels[width * 4 - 1] = 0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3213 | pixels[width * 4 - 5] = 0x80; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3214 | pixels[width * 4 - 9] = 0xC0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3215 | pixels[rowstride + (width * 4) - 1] = 0x80; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3216 | pixels[(2 * rowstride) + (width * 4) - 1] = 0xC0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3217 | |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3218 | /* Bottom left */ |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3219 | pixels[(height - 1) * rowstride + 3] = 0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3220 | pixels[(height - 1) * rowstride + 7] = 0x80; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3221 | pixels[(height - 1) * rowstride + 11] = 0xC0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3222 | pixels[(height - 2) * rowstride + 3] = 0x80; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3223 | pixels[(height - 3) * rowstride + 3] = 0xC0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3224 | |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3225 | /* Bottom right */ |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3226 | pixels[height * rowstride - 1] = 0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3227 | pixels[(height - 1) * rowstride - 1] = 0x80; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3228 | pixels[(height - 2) * rowstride - 1] = 0xC0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3229 | pixels[height * rowstride - 5] = 0x80; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3230 | pixels[height * rowstride - 9] = 0xC0; |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3231 | } |
|
b9633ef422b0
Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@pidgin.im>
parents:
18238
diff
changeset
|
3232 | |
|
18278
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3233 | 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
|
3234 | static char dim_grey_string[8] = ""; |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3235 | GtkStyle *style; |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3236 | |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3237 | if (!widget) |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3238 | return "dim grey"; |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3239 | |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3240 | style = gtk_widget_get_style(widget); |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3241 | if (!style) |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3242 | return "dim grey"; |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3243 | |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3244 | snprintf(dim_grey_string, sizeof(dim_grey_string), "#%02x%02x%02x", |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3245 | style->text_aa[GTK_STATE_NORMAL].red >> 8, |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3246 | style->text_aa[GTK_STATE_NORMAL].green >> 8, |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3247 | style->text_aa[GTK_STATE_NORMAL].blue >> 8); |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3248 | return dim_grey_string; |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3249 | } |
|
06bf54cee797
Chat topics in status line of chat infopanes
Sean Egan <seanegan@pidgin.im>
parents:
18275
diff
changeset
|
3250 | |
|
15320
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3251 | #if !GTK_CHECK_VERSION(2,2,0) |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3252 | GtkTreePath * |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3253 | gtk_tree_path_new_from_indices (gint first_index, ...) |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3254 | { |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3255 | int arg; |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3256 | va_list args; |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3257 | GtkTreePath *path; |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3258 | |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3259 | path = gtk_tree_path_new (); |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3260 | |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3261 | va_start (args, first_index); |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3262 | arg = first_index; |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3263 | |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3264 | while (arg != -1) |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3265 | { |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3266 | gtk_tree_path_append_index (path, arg); |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3267 | arg = va_arg (args, gint); |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3268 | } |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3269 | |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3270 | va_end (args); |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3271 | |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3272 | return path; |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3273 | } |
|
c4eea0409712
[gaim-migrate @ 18048]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15302
diff
changeset
|
3274 | #endif |
|
18185
d4f1719d812b
merge of '26a92816b762feba6da1013204d48f8d4364797d'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
3275 | |
|
20036
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3276 | static void |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3277 | combo_box_changed_cb(GtkComboBox *combo_box, GtkEntry *entry) |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3278 | { |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3279 | char *text = gtk_combo_box_get_active_text(combo_box); |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3280 | 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
|
3281 | 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
|
3282 | } |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3283 | |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3284 | static gboolean |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3285 | entry_key_pressed_cb(GtkWidget *entry, GdkEventKey *key, GtkComboBox *combo) |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3286 | { |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3287 | if (key->keyval == GDK_Down || key->keyval == GDK_Up) { |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3288 | gtk_combo_box_popup(combo); |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3289 | 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
|
3290 | } |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3291 | 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
|
3292 | } |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3293 | |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3294 | GtkWidget * |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3295 | 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
|
3296 | { |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3297 | GtkComboBox *ret = NULL; |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3298 | 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
|
3299 | |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3300 | ret = GTK_COMBO_BOX(gtk_combo_box_new_text()); |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3301 | the_entry = gtk_entry_new(); |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3302 | gtk_container_add(GTK_CONTAINER(ret), 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
|
3303 | |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3304 | 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
|
3305 | 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
|
3306 | |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3307 | 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
|
3308 | 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
|
3309 | if (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
|
3310 | gtk_combo_box_append_text(ret, text); |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3311 | } |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3312 | |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3313 | 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
|
3314 | 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
|
3315 | |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3316 | 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
|
3317 | } |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3318 | |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3319 | 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
|
3320 | { |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3321 | return gtk_entry_get_text(GTK_ENTRY(GTK_BIN((widget))->child)); |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3322 | } |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3323 | |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3324 | void pidgin_text_combo_box_entry_set_text(GtkWidget *widget, const char *text) |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3325 | { |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3326 | gtk_entry_set_text(GTK_ENTRY(GTK_BIN((widget))->child), (text)); |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3327 | } |
|
3bdbea94ad0c
Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
3328 | |
|
22131
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3329 | GtkWidget * |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3330 | 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
|
3331 | { |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3332 | 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
|
3333 | 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
|
3334 | |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3335 | if (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
|
3336 | hbox = gtk_hbox_new(FALSE, 5); |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3337 | 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
|
3338 | 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
|
3339 | |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3340 | 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
|
3341 | 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
|
3342 | if (sg) { |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3343 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3344 | 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
|
3345 | } |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3346 | 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
|
3347 | } else { |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3348 | 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
|
3349 | } |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3350 | |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3351 | 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
|
3352 | 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
|
3353 | 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
|
3354 | gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget); |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3355 | pidgin_set_accessible_label (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
|
3356 | } |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3357 | |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3358 | 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
|
3359 | (*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
|
3360 | 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
|
3361 | } |
|
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22013
diff
changeset
|
3362 | |
|
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
|
3363 | 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
|
3364 | { |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3365 | #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
|
3366 | /* 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
|
3367 | * 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
|
3368 | #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
|
3369 | 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
|
3370 | 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
|
3371 | 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
|
3372 | 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
|
3373 | 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
|
3374 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3375 | 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
|
3376 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3377 | 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
|
3378 | _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
|
3379 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3380 | 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
|
3381 | _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
|
3382 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3383 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3384 | 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
|
3385 | 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
|
3386 | 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
|
3387 | 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
|
3388 | 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
|
3389 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3390 | 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
|
3391 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3392 | if (window == 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
|
3393 | !GTK_WIDGET_VISIBLE(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
|
3394 | 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
|
3395 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3396 | 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
|
3397 | 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
|
3398 | 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
|
3399 | 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
|
3400 | 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
|
3401 | 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
|
3402 | 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
|
3403 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3404 | 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
|
3405 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3406 | 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
|
3407 | 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
|
3408 | 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
|
3409 | 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
|
3410 | /* 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
|
3411 | * 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
|
3412 | */ |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3413 | 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
|
3414 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3415 | 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
|
3416 | 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
|
3417 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3418 | 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
|
3419 | #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
|
3420 | #else |
|
22639
7ff3669b196e
gtk_window_has_toplevel_focus() is new in Gtk 2.4, making pidgin_auto_parent_window()
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22269
diff
changeset
|
3421 | #if GTK_CHECK_VERSION(2,4,0) |
|
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
|
3422 | /* 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
|
3423 | 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
|
3424 | 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
|
3425 | 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
|
3426 | GdkWindow *menu = 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
|
3427 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3428 | 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
|
3429 | /* 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
|
3430 | 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
|
3431 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3432 | /* 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
|
3433 | 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
|
3434 | /* 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
|
3435 | 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
|
3436 | 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
|
3437 | 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
|
3438 | */ |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3439 | } 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
|
3440 | 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
|
3441 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3442 | 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
|
3443 | 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
|
3444 | 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
|
3445 | 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
|
3446 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3447 | if (window == 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
|
3448 | !GTK_WIDGET_VISIBLE(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
|
3449 | 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
|
3450 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3451 | |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3452 | if (gtk_window_has_toplevel_focus(GTK_WINDOW(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
|
3453 | (menu && menu == window->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
|
3454 | 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
|
3455 | 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
|
3456 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3457 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3458 | 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
|
3459 | 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
|
3460 | 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
|
3461 | 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
|
3462 | 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
|
3463 | } |
|
22639
7ff3669b196e
gtk_window_has_toplevel_focus() is new in Gtk 2.4, making pidgin_auto_parent_window()
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22269
diff
changeset
|
3464 | #endif |
|
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
|
3465 | 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
|
3466 | #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
|
3467 | } |
|
386062b58867
Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22005
diff
changeset
|
3468 | |
|
22897
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3469 | GdkPixbuf * pidgin_pixbuf_from_imgstore(PurpleStoredImage *image) |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3470 | { |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3471 | GdkPixbuf *pixbuf; |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3472 | GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3473 | gdk_pixbuf_loader_write(loader, purple_imgstore_get_data(image), |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3474 | purple_imgstore_get_size(image), NULL); |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3475 | gdk_pixbuf_loader_close(loader, NULL); |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3476 | pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3477 | if (pixbuf) |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3478 | g_object_ref(pixbuf); |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3479 | g_object_unref(loader); |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3480 | return pixbuf; |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3481 | } |
|
93d7ad160755
Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22895
diff
changeset
|
3482 |