annotate src/gtkutils.c @ 12243:d3cb077caf3e

[gaim-migrate @ 14545] HIG-ify some protocol actions. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 28 Nov 2005 01:59:29 +0000
parents 2cbb5993c819
children c7ae1fd0827d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
1 /**
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
2 * @file gtkutils.h GTK+ utility functions
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
3 * @ingroup gtkui
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
4 *
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 * gaim
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7988
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7988
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7988
diff changeset
9 * source distribution.
7060
9946001989a3 [gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents: 6846
diff changeset
10 *
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * (at your option) any later version.
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * GNU General Public License for more details.
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 */
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9767
diff changeset
25 #include "internal.h"
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9767
diff changeset
26 #include "gtkgaim.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
27
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 #ifndef _WIN32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
29 # include <X11/Xlib.h>
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 #else
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
31 # ifdef small
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
32 # undef small
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
33 # endif
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 #endif /*_WIN32*/
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
35
7538
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
36 #ifdef USE_GTKSPELL
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
37 # include <gtkspell/gtkspell.h>
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
38 # ifdef _WIN32
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
39 # include "wspell.h"
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
40 # endif
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
41 #endif
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
42
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 #include <gdk/gdkkeysyms.h>
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
44
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
45 #include "conversation.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
46 #include "debug.h"
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
47 #include "desktopitem.h"
7078
acd2a66e59ed [gaim-migrate @ 7643]
Nathan Walp <nwalp@pidgin.im>
parents: 7060
diff changeset
48 #include "imgstore.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
49 #include "notify.h"
5548
80e4ba770f97 [gaim-migrate @ 5949]
Nathan Walp <nwalp@pidgin.im>
parents: 5530
diff changeset
50 #include "prefs.h"
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 #include "prpl.h"
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
52 #include "request.h"
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
53 #include "signals.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
54 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
55
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
56 #include "gtkconv.h"
9709
4d05b6e9e9cd [gaim-migrate @ 10570]
Mark Doliner <mark@kingant.net>
parents: 9706
diff changeset
57 #include "gtkdialogs.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
58 #include "gtkimhtml.h"
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
59 #include "gtkimhtmltoolbar.h"
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11338
diff changeset
60 #include "gtkthemes.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
61 #include "gtkutils.h"
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
10850
fa06fda62868 [gaim-migrate @ 12522]
Mark Doliner <mark@kingant.net>
parents: 10681
diff changeset
63 static guint accels_save_timer = 0;
7420
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
64
8913
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
65 static gboolean
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
66 url_clicked_idle_cb(gpointer data)
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
67 {
10240
95ca0db2d01d [gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 10229
diff changeset
68 gaim_notify_uri(NULL, data);
8913
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
69 g_free(data);
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
70 return FALSE;
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
71 }
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
72
6465
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
73 static void
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
74 url_clicked_cb(GtkWidget *w, const char *uri)
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
75 {
8913
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
76 g_idle_add(url_clicked_idle_cb, g_strdup(uri));
6465
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
77 }
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
78
10871
6240d7fd5b2c [gaim-migrate @ 12558]
Mark Doliner <mark@kingant.net>
parents: 10850
diff changeset
79 static GtkIMHtmlFuncs gtkimhtml_cbs = {
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
80 (GtkIMHtmlGetImageFunc)gaim_imgstore_get,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
81 (GtkIMHtmlGetImageDataFunc)gaim_imgstore_get_data,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
82 (GtkIMHtmlGetImageSizeFunc)gaim_imgstore_get_size,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
83 (GtkIMHtmlGetImageFilenameFunc)gaim_imgstore_get_filename,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
84 gaim_imgstore_ref,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
85 gaim_imgstore_unref,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
86 };
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
87
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 gaim_setup_imhtml(GtkWidget *imhtml)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 g_return_if_fail(imhtml != NULL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 g_return_if_fail(GTK_IS_IMHTML(imhtml));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 g_signal_connect(G_OBJECT(imhtml), "url_clicked",
6465
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
95 G_CALLBACK(url_clicked_cb), NULL);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11338
diff changeset
97 gaim_gtkthemes_smiley_themeize(imhtml);
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
98
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
99 gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), &gtkimhtml_cbs);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
102 GtkWidget *
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
103 gaim_gtk_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret)
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
104 {
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
105 GtkWidget *frame;
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
106 GtkWidget *imhtml;
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
107 GtkWidget *sep;
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
108 GtkWidget *sw;
10177
82c1322c4b56 [gaim-migrate @ 11292]
Christian Hammond <chipx86@chipx86.com>
parents: 10175
diff changeset
109 GtkWidget *toolbar = NULL;
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
110 GtkWidget *vbox;
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
111
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
112 frame = gtk_frame_new(NULL);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
113 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
114
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
115 vbox = gtk_vbox_new(FALSE, 0);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
116 gtk_container_add(GTK_CONTAINER(frame), vbox);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
117 gtk_widget_show(vbox);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
118
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
119 if (editable) {
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
120 toolbar = gtk_imhtmltoolbar_new();
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
121 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
122 gtk_widget_show(toolbar);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
123
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
124 sep = gtk_hseparator_new();
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
125 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
126 gtk_widget_show(sep);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
127 }
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
128
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
129 /*
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
130 * We never show the horizontal scrollbar in editable imhtmls becuase
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
131 * it was causing weird lockups when typing text just as you type the
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
132 * character that would cause both scrollbars to appear. Definitely
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
133 * seems like a gtk bug to me.
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
134 */
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
135 sw = gtk_scrolled_window_new(NULL, NULL);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
136 if (editable)
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
137 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
138 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
139 else
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
140 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
141 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
142 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
143 gtk_widget_show(sw);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
144
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
145 imhtml = gtk_imhtml_new(NULL, NULL);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
146 gtk_imhtml_set_editable(GTK_IMHTML(imhtml), editable);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
147 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
148 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
149 if (editable && gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck"))
12067
e859c1663a27 [gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents: 12063
diff changeset
150 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(imhtml));
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
151 gtk_widget_show(imhtml);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
152
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
153 if (editable) {
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
154 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), imhtml);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
155 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(toolbar), "default");
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
156 }
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
157 gaim_setup_imhtml(imhtml);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
158
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
159 gtk_container_add(GTK_CONTAINER(sw), imhtml);
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
160
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
161 if (imhtml_ret != NULL)
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
162 *imhtml_ret = imhtml;
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
163
10181
5b33637b69fd [gaim-migrate @ 11296]
Mark Doliner <mark@kingant.net>
parents: 10177
diff changeset
164 if (editable && (toolbar_ret != NULL))
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
165 *toolbar_ret = toolbar;
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
166
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
167 return frame;
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
168 }
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
169
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 void
7751
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
171 gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog)
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
172 {
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
173 const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
174 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK,
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
175 (*text != '\0'));
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
176 }
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
177
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 gboolean sensitivity;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 if (to_toggle == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 gtk_widget_set_sensitive(to_toggle, !sensitivity);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
191 void
10590
896efbdc74e2 [gaim-migrate @ 11995]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10566
diff changeset
192 gaim_gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data)
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
193 {
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
194 gboolean sensitivity;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
195 gpointer element;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
196 int i;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
197
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
198 for (i=0; i < data->len; i++) {
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
199 element = g_ptr_array_index(data,i);
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
200 if (element == NULL)
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
201 continue;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
202
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
203 sensitivity = GTK_WIDGET_IS_SENSITIVE(element);
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
204
10175
53410b84336f [gaim-migrate @ 11290]
Mark Doliner <mark@kingant.net>
parents: 10061
diff changeset
205 gtk_widget_set_sensitive(element, !sensitivity);
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
206 }
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
207 }
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
208
8901
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
209 void
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
210 gaim_gtk_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle)
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
211 {
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
212 if (to_toggle == NULL)
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
213 return;
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
214
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
215 if (GTK_WIDGET_VISIBLE(to_toggle))
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
216 gtk_widget_hide(to_toggle);
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
217 else
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
218 gtk_widget_show(to_toggle);
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
219 }
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
220
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
221 void gaim_separator(GtkWidget *menu)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
222 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
223 GtkWidget *menuitem;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
224
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
225 menuitem = gtk_separator_menu_item_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
226 gtk_widget_show(menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
227 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
228 }
5160
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
229
5162
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
230 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str)
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
231 {
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
232 GtkWidget *menuitem;
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
233 GtkWidget *label;
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
234
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
235 menuitem = gtk_menu_item_new();
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
236 if (menu)
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
237 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
238 gtk_widget_show(menuitem);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
239
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
240 label = gtk_label_new(str);
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6236
diff changeset
241 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
5162
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
242 gtk_label_set_pattern(GTK_LABEL(label), "_");
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
243 gtk_container_add(GTK_CONTAINER(menuitem), label);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
244 gtk_widget_show(label);
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11338
diff changeset
245 /* FIXME: Go back and fix this
5162
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
246 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0],
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
247 GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
248 */
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
249 gaim_set_accessible_label (menuitem, label);
5162
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
250 return menuitem;
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
251 }
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
252
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
253 GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str,
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
254 GtkSignalFunc sf, gpointer data, gboolean checked)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
255 {
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
256 GtkWidget *menuitem;
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
257 menuitem = gtk_check_menu_item_new_with_mnemonic(str);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
258
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
259 if (menu)
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
260 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
261
7299
2737c287f84d [gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents: 7118
diff changeset
262 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), checked);
2737c287f84d [gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents: 7118
diff changeset
263
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
264 if (sf)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
265 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
266
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
267 gtk_widget_show_all(menuitem);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
268
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
269 return menuitem;
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
270 }
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
271
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
272 GtkWidget *
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
273 gaim_pixbuf_toolbar_button_from_stock(const char *icon)
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
274 {
9706
d4634f26ef9b [gaim-migrate @ 10567]
Mark Doliner <mark@kingant.net>
parents: 9534
diff changeset
275 GtkWidget *button, *image, *bbox;
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
276
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
277 button = gtk_toggle_button_new();
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
278 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
279
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
280 bbox = gtk_vbox_new(FALSE, 0);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
281
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
282 gtk_container_add (GTK_CONTAINER(button), bbox);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
283
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
284 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
285 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
286
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
287 gtk_widget_show_all(bbox);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
288
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
289 return button;
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
290 }
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
291
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
292 GtkWidget *
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
293 gaim_pixbuf_button_from_stock(const char *text, const char *icon,
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
294 GaimButtonOrientation style)
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
295 {
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10483
diff changeset
296 GtkWidget *button, *image, *label, *bbox, *ibox, *lbox = NULL;
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
297
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
298 button = gtk_button_new();
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
299
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
300 if (style == GAIM_BUTTON_HORIZONTAL) {
9750
4f8476beabf5 [gaim-migrate @ 10617]
Mark Doliner <mark@kingant.net>
parents: 9749
diff changeset
301 bbox = gtk_hbox_new(FALSE, 0);
4f8476beabf5 [gaim-migrate @ 10617]
Mark Doliner <mark@kingant.net>
parents: 9749
diff changeset
302 ibox = gtk_hbox_new(FALSE, 0);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10483
diff changeset
303 if (text)
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10483
diff changeset
304 lbox = gtk_hbox_new(FALSE, 0);
9750
4f8476beabf5 [gaim-migrate @ 10617]
Mark Doliner <mark@kingant.net>
parents: 9749
diff changeset
305 } else {
4f8476beabf5 [gaim-migrate @ 10617]
Mark Doliner <mark@kingant.net>
parents: 9749
diff changeset
306 bbox = gtk_vbox_new(FALSE, 0);
4f8476beabf5 [gaim-migrate @ 10617]
Mark Doliner <mark@kingant.net>
parents: 9749
diff changeset
307 ibox = gtk_vbox_new(FALSE, 0);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10483
diff changeset
308 if (text)
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10483
diff changeset
309 lbox = gtk_vbox_new(FALSE, 0);
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
310 }
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
311
9750
4f8476beabf5 [gaim-migrate @ 10617]
Mark Doliner <mark@kingant.net>
parents: 9749
diff changeset
312 gtk_container_add(GTK_CONTAINER(button), bbox);
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
313
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
314 if (icon) {
9750
4f8476beabf5 [gaim-migrate @ 10617]
Mark Doliner <mark@kingant.net>
parents: 9749
diff changeset
315 gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox);
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
316 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
9767
c31e64c2bd85 [gaim-migrate @ 10635]
Mark Doliner <mark@kingant.net>
parents: 9750
diff changeset
317 gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, TRUE, 0);
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
318 }
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
319
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
320 if (text) {
9750
4f8476beabf5 [gaim-migrate @ 10617]
Mark Doliner <mark@kingant.net>
parents: 9749
diff changeset
321 gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox);
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
322 label = gtk_label_new(NULL);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
323 gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
324 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
9767
c31e64c2bd85 [gaim-migrate @ 10635]
Mark Doliner <mark@kingant.net>
parents: 9750
diff changeset
325 gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, TRUE, 0);
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
326 gaim_set_accessible_label (button, label);
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
327 }
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
328
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
329 gtk_widget_show_all(bbox);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
330
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
331 return button;
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
332 }
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
333
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
334
5160
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
335 GtkWidget *gaim_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod)
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
336 {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
337 GtkWidget *menuitem;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
338 /*
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
339 GtkWidget *hbox;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
340 GtkWidget *label;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
341 */
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
342 GtkWidget *image;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
343
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
344 if (icon == NULL)
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
345 menuitem = gtk_menu_item_new_with_mnemonic(str);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
346 else
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
347 menuitem = gtk_image_menu_item_new_with_mnemonic(str);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
348
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
349 if (menu)
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
350 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
351
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
352 if (sf)
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
353 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data);
5160
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
354
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
355 if (icon != NULL) {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
356 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
357 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
358 }
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
359 /* FIXME: this isn't right
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
360 if (mod) {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
361 label = gtk_label_new(mod);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
362 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
363 gtk_widget_show(label);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
364 }
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
365 */
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
366 /*
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
367 if (accel_key) {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
368 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
369 accel_mods, GTK_ACCEL_LOCKED);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
370 }
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
371 */
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
372
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
373 gtk_widget_show_all(menuitem);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
374
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
375 return menuitem;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
376 }
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
377
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
378 GtkWidget *
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
379 gaim_gtk_make_frame(GtkWidget *parent, const char *title)
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
380 {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
381 GtkWidget *vbox, *label, *hbox;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
382 char labeltitle[256];
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
383
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11135
diff changeset
384 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
385 gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
386 gtk_widget_show(vbox);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
387
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
388 label = gtk_label_new(NULL);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
389 g_snprintf(labeltitle, sizeof(labeltitle),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
390 "<span weight=\"bold\">%s</span>", title);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
391
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
392 gtk_label_set_markup(GTK_LABEL(label), labeltitle);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
393 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
394 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
395 gtk_widget_show(label);
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
396 gaim_set_accessible_label (vbox, label);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
397
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11135
diff changeset
398 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
399 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
400 gtk_widget_show(hbox);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
401
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
402 label = gtk_label_new(" ");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
403 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
404 gtk_widget_show(label);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
405
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 11135
diff changeset
406 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
407 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
408 gtk_widget_show(vbox);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
409
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
410 return vbox;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
411 }
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
412
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
413 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5746
diff changeset
414 protocol_menu_cb(GtkWidget *optmenu, GCallback cb)
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
415 {
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
416 GtkWidget *menu;
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
417 GtkWidget *item;
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
418 const char *protocol;
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
419 gpointer user_data;
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
420
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
421 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
422 item = gtk_menu_get_active(GTK_MENU(menu));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
423
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
424 protocol = g_object_get_data(G_OBJECT(item), "protocol");
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
425 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data"));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
426
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
427 if (cb != NULL)
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
428 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol,
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
429 user_data);
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
430 }
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
431
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
432 GtkWidget *
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
433 gaim_gtk_protocol_option_menu_new(const char *id, GCallback cb,
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
434 gpointer user_data)
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
435 {
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
436 GaimPluginProtocolInfo *prpl_info;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
437 GaimPlugin *plugin;
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
438 GtkWidget *hbox;
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
439 GtkWidget *label;
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
440 GtkWidget *optmenu;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
441 GtkWidget *menu;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
442 GtkWidget *item;
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
443 GtkWidget *image;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
444 GdkPixbuf *pixbuf;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
445 GdkPixbuf *scale;
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
446 GList *p;
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
447 GtkSizeGroup *sg;
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
448 char *filename;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
449 const char *proto_name;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
450 char buf[256];
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
451 int i, selected_index = -1;
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
452
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
453 optmenu = gtk_option_menu_new();
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
454 gtk_widget_show(optmenu);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
455
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
456 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
457
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
458 menu = gtk_menu_new();
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
459 gtk_widget_show(menu);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
460
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
461 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
462
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
463 for (p = gaim_plugins_get_protocols(), i = 0;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
464 p != NULL;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
465 p = p->next, i++) {
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
466
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
467 plugin = (GaimPlugin *)p->data;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
468 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
469
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
470 /* Create the item. */
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
471 item = gtk_menu_item_new();
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
472
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
473 /* Create the hbox. */
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
474 hbox = gtk_hbox_new(FALSE, 4);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
475 gtk_container_add(GTK_CONTAINER(item), hbox);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
476 gtk_widget_show(hbox);
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
477
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
478 /* Load the image. */
6430
5211873190ea [gaim-migrate @ 6938]
Sean Egan <seanegan@gmail.com>
parents: 6429
diff changeset
479 proto_name = prpl_info->list_icon(NULL, NULL);
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
480 g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
481
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
482 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
483 "default", buf, NULL);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
484 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
485 g_free(filename);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
486
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
487 if (pixbuf != NULL) {
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
488 /* Scale and insert the image */
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
489 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
490 GDK_INTERP_BILINEAR);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
491 image = gtk_image_new_from_pixbuf(scale);
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
492
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
493 g_object_unref(G_OBJECT(pixbuf));
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
494 g_object_unref(G_OBJECT(scale));
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
495 }
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
496 else
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
497 image = gtk_image_new();
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
498
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
499 gtk_size_group_add_widget(sg, image);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
500
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
501 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
502 gtk_widget_show(image);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
503
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
504 /* Create the label. */
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
505 label = gtk_label_new(plugin->info->name);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
506 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
507 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
508 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
509 gtk_widget_show(label);
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
510
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
511 g_object_set_data(G_OBJECT(item), "protocol", plugin->info->id);
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
512
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
513 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
514 gtk_widget_show(item);
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
515 gaim_set_accessible_label (item, label);
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
516
8218
4beaf6b35483 [gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents: 8215
diff changeset
517 if (id != NULL && !strcmp(plugin->info->id, id))
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
518 selected_index = i;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
519 }
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
520
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
521 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
522
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
523 if (selected_index != -1)
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
524 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
525
5688
e43e1b8dca8b [gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
526 g_signal_connect(G_OBJECT(optmenu), "changed",
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5746
diff changeset
527 G_CALLBACK(protocol_menu_cb), cb);
5688
e43e1b8dca8b [gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
528
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
529 g_object_unref(sg);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
530
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
531 return optmenu;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
532 }
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
533
8940
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
534 GaimAccount *
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
535 gaim_gtk_account_option_menu_get_selected(GtkWidget *optmenu)
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
536 {
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
537 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
538 GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu));
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
539 return g_object_get_data(G_OBJECT(item), "account");
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
540 }
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
541
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
542 static void
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
543 account_menu_cb(GtkWidget *optmenu, GCallback cb)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
544 {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
545 GtkWidget *menu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
546 GtkWidget *item;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
547 GaimAccount *account;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
548 gpointer user_data;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
549
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
550 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
551 item = gtk_menu_get_active(GTK_MENU(menu));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
552
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
553 account = g_object_get_data(G_OBJECT(item), "account");
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
554 user_data = g_object_get_data(G_OBJECT(optmenu), "user_data");
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
555
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
556 if (cb != NULL)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
557 ((void (*)(GtkWidget *, GaimAccount *, gpointer))cb)(item, account,
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
558 user_data);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
559 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
560
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
561 static void
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
562 create_account_menu(GtkWidget *optmenu, GaimAccount *default_account,
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
563 GaimFilterAccountFunc filter_func, gboolean show_all)
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
564 {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
565 GaimAccount *account;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
566 GtkWidget *menu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
567 GtkWidget *item;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
568 GtkWidget *image;
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
569 GtkWidget *hbox;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
570 GtkWidget *label;
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
571 GdkPixbuf *pixbuf;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
572 GdkPixbuf *scale;
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
573 GList *list;
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
574 GList *p;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
575 GtkSizeGroup *sg;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
576 char *filename;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
577 const char *proto_name;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
578 char buf[256];
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
579 int i, selected_index = -1;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
580
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
581 if (show_all)
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
582 list = gaim_accounts_get_all();
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
583 else
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
584 list = gaim_connections_get_all();
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
585
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
586 menu = gtk_menu_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
587 gtk_widget_show(menu);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
588
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
589 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
590
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
591 for (p = list, i = 0; p != NULL; p = p->next, i++) {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
592 GaimPluginProtocolInfo *prpl_info = NULL;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
593 GaimPlugin *plugin;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
594
5879
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
595 if (show_all)
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
596 account = (GaimAccount *)p->data;
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
597 else {
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
598 GaimConnection *gc = (GaimConnection *)p->data;
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
599
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
600 account = gaim_connection_get_account(gc);
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
601 }
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
602
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
603 if (filter_func && !filter_func(account)) {
8215
83830cb8467e [gaim-migrate @ 8938]
Nathan Walp <nwalp@pidgin.im>
parents: 8155
diff changeset
604 i--;
6646
b89d98f0bf79 [gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
605 continue;
8215
83830cb8467e [gaim-migrate @ 8938]
Nathan Walp <nwalp@pidgin.im>
parents: 8155
diff changeset
606 }
6646
b89d98f0bf79 [gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
607
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
608 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account));
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
609
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
610 if (plugin != NULL)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
611 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
612
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
613 /* Create the item. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
614 item = gtk_menu_item_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
615
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
616 /* Create the hbox. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
617 hbox = gtk_hbox_new(FALSE, 4);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
618 gtk_container_add(GTK_CONTAINER(item), hbox);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
619 gtk_widget_show(hbox);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
620
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
621 /* Load the image. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
622 if (prpl_info != NULL) {
6430
5211873190ea [gaim-migrate @ 6938]
Sean Egan <seanegan@gmail.com>
parents: 6429
diff changeset
623 proto_name = prpl_info->list_icon(account, NULL);
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
624 g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
625
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
626 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
8155
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
627 "default", buf, NULL);
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
628 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
629 g_free(filename);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
630
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
631 if (pixbuf != NULL) {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
632 /* Scale and insert the image */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
633 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
8155
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
634 GDK_INTERP_BILINEAR);
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
635
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
636 if (gaim_account_is_disconnected(account) && show_all &&
8215
83830cb8467e [gaim-migrate @ 8938]
Nathan Walp <nwalp@pidgin.im>
parents: 8155
diff changeset
637 gaim_connections_get_all())
8155
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
638 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
639
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
640 image = gtk_image_new_from_pixbuf(scale);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
641
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
642 g_object_unref(G_OBJECT(pixbuf));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
643 g_object_unref(G_OBJECT(scale));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
644 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
645 else
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
646 image = gtk_image_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
647 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
648 else
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
649 image = gtk_image_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
650
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
651 gtk_size_group_add_widget(sg, image);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
652
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
653 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
654 gtk_widget_show(image);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
655
11017
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
656 if (gaim_account_get_alias(account)) {
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
657 g_snprintf(buf, sizeof(buf), "%s (%s) (%s)",
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
658 gaim_account_get_username(account),
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
659 gaim_account_get_alias(account),
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
660 gaim_account_get_protocol_name(account));
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
661 } else {
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
662 g_snprintf(buf, sizeof(buf), "%s (%s)",
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
663 gaim_account_get_username(account),
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
664 gaim_account_get_protocol_name(account));
829ab6b71ffe [gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10951
diff changeset
665 }
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
666
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
667 /* Create the label. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
668 label = gtk_label_new(buf);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
669 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
670 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
671 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
672 gtk_widget_show(label);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
673
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
674 g_object_set_data(G_OBJECT(item), "account", account);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
675
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
676 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
677 gtk_widget_show(item);
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
678 gaim_set_accessible_label (item, label);
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
679
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
680 if (default_account != NULL && account == default_account)
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
681 selected_index = i;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
682 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
683
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
684 g_object_unref(sg);
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
685
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
686 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
687
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
688 /* Set the place we should be at. */
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
689 if (selected_index != -1)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
690 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
691 }
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
692
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
693 static void
8134
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
694 regenerate_account_menu(GtkWidget *optmenu)
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
695 {
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
696 GtkWidget *menu;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
697 GtkWidget *item;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
698 gboolean show_all;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
699 GaimAccount *account;
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
700 GaimFilterAccountFunc filter_func;
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
701
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
702 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
703 item = gtk_menu_get_active(GTK_MENU(menu));
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
704 account = g_object_get_data(G_OBJECT(item), "account");
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
705
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
706 show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu),
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
707 "show_all"));
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
708
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
709 filter_func = g_object_get_data(G_OBJECT(optmenu),
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
710 "filter_func");
6646
b89d98f0bf79 [gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
711
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
712 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu));
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
713
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
714 create_account_menu(optmenu, account, filter_func, show_all);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
715 }
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
716
8134
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
717 static void
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
718 account_menu_sign_on_off_cb(GaimConnection *gc, GtkWidget *optmenu)
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
719 {
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
720 regenerate_account_menu(optmenu);
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
721 }
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
722
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
723 static void
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
724 account_menu_added_removed_cb(GaimAccount *account, GtkWidget *optmenu)
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
725 {
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
726 regenerate_account_menu(optmenu);
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
727 }
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
728
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
729 static gboolean
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
730 account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event,
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
731 void *user_data)
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
732 {
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
733 gaim_signals_disconnect_by_handle(optmenu);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
734
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
735 return FALSE;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
736 }
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
737
9910
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
738 void
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
739 gaim_gtk_account_option_menu_set_selected(GtkWidget *optmenu, GaimAccount *account)
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
740 {
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
741 GtkWidget *menu;
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
742 GtkWidget *item;
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
743 gboolean show_all;
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
744 GaimAccount *curaccount;
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
745 GaimFilterAccountFunc filter_func;
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
746
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
747 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
748 item = gtk_menu_get_active(GTK_MENU(menu));
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
749 curaccount = g_object_get_data(G_OBJECT(item), "account");
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
750
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
751 if (account == curaccount)
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
752 return;
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
753
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
754 show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu),
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
755 "show_all"));
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
756
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
757 filter_func = g_object_get_data(G_OBJECT(optmenu),
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
758 "filter_func");
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
759
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
760 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu));
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
761
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
762 create_account_menu(optmenu, account, filter_func, show_all);
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
763 }
0cb20555b3ab [gaim-migrate @ 10802]
Luke Schierer <lschiere@pidgin.im>
parents: 9899
diff changeset
764
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
765 GtkWidget *
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
766 gaim_gtk_account_option_menu_new(GaimAccount *default_account,
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
767 gboolean show_all, GCallback cb,
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
768 GaimFilterAccountFunc filter_func,
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
769 gpointer user_data)
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
770 {
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
771 GtkWidget *optmenu;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
772
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
773 /* Create the option menu */
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
774 optmenu = gtk_option_menu_new();
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
775 gtk_widget_show(optmenu);
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
776
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
777 g_signal_connect(G_OBJECT(optmenu), "destroy",
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
778 G_CALLBACK(account_menu_destroyed_cb), NULL);
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
779
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
780 /* Register the gaim sign on/off event callbacks. */
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
781 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
782 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb),
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
783 optmenu);
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
784 gaim_signal_connect(gaim_connections_get_handle(), "signed-off",
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
785 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb),
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
786 optmenu);
8134
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
787 gaim_signal_connect(gaim_accounts_get_handle(), "account-added",
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
788 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb),
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
789 optmenu);
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
790 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed",
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
791 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb),
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
792 optmenu);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
793
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
794 /* Set some data. */
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
795 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
796 g_object_set_data(G_OBJECT(optmenu), "show_all", GINT_TO_POINTER(show_all));
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
797 g_object_set_data(G_OBJECT(optmenu), "filter_func",
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
798 filter_func);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
799
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
800 /* Create and set the actual menu. */
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
801 create_account_menu(optmenu, default_account, filter_func, show_all);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
802
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
803 /* And now the last callback. */
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
804 g_signal_connect(G_OBJECT(optmenu), "changed",
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
805 G_CALLBACK(account_menu_cb), cb);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
806
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
807 return optmenu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
808 }
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
809
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
810 gboolean
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
811 gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel)
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
812 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
813 char *dirname;
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
814
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
815 if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
816 /* append a / if needed */
9534
6f0c90000bb5 [gaim-migrate @ 10362]
Mark Doliner <mark@kingant.net>
parents: 9497
diff changeset
817 if (path[strlen(path) - 1] != G_DIR_SEPARATOR) {
6f0c90000bb5 [gaim-migrate @ 10362]
Mark Doliner <mark@kingant.net>
parents: 9497
diff changeset
818 dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL);
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
819 } else {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
820 dirname = g_strdup(path);
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
821 }
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
822 gtk_file_selection_set_filename(filesel, dirname);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
823 g_free(dirname);
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
824 return TRUE;
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
825 }
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
826
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
827 return FALSE;
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
828 }
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
829
12067
e859c1663a27 [gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents: 12063
diff changeset
830 void
e859c1663a27 [gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents: 12063
diff changeset
831 gaim_gtk_setup_gtkspell(GtkTextView *textview)
12061
29dc8fc0dd6c [gaim-migrate @ 14356]
Richard Laager <rlaager@wiktel.com>
parents: 11878
diff changeset
832 {
12067
e859c1663a27 [gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents: 12063
diff changeset
833 #ifdef USE_GTKSPELL
7538
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
834 GError *error = NULL;
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
835 char *locale = NULL;
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
836
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
837 g_return_if_fail(textview != NULL);
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
838 g_return_if_fail(GTK_IS_TEXT_VIEW(textview));
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
839
12067
e859c1663a27 [gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents: 12063
diff changeset
840 if (gtkspell_new_attach(textview, locale, &error) == NULL && error)
7538
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
841 {
12067
e859c1663a27 [gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents: 12063
diff changeset
842 gaim_debug_warning("gtkspell", "Failed to setup GtkSpell: %s\n",
e859c1663a27 [gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents: 12063
diff changeset
843 error->message);
7538
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
844 g_error_free(error);
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
845 }
12067
e859c1663a27 [gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents: 12063
diff changeset
846 #endif /* USE_GTKSPELL */
7538
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
847 }
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
848
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
849 void
7420
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
850 gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
851 GdkModifierType arg2, GClosure *arg3,
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
852 gpointer data)
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
853 {
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
854 gaim_debug(GAIM_DEBUG_MISC, "accels", "accel changed, scheduling save.\n");
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
855
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
856 if (!accels_save_timer)
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
857 accels_save_timer = g_timeout_add(5000, gaim_gtk_save_accels, NULL);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
858 }
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
859
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
860 gboolean
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
861 gaim_gtk_save_accels(gpointer data)
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
862 {
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
863 char *filename = NULL;
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
864
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
865 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S,
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
866 "accels", NULL);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
867 gaim_debug(GAIM_DEBUG_MISC, "accels", "saving accels to %s\n", filename);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
868 gtk_accel_map_save(filename);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
869 g_free(filename);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
870
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
871 accels_save_timer = 0;
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
872 return FALSE;
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
873 }
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
874
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
875 void
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
876 gaim_gtk_load_accels(gpointer data)
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
877 {
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
878 char *filename = NULL;
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
879
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
880 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S,
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
881 "accels", NULL);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
882 gtk_accel_map_load(filename);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
883 g_free(filename);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
884 }
7712
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
885
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
886 gboolean
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
887 gaim_gtk_parse_x_im_contact(const char *msg, gboolean all_accounts,
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
888 GaimAccount **ret_account, char **ret_protocol,
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
889 char **ret_username, char **ret_alias)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
890 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
891 char *protocol = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
892 char *username = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
893 char *alias = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
894 char *str;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
895 char *c, *s;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
896 gboolean valid;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
897
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
898 g_return_val_if_fail(msg != NULL, FALSE);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
899 g_return_val_if_fail(ret_protocol != NULL, FALSE);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
900 g_return_val_if_fail(ret_username != NULL, FALSE);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
901
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
902 s = str = g_strdup(msg);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
903
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
904 while (*s != '\r' && *s != '\n' && *s != '\0')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
905 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
906 char *key, *value;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
907
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
908 key = s;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
909
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
910 /* Grab the key */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
911 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
912 s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
913
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
914 if (*s == '\r') s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
915
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
916 if (*s == '\n')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
917 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
918 s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
919 continue;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
920 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
921
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
922 if (*s != '\0') *s++ = '\0';
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
923
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
924 /* Clear past any whitespace */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
925 while (*s != '\0' && *s == ' ')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
926 s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
927
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
928 /* Now let's grab until the end of the line. */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
929 value = s;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
930
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
931 while (*s != '\r' && *s != '\n' && *s != '\0')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
932 s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
933
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
934 if (*s == '\r') *s++ = '\0';
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
935 if (*s == '\n') *s++ = '\0';
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
936
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
937 if ((c = strchr(key, ':')) != NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
938 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
939 if (!g_ascii_strcasecmp(key, "X-IM-Username:"))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
940 username = g_strdup(value);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
941 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:"))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
942 protocol = g_strdup(value);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
943 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:"))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
944 alias = g_strdup(value);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
945 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
946 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
947
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
948 if (username != NULL && protocol != NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
949 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
950 valid = TRUE;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
951
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
952 *ret_username = username;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
953 *ret_protocol = protocol;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
954
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
955 if (ret_alias != NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
956 *ret_alias = alias;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
957
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
958 /* Check for a compatible account. */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
959 if (ret_account != NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
960 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
961 GList *list;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
962 GaimAccount *account = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
963 GList *l;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
964 const char *protoname;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
965
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
966 if (all_accounts)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
967 list = gaim_accounts_get_all();
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
968 else
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
969 list = gaim_connections_get_all();
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
970
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
971 for (l = list; l != NULL; l = l->next)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
972 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
973 GaimConnection *gc;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
974 GaimPluginProtocolInfo *prpl_info = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
975 GaimPlugin *plugin;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
976
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
977 if (all_accounts)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
978 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
979 account = (GaimAccount *)l->data;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
980
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
981 plugin = gaim_plugins_find_with_id(
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
982 gaim_account_get_protocol_id(account));
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
983
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
984 if (plugin == NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
985 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
986 account = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
987
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
988 continue;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
989 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
990
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
991 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
992 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
993 else
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
994 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
995 gc = (GaimConnection *)l->data;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
996 account = gaim_connection_get_account(gc);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
997
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
998 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
999 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1000
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1001 protoname = prpl_info->list_icon(account, NULL);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1002
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1003 if (!strcmp(protoname, protocol))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1004 break;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1005
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1006 account = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1007 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1008
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1009 /* Special case for AIM and ICQ */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1010 if (account == NULL && (!strcmp(protocol, "aim") ||
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1011 !strcmp(protocol, "icq")))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1012 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1013 for (l = list; l != NULL; l = l->next)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1014 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1015 GaimConnection *gc;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1016 GaimPluginProtocolInfo *prpl_info = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1017 GaimPlugin *plugin;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1018
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1019 if (all_accounts)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1020 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1021 account = (GaimAccount *)l->data;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1022
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1023 plugin = gaim_plugins_find_with_id(
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1024 gaim_account_get_protocol_id(account));
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1025
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1026 if (plugin == NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1027 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1028 account = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1029
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1030 continue;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1031 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1032
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1033 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1034 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1035 else
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1036 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1037 gc = (GaimConnection *)l->data;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1038 account = gaim_connection_get_account(gc);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1039
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1040 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1041 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1042
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1043 protoname = prpl_info->list_icon(account, NULL);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1044
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1045 if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq"))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1046 break;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1047
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1048 account = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1049 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1050 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1051
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1052 *ret_account = account;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1053 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1054 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1055 else
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1056 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1057 valid = FALSE;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1058
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1059 if (username != NULL) g_free(username);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1060 if (protocol != NULL) g_free(protocol);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1061 if (alias != NULL) g_free(alias);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1062 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1063
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1064 g_free(str);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1065
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1066 return valid;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1067 }
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1068
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1069 void
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1070 gaim_set_accessible_label (GtkWidget *w, GtkWidget *l)
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1071 {
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1072 AtkObject *acc, *label;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1073 AtkObject *rel_obj[1];
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1074 AtkRelationSet *set;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1075 AtkRelation *relation;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1076 const gchar *label_text;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1077 const gchar *existing_name;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1078
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1079 acc = gtk_widget_get_accessible (w);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1080 label = gtk_widget_get_accessible (l);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1081
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1082 /* If this object has no name, set it's name with the label text */
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1083 existing_name = atk_object_get_name (acc);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1084 if (!existing_name) {
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1085 label_text = gtk_label_get_text (GTK_LABEL(l));
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1086 if (label_text)
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1087 atk_object_set_name (acc, label_text);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1088 }
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1089
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1090 /* Create the labeled-by relation */
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1091 set = atk_object_ref_relation_set (acc);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1092 rel_obj[0] = label;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1093 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1094 atk_relation_set_add (set, relation);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1095 g_object_unref (relation);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1096
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1097 /* Create the label-for relation */
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1098 set = atk_object_ref_relation_set (label);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1099 rel_obj[0] = acc;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1100 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1101 atk_relation_set_add (set, relation);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1102 g_object_unref (relation);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1103 }
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1104
8247
4a6448907382 [gaim-migrate @ 8970]
Nathan Walp <nwalp@pidgin.im>
parents: 8218
diff changeset
1105 #if GTK_CHECK_VERSION(2,2,0)
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1106 static void
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1107 gaim_gtk_menu_position_func(GtkMenu *menu,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1108 gint *x,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1109 gint *y,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1110 gboolean *push_in,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1111 gpointer data)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1112 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1113 GtkWidget *widget;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1114 GtkRequisition requisition;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1115 GdkScreen *screen;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1116 GdkRectangle monitor;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1117 gint monitor_num;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1118 gint space_left, space_right, space_above, space_below;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1119 gint needed_width;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1120 gint needed_height;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1121 gint xthickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1122 gint ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1123 gboolean rtl;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1124
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1125 g_return_if_fail(GTK_IS_MENU(menu));
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1126
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1127 widget = GTK_WIDGET(menu);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1128 screen = gtk_widget_get_screen(widget);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1129 xthickness = widget->style->xthickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1130 ythickness = widget->style->ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1131 rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1132
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1133 /*
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1134 * We need the requisition to figure out the right place to
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1135 * popup the menu. In fact, we always need to ask here, since
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1136 * if a size_request was queued while we weren't popped up,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1137 * the requisition won't have been recomputed yet.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1138 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1139 gtk_widget_size_request (widget, &requisition);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1140
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1141 monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1142
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1143 push_in = FALSE;
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11338
diff changeset
1144
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1145 /*
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1146 * The placement of popup menus horizontally works like this (with
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1147 * RTL in parentheses)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1148 *
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1149 * - If there is enough room to the right (left) of the mouse cursor,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1150 * position the menu there.
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11338
diff changeset
1151 *
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11338
diff changeset
1152 * - Otherwise, if if there is enough room to the left (right) of the
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1153 * mouse cursor, position the menu there.
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11338
diff changeset
1154 *
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1155 * - Otherwise if the menu is smaller than the monitor, position it
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1156 * on the side of the mouse cursor that has the most space available
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1157 *
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1158 * - Otherwise (if there is simply not enough room for the menu on the
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1159 * monitor), position it as far left (right) as possible.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1160 *
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1161 * Positioning in the vertical direction is similar: first try below
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1162 * mouse cursor, then above.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1163 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1164 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1165
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1166 space_left = *x - monitor.x;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1167 space_right = monitor.x + monitor.width - *x - 1;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1168 space_above = *y - monitor.y;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1169 space_below = monitor.y + monitor.height - *y - 1;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1170
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1171 /* position horizontally */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1172
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1173 /* the amount of space we need to position the menu. Note the
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11338
diff changeset
1174 * menu is offset "xthickness" pixels
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1175 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1176 needed_width = requisition.width - xthickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1177
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1178 if (needed_width <= space_left ||
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1179 needed_width <= space_right)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1180 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1181 if ((rtl && needed_width <= space_left) ||
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1182 (!rtl && needed_width > space_right))
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1183 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1184 /* position left */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1185 *x = *x + xthickness - requisition.width + 1;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1186 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1187 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1188 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1189 /* position right */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1190 *x = *x - xthickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1191 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1192
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1193 /* x is clamped on-screen further down */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1194 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1195 else if (requisition.width <= monitor.width)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1196 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1197 /* the menu is too big to fit on either side of the mouse
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1198 * cursor, but smaller than the monitor. Position it on
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1199 * the side that has the most space
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1200 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1201 if (space_left > space_right)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1202 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1203 /* left justify */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1204 *x = monitor.x;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1205 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1206 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1207 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1208 /* right justify */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1209 *x = monitor.x + monitor.width - requisition.width;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1210 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1211 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1212 else /* menu is simply too big for the monitor */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1213 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1214 if (rtl)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1215 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1216 /* right justify */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1217 *x = monitor.x + monitor.width - requisition.width;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1218 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1219 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1220 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1221 /* left justify */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1222 *x = monitor.x;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1223 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1224 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1225
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1226 /* Position vertically. The algorithm is the same as above, but
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1227 * simpler because we don't have to take RTL into account.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1228 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1229 needed_height = requisition.height - ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1230
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1231 if (needed_height <= space_above ||
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1232 needed_height <= space_below)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1233 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1234 if (needed_height <= space_below)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1235 *y = *y - ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1236 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1237 *y = *y + ythickness - requisition.height + 1;
11525
b47708f46a38 [gaim-migrate @ 13773]
Tim Ringenbach <marv@pidgin.im>
parents: 11338
diff changeset
1238
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1239 *y = CLAMP (*y, monitor.y,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1240 monitor.y + monitor.height - requisition.height);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1241 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1242 else if (needed_height > space_below && needed_height > space_above)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1243 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1244 if (space_below >= space_above)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1245 *y = monitor.y + monitor.height - requisition.height;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1246 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1247 *y = monitor.y;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1248 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1249 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1250 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1251 *y = monitor.y;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1252 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1253 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1254
8247
4a6448907382 [gaim-migrate @ 8970]
Nathan Walp <nwalp@pidgin.im>
parents: 8218
diff changeset
1255 #endif
4a6448907382 [gaim-migrate @ 8970]
Nathan Walp <nwalp@pidgin.im>
parents: 8218
diff changeset
1256
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1257 void
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1258 gaim_gtk_treeview_popup_menu_position_func(GtkMenu *menu,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1259 gint *x,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1260 gint *y,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1261 gboolean *push_in,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1262 gpointer data)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1263 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1264 GtkWidget *widget = GTK_WIDGET(data);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1265 GtkTreeView *tv = GTK_TREE_VIEW(data);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1266 GtkTreePath *path;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1267 GtkTreeViewColumn *col;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1268 GdkRectangle rect;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1269 gint ythickness = GTK_WIDGET(menu)->style->ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1270
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1271 gdk_window_get_origin (widget->window, x, y);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1272 gtk_tree_view_get_cursor (tv, &path, &col);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1273 gtk_tree_view_get_cell_area (tv, path, col, &rect);
8218
4beaf6b35483 [gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents: 8215
diff changeset
1274
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1275 *x += rect.x+rect.width;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1276 *y += rect.y+rect.height+ythickness;
8247
4a6448907382 [gaim-migrate @ 8970]
Nathan Walp <nwalp@pidgin.im>
parents: 8218
diff changeset
1277 #if GTK_CHECK_VERSION(2,2,0)
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1278 gaim_gtk_menu_position_func (menu, x, y, push_in, data);
8247
4a6448907382 [gaim-migrate @ 8970]
Nathan Walp <nwalp@pidgin.im>
parents: 8218
diff changeset
1279 #endif
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1280 }
10061
83eb12b1f1a1 [gaim-migrate @ 11033]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9910
diff changeset
1281
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1282 enum {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1283 DND_FILE_TRANSFER,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1284 DND_IM_IMAGE,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1285 DND_BUDDY_ICON
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1286 };
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1287
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1288 typedef struct {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1289 char *filename;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1290 GaimAccount *account;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1291 char *who;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1292 } _DndData;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1293
10850
fa06fda62868 [gaim-migrate @ 12522]
Mark Doliner <mark@kingant.net>
parents: 10681
diff changeset
1294 static void dnd_image_ok_callback(_DndData *data, int choice)
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1295 {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1296 char *filedata;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1297 size_t size;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1298 GError *err = NULL;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1299 GaimConversation *conv;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1300 GaimGtkConversation *gtkconv;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1301 GtkTextIter iter;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1302 int id;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1303 switch (choice) {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1304 case DND_BUDDY_ICON:
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1305 if (!g_file_get_contents(data->filename, &filedata, &size,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1306 &err)) {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1307 char *str;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1308
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1309 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1310 gaim_notify_error(NULL, NULL,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1311 _("Failed to load image"),
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1312 str);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1313
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1314 g_error_free(err);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1315 g_free(str);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1316
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1317 return;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1318 }
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1319
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1320 gaim_buddy_icons_set_for_user(data->account, data->who, filedata, size);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1321 g_free(filedata);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1322 break;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1323 case DND_FILE_TRANSFER:
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1324 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1325 break;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1326 case DND_IM_IMAGE:
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
1327 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, data->account, data->who);
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1328 gtkconv = GAIM_GTK_CONVERSATION(conv);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1329
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1330 if (!g_file_get_contents(data->filename, &filedata, &size,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1331 &err)) {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1332 char *str;
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1333
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1334 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1335 gaim_notify_error(NULL, NULL,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1336 _("Failed to load image"),
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1337 str);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1338
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1339 g_error_free(err);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1340 g_free(str);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1341
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1342 return;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1343 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1344 id = gaim_imgstore_add(filedata, size, data->filename);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1345 g_free(filedata);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1346
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1347 gtk_text_buffer_get_iter_at_mark(GTK_IMHTML(gtkconv->entry)->text_buffer, &iter,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1348 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer));
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1349 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(gtkconv->entry), id, &iter);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1350 gaim_imgstore_unref(id);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1351
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1352 break;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1353 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1354 free(data->filename);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1355 free(data->who);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1356 free(data);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1357 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1358
10850
fa06fda62868 [gaim-migrate @ 12522]
Mark Doliner <mark@kingant.net>
parents: 10681
diff changeset
1359 static void dnd_image_cancel_callback(_DndData *data, int choice)
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1360 {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1361 free(data->filename);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1362 free(data->who);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1363 free(data);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1364 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1365
11110
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1366 static void dnd_set_icon_ok_cb(_DndData *data)
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1367 {
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1368 dnd_image_ok_callback(data, DND_BUDDY_ICON);
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1369 }
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1370
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1371 static void dnd_set_icon_cancel_cb(_DndData *data)
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1372 {
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1373 free(data->filename);
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1374 free(data->who);
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1375 free(data);
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1376 }
f7ce10cad83d [gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents: 11017
diff changeset
1377
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1378 void
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1379 gaim_dnd_file_manage(GtkSelectionData *sd, GaimAccount *account, const char *who)
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1380 {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1381 GList *tmp;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1382 GdkPixbuf *pb;
11135
f2755f58a7da [gaim-migrate @ 13196]
Mark Doliner <mark@kingant.net>
parents: 11110
diff changeset
1383 GList *files = gaim_uri_list_extract_filenames((const gchar *)sd->data);
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1384 GaimConnection *gc = gaim_account_get_connection(account);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1385 GaimPluginProtocolInfo *prpl_info = NULL;
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1386 gboolean file_send_ok = FALSE;
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1387 #ifndef _WIN32
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1388 GaimDesktopItem *item;
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1389 #endif
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1390
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1391 g_return_if_fail(account != NULL);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1392 g_return_if_fail(who != NULL);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1393
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1394 for(tmp = files; tmp != NULL ; tmp = g_list_next(tmp)) {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1395 gchar *filename = tmp->data;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1396 gchar *basename = g_path_get_basename(filename);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1397
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1398 /* Set the default action: don't send anything */
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1399 file_send_ok = FALSE;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1400
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1401 /* XXX - Make ft API support creating a transfer with more than one file */
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1402 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1403 continue;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1404 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1405
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1406 /* XXX - make ft api suupport sending a directory */
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1407 /* Are we dealing with a directory? */
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1408 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1409 char *str;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1410
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1411 str = g_strdup_printf(_("Cannot send folder %s."), basename);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1412 gaim_notify_error(NULL, NULL,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1413 str,_("Gaim cannot transfer a folder. You will need to send the files within individually"));
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1414
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1415 g_free(str);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1416
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1417 continue;
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1418 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1419
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1420 /* Are we dealing with an image? */
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1421 pb = gdk_pixbuf_new_from_file(filename, NULL);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1422 if (pb) {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1423 _DndData *data = g_malloc(sizeof(_DndData));
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1424 gboolean ft = FALSE, im = FALSE;
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1425
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1426 data->who = g_strdup(who);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1427 data->filename = g_strdup(filename);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1428 data->account = account;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1429
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1430 if (gc)
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1431 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
10348
64bc206c7473 [gaim-migrate @ 11562]
Mark Doliner <mark@kingant.net>
parents: 10335
diff changeset
1432
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1433 if (prpl_info && prpl_info->options & OPT_PROTO_IM_IMAGE)
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1434 im = TRUE;
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1435
10348
64bc206c7473 [gaim-migrate @ 11562]
Mark Doliner <mark@kingant.net>
parents: 10335
diff changeset
1436 if (prpl_info && prpl_info->can_receive_file)
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1437 ft = prpl_info->can_receive_file(gc, who);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1438
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1439 if (im && ft)
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1440 gaim_request_choice(NULL, NULL,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1441 _("You have dragged an image"),
10951
84d8279259c9 [gaim-migrate @ 12751]
Mark Doliner <mark@kingant.net>
parents: 10871
diff changeset
1442 _("You can send this image as a file transfer, "
84d8279259c9 [gaim-migrate @ 12751]
Mark Doliner <mark@kingant.net>
parents: 10871
diff changeset
1443 "embed it into this message, or use it as the buddy icon for this user."),
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1444 DND_BUDDY_ICON, "OK", (GCallback)dnd_image_ok_callback,
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1445 "Cancel", (GCallback)dnd_image_cancel_callback, data,
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1446 _("Set as buddy icon"), DND_BUDDY_ICON,
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1447 _("Send image file"), DND_FILE_TRANSFER,
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1448 _("Insert in message"), DND_IM_IMAGE, NULL);
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1449 else if (!(im || ft))
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1450 gaim_request_yes_no(NULL, NULL, _("You have dragged an image"),
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1451 _("Would you like to set it as the buddy icon for this user?"),
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1452 0, data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1453 else
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1454 gaim_request_choice(NULL, NULL,
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1455 _("You have dragged an image"),
10951
84d8279259c9 [gaim-migrate @ 12751]
Mark Doliner <mark@kingant.net>
parents: 10871
diff changeset
1456 ft ? _("You can send this image as a file transfer or "
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1457 "embed it into this message, or use it as the buddy icon for this user.") :
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1458 _("You can insert this image into this message, or use it as the buddy icon for this user"),
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1459 DND_BUDDY_ICON, "OK", (GCallback)dnd_image_ok_callback,
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1460 "Cancel", (GCallback)dnd_image_cancel_callback, data,
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1461 _("Set as buddy icon"), DND_BUDDY_ICON,
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1462 ft ? _("Send image file") : _("Insert in message"), ft ? DND_FILE_TRANSFER : DND_IM_IMAGE, NULL);
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1463 return;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1464 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1465
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1466 #ifndef _WIN32
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1467 /* Are we trying to send a .desktop file? */
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11638
diff changeset
1468 else if (gaim_str_has_suffix(basename, ".desktop") && (item = gaim_desktop_item_new_from_file(filename))) {
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1469 GaimDesktopItemType dtype;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1470 char key[64];
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1471 const char *itemname = NULL;
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1472
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1473 #if GTK_CHECK_VERSION(2,6,0)
10679
dbdf6618cc49 [gaim-migrate @ 12225]
Nathan Walp <nwalp@pidgin.im>
parents: 10590
diff changeset
1474 const char * const *langs;
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1475 int i;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1476 langs = g_get_language_names();
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1477 for (i = 0; langs[i]; i++) {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1478 g_snprintf(key, sizeof(key), "Name[%s]", langs[i]);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1479 itemname = gaim_desktop_item_get_string(item, key);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1480 break;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1481 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1482 #else
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1483 const char *lang = g_getenv("LANG");
10681
d29fae081061 [gaim-migrate @ 12227]
Mark Doliner <mark@kingant.net>
parents: 10679
diff changeset
1484 char *dot;
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1485 dot = strchr(lang, '.');
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1486 if (dot)
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1487 *dot = '\0';
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1488 g_snprintf(key, sizeof(key), "Name[%s]", lang);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1489 itemname = gaim_desktop_item_get_string(item, key);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1490 #endif
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1491 if (!itemname)
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1492 itemname = gaim_desktop_item_get_string(item, "Name");
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1493
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1494 dtype = gaim_desktop_item_get_entry_type(item);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1495 switch (dtype) {
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1496 GaimConversation *conv;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1497 GaimGtkConversation *gtkconv;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1498
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1499 case GAIM_DESKTOP_ITEM_TYPE_LINK:
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
1500 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, who);
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1501 gtkconv = GAIM_GTK_CONVERSATION(conv);
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1502 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry),
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1503 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer),
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1504 gaim_desktop_item_get_string(item, "URL"), itemname);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1505 break;
10335
20e750dd21a0 [gaim-migrate @ 11542]
Mark Doliner <mark@kingant.net>
parents: 10240
diff changeset
1506 default:
10229
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1507 /* I don't know if we really want to do anything here. Most of the desktop item types are crap like
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1508 * "MIME Type" (I have no clue how that would be a desktop item) and "Comment"... nothing we can really
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1509 * send. The only logical one is "Application," but do we really want to send a binary and nothing else?
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1510 * Probably not. I'll just give an error and return. */
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1511 /* The original patch sent the icon used by the launcher. That's probably wrong */
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1512 gaim_notify_error(NULL, NULL, _("Cannot send launcher"), _("You dragged a desktop launcher. "
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1513 "Most likely you wanted to send whatever this launcher points to instead of this launcher"
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1514 " itself."));
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1515 break;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1516 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1517 gaim_desktop_item_unref(item);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1518 return;
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1519 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1520 #endif /* _WIN32 */
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1521
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1522 /* Everything is fine, let's send */
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1523 serv_send_file(gc, who, filename);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1524 g_free(filename);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1525 }
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1526 g_list_free(files);
9aa0b6d11bbf [gaim-migrate @ 11364]
Sean Egan <seanegan@gmail.com>
parents: 10209
diff changeset
1527 }
10483
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1528
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1529 void gaim_gtk_buddy_icon_get_scale_size(GdkPixbuf *buf, GaimBuddyIconSpec *spec, int *width, int *height)
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1530 {
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1531 *width = gdk_pixbuf_get_width(buf);
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1532 *height = gdk_pixbuf_get_height(buf);
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1533
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1534 gaim_buddy_icon_get_scale_size(spec, width, height);
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1535
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1536 /* and now for some arbitrary sanity checks */
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1537 if(*width > 100)
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1538 *width = 100;
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1539 if(*height > 100)
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1540 *height = 100;
748aa3c6de36 [gaim-migrate @ 11773]
Nathan Walp <nwalp@pidgin.im>
parents: 10348
diff changeset
1541 }
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1542
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1543 GdkPixbuf *
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1544 gaim_gtk_create_prpl_icon(GaimAccount *account)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1545 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1546 GaimPlugin *prpl;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1547 GaimPluginProtocolInfo *prpl_info = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1548 GdkPixbuf *status = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1549 char *filename = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1550 const char *protoname = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1551 char buf[256]; /* TODO: We should use a define for max file length */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1552
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1553 g_return_val_if_fail(account != NULL, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1554
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1555 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1556
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1557 if (prpl != NULL) {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1558 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1559
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1560 if (prpl_info->list_icon != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1561 protoname = prpl_info->list_icon(account, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1562 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1563
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1564 if (protoname == NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1565 return NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1566
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1567 /*
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1568 * Status icons will be themeable too, and then it will look up
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1569 * protoname from the theme
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1570 */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1571 g_snprintf(buf, sizeof(buf), "%s.png", protoname);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1572
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1573 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1574 "default", buf, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1575 status = gdk_pixbuf_new_from_file(filename, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1576 g_free(filename);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1577
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1578 return status;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1579 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1580
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1581 GdkPixbuf *
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1582 gaim_gtk_create_prpl_icon_with_status(GaimAccount *account, GaimStatusType *status_type)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1583 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1584 char basename2[BUFSIZ];
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1585 char *filename;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1586 const char *type_name;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1587 GdkPixbuf *pixbuf, *scale = NULL, *emblem;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1588
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1589 pixbuf = gaim_gtk_create_prpl_icon(account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1590
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1591 if (pixbuf != NULL) {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1592 scale = gdk_pixbuf_scale_simple(pixbuf, 32, 32,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1593 GDK_INTERP_BILINEAR);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1594 g_object_unref(G_OBJECT(pixbuf));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1595 } else {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1596 return NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1597 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1598
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1599 /* TODO: let the prpl pick the emblem on a per status basis, and only
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1600 * use the primitive as a fallback */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1601 type_name = gaim_primitive_get_id_from_type(gaim_status_type_get_primitive(status_type));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1602 if (!strcmp(type_name, "hidden"))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1603 type_name = "invisible";
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1604 else if (!strcmp(type_name, "unavailable"))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1605 type_name = "na";
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1606 g_snprintf(basename2, sizeof(basename2), "%s.png",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1607 type_name);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1608 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1609 basename2, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1610 emblem = gdk_pixbuf_new_from_file(filename, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1611 g_free(filename);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1612
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1613 if (emblem) {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1614 gdk_pixbuf_composite(emblem,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1615 scale, 32-15, 32-15,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1616 15, 15,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1617 32-15, 32-15,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1618 1, 1,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1619 GDK_INTERP_BILINEAR,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1620 255);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1621
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1622 g_object_unref(emblem);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1623 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1624 return scale;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1625 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 12067
diff changeset
1626