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