annotate src/gtkutils.c @ 9557:1ea8d59a7957

[gaim-migrate @ 10393] And one that is less likely to crash. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sun, 18 Jul 2004 18:21:26 +0000
parents 6f0c90000bb5
children d4634f26ef9b
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 */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6236
diff changeset
25 #include "gtkinternal.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
26
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 #ifndef _WIN32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
28 # include <X11/Xlib.h>
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 #else
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
30 # ifdef small
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
31 # undef small
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
32 # endif
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 #endif /*_WIN32*/
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
34
7538
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
35 #ifdef USE_GTKSPELL
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
36 # include <gtkspell/gtkspell.h>
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
37 # ifdef _WIN32
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
38 # include "wspell.h"
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
39 # endif
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
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 #include <gdk/gdkkeysyms.h>
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
43
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
44 #include "debug.h"
7078
acd2a66e59ed [gaim-migrate @ 7643]
Nathan Walp <nwalp@pidgin.im>
parents: 7060
diff changeset
45 #include "imgstore.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
46 #include "notify.h"
5548
80e4ba770f97 [gaim-migrate @ 5949]
Nathan Walp <nwalp@pidgin.im>
parents: 5530
diff changeset
47 #include "prefs.h"
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 #include "prpl.h"
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
49 #include "signals.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
50 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
51
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
52 #include "gtkconv.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
53 #include "gtkimhtml.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
54 #include "gtkutils.h"
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 #include "ui.h"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56
7420
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
57 guint accels_save_timer = 0;
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
58
8913
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
59 static gboolean
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
60 url_clicked_idle_cb(gpointer data)
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
61 {
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
62 gaim_notify_uri(NULL, data);
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
63 g_free(data);
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
64 return FALSE;
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
65 }
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
66
6465
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
67 static void
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
68 url_clicked_cb(GtkWidget *w, const char *uri)
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
69 {
8913
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8901
diff changeset
70 g_idle_add(url_clicked_idle_cb, g_strdup(uri));
6465
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
71 }
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
72
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
73 GtkIMHtmlFuncs gtkimhtml_cbs = {
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
74 (GtkIMHtmlGetImageFunc)gaim_imgstore_get,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
75 (GtkIMHtmlGetImageDataFunc)gaim_imgstore_get_data,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
76 (GtkIMHtmlGetImageSizeFunc)gaim_imgstore_get_size,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
77 (GtkIMHtmlGetImageFilenameFunc)gaim_imgstore_get_filename,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
78 gaim_imgstore_ref,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
79 gaim_imgstore_unref,
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
80 };
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
81
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 gaim_setup_imhtml(GtkWidget *imhtml)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 g_return_if_fail(imhtml != NULL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 g_return_if_fail(GTK_IS_IMHTML(imhtml));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 g_signal_connect(G_OBJECT(imhtml), "url_clicked",
6465
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6430
diff changeset
89 G_CALLBACK(url_clicked_cb), NULL);
4359
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 smiley_themeize(imhtml);
8962
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
92
4ff4c34b7500 [gaim-migrate @ 9736]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
93 gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), &gtkimhtml_cbs);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 gboolean sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle);
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 gtk_widget_set_sensitive(to_toggle, !sensitivity);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103
7751
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
104 void
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
105 gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog)
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
106 {
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
107 const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
108 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK,
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
109 (*text != '\0'));
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
110 }
d691cb95ee67 [gaim-migrate @ 8396]
Mark Doliner <mark@kingant.net>
parents: 7717
diff changeset
111
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 int
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 gaim_gtk_get_dispstyle(GaimConversationType type)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 int dispstyle = 2;
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
116 int value;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117
9150
05532ad61ed5 [gaim-migrate @ 9934]
Luke Schierer <lschiere@pidgin.im>
parents: 9123
diff changeset
118 value = gaim_prefs_get_int("/gaim/gtk/conversations/button_type");
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119
9150
05532ad61ed5 [gaim-migrate @ 9934]
Luke Schierer <lschiere@pidgin.im>
parents: 9123
diff changeset
120 switch (value) {
05532ad61ed5 [gaim-migrate @ 9934]
Luke Schierer <lschiere@pidgin.im>
parents: 9123
diff changeset
121 case GAIM_BUTTON_TEXT: dispstyle = 1; break;
05532ad61ed5 [gaim-migrate @ 9934]
Luke Schierer <lschiere@pidgin.im>
parents: 9123
diff changeset
122 case GAIM_BUTTON_IMAGE: dispstyle = 0; break;
05532ad61ed5 [gaim-migrate @ 9934]
Luke Schierer <lschiere@pidgin.im>
parents: 9123
diff changeset
123 default: dispstyle = 2; break; /* both/neither */
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 return dispstyle;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 GtkWidget *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 gaim_gtk_change_text(const char *text, GtkWidget *button,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 const char *stock, GaimConversationType type)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 int dispstyle = gaim_gtk_get_dispstyle(type);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 if (button != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 gtk_widget_destroy(button);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 button = gaim_pixbuf_button_from_stock((dispstyle == 0 ? NULL : text),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 (dispstyle == 1 ? NULL : stock),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 GAIM_BUTTON_VERTICAL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 gtk_widget_show(button);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 return button;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 gboolean sensitivity;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 if (to_toggle == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 gtk_widget_set_sensitive(to_toggle, !sensitivity);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
160 void
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
161 gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data)
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
162 {
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
163 gboolean sensitivity;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
164 gpointer element;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
165 int i;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
166
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
167 for (i=0; i < data->len; i++) {
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
168 element = g_ptr_array_index(data,i);
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
169 if (element == NULL)
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
170 continue;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
171
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
172 sensitivity = GTK_WIDGET_IS_SENSITIVE(element);
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
173
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
174 gtk_widget_set_sensitive(element, !sensitivity);
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
175 }
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
176 }
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
177
8901
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
178 void
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
179 gaim_gtk_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle)
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
180 {
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
181 if (to_toggle == NULL)
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
182 return;
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
183
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
184 if (GTK_WIDGET_VISIBLE(to_toggle))
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
185 gtk_widget_hide(to_toggle);
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
186 else
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
187 gtk_widget_show(to_toggle);
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
188 }
c430e99bb147 [gaim-migrate @ 9670]
Mark Doliner <mark@kingant.net>
parents: 8881
diff changeset
189
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
190 void gaim_separator(GtkWidget *menu)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
191 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
192 GtkWidget *menuitem;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
193
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
194 menuitem = gtk_separator_menu_item_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
195 gtk_widget_show(menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
196 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
197 }
5160
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
198
5162
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
199 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str)
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
200 {
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
201 GtkWidget *menuitem;
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
202 GtkWidget *label;
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
203
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
204 menuitem = gtk_menu_item_new();
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
205 if (menu)
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
206 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
207 gtk_widget_show(menuitem);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
208
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
209 label = gtk_label_new(str);
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6236
diff changeset
210 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
5162
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
211 gtk_label_set_pattern(GTK_LABEL(label), "_");
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
212 gtk_container_add(GTK_CONTAINER(menuitem), label);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
213 gtk_widget_show(label);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
214 /* FIXME: Go back and fix this
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
215 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0],
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
216 GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
217 */
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
218 gaim_set_accessible_label (menuitem, label);
5162
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
219 return menuitem;
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
220 }
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
221
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
222 GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str,
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
223 GtkSignalFunc sf, gpointer data, gboolean checked)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
224 {
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
225 GtkWidget *menuitem;
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
226 menuitem = gtk_check_menu_item_new_with_mnemonic(str);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
227
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
228 if (menu)
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
229 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
230
7299
2737c287f84d [gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents: 7118
diff changeset
231 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
232
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
233 if (sf)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
234 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
235
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
236 gtk_widget_show_all(menuitem);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
237
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
238 return menuitem;
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
239 }
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
240
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
241 GtkWidget *
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
242 gaim_pixbuf_toolbar_button_from_stock(const char *icon)
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
243 {
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
244 GtkWidget *button, *image, *bbox;
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
245
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
246 button = gtk_toggle_button_new();
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
247 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
248
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
249 bbox = gtk_vbox_new(FALSE, 0);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
250
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
251 gtk_container_add (GTK_CONTAINER(button), bbox);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
252
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
253 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
254 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
255
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
256 gtk_widget_show_all(bbox);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
257
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
258 return button;
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
259 }
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
260
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
261 GtkWidget *
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
262 gaim_pixbuf_button_from_stock(const char *text, const char *icon,
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
263 GaimButtonOrientation style)
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
264 {
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
265 GtkWidget *button, *image, *label, *bbox, *ibox, *lbox;
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
266
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
267 button = gtk_button_new();
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
268
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
269 if (style == GAIM_BUTTON_HORIZONTAL) {
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
270 bbox = gtk_hbox_new(FALSE, 5);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
271 ibox = gtk_hbox_new(FALSE, 0);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
272 lbox = gtk_hbox_new(FALSE, 0);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
273 }
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
274 else {
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
275 bbox = gtk_vbox_new(FALSE, 5);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
276 ibox = gtk_vbox_new(FALSE, 0);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
277 lbox = gtk_vbox_new(FALSE, 0);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
278 }
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 gtk_container_add (GTK_CONTAINER(button), bbox);
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_box_pack_start_defaults(GTK_BOX(bbox), ibox);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
283 gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
284
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
285 if (icon) {
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
286 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
287 gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, FALSE, 0);
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
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
290 if (text) {
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
291 label = gtk_label_new(NULL);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
292 gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
293 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
294 gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, FALSE, 0);
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
295 gaim_set_accessible_label (button, label);
6372
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
296 }
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 gtk_widget_show_all(bbox);
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 return button;
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
301 }
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
302
9dd4bb3cf1df [gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
303
5160
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
304 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
305 {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
306 GtkWidget *menuitem;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
307 /*
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
308 GtkWidget *hbox;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
309 GtkWidget *label;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
310 */
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
311 GtkWidget *image;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
312
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
313 if (icon == NULL)
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
314 menuitem = gtk_menu_item_new_with_mnemonic(str);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
315 else
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
316 menuitem = gtk_image_menu_item_new_with_mnemonic(str);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
317
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
318 if (menu)
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
319 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
320
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
321 if (sf)
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
322 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data);
5160
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
323
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
324 if (icon != NULL) {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
325 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
326 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
327 }
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
328 /* FIXME: this isn't right
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
329 if (mod) {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
330 label = gtk_label_new(mod);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
331 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
332 gtk_widget_show(label);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
333 }
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
334 */
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
335 /*
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
336 if (accel_key) {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
337 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
338 accel_mods, GTK_ACCEL_LOCKED);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
339 }
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
340 */
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 gtk_widget_show_all(menuitem);
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 return menuitem;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
345 }
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
346
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
347 GtkWidget *
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
348 gaim_gtk_make_frame(GtkWidget *parent, const char *title)
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
349 {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
350 GtkWidget *vbox, *label, *hbox;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
351 char labeltitle[256];
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
352
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
353 vbox = gtk_vbox_new(FALSE, 6);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
354 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
355 gtk_widget_show(vbox);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
356
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
357 label = gtk_label_new(NULL);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
358 g_snprintf(labeltitle, sizeof(labeltitle),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
359 "<span weight=\"bold\">%s</span>", title);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
360
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
361 gtk_label_set_markup(GTK_LABEL(label), labeltitle);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
362 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
363 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
364 gtk_widget_show(label);
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
365 gaim_set_accessible_label (vbox, label);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
366
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
367 hbox = gtk_hbox_new(FALSE, 6);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
368 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
369 gtk_widget_show(hbox);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
370
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
371 label = gtk_label_new(" ");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
372 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
373 gtk_widget_show(label);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
374
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
375 vbox = gtk_vbox_new(FALSE, 6);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
376 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
377 gtk_widget_show(vbox);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
378
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
379 return vbox;
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
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
382 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5746
diff changeset
383 protocol_menu_cb(GtkWidget *optmenu, GCallback cb)
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
384 {
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
385 GtkWidget *menu;
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
386 GtkWidget *item;
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
387 const char *protocol;
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
388 gpointer user_data;
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
389
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
390 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
391 item = gtk_menu_get_active(GTK_MENU(menu));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
392
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
393 protocol = g_object_get_data(G_OBJECT(item), "protocol");
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
394 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data"));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
395
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
396 if (cb != NULL)
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
397 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol,
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
398 user_data);
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
399 }
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
400
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
401 GtkWidget *
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
402 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
403 gpointer user_data)
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
404 {
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
405 GaimPluginProtocolInfo *prpl_info;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
406 GaimPlugin *plugin;
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
407 GtkWidget *hbox;
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
408 GtkWidget *label;
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
409 GtkWidget *optmenu;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
410 GtkWidget *menu;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
411 GtkWidget *item;
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
412 GtkWidget *image;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
413 GdkPixbuf *pixbuf;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
414 GdkPixbuf *scale;
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
415 GList *p;
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
416 GtkSizeGroup *sg;
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
417 char *filename;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
418 const char *proto_name;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
419 char buf[256];
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
420 int i, selected_index = -1;
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
421
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
422 optmenu = gtk_option_menu_new();
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
423 gtk_widget_show(optmenu);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
424
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
425 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
426
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
427 menu = gtk_menu_new();
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
428 gtk_widget_show(menu);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
429
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
430 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
431
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
432 for (p = gaim_plugins_get_protocols(), i = 0;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
433 p != NULL;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
434 p = p->next, i++) {
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 plugin = (GaimPlugin *)p->data;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
437 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
438
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
439 /* Create the item. */
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
440 item = gtk_menu_item_new();
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
441
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
442 /* Create the hbox. */
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
443 hbox = gtk_hbox_new(FALSE, 4);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
444 gtk_container_add(GTK_CONTAINER(item), hbox);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
445 gtk_widget_show(hbox);
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
446
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
447 /* Load the image. */
6430
5211873190ea [gaim-migrate @ 6938]
Sean Egan <seanegan@gmail.com>
parents: 6429
diff changeset
448 proto_name = prpl_info->list_icon(NULL, NULL);
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
449 g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
450
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
451 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
452 "default", buf, NULL);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
453 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
454 g_free(filename);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
455
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
456 if (pixbuf != NULL) {
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
457 /* Scale and insert the image */
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
458 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
459 GDK_INTERP_BILINEAR);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
460 image = gtk_image_new_from_pixbuf(scale);
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
461
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
462 g_object_unref(G_OBJECT(pixbuf));
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
463 g_object_unref(G_OBJECT(scale));
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
464 }
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
465 else
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
466 image = gtk_image_new();
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
467
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
468 gtk_size_group_add_widget(sg, image);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
469
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
470 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
471 gtk_widget_show(image);
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 label. */
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
474 label = gtk_label_new(plugin->info->name);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
475 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
476 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
477 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
478 gtk_widget_show(label);
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
479
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
480 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
481
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
482 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
483 gtk_widget_show(item);
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
484 gaim_set_accessible_label (item, label);
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
485
8218
4beaf6b35483 [gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents: 8215
diff changeset
486 if (id != NULL && !strcmp(plugin->info->id, id))
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
487 selected_index = i;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
488 }
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
489
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
490 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
491
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
492 if (selected_index != -1)
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
493 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
494
5688
e43e1b8dca8b [gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
495 g_signal_connect(G_OBJECT(optmenu), "changed",
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5746
diff changeset
496 G_CALLBACK(protocol_menu_cb), cb);
5688
e43e1b8dca8b [gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
497
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
498 g_object_unref(sg);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
499
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
500 return optmenu;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
501 }
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
502
8940
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
503 GaimAccount *
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
504 gaim_gtk_account_option_menu_get_selected(GtkWidget *optmenu)
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
505 {
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
506 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
507 GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu));
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
508 return g_object_get_data(G_OBJECT(item), "account");
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
509 }
b875f5d57b81 [gaim-migrate @ 9710]
Mark Doliner <mark@kingant.net>
parents: 8913
diff changeset
510
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
511 static void
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
512 account_menu_cb(GtkWidget *optmenu, GCallback cb)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
513 {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
514 GtkWidget *menu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
515 GtkWidget *item;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
516 GaimAccount *account;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
517 gpointer user_data;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
518
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
519 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
520 item = gtk_menu_get_active(GTK_MENU(menu));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
521
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
522 account = g_object_get_data(G_OBJECT(item), "account");
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
523 user_data = g_object_get_data(G_OBJECT(optmenu), "user_data");
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
524
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
525 if (cb != NULL)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
526 ((void (*)(GtkWidget *, GaimAccount *, gpointer))cb)(item, account,
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
527 user_data);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
528 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
529
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
530 static void
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
531 create_account_menu(GtkWidget *optmenu, GaimAccount *default_account,
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
532 GaimFilterAccountFunc filter_func, gboolean show_all)
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
533 {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
534 GaimAccount *account;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
535 GtkWidget *menu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
536 GtkWidget *item;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
537 GtkWidget *image;
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
538 GtkWidget *hbox;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
539 GtkWidget *label;
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
540 GdkPixbuf *pixbuf;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
541 GdkPixbuf *scale;
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
542 GList *list;
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
543 GList *p;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
544 GtkSizeGroup *sg;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
545 char *filename;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
546 const char *proto_name;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
547 char buf[256];
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
548 int i, selected_index = -1;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
549
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
550 if (show_all)
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
551 list = gaim_accounts_get_all();
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
552 else
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
553 list = gaim_connections_get_all();
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
554
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
555 menu = gtk_menu_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
556 gtk_widget_show(menu);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
557
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
558 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
5877
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 for (p = list, i = 0; p != NULL; p = p->next, i++) {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
561 GaimPluginProtocolInfo *prpl_info = NULL;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
562 GaimPlugin *plugin;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
563
5879
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
564 if (show_all)
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
565 account = (GaimAccount *)p->data;
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
566 else {
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
567 GaimConnection *gc = (GaimConnection *)p->data;
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
568
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
569 account = gaim_connection_get_account(gc);
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
570 }
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
571
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
572 if (filter_func && !filter_func(account)) {
8215
83830cb8467e [gaim-migrate @ 8938]
Nathan Walp <nwalp@pidgin.im>
parents: 8155
diff changeset
573 i--;
6646
b89d98f0bf79 [gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
574 continue;
8215
83830cb8467e [gaim-migrate @ 8938]
Nathan Walp <nwalp@pidgin.im>
parents: 8155
diff changeset
575 }
6646
b89d98f0bf79 [gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
576
7956
1b8261f374ea [gaim-migrate @ 8631]
Nathan Walp <nwalp@pidgin.im>
parents: 7943
diff changeset
577 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account));
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
578
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
579 if (plugin != NULL)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
580 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
581
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
582 /* Create the item. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
583 item = gtk_menu_item_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
584
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
585 /* Create the hbox. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
586 hbox = gtk_hbox_new(FALSE, 4);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
587 gtk_container_add(GTK_CONTAINER(item), hbox);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
588 gtk_widget_show(hbox);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
589
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
590 /* Load the image. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
591 if (prpl_info != NULL) {
6430
5211873190ea [gaim-migrate @ 6938]
Sean Egan <seanegan@gmail.com>
parents: 6429
diff changeset
592 proto_name = prpl_info->list_icon(account, NULL);
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
593 g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
594
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
595 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
8155
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
596 "default", buf, NULL);
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
597 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
598 g_free(filename);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
599
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
600 if (pixbuf != NULL) {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
601 /* Scale and insert the image */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
602 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
8155
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
603 GDK_INTERP_BILINEAR);
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
604
8215
83830cb8467e [gaim-migrate @ 8938]
Nathan Walp <nwalp@pidgin.im>
parents: 8155
diff changeset
605 if (!gaim_account_is_connected(account) && show_all &&
83830cb8467e [gaim-migrate @ 8938]
Nathan Walp <nwalp@pidgin.im>
parents: 8155
diff changeset
606 gaim_connections_get_all())
8155
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
607 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
77d1252b3803 [gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents: 8143
diff changeset
608
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
609 image = gtk_image_new_from_pixbuf(scale);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
610
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
611 g_object_unref(G_OBJECT(pixbuf));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
612 g_object_unref(G_OBJECT(scale));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
613 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
614 else
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
615 image = gtk_image_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
616 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
617 else
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
618 image = gtk_image_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
619
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
620 gtk_size_group_add_widget(sg, image);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
621
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
622 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
623 gtk_widget_show(image);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
624
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
625 g_snprintf(buf, sizeof(buf), "%s (%s)",
6236
7ff81c01d238 [gaim-migrate @ 6729]
Mark Doliner <mark@kingant.net>
parents: 5967
diff changeset
626 gaim_account_get_username(account),
7ff81c01d238 [gaim-migrate @ 6729]
Mark Doliner <mark@kingant.net>
parents: 5967
diff changeset
627 (plugin != NULL) ? plugin->info->name : _("Unknown"));
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
628
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
629 /* Create the label. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
630 label = gtk_label_new(buf);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
631 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
632 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
633 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
634 gtk_widget_show(label);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
635
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
636 g_object_set_data(G_OBJECT(item), "account", account);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
637
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
638 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
639 gtk_widget_show(item);
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
640 gaim_set_accessible_label (item, label);
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
641
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
642 if (default_account != NULL && account == default_account)
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
643 selected_index = i;
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
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
646 g_object_unref(sg);
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
647
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
648 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
649
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
650 /* Set the place we should be at. */
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
651 if (selected_index != -1)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
652 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
653 }
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
654
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
655 static void
8134
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
656 regenerate_account_menu(GtkWidget *optmenu)
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
657 {
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
658 GtkWidget *menu;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
659 GtkWidget *item;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
660 gboolean show_all;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
661 GaimAccount *account;
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
662 GaimFilterAccountFunc filter_func;
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
663
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
664 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
665 item = gtk_menu_get_active(GTK_MENU(menu));
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
666 account = g_object_get_data(G_OBJECT(item), "account");
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
667
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
668 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
669 "show_all"));
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
670
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
671 filter_func = g_object_get_data(G_OBJECT(optmenu),
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
672 "filter_func");
6646
b89d98f0bf79 [gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents: 6485
diff changeset
673
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
674 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu));
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
675
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
676 create_account_menu(optmenu, account, filter_func, show_all);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
677 }
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
678
8134
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
679 static void
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
680 account_menu_sign_on_off_cb(GaimConnection *gc, GtkWidget *optmenu)
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
681 {
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
682 regenerate_account_menu(optmenu);
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
683 }
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
684
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
685 static void
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
686 account_menu_added_removed_cb(GaimAccount *account, GtkWidget *optmenu)
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
687 {
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
688 regenerate_account_menu(optmenu);
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
689 }
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
690
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
691 static gboolean
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
692 account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event,
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
693 void *user_data)
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
694 {
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
695 gaim_signals_disconnect_by_handle(optmenu);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
696
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
697 return FALSE;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
698 }
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
699
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
700 GtkWidget *
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
701 gaim_gtk_account_option_menu_new(GaimAccount *default_account,
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
702 gboolean show_all, GCallback cb,
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
703 GaimFilterAccountFunc filter_func,
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
704 gpointer user_data)
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 GtkWidget *optmenu;
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
707
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
708 /* Create the option menu */
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
709 optmenu = gtk_option_menu_new();
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
710 gtk_widget_show(optmenu);
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
711
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
712 g_signal_connect(G_OBJECT(optmenu), "destroy",
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
713 G_CALLBACK(account_menu_destroyed_cb), NULL);
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
714
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
715 /* Register the gaim sign on/off event callbacks. */
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
716 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
717 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb),
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
718 optmenu);
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
719 gaim_signal_connect(gaim_connections_get_handle(), "signed-off",
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
720 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb),
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6465
diff changeset
721 optmenu);
8134
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
722 gaim_signal_connect(gaim_accounts_get_handle(), "account-added",
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
723 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb),
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
724 optmenu);
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
725 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed",
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
726 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb),
ea3eb461efc0 [gaim-migrate @ 8839]
Nathan Walp <nwalp@pidgin.im>
parents: 8061
diff changeset
727 optmenu);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
728
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
729 /* Set some data. */
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
730 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
731 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
732 g_object_set_data(G_OBJECT(optmenu), "filter_func",
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
733 filter_func);
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 /* Create and set the actual menu. */
8289
e39ea2b4f6cd [gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents: 8247
diff changeset
736 create_account_menu(optmenu, default_account, filter_func, show_all);
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
737
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
738 /* And now the last callback. */
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
739 g_signal_connect(G_OBJECT(optmenu), "changed",
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
740 G_CALLBACK(account_menu_cb), cb);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
741
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
742 return optmenu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
743 }
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
744
6391
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
745 gboolean
4b2d8d7d0118 [gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents: 6372
diff changeset
746 gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel)
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
747 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
748 char *dirname;
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
749
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
750 if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
751 /* append a / if needed */
9534
6f0c90000bb5 [gaim-migrate @ 10362]
Mark Doliner <mark@kingant.net>
parents: 9497
diff changeset
752 if (path[strlen(path) - 1] != G_DIR_SEPARATOR) {
6f0c90000bb5 [gaim-migrate @ 10362]
Mark Doliner <mark@kingant.net>
parents: 9497
diff changeset
753 dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL);
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
754 } else {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
755 dirname = g_strdup(path);
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
756 }
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
757 gtk_file_selection_set_filename(filesel, dirname);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
758 g_free(dirname);
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
759 return TRUE;
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
760 }
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
761
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
762 return FALSE;
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
763 }
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
764
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
765 char *stylize(const gchar *text, int length)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
766 {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
767 gchar *buf;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
768 char *tmp = g_malloc(length);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
769
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
770 buf = g_malloc(length);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
771 g_snprintf(buf, length, "%s", text);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
772
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
773 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_formatting")) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
774 const char *font;
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
775 GdkColor fg_color, bg_color;
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
776
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
777 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
778 g_snprintf(tmp, length, "<B>%s</B>", buf);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
779 strcpy(buf, tmp);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
780 }
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
781
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
782 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
783 g_snprintf(tmp, length, "<I>%s</I>", buf);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
784 strcpy(buf, tmp);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
785 }
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
786
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
787 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
788 g_snprintf(tmp, length, "<U>%s</U>", buf);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
789 strcpy(buf, tmp);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
790 }
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
791
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
792 font = gaim_prefs_get_string("/gaim/gtk/conversations/font_face");
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
793
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
794 if (strcmp(font, "") != 0) {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
795 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", font, buf);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
796 strcpy(buf, tmp);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
797 }
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
798
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
799 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>",
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
800 gaim_prefs_get_int("/gaim/gtk/conversations/font_size"), buf);
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
801 strcpy(buf, tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
802
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
803 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0)
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
804 {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
805 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"),
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
806 &fg_color);
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
807
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
808 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>",
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
809 fg_color.red/256, fg_color.green/256,
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
810 fg_color.blue/256, buf);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
811 strcpy(buf, tmp);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
812 }
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
813
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
814 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0)
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
815 {
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
816 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"),
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
817 &bg_color);
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
818
9025
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
819 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>",
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
820 bg_color.red/256, bg_color.green/256,
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
821 bg_color.blue/256, buf);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
822 strcpy(buf, tmp);
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
823 }
b24967757d46 [gaim-migrate @ 9801]
Luke Schierer <lschiere@pidgin.im>
parents: 8962
diff changeset
824
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
825 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
826
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
827 g_free(tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
828 return buf;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
829 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
830
7538
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
831 void
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
832 gaim_gtk_setup_gtkspell(GtkTextView *textview)
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
833 {
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
834 #ifdef USE_GTKSPELL
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
835 GError *error = NULL;
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
836 char *locale = NULL;
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
837
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
838 g_return_if_fail(textview != NULL);
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
839 g_return_if_fail(GTK_IS_TEXT_VIEW(textview));
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
840
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
841 if (gtkspell_new_attach(textview, locale, &error) == NULL && error)
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
842 {
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
843 gaim_debug_warning("gtkspell", "Failed to setup GtkSpell: %s\n",
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
844 error->message);
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
845 g_error_free(error);
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
846 }
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
847 #endif /* USE_GTKSPELL */
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
357eb1c39b72 [gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents: 7420
diff changeset
850 void
7420
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
851 gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
852 GdkModifierType arg2, GClosure *arg3,
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
853 gpointer data)
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
854 {
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
855 gaim_debug(GAIM_DEBUG_MISC, "accels", "accel changed, scheduling save.\n");
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
856
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
857 if (!accels_save_timer)
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
858 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
859 }
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
860
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
861 gboolean
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
862 gaim_gtk_save_accels(gpointer data)
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
863 {
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
864 char *filename = NULL;
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
865
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
866 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S,
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
867 "accels", NULL);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
868 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
869 gtk_accel_map_save(filename);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
870 g_free(filename);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
871
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
872 accels_save_timer = 0;
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
873 return FALSE;
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
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
876 void
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
877 gaim_gtk_load_accels(gpointer data)
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
878 {
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
879 char *filename = NULL;
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
880
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
881 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S,
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
882 "accels", NULL);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
883 gtk_accel_map_load(filename);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
884 g_free(filename);
53c86d59f20b [gaim-migrate @ 8022]
Luke Schierer <lschiere@pidgin.im>
parents: 7299
diff changeset
885 }
7712
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
886
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
887 gboolean
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
888 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
889 GaimAccount **ret_account, char **ret_protocol,
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
890 char **ret_username, char **ret_alias)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
891 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
892 char *protocol = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
893 char *username = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
894 char *alias = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
895 char *str;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
896 char *c, *s;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
897 gboolean valid;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
898
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
899 g_return_val_if_fail(msg != NULL, FALSE);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
900 g_return_val_if_fail(ret_protocol != NULL, FALSE);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
901 g_return_val_if_fail(ret_username != NULL, FALSE);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
902
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
903 s = str = g_strdup(msg);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
904
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
905 while (*s != '\r' && *s != '\n' && *s != '\0')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
906 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
907 char *key, *value;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
908
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
909 key = s;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
910
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
911 /* Grab the key */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
912 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
913 s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
914
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
915 if (*s == '\r') s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
916
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
917 if (*s == '\n')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
918 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
919 s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
920 continue;
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
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
923 if (*s != '\0') *s++ = '\0';
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
924
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
925 /* Clear past any whitespace */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
926 while (*s != '\0' && *s == ' ')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
927 s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
928
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
929 /* Now let's grab until the end of the line. */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
930 value = s;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
931
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
932 while (*s != '\r' && *s != '\n' && *s != '\0')
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
933 s++;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
934
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
935 if (*s == '\r') *s++ = '\0';
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
936 if (*s == '\n') *s++ = '\0';
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
937
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
938 if ((c = strchr(key, ':')) != NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
939 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
940 if (!g_ascii_strcasecmp(key, "X-IM-Username:"))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
941 username = g_strdup(value);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
942 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:"))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
943 protocol = g_strdup(value);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
944 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:"))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
945 alias = g_strdup(value);
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
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
949 if (username != NULL && protocol != NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
950 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
951 valid = TRUE;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
952
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
953 *ret_username = username;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
954 *ret_protocol = protocol;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
955
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
956 if (ret_alias != NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
957 *ret_alias = alias;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
958
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
959 /* Check for a compatible account. */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
960 if (ret_account != NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
961 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
962 GList *list;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
963 GaimAccount *account = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
964 GList *l;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
965 const char *protoname;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
966
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
967 if (all_accounts)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
968 list = gaim_accounts_get_all();
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
969 else
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
970 list = gaim_connections_get_all();
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
971
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
972 for (l = list; l != NULL; l = l->next)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
973 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
974 GaimConnection *gc;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
975 GaimPluginProtocolInfo *prpl_info = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
976 GaimPlugin *plugin;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
977
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
978 if (all_accounts)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
979 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
980 account = (GaimAccount *)l->data;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
981
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
982 plugin = gaim_plugins_find_with_id(
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
983 gaim_account_get_protocol_id(account));
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
984
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
985 if (plugin == NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
986 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
987 account = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
988
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
989 continue;
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
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
992 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
993 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
994 else
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
995 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
996 gc = (GaimConnection *)l->data;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
997 account = gaim_connection_get_account(gc);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
998
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
999 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
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
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1002 protoname = prpl_info->list_icon(account, NULL);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1003
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1004 if (!strcmp(protoname, protocol))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1005 break;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1006
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1007 account = NULL;
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
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1010 /* Special case for AIM and ICQ */
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1011 if (account == NULL && (!strcmp(protocol, "aim") ||
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1012 !strcmp(protocol, "icq")))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1013 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1014 for (l = list; l != NULL; l = l->next)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1015 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1016 GaimConnection *gc;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1017 GaimPluginProtocolInfo *prpl_info = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1018 GaimPlugin *plugin;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1019
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1020 if (all_accounts)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1021 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1022 account = (GaimAccount *)l->data;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1023
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1024 plugin = gaim_plugins_find_with_id(
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1025 gaim_account_get_protocol_id(account));
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1026
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1027 if (plugin == NULL)
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1028 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1029 account = NULL;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1030
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1031 continue;
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
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1034 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1035 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1036 else
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1037 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1038 gc = (GaimConnection *)l->data;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1039 account = gaim_connection_get_account(gc);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1040
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1041 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
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
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1044 protoname = prpl_info->list_icon(account, NULL);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1045
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1046 if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq"))
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1047 break;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1048
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1049 account = NULL;
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
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1053 *ret_account = account;
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 }
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1056 else
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1057 {
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1058 valid = FALSE;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1059
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1060 if (username != NULL) g_free(username);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1061 if (protocol != NULL) g_free(protocol);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1062 if (alias != NULL) g_free(alias);
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
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1065 g_free(str);
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1066
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1067 return valid;
2823111061ba [gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents: 7538
diff changeset
1068 }
8137
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1069
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1070 void
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1071 gaim_set_accessible_label (GtkWidget *w, GtkWidget *l)
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1072 {
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1073 AtkObject *acc, *label;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1074 AtkObject *rel_obj[1];
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1075 AtkRelationSet *set;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1076 AtkRelation *relation;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1077 const gchar *label_text;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1078 const gchar *existing_name;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1079
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1080 acc = gtk_widget_get_accessible (w);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1081 label = gtk_widget_get_accessible (l);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1082
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1083 /* 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
1084 existing_name = atk_object_get_name (acc);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1085 if (!existing_name) {
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1086 label_text = gtk_label_get_text (GTK_LABEL(l));
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1087 if (label_text)
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1088 atk_object_set_name (acc, label_text);
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
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1091 /* Create the labeled-by relation */
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1092 set = atk_object_ref_relation_set (acc);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1093 rel_obj[0] = label;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1094 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1095 atk_relation_set_add (set, relation);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1096 g_object_unref (relation);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1097
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1098 /* Create the label-for relation */
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1099 set = atk_object_ref_relation_set (label);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1100 rel_obj[0] = acc;
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1101 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1102 atk_relation_set_add (set, relation);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1103 g_object_unref (relation);
4971193f761d [gaim-migrate @ 8842]
Mark Doliner <mark@kingant.net>
parents: 8134
diff changeset
1104 }
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1105
8247
4a6448907382 [gaim-migrate @ 8970]
Nathan Walp <nwalp@pidgin.im>
parents: 8218
diff changeset
1106 #if GTK_CHECK_VERSION(2,2,0)
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1107 static void
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1108 gaim_gtk_menu_position_func(GtkMenu *menu,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1109 gint *x,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1110 gint *y,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1111 gboolean *push_in,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1112 gpointer data)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1113 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1114 GtkWidget *widget;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1115 GtkRequisition requisition;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1116 GdkScreen *screen;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1117 GdkRectangle monitor;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1118 gint monitor_num;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1119 gint space_left, space_right, space_above, space_below;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1120 gint needed_width;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1121 gint needed_height;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1122 gint xthickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1123 gint ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1124 gboolean rtl;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1125
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1126 g_return_if_fail(GTK_IS_MENU(menu));
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1127
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1128 widget = GTK_WIDGET(menu);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1129 screen = gtk_widget_get_screen(widget);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1130 xthickness = widget->style->xthickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1131 ythickness = widget->style->ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1132 rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL);
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 /*
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1135 * We need the requisition to figure out the right place to
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1136 * 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
1137 * 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
1138 * the requisition won't have been recomputed yet.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1139 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1140 gtk_widget_size_request (widget, &requisition);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1141
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1142 monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1144 push_in = FALSE;
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 /*
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1147 * The placement of popup menus horizontally works like this (with
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1148 * RTL in parentheses)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1149 *
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1150 * - 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
1151 * position the menu there.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1152 *
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1153 * - Otherwise, if if there is enough room to the left (right) of the
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1154 * mouse cursor, position the menu there.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1155 *
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1156 * - Otherwise if the menu is smaller than the monitor, position it
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1157 * 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
1158 *
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1159 * - 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
1160 * monitor), position it as far left (right) as possible.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1161 *
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1162 * Positioning in the vertical direction is similar: first try below
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1163 * mouse cursor, then above.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1164 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1165 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1166
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1167 space_left = *x - monitor.x;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1168 space_right = monitor.x + monitor.width - *x - 1;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1169 space_above = *y - monitor.y;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1170 space_below = monitor.y + monitor.height - *y - 1;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1171
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1172 /* position horizontally */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1173
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1174 /* the amount of space we need to position the menu. Note the
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1175 * menu is offset "xthickness" pixels
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1176 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1177 needed_width = requisition.width - xthickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1178
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1179 if (needed_width <= space_left ||
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1180 needed_width <= space_right)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1181 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1182 if ((rtl && needed_width <= space_left) ||
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1183 (!rtl && needed_width > space_right))
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1184 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1185 /* position left */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1186 *x = *x + xthickness - requisition.width + 1;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1187 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1188 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1189 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1190 /* position right */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1191 *x = *x - xthickness;
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
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1194 /* x is clamped on-screen further down */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1195 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1196 else if (requisition.width <= monitor.width)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1197 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1198 /* 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
1199 * cursor, but smaller than the monitor. Position it on
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1200 * the side that has the most space
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1201 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1202 if (space_left > space_right)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1203 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1204 /* left justify */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1205 *x = monitor.x;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1206 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1207 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1208 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1209 /* right justify */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1210 *x = monitor.x + monitor.width - requisition.width;
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 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1213 else /* menu is simply too big for the monitor */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1214 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1215 if (rtl)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1216 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1217 /* right justify */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1218 *x = monitor.x + monitor.width - requisition.width;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1219 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1220 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1221 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1222 /* left justify */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1223 *x = monitor.x;
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
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1227 /* Position vertically. The algorithm is the same as above, but
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1228 * simpler because we don't have to take RTL into account.
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1229 */
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1230 needed_height = requisition.height - ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1231
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1232 if (needed_height <= space_above ||
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1233 needed_height <= space_below)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1234 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1235 if (needed_height <= space_below)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1236 *y = *y - ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1237 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1238 *y = *y + ythickness - requisition.height + 1;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1239
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1240 *y = CLAMP (*y, monitor.y,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1241 monitor.y + monitor.height - requisition.height);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1242 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1243 else if (needed_height > space_below && needed_height > space_above)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1244 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1245 if (space_below >= space_above)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1246 *y = monitor.y + monitor.height - requisition.height;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1247 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1248 *y = monitor.y;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1249 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1250 else
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1251 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1252 *y = monitor.y;
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 }
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1255
8247
4a6448907382 [gaim-migrate @ 8970]
Nathan Walp <nwalp@pidgin.im>
parents: 8218
diff changeset
1256 #endif
4a6448907382 [gaim-migrate @ 8970]
Nathan Walp <nwalp@pidgin.im>
parents: 8218
diff changeset
1257
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1258 void
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1259 gaim_gtk_treeview_popup_menu_position_func(GtkMenu *menu,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1260 gint *x,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1261 gint *y,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1262 gboolean *push_in,
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1263 gpointer data)
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1264 {
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1265 GtkWidget *widget = GTK_WIDGET(data);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1266 GtkTreeView *tv = GTK_TREE_VIEW(data);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1267 GtkTreePath *path;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1268 GtkTreeViewColumn *col;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1269 GdkRectangle rect;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1270 gint ythickness = GTK_WIDGET(menu)->style->ythickness;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1271
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1272 gdk_window_get_origin (widget->window, x, y);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1273 gtk_tree_view_get_cursor (tv, &path, &col);
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1274 gtk_tree_view_get_cell_area (tv, path, col, &rect);
8218
4beaf6b35483 [gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents: 8215
diff changeset
1275
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1276 *x += rect.x+rect.width;
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1277 *y += rect.y+rect.height+ythickness;
8247
4a6448907382 [gaim-migrate @ 8970]
Nathan Walp <nwalp@pidgin.im>
parents: 8218
diff changeset
1278 #if GTK_CHECK_VERSION(2,2,0)
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1279 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
1280 #endif
8143
8633dc570442 [gaim-migrate @ 8851]
Mark Doliner <mark@kingant.net>
parents: 8137
diff changeset
1281 }