annotate gtk/gtkutils.c @ 14200:5300e2f1fed3

[gaim-migrate @ 16872] Test program to detect keycodes. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 19 Aug 2006 05:44:40 +0000
parents 009db0b357b5
children c18bdf510325
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14191
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1 /**
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2 * @file gtkutils.h GTK+ utility functions
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
3 * @ingroup gtkui
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
4 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
5 * gaim
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
6 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
9 * source distribution.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
10 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
14 * (at your option) any later version.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
15 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
19 * GNU General Public License for more details.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
20 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
24 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
25 #include "internal.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
26 #include "gtkgaim.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
27
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
28 #ifndef _WIN32
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
29 # include <X11/Xlib.h>
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
30 #else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
31 # ifdef small
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
32 # undef small
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
33 # endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
34 #endif /*_WIN32*/
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
35
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
36 #ifdef USE_GTKSPELL
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
37 # include <gtkspell/gtkspell.h>
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
38 # ifdef _WIN32
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
39 # include "wspell.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
40 # endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
41 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
42
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
43 #include <gdk/gdkkeysyms.h>
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
44
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
45 #include "conversation.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
46 #include "debug.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
47 #include "desktopitem.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
48 #include "imgstore.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
49 #include "notify.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
50 #include "prefs.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
51 #include "prpl.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
52 #include "request.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
53 #include "signals.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
54 #include "util.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
55
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
56 #include "gtkconv.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
57 #include "gtkdialogs.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
58 #include "gtkimhtml.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
59 #include "gtkimhtmltoolbar.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
60 #include "gaimstock.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
61 #include "gtkthemes.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
62 #include "gtkutils.h"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
63
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
64 static guint accels_save_timer = 0;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
65
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
66 static gboolean
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
67 url_clicked_idle_cb(gpointer data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
68 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
69 gaim_notify_uri(NULL, data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
70 g_free(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
71 return FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
72 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
73
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
74 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
75 url_clicked_cb(GtkWidget *w, const char *uri)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
76 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
77 g_idle_add(url_clicked_idle_cb, g_strdup(uri));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
78 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
79
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
80 static GtkIMHtmlFuncs gtkimhtml_cbs = {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
81 (GtkIMHtmlGetImageFunc)gaim_imgstore_get,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
82 (GtkIMHtmlGetImageDataFunc)gaim_imgstore_get_data,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
83 (GtkIMHtmlGetImageSizeFunc)gaim_imgstore_get_size,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
84 (GtkIMHtmlGetImageFilenameFunc)gaim_imgstore_get_filename,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
85 gaim_imgstore_ref,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
86 gaim_imgstore_unref,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
87 };
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
88
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
89 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
90 gaim_setup_imhtml(GtkWidget *imhtml)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
91 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
92 g_return_if_fail(imhtml != NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
93 g_return_if_fail(GTK_IS_IMHTML(imhtml));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
94
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
95 g_signal_connect(G_OBJECT(imhtml), "url_clicked",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
96 G_CALLBACK(url_clicked_cb), NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
97
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
98 gaim_gtkthemes_smiley_themeize(imhtml);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
99
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
100 gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), &gtkimhtml_cbs);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
101 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
102
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
103 GtkWidget *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
104 gaim_gtk_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
105 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
106 GtkWidget *frame;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
107 GtkWidget *imhtml;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
108 GtkWidget *sep;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
109 GtkWidget *sw;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
110 GtkWidget *toolbar = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
111 GtkWidget *vbox;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
112
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
113 frame = gtk_frame_new(NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
114 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
115
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
116 vbox = gtk_vbox_new(FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
117 gtk_container_add(GTK_CONTAINER(frame), vbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
118 gtk_widget_show(vbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
119
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
120 if (editable) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
121 toolbar = gtk_imhtmltoolbar_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
122 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
123 gtk_widget_show(toolbar);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
124
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
125 sep = gtk_hseparator_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
126 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
127 gtk_widget_show(sep);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
128 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
129
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
130 sw = gtk_scrolled_window_new(NULL, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
131 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
132 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
133 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
134 gtk_widget_show(sw);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
135
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
136 imhtml = gtk_imhtml_new(NULL, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
137 gtk_imhtml_set_editable(GTK_IMHTML(imhtml), editable);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
138 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
139 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
140 #ifdef USE_GTKSPELL
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
141 if (editable && gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck"))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
142 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(imhtml));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
143 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
144 gtk_widget_show(imhtml);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
145
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
146 if (editable) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
147 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), imhtml);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
148 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(toolbar), "default");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
149 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
150 gaim_setup_imhtml(imhtml);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
151
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
152 gtk_container_add(GTK_CONTAINER(sw), imhtml);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
153
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
154 if (imhtml_ret != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
155 *imhtml_ret = imhtml;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
156
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
157 if (editable && (toolbar_ret != NULL))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
158 *toolbar_ret = toolbar;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
159
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
160 if (sw_ret != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
161 *sw_ret = sw;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
162
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
163 return frame;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
164 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
165
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
166 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
167 gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
168 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
169 const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
170 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
171 (*text != '\0'));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
172 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
173
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
174 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
175 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
176 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
177 gboolean sensitivity;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
178
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
179 if (to_toggle == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
180 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
181
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
182 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
183
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
184 gtk_widget_set_sensitive(to_toggle, !sensitivity);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
185 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
186
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
187 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
188 gaim_gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
189 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
190 gboolean sensitivity;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
191 gpointer element;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
192 int i;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
193
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
194 for (i=0; i < data->len; i++) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
195 element = g_ptr_array_index(data,i);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
196 if (element == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
197 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
198
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
199 sensitivity = GTK_WIDGET_IS_SENSITIVE(element);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
200
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
201 gtk_widget_set_sensitive(element, !sensitivity);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
202 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
203 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
204
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
205 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
206 gaim_gtk_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
207 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
208 if (to_toggle == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
209 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
210
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
211 if (GTK_WIDGET_VISIBLE(to_toggle))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
212 gtk_widget_hide(to_toggle);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
213 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
214 gtk_widget_show(to_toggle);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
215 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
216
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
217 void gaim_separator(GtkWidget *menu)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
218 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
219 GtkWidget *menuitem;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
220
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
221 menuitem = gtk_separator_menu_item_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
222 gtk_widget_show(menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
223 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
224 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
225
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
226 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
227 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
228 GtkWidget *menuitem;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
229 GtkWidget *label;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
230
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
231 menuitem = gtk_menu_item_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
232 if (menu)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
233 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
234 gtk_widget_show(menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
235
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
236 label = gtk_label_new(str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
237 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
238 gtk_label_set_pattern(GTK_LABEL(label), "_");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
239 gtk_container_add(GTK_CONTAINER(menuitem), label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
240 gtk_widget_show(label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
241 /* FIXME: Go back and fix this
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
242 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0],
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
243 GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
244 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
245 gaim_set_accessible_label (menuitem, label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
246 return menuitem;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
247 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
248
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
249 GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
250 GtkSignalFunc sf, gpointer data, gboolean checked)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
251 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
252 GtkWidget *menuitem;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
253 menuitem = gtk_check_menu_item_new_with_mnemonic(str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
254
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
255 if (menu)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
256 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
257
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
258 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), checked);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
259
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
260 if (sf)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
261 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
262
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
263 gtk_widget_show_all(menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
264
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
265 return menuitem;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
266 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
267
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
268 GtkWidget *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
269 gaim_pixbuf_toolbar_button_from_stock(const char *icon)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
270 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
271 GtkWidget *button, *image, *bbox;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
272
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
273 button = gtk_toggle_button_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
274 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
275
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
276 bbox = gtk_vbox_new(FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
277
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
278 gtk_container_add (GTK_CONTAINER(button), bbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
279
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
280 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
281 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
282
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
283 gtk_widget_show_all(bbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
284
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
285 return button;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
286 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
287
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
288 GtkWidget *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
289 gaim_pixbuf_button_from_stock(const char *text, const char *icon,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
290 GaimButtonOrientation style)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
291 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
292 GtkWidget *button, *image, *label, *bbox, *ibox, *lbox = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
293
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
294 button = gtk_button_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
295
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
296 if (style == GAIM_BUTTON_HORIZONTAL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
297 bbox = gtk_hbox_new(FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
298 ibox = gtk_hbox_new(FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
299 if (text)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
300 lbox = gtk_hbox_new(FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
301 } else {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
302 bbox = gtk_vbox_new(FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
303 ibox = gtk_vbox_new(FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
304 if (text)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
305 lbox = gtk_vbox_new(FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
306 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
307
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
308 gtk_container_add(GTK_CONTAINER(button), bbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
309
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
310 if (icon) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
311 gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
312 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
313 gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, TRUE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
314 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
315
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
316 if (text) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
317 gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
318 label = gtk_label_new(NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
319 gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
320 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
321 gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, TRUE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
322 gaim_set_accessible_label (button, label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
323 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
324
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
325 gtk_widget_show_all(bbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
326
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
327 return button;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
328 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
329
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
330
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
331 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)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
332 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
333 GtkWidget *menuitem;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
334 /*
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
335 GtkWidget *hbox;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
336 GtkWidget *label;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
337 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
338 GtkWidget *image;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
339
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
340 if (icon == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
341 menuitem = gtk_menu_item_new_with_mnemonic(str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
342 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
343 menuitem = gtk_image_menu_item_new_with_mnemonic(str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
344
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
345 if (menu)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
346 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
347
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
348 if (sf)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
349 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
350
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
351 if (icon != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
352 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
353 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
354 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
355 /* FIXME: this isn't right
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
356 if (mod) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
357 label = gtk_label_new(mod);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
358 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
359 gtk_widget_show(label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
360 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
361 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
362 /*
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
363 if (accel_key) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
364 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
365 accel_mods, GTK_ACCEL_LOCKED);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
366 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
367 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
368
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
369 gtk_widget_show_all(menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
370
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
371 return menuitem;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
372 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
373
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
374 GtkWidget *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
375 gaim_gtk_make_frame(GtkWidget *parent, const char *title)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
376 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
377 GtkWidget *vbox, *label, *hbox;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
378 char *labeltitle;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
379
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
380 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
381 gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
382 gtk_widget_show(vbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
383
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
384 label = gtk_label_new(NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
385
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
386 labeltitle = g_strdup_printf("<span weight=\"bold\">%s</span>", title);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
387 gtk_label_set_markup(GTK_LABEL(label), labeltitle);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
388 g_free(labeltitle);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
389
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
390 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
391 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
392 gtk_widget_show(label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
393 gaim_set_accessible_label (vbox, label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
394
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
395 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
396 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
397 gtk_widget_show(hbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
398
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
399 label = gtk_label_new(" ");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
400 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
401 gtk_widget_show(label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
402
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
403 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
404 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
405 gtk_widget_show(vbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
406
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
407 return vbox;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
408 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
409
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
410 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
411 protocol_menu_cb(GtkWidget *optmenu, GCallback cb)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
412 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
413 GtkWidget *menu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
414 GtkWidget *item;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
415 const char *protocol;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
416 gpointer user_data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
417
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
418 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
419 item = gtk_menu_get_active(GTK_MENU(menu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
420
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
421 protocol = g_object_get_data(G_OBJECT(item), "protocol");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
422 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data"));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
423
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
424 if (cb != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
425 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
426 user_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
427 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
428
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
429 GtkWidget *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
430 gaim_gtk_protocol_option_menu_new(const char *id, GCallback cb,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
431 gpointer user_data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
432 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
433 GaimPluginProtocolInfo *prpl_info;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
434 GaimPlugin *plugin;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
435 GtkWidget *hbox;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
436 GtkWidget *label;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
437 GtkWidget *optmenu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
438 GtkWidget *menu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
439 GtkWidget *item;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
440 GtkWidget *image;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
441 GdkPixbuf *pixbuf;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
442 GdkPixbuf *scale;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
443 GList *p;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
444 GtkSizeGroup *sg;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
445 char *filename;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
446 const char *proto_name;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
447 char buf[256];
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
448 int i, selected_index = -1;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
449
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
450 optmenu = gtk_option_menu_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
451 gtk_widget_show(optmenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
452
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
453 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
454
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
455 menu = gtk_menu_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
456 gtk_widget_show(menu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
457
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
458 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
459
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
460 for (p = gaim_plugins_get_protocols(), i = 0;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
461 p != NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
462 p = p->next, i++) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
463
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
464 plugin = (GaimPlugin *)p->data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
465 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
466
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
467 /* Create the item. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
468 item = gtk_menu_item_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
469
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
470 /* Create the hbox. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
471 hbox = gtk_hbox_new(FALSE, 4);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
472 gtk_container_add(GTK_CONTAINER(item), hbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
473 gtk_widget_show(hbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
474
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
475 /* Load the image. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
476 proto_name = prpl_info->list_icon(NULL, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
477 g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
478
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
479 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
480 "default", buf, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
481 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
482 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
483
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
484 if (pixbuf != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
485 /* Scale and insert the image */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
486 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
487 GDK_INTERP_BILINEAR);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
488 image = gtk_image_new_from_pixbuf(scale);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
489
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
490 g_object_unref(G_OBJECT(pixbuf));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
491 g_object_unref(G_OBJECT(scale));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
492 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
493 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
494 image = gtk_image_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
495
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
496 gtk_size_group_add_widget(sg, image);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
497
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
498 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
499 gtk_widget_show(image);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
500
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
501 /* Create the label. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
502 label = gtk_label_new(plugin->info->name);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
503 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
504 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
505 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
506 gtk_widget_show(label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
507
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
508 g_object_set_data(G_OBJECT(item), "protocol", plugin->info->id);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
509
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
510 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
511 gtk_widget_show(item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
512 gaim_set_accessible_label (item, label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
513
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
514 if (id != NULL && !strcmp(plugin->info->id, id))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
515 selected_index = i;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
516 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
517
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
518 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
519
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
520 if (selected_index != -1)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
521 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
522
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
523 g_signal_connect(G_OBJECT(optmenu), "changed",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
524 G_CALLBACK(protocol_menu_cb), cb);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
525
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
526 g_object_unref(sg);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
527
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
528 return optmenu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
529 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
530
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
531 GaimAccount *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
532 gaim_gtk_account_option_menu_get_selected(GtkWidget *optmenu)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
533 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
534 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
535 GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
536 return g_object_get_data(G_OBJECT(item), "account");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
537 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
538
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
539 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
540 account_menu_cb(GtkWidget *optmenu, GCallback cb)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
541 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
542 GtkWidget *menu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
543 GtkWidget *item;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
544 GaimAccount *account;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
545 gpointer user_data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
546
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
547 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
548 item = gtk_menu_get_active(GTK_MENU(menu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
549
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
550 account = g_object_get_data(G_OBJECT(item), "account");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
551 user_data = g_object_get_data(G_OBJECT(optmenu), "user_data");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
552
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
553 if (cb != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
554 ((void (*)(GtkWidget *, GaimAccount *, gpointer))cb)(item, account,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
555 user_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
556 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
557
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
558 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
559 create_account_menu(GtkWidget *optmenu, GaimAccount *default_account,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
560 GaimFilterAccountFunc filter_func, gboolean show_all)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
561 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
562 GaimAccount *account;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
563 GtkWidget *menu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
564 GtkWidget *item;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
565 GtkWidget *image;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
566 GtkWidget *hbox;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
567 GtkWidget *label;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
568 GdkPixbuf *pixbuf;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
569 GdkPixbuf *scale;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
570 GList *list;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
571 GList *p;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
572 GtkSizeGroup *sg;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
573 char *filename;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
574 const char *proto_name;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
575 char buf[256];
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
576 int i, selected_index = -1;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
577
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
578 if (show_all)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
579 list = gaim_accounts_get_all();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
580 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
581 list = gaim_connections_get_all();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
582
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
583 menu = gtk_menu_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
584 gtk_widget_show(menu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
585
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
586 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
587
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
588 for (p = list, i = 0; p != NULL; p = p->next, i++) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
589 GaimPluginProtocolInfo *prpl_info = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
590 GaimPlugin *plugin;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
591
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
592 if (show_all)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
593 account = (GaimAccount *)p->data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
594 else {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
595 GaimConnection *gc = (GaimConnection *)p->data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
596
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
597 account = gaim_connection_get_account(gc);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
598 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
599
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
600 if (filter_func && !filter_func(account)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
601 i--;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
602 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
603 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
604
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
605 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
606
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
607 if (plugin != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
608 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
609
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
610 /* Create the item. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
611 item = gtk_menu_item_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
612
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
613 /* Create the hbox. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
614 hbox = gtk_hbox_new(FALSE, 4);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
615 gtk_container_add(GTK_CONTAINER(item), hbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
616 gtk_widget_show(hbox);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
617
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
618 /* Load the image. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
619 if (prpl_info != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
620 proto_name = prpl_info->list_icon(account, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
621 g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
622
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
623 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
624 "default", buf, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
625 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
626 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
627
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
628 if (pixbuf != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
629 /* Scale and insert the image */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
630 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
631 GDK_INTERP_BILINEAR);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
632
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
633 if (gaim_account_is_disconnected(account) && show_all &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
634 gaim_connections_get_all())
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
635 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
636
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
637 image = gtk_image_new_from_pixbuf(scale);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
638
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
639 g_object_unref(G_OBJECT(pixbuf));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
640 g_object_unref(G_OBJECT(scale));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
641 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
642 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
643 image = gtk_image_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
644 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
645 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
646 image = gtk_image_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
647
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
648 gtk_size_group_add_widget(sg, image);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
649
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
650 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
651 gtk_widget_show(image);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
652
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
653 if (gaim_account_get_alias(account)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
654 g_snprintf(buf, sizeof(buf), "%s (%s) (%s)",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
655 gaim_account_get_username(account),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
656 gaim_account_get_alias(account),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
657 gaim_account_get_protocol_name(account));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
658 } else {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
659 g_snprintf(buf, sizeof(buf), "%s (%s)",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
660 gaim_account_get_username(account),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
661 gaim_account_get_protocol_name(account));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
662 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
663
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
664 /* Create the label. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
665 label = gtk_label_new(buf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
666 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
667 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
668 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
669 gtk_widget_show(label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
670
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
671 g_object_set_data(G_OBJECT(item), "account", account);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
672
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
673 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
674 gtk_widget_show(item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
675 gaim_set_accessible_label (item, label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
676
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
677 if (default_account != NULL && account == default_account)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
678 selected_index = i;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
679 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
680
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
681 g_object_unref(sg);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
682
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
683 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
684
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
685 /* Set the place we should be at. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
686 if (selected_index != -1)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
687 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
688 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
689
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
690 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
691 regenerate_account_menu(GtkWidget *optmenu)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
692 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
693 GtkWidget *menu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
694 GtkWidget *item;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
695 gboolean show_all;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
696 GaimAccount *account;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
697 GaimFilterAccountFunc filter_func;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
698
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
699 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
700 item = gtk_menu_get_active(GTK_MENU(menu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
701 account = g_object_get_data(G_OBJECT(item), "account");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
702
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
703 show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
704 "show_all"));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
705
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
706 filter_func = g_object_get_data(G_OBJECT(optmenu),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
707 "filter_func");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
708
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
709 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
710
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
711 create_account_menu(optmenu, account, filter_func, show_all);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
712 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
713
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
714 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
715 account_menu_sign_on_off_cb(GaimConnection *gc, GtkWidget *optmenu)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
716 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
717 regenerate_account_menu(optmenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
718 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
719
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
720 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
721 account_menu_added_removed_cb(GaimAccount *account, GtkWidget *optmenu)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
722 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
723 regenerate_account_menu(optmenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
724 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
725
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
726 static gboolean
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
727 account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
728 void *user_data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
729 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
730 gaim_signals_disconnect_by_handle(optmenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
731
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
732 return FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
733 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
734
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
735 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
736 gaim_gtk_account_option_menu_set_selected(GtkWidget *optmenu, GaimAccount *account)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
737 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
738 GtkWidget *menu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
739 GtkWidget *item;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
740 gboolean show_all;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
741 GaimAccount *curaccount;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
742 GaimFilterAccountFunc filter_func;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
743
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
744 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
745 item = gtk_menu_get_active(GTK_MENU(menu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
746 curaccount = g_object_get_data(G_OBJECT(item), "account");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
747
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
748 if (account == curaccount)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
749 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
750
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
751 show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
752 "show_all"));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
753
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
754 filter_func = g_object_get_data(G_OBJECT(optmenu),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
755 "filter_func");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
756
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
757 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
758
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
759 create_account_menu(optmenu, account, filter_func, show_all);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
760 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
761
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
762 GtkWidget *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
763 gaim_gtk_account_option_menu_new(GaimAccount *default_account,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
764 gboolean show_all, GCallback cb,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
765 GaimFilterAccountFunc filter_func,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
766 gpointer user_data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
767 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
768 GtkWidget *optmenu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
769
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
770 /* Create the option menu */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
771 optmenu = gtk_option_menu_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
772 gtk_widget_show(optmenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
773
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
774 g_signal_connect(G_OBJECT(optmenu), "destroy",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
775 G_CALLBACK(account_menu_destroyed_cb), NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
776
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
777 /* Register the gaim sign on/off event callbacks. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
778 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
779 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
780 optmenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
781 gaim_signal_connect(gaim_connections_get_handle(), "signed-off",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
782 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
783 optmenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
784 gaim_signal_connect(gaim_accounts_get_handle(), "account-added",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
785 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
786 optmenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
787 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
788 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
789 optmenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
790
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
791 /* Set some data. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
792 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
793 g_object_set_data(G_OBJECT(optmenu), "show_all", GINT_TO_POINTER(show_all));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
794 g_object_set_data(G_OBJECT(optmenu), "filter_func",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
795 filter_func);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
796
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
797 /* Create and set the actual menu. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
798 create_account_menu(optmenu, default_account, filter_func, show_all);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
799
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
800 /* And now the last callback. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
801 g_signal_connect(G_OBJECT(optmenu), "changed",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
802 G_CALLBACK(account_menu_cb), cb);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
803
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
804 return optmenu;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
805 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
806
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
807 gboolean
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
808 gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
809 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
810 char *dirname;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
811
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
812 if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
813 /* append a / if needed */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
814 if (path[strlen(path) - 1] != G_DIR_SEPARATOR) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
815 dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
816 } else {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
817 dirname = g_strdup(path);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
818 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
819 gtk_file_selection_set_filename(filesel, dirname);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
820 g_free(dirname);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
821 return TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
822 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
823
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
824 return FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
825 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
826
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
827 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
828 gaim_gtk_setup_gtkspell(GtkTextView *textview)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
829 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
830 #ifdef USE_GTKSPELL
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
831 GError *error = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
832 char *locale = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
833
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
834 g_return_if_fail(textview != NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
835 g_return_if_fail(GTK_IS_TEXT_VIEW(textview));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
836
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
837 if (gtkspell_new_attach(textview, locale, &error) == NULL && error)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
838 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
839 gaim_debug_warning("gtkspell", "Failed to setup GtkSpell: %s\n",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
840 error->message);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
841 g_error_free(error);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
842 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
843 #endif /* USE_GTKSPELL */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
844 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
845
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
846 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
847 gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
848 GdkModifierType arg2, GClosure *arg3,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
849 gpointer data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
850 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
851 gaim_debug(GAIM_DEBUG_MISC, "accels", "accel changed, scheduling save.\n");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
852
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
853 if (!accels_save_timer)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
854 accels_save_timer = g_timeout_add(5000, gaim_gtk_save_accels, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
855 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
856
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
857 gboolean
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
858 gaim_gtk_save_accels(gpointer data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
859 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
860 char *filename = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
861
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
862 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
863 "accels", NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
864 gaim_debug(GAIM_DEBUG_MISC, "accels", "saving accels to %s\n", filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
865 gtk_accel_map_save(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
866 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
867
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
868 accels_save_timer = 0;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
869 return FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
870 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
871
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
872 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
873 gaim_gtk_load_accels()
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
874 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
875 char *filename = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
876
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
877 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
878 "accels", NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
879 gtk_accel_map_load(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
880 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
881 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
882
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
883 gboolean
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
884 gaim_gtk_parse_x_im_contact(const char *msg, gboolean all_accounts,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
885 GaimAccount **ret_account, char **ret_protocol,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
886 char **ret_username, char **ret_alias)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
887 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
888 char *protocol = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
889 char *username = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
890 char *alias = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
891 char *str;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
892 char *c, *s;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
893 gboolean valid;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
894
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
895 g_return_val_if_fail(msg != NULL, FALSE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
896 g_return_val_if_fail(ret_protocol != NULL, FALSE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
897 g_return_val_if_fail(ret_username != NULL, FALSE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
898
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
899 s = str = g_strdup(msg);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
900
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
901 while (*s != '\r' && *s != '\n' && *s != '\0')
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
902 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
903 char *key, *value;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
904
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
905 key = s;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
906
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
907 /* Grab the key */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
908 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ')
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
909 s++;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
910
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
911 if (*s == '\r') s++;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
912
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
913 if (*s == '\n')
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
914 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
915 s++;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
916 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
917 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
918
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
919 if (*s != '\0') *s++ = '\0';
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
920
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
921 /* Clear past any whitespace */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
922 while (*s != '\0' && *s == ' ')
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
923 s++;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
924
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
925 /* Now let's grab until the end of the line. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
926 value = s;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
927
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
928 while (*s != '\r' && *s != '\n' && *s != '\0')
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
929 s++;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
930
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
931 if (*s == '\r') *s++ = '\0';
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
932 if (*s == '\n') *s++ = '\0';
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
933
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
934 if ((c = strchr(key, ':')) != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
935 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
936 if (!g_ascii_strcasecmp(key, "X-IM-Username:"))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
937 username = g_strdup(value);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
938 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:"))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
939 protocol = g_strdup(value);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
940 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:"))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
941 alias = g_strdup(value);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
942 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
943 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
944
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
945 if (username != NULL && protocol != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
946 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
947 valid = TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
948
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
949 *ret_username = username;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
950 *ret_protocol = protocol;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
951
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
952 if (ret_alias != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
953 *ret_alias = alias;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
954
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
955 /* Check for a compatible account. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
956 if (ret_account != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
957 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
958 GList *list;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
959 GaimAccount *account = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
960 GList *l;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
961 const char *protoname;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
962
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
963 if (all_accounts)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
964 list = gaim_accounts_get_all();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
965 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
966 list = gaim_connections_get_all();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
967
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
968 for (l = list; l != NULL; l = l->next)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
969 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
970 GaimConnection *gc;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
971 GaimPluginProtocolInfo *prpl_info = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
972 GaimPlugin *plugin;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
973
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
974 if (all_accounts)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
975 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
976 account = (GaimAccount *)l->data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
977
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
978 plugin = gaim_plugins_find_with_id(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
979 gaim_account_get_protocol_id(account));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
980
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
981 if (plugin == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
982 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
983 account = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
984
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
985 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
986 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
987
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
988 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
989 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
990 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
991 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
992 gc = (GaimConnection *)l->data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
993 account = gaim_connection_get_account(gc);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
994
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
995 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
996 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
997
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
998 protoname = prpl_info->list_icon(account, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
999
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1000 if (!strcmp(protoname, protocol))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1001 break;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1002
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1003 account = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1004 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1005
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1006 /* Special case for AIM and ICQ */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1007 if (account == NULL && (!strcmp(protocol, "aim") ||
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1008 !strcmp(protocol, "icq")))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1009 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1010 for (l = list; l != NULL; l = l->next)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1011 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1012 GaimConnection *gc;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1013 GaimPluginProtocolInfo *prpl_info = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1014 GaimPlugin *plugin;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1015
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1016 if (all_accounts)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1017 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1018 account = (GaimAccount *)l->data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1019
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1020 plugin = gaim_plugins_find_with_id(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1021 gaim_account_get_protocol_id(account));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1022
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1023 if (plugin == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1024 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1025 account = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1026
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1027 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1028 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1029
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1030 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1031 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1032 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1033 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1034 gc = (GaimConnection *)l->data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1035 account = gaim_connection_get_account(gc);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1036
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1037 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1038 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1039
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1040 protoname = prpl_info->list_icon(account, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1041
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1042 if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq"))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1043 break;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1044
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1045 account = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1046 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1047 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1048
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1049 *ret_account = account;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1050 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1051 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1052 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1053 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1054 valid = FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1055
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1056 g_free(username);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1057 g_free(protocol);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1058 g_free(alias);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1059 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1060
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1061 g_free(str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1062
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1063 return valid;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1064 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1065
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1066 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1067 gaim_set_accessible_label (GtkWidget *w, GtkWidget *l)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1068 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1069 AtkObject *acc, *label;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1070 AtkObject *rel_obj[1];
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1071 AtkRelationSet *set;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1072 AtkRelation *relation;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1073 const gchar *label_text;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1074 const gchar *existing_name;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1075
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1076 acc = gtk_widget_get_accessible (w);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1077 label = gtk_widget_get_accessible (l);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1078
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1079 /* If this object has no name, set it's name with the label text */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1080 existing_name = atk_object_get_name (acc);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1081 if (!existing_name) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1082 label_text = gtk_label_get_text (GTK_LABEL(l));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1083 if (label_text)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1084 atk_object_set_name (acc, label_text);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1085 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1086
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1087 /* Create the labeled-by relation */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1088 set = atk_object_ref_relation_set (acc);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1089 rel_obj[0] = label;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1090 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1091 atk_relation_set_add (set, relation);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1092 g_object_unref (relation);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1093
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1094 /* Create the label-for relation */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1095 set = atk_object_ref_relation_set (label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1096 rel_obj[0] = acc;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1097 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1098 atk_relation_set_add (set, relation);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1099 g_object_unref (relation);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1100 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1101
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1102 #if GTK_CHECK_VERSION(2,2,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1103 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1104 gaim_gtk_menu_position_func(GtkMenu *menu,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1105 gint *x,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1106 gint *y,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1107 gboolean *push_in,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1108 gpointer data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1109 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1110 GtkWidget *widget;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1111 GtkRequisition requisition;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1112 GdkScreen *screen;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1113 GdkRectangle monitor;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1114 gint monitor_num;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1115 gint space_left, space_right, space_above, space_below;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1116 gint needed_width;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1117 gint needed_height;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1118 gint xthickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1119 gint ythickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1120 gboolean rtl;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1121
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1122 g_return_if_fail(GTK_IS_MENU(menu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1123
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1124 widget = GTK_WIDGET(menu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1125 screen = gtk_widget_get_screen(widget);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1126 xthickness = widget->style->xthickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1127 ythickness = widget->style->ythickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1128 rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1129
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1130 /*
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1131 * We need the requisition to figure out the right place to
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1132 * popup the menu. In fact, we always need to ask here, since
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1133 * if a size_request was queued while we weren't popped up,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1134 * the requisition won't have been recomputed yet.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1135 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1136 gtk_widget_size_request (widget, &requisition);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1137
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1138 monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1139
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1140 push_in = FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1141
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1142 /*
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1143 * The placement of popup menus horizontally works like this (with
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1144 * RTL in parentheses)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1145 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1146 * - If there is enough room to the right (left) of the mouse cursor,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1147 * position the menu there.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1148 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1149 * - Otherwise, if if there is enough room to the left (right) of the
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1150 * mouse cursor, position the menu there.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1151 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1152 * - Otherwise if the menu is smaller than the monitor, position it
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1153 * on the side of the mouse cursor that has the most space available
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1154 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1155 * - Otherwise (if there is simply not enough room for the menu on the
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1156 * monitor), position it as far left (right) as possible.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1157 *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1158 * Positioning in the vertical direction is similar: first try below
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1159 * mouse cursor, then above.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1160 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1161 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1162
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1163 space_left = *x - monitor.x;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1164 space_right = monitor.x + monitor.width - *x - 1;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1165 space_above = *y - monitor.y;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1166 space_below = monitor.y + monitor.height - *y - 1;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1167
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1168 /* position horizontally */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1169
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1170 /* the amount of space we need to position the menu. Note the
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1171 * menu is offset "xthickness" pixels
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1172 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1173 needed_width = requisition.width - xthickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1174
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1175 if (needed_width <= space_left ||
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1176 needed_width <= space_right)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1177 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1178 if ((rtl && needed_width <= space_left) ||
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1179 (!rtl && needed_width > space_right))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1180 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1181 /* position left */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1182 *x = *x + xthickness - requisition.width + 1;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1183 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1184 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1185 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1186 /* position right */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1187 *x = *x - xthickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1188 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1189
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1190 /* x is clamped on-screen further down */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1191 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1192 else if (requisition.width <= monitor.width)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1193 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1194 /* the menu is too big to fit on either side of the mouse
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1195 * cursor, but smaller than the monitor. Position it on
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1196 * the side that has the most space
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1197 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1198 if (space_left > space_right)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1199 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1200 /* left justify */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1201 *x = monitor.x;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1202 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1203 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1204 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1205 /* right justify */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1206 *x = monitor.x + monitor.width - requisition.width;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1207 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1208 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1209 else /* menu is simply too big for the monitor */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1210 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1211 if (rtl)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1212 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1213 /* right justify */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1214 *x = monitor.x + monitor.width - requisition.width;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1215 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1216 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1217 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1218 /* left justify */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1219 *x = monitor.x;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1220 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1221 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1222
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1223 /* Position vertically. The algorithm is the same as above, but
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1224 * simpler because we don't have to take RTL into account.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1225 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1226 needed_height = requisition.height - ythickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1227
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1228 if (needed_height <= space_above ||
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1229 needed_height <= space_below)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1230 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1231 if (needed_height <= space_below)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1232 *y = *y - ythickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1233 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1234 *y = *y + ythickness - requisition.height + 1;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1235
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1236 *y = CLAMP (*y, monitor.y,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1237 monitor.y + monitor.height - requisition.height);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1238 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1239 else if (needed_height > space_below && needed_height > space_above)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1240 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1241 if (space_below >= space_above)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1242 *y = monitor.y + monitor.height - requisition.height;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1243 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1244 *y = monitor.y;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1245 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1246 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1247 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1248 *y = monitor.y;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1249 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1250 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1251
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1252 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1253
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1254 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1255 gaim_gtk_treeview_popup_menu_position_func(GtkMenu *menu,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1256 gint *x,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1257 gint *y,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1258 gboolean *push_in,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1259 gpointer data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1260 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1261 GtkWidget *widget = GTK_WIDGET(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1262 GtkTreeView *tv = GTK_TREE_VIEW(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1263 GtkTreePath *path;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1264 GtkTreeViewColumn *col;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1265 GdkRectangle rect;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1266 gint ythickness = GTK_WIDGET(menu)->style->ythickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1267
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1268 gdk_window_get_origin (widget->window, x, y);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1269 gtk_tree_view_get_cursor (tv, &path, &col);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1270 gtk_tree_view_get_cell_area (tv, path, col, &rect);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1271
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1272 *x += rect.x+rect.width;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1273 *y += rect.y+rect.height+ythickness;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1274 #if GTK_CHECK_VERSION(2,2,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1275 gaim_gtk_menu_position_func (menu, x, y, push_in, data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1276 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1277 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1278
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1279 enum {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1280 DND_FILE_TRANSFER,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1281 DND_IM_IMAGE,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1282 DND_BUDDY_ICON
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1283 };
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1284
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1285 typedef struct {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1286 char *filename;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1287 GaimAccount *account;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1288 char *who;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1289 } _DndData;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1290
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1291 static void dnd_image_ok_callback(_DndData *data, int choice)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1292 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1293 char *filedata;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1294 size_t size;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1295 GError *err = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1296 GaimConversation *conv;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1297 GaimGtkConversation *gtkconv;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1298 GtkTextIter iter;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1299 int id;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1300 switch (choice) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1301 case DND_BUDDY_ICON:
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1302 if (!g_file_get_contents(data->filename, &filedata, &size,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1303 &err)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1304 char *str;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1305
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1306 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1307 gaim_notify_error(NULL, NULL,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1308 _("Failed to load image"),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1309 str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1310
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1311 g_error_free(err);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1312 g_free(str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1313
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1314 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1315 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1316
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1317 gaim_buddy_icons_set_for_user(data->account, data->who, filedata, size);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1318 g_free(filedata);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1319 break;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1320 case DND_FILE_TRANSFER:
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1321 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1322 break;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1323 case DND_IM_IMAGE:
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1324 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, data->account, data->who);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1325 gtkconv = GAIM_GTK_CONVERSATION(conv);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1326
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1327 if (!g_file_get_contents(data->filename, &filedata, &size,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1328 &err)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1329 char *str;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1330
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1331 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1332 gaim_notify_error(NULL, NULL,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1333 _("Failed to load image"),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1334 str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1335
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1336 g_error_free(err);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1337 g_free(str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1338
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1339 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1340 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1341 id = gaim_imgstore_add(filedata, size, data->filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1342 g_free(filedata);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1343
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1344 gtk_text_buffer_get_iter_at_mark(GTK_IMHTML(gtkconv->entry)->text_buffer, &iter,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1345 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1346 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(gtkconv->entry), id, &iter);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1347 gaim_imgstore_unref(id);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1348
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1349 break;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1350 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1351 free(data->filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1352 free(data->who);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1353 free(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1354 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1355
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1356 static void dnd_image_cancel_callback(_DndData *data, int choice)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1357 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1358 free(data->filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1359 free(data->who);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1360 free(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1361 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1362
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1363 static void dnd_set_icon_ok_cb(_DndData *data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1364 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1365 dnd_image_ok_callback(data, DND_BUDDY_ICON);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1366 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1367
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1368 static void dnd_set_icon_cancel_cb(_DndData *data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1369 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1370 free(data->filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1371 free(data->who);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1372 free(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1373 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1374
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1375 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1376 gaim_dnd_file_manage(GtkSelectionData *sd, GaimAccount *account, const char *who)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1377 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1378 GList *tmp;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1379 GdkPixbuf *pb;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1380 GList *files = gaim_uri_list_extract_filenames((const gchar *)sd->data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1381 GaimConnection *gc = gaim_account_get_connection(account);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1382 GaimPluginProtocolInfo *prpl_info = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1383 gboolean file_send_ok = FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1384 #ifndef _WIN32
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1385 GaimDesktopItem *item;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1386 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1387
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1388 g_return_if_fail(account != NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1389 g_return_if_fail(who != NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1390
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1391 for(tmp = files; tmp != NULL ; tmp = g_list_next(tmp)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1392 gchar *filename = tmp->data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1393 gchar *basename = g_path_get_basename(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1394
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1395 /* Set the default action: don't send anything */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1396 file_send_ok = FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1397
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1398 /* XXX - Make ft API support creating a transfer with more than one file */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1399 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1400 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1401 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1402
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1403 /* XXX - make ft api suupport sending a directory */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1404 /* Are we dealing with a directory? */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1405 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1406 char *str;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1407
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1408 str = g_strdup_printf(_("Cannot send folder %s."), basename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1409 gaim_notify_error(NULL, NULL,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1410 str,_("Gaim cannot transfer a folder. You will need to send the files within individually"));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1411
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1412 g_free(str);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1413
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1414 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1415 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1416
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1417 /* Are we dealing with an image? */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1418 pb = gdk_pixbuf_new_from_file(filename, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1419 if (pb) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1420 _DndData *data = g_malloc(sizeof(_DndData));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1421 gboolean ft = FALSE, im = FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1422
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1423 data->who = g_strdup(who);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1424 data->filename = g_strdup(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1425 data->account = account;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1426
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1427 if (gc)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1428 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1429
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1430 if (prpl_info && prpl_info->options & OPT_PROTO_IM_IMAGE)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1431 im = TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1432
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1433 if (prpl_info && prpl_info->can_receive_file)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1434 ft = prpl_info->can_receive_file(gc, who);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1435
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1436 if (im && ft)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1437 gaim_request_choice(NULL, NULL,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1438 _("You have dragged an image"),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1439 _("You can send this image as a file transfer, "
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1440 "embed it into this message, or use it as the buddy icon for this user."),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1441 DND_FILE_TRANSFER, "OK", (GCallback)dnd_image_ok_callback,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1442 "Cancel", (GCallback)dnd_image_cancel_callback, data,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1443 _("Set as buddy icon"), DND_BUDDY_ICON,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1444 _("Send image file"), DND_FILE_TRANSFER,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1445 _("Insert in message"), DND_IM_IMAGE, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1446 else if (!(im || ft))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1447 gaim_request_yes_no(NULL, NULL, _("You have dragged an image"),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1448 _("Would you like to set it as the buddy icon for this user?"),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1449 0, data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1450 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1451 gaim_request_choice(NULL, NULL,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1452 _("You have dragged an image"),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1453 ft ? _("You can send this image as a file transfer or "
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1454 "embed it into this message, or use it as the buddy icon for this user.") :
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1455 _("You can insert this image into this message, or use it as the buddy icon for this user"),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1456 ft ? DND_FILE_TRANSFER : DND_IM_IMAGE, "OK", (GCallback)dnd_image_ok_callback,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1457 "Cancel", (GCallback)dnd_image_cancel_callback, data,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1458 _("Set as buddy icon"), DND_BUDDY_ICON,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1459 ft ? _("Send image file") : _("Insert in message"), ft ? DND_FILE_TRANSFER : DND_IM_IMAGE, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1460 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1461 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1462
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1463 #ifndef _WIN32
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1464 /* Are we trying to send a .desktop file? */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1465 else if (gaim_str_has_suffix(basename, ".desktop") && (item = gaim_desktop_item_new_from_file(filename))) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1466 GaimDesktopItemType dtype;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1467 char key[64];
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1468 const char *itemname = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1469
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1470 #if GTK_CHECK_VERSION(2,6,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1471 const char * const *langs;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1472 int i;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1473 langs = g_get_language_names();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1474 for (i = 0; langs[i]; i++) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1475 g_snprintf(key, sizeof(key), "Name[%s]", langs[i]);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1476 itemname = gaim_desktop_item_get_string(item, key);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1477 break;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1478 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1479 #else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1480 const char *lang = g_getenv("LANG");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1481 char *dot;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1482 dot = strchr(lang, '.');
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1483 if (dot)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1484 *dot = '\0';
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1485 g_snprintf(key, sizeof(key), "Name[%s]", lang);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1486 itemname = gaim_desktop_item_get_string(item, key);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1487 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1488 if (!itemname)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1489 itemname = gaim_desktop_item_get_string(item, "Name");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1490
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1491 dtype = gaim_desktop_item_get_entry_type(item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1492 switch (dtype) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1493 GaimConversation *conv;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1494 GaimGtkConversation *gtkconv;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1495
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1496 case GAIM_DESKTOP_ITEM_TYPE_LINK:
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1497 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, who);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1498 gtkconv = GAIM_GTK_CONVERSATION(conv);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1499 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1500 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1501 gaim_desktop_item_get_string(item, "URL"), itemname);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1502 break;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1503 default:
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1504 /* I don't know if we really want to do anything here. Most of the desktop item types are crap like
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1505 * "MIME Type" (I have no clue how that would be a desktop item) and "Comment"... nothing we can really
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1506 * send. The only logical one is "Application," but do we really want to send a binary and nothing else?
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1507 * Probably not. I'll just give an error and return. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1508 /* The original patch sent the icon used by the launcher. That's probably wrong */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1509 gaim_notify_error(NULL, NULL, _("Cannot send launcher"), _("You dragged a desktop launcher. "
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1510 "Most likely you wanted to send whatever this launcher points to instead of this launcher"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1511 " itself."));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1512 break;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1513 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1514 gaim_desktop_item_unref(item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1515 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1516 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1517 #endif /* _WIN32 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1518
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1519 /* Everything is fine, let's send */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1520 serv_send_file(gc, who, filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1521 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1522 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1523 g_list_free(files);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1524 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1525
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1526 void gaim_gtk_buddy_icon_get_scale_size(GdkPixbuf *buf, GaimBuddyIconSpec *spec, int *width, int *height)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1527 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1528 *width = gdk_pixbuf_get_width(buf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1529 *height = gdk_pixbuf_get_height(buf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1530
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1531 gaim_buddy_icon_get_scale_size(spec, width, height);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1532
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1533 /* and now for some arbitrary sanity checks */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1534 if(*width > 100)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1535 *width = 100;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1536 if(*height > 100)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1537 *height = 100;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1538 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1539
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1540 GdkPixbuf *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1541 gaim_gtk_create_prpl_icon(GaimAccount *account, double scale_factor)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1542 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1543 GaimPlugin *prpl;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1544 GaimPluginProtocolInfo *prpl_info;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1545 const char *protoname = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1546 char buf[256]; /* TODO: We should use a define for max file length */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1547 char *filename = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1548 GdkPixbuf *pixbuf, *scaled;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1549
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1550 g_return_val_if_fail(account != NULL, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1551
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1552 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1553 if (prpl == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1554 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1555
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1556 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1557 if (prpl_info->list_icon == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1558 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1559
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1560 protoname = prpl_info->list_icon(account, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1561 if (protoname == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1562 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1563
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1564 /*
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1565 * Status icons will be themeable too, and then it will look up
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1566 * protoname from the theme
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1567 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1568 g_snprintf(buf, sizeof(buf), "%s.png", protoname);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1569
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1570 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1571 "default", buf, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1572 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1573 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1574
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1575 scaled = gdk_pixbuf_scale_simple(pixbuf, 32*scale_factor,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1576 32*scale_factor, GDK_INTERP_BILINEAR);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1577 g_object_unref(pixbuf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1578
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1579 return scaled;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1580 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1581
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1582 static GdkPixbuf *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1583 overlay_status_onto_icon(GdkPixbuf *pixbuf, GaimStatusPrimitive primitive)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1584 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1585 const char *type_name;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1586 char basename[256];
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1587 char *filename;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1588 GdkPixbuf *emblem;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1589
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1590 type_name = gaim_primitive_get_id_from_type(primitive);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1591
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1592 g_snprintf(basename, sizeof(basename), "%s.png", type_name);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1593 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1594 "default", basename, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1595 emblem = gdk_pixbuf_new_from_file(filename, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1596 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1597
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1598 if (emblem != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1599 int width, height, emblem_width, emblem_height;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1600 int new_emblem_width, new_emblem_height;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1601
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1602 width = gdk_pixbuf_get_width(pixbuf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1603 height = gdk_pixbuf_get_height(pixbuf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1604 emblem_width = gdk_pixbuf_get_width(emblem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1605 emblem_height = gdk_pixbuf_get_height(emblem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1606
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1607 /*
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1608 * Figure out how big to make the emblem. Normally the emblem
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1609 * will have half the width of the pixbuf. But we don't make
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1610 * an emblem any smaller than 10 pixels because it becomes
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1611 * unrecognizable, unless the width of the pixbuf is less than
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1612 * 10 pixels, in which case we make the emblem width the same
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1613 * as the pixbuf width.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1614 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1615 new_emblem_width = MAX(width / 2, MIN(width, 10));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1616 new_emblem_height = MAX(height / 2, MIN(height, 10));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1617
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1618 /* Overlay emblem onto the bottom right corner of pixbuf */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1619 gdk_pixbuf_composite(emblem, pixbuf,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1620 width - new_emblem_width, height - new_emblem_height,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1621 new_emblem_width, new_emblem_height,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1622 width - new_emblem_width, height - new_emblem_height,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1623 (double)new_emblem_width / (double)emblem_width,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1624 (double)new_emblem_height / (double)emblem_height,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1625 GDK_INTERP_BILINEAR,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1626 255);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1627 g_object_unref(emblem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1628 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1629
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1630 return pixbuf;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1631 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1632
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1633 GdkPixbuf *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1634 gaim_gtk_create_prpl_icon_with_status(GaimAccount *account, GaimStatusType *status_type, double scale_factor)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1635 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1636 GdkPixbuf *pixbuf;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1637
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1638 pixbuf = gaim_gtk_create_prpl_icon(account, scale_factor);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1639 if (pixbuf == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1640 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1641
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1642 /*
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1643 * TODO: Let the prpl pick the emblem on a per status basis,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1644 * and only use the primitive as a fallback?
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1645 */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1646
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1647 return overlay_status_onto_icon(pixbuf,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1648 gaim_status_type_get_primitive(status_type));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1649 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1650
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1651 GdkPixbuf *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1652 gaim_gtk_create_gaim_icon_with_status(GaimStatusPrimitive primitive, double scale_factor)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1653 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1654 gchar *filename;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1655 GdkPixbuf *orig, *pixbuf;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1656
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1657 filename = g_build_filename(DATADIR, "pixmaps", "gaim.png", NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1658 orig = gdk_pixbuf_new_from_file(filename, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1659 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1660 if (orig == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1661 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1662
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1663 pixbuf = gdk_pixbuf_scale_simple(orig, 32*scale_factor,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1664 32*scale_factor, GDK_INTERP_BILINEAR);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1665 g_object_unref(G_OBJECT(orig));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1666
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1667 return overlay_status_onto_icon(pixbuf, primitive);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1668 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1669
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1670 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1671 menu_action_cb(GtkMenuItem *item, gpointer object)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1672 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1673 gpointer data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1674 void (*callback)(gpointer, gpointer);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1675
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1676 callback = g_object_get_data(G_OBJECT(item), "gaimcallback");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1677 data = g_object_get_data(G_OBJECT(item), "gaimcallbackdata");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1678
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1679 if (callback)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1680 callback(object, data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1681 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1682
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1683 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1684 gaim_gtk_append_menu_action(GtkWidget *menu, GaimMenuAction *act,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1685 gpointer object)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1686 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1687 if (act == NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1688 gaim_separator(menu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1689 } else {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1690 GtkWidget *menuitem;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1691
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1692 if (act->children == NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1693 menuitem = gtk_menu_item_new_with_mnemonic(act->label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1694
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1695 if (act->callback != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1696 g_object_set_data(G_OBJECT(menuitem),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1697 "gaimcallback",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1698 act->callback);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1699 g_object_set_data(G_OBJECT(menuitem),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1700 "gaimcallbackdata",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1701 act->data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1702 g_signal_connect(G_OBJECT(menuitem), "activate",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1703 G_CALLBACK(menu_action_cb),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1704 object);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1705 } else {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1706 gtk_widget_set_sensitive(menuitem, FALSE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1707 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1708
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1709 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1710 } else {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1711 GList *l = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1712 GtkWidget *submenu = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1713 GtkAccelGroup *group;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1714
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1715 menuitem = gtk_menu_item_new_with_mnemonic(act->label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1716 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1717
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1718 submenu = gtk_menu_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1719 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1720
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1721 group = gtk_menu_get_accel_group(GTK_MENU(menu));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1722 if (group) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1723 char *path = g_strdup_printf("%s/%s", GTK_MENU_ITEM(menuitem)->accel_path, act->label);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1724 gtk_menu_set_accel_path(GTK_MENU(submenu), path);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1725 g_free(path);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1726 gtk_menu_set_accel_group(GTK_MENU(submenu), group);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1727 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1728
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1729 for (l = act->children; l; l = l->next) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1730 GaimMenuAction *act = (GaimMenuAction *)l->data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1731
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1732 gaim_gtk_append_menu_action(submenu, act, object);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1733 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1734 g_list_free(act->children);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1735 act->children = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1736 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1737 gaim_menu_action_free(act);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1738 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1739 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1740
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1741 #if GTK_CHECK_VERSION(2,3,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1742 # define NEW_STYLE_COMPLETION
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1743 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1744
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1745 #ifndef NEW_STYLE_COMPLETION
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1746 typedef struct
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1747 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1748 GCompletion *completion;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1749
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1750 gboolean completion_started;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1751 gboolean all;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1752
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1753 } GaimGtkCompletionData;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1754 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1755
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1756 #ifndef NEW_STYLE_COMPLETION
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1757 static gboolean
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1758 completion_entry_event(GtkEditable *entry, GdkEventKey *event,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1759 GaimGtkCompletionData *data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1760 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1761 int pos, end_pos;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1762
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1763 if (event->type == GDK_KEY_PRESS && event->keyval == GDK_Tab)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1764 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1765 gtk_editable_get_selection_bounds(entry, &pos, &end_pos);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1766
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1767 if (data->completion_started &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1768 pos != end_pos && pos > 1 &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1769 end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry))))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1770 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1771 gtk_editable_select_region(entry, 0, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1772 gtk_editable_set_position(entry, -1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1773
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1774 return TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1775 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1776 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1777 else if (event->type == GDK_KEY_PRESS && event->length > 0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1778 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1779 char *prefix, *nprefix;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1780
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1781 gtk_editable_get_selection_bounds(entry, &pos, &end_pos);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1782
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1783 if (data->completion_started &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1784 pos != end_pos && pos > 1 &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1785 end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry))))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1786 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1787 char *temp;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1788
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1789 temp = gtk_editable_get_chars(entry, 0, pos);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1790 prefix = g_strconcat(temp, event->string, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1791 g_free(temp);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1792 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1793 else if (pos == end_pos && pos > 1 &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1794 end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry))))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1795 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1796 prefix = g_strconcat(gtk_entry_get_text(GTK_ENTRY(entry)),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1797 event->string, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1798 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1799 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1800 return FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1801
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1802 pos = strlen(prefix);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1803 nprefix = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1804
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1805 g_completion_complete(data->completion, prefix, &nprefix);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1806
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1807 if (nprefix != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1808 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1809 gtk_entry_set_text(GTK_ENTRY(entry), nprefix);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1810 gtk_editable_set_position(entry, pos);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1811 gtk_editable_select_region(entry, pos, -1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1812
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1813 data->completion_started = TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1814
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1815 g_free(nprefix);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1816 g_free(prefix);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1817
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1818 return TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1819 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1820
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1821 g_free(prefix);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1822 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1823
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1824 return FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1825 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1826
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1827 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1828 destroy_completion_data(GtkWidget *w, GaimGtkCompletionData *data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1829 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1830 g_list_foreach(data->completion->items, (GFunc)g_free, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1831 g_completion_free(data->completion);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1832
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1833 g_free(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1834 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1835 #endif /* !NEW_STYLE_COMPLETION */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1836
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1837 #ifdef NEW_STYLE_COMPLETION
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1838 static gboolean screenname_completion_match_func(GtkEntryCompletion *completion,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1839 const gchar *key, GtkTreeIter *iter, gpointer user_data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1840 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1841 GtkTreeModel *model;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1842 GValue val1;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1843 GValue val2;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1844 const char *tmp;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1845
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1846 model = gtk_entry_completion_get_model (completion);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1847
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1848 val1.g_type = 0;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1849 gtk_tree_model_get_value(model, iter, 2, &val1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1850 tmp = g_value_get_string(&val1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1851 if (tmp != NULL && gaim_str_has_prefix(tmp, key))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1852 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1853 g_value_unset(&val1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1854 return TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1855 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1856 g_value_unset(&val1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1857
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1858 val2.g_type = 0;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1859 gtk_tree_model_get_value(model, iter, 3, &val2);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1860 tmp = g_value_get_string(&val2);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1861 if (tmp != NULL && gaim_str_has_prefix(tmp, key))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1862 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1863 g_value_unset(&val2);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1864 return TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1865 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1866 g_value_unset(&val2);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1867
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1868 return FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1869 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1870
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1871 static gboolean screenname_completion_match_selected_cb(GtkEntryCompletion *completion,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1872 GtkTreeModel *model, GtkTreeIter *iter, gpointer *user_data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1873 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1874 GValue val;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1875 GtkWidget *optmenu = user_data[1];
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1876 GaimAccount *account;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1877
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1878 val.g_type = 0;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1879 gtk_tree_model_get_value(model, iter, 1, &val);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1880 gtk_entry_set_text(GTK_ENTRY(user_data[0]), g_value_get_string(&val));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1881 g_value_unset(&val);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1882
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1883 gtk_tree_model_get_value(model, iter, 4, &val);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1884 account = g_value_get_pointer(&val);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1885 g_value_unset(&val);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1886
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1887 if (account == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1888 return TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1889
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1890 if (optmenu != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1891 GList *items;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1892 guint index = 0;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1893 gaim_gtk_account_option_menu_set_selected(optmenu, account);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1894 items = GTK_MENU_SHELL(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)))->children;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1895
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1896 do {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1897 if (account == g_object_get_data(G_OBJECT(items->data), "account")) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1898 /* Set the account in the GUI. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1899 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), index);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1900 return TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1901 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1902 index++;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1903 } while ((items = items->next) != NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1904 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1905
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1906 return TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1907 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1908
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1909 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1910 add_screenname_autocomplete_entry(GtkListStore *store, const char *buddy_alias, const char *contact_alias,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1911 const GaimAccount *account, const char *screenname)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1912 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1913 GtkTreeIter iter;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1914 gboolean completion_added = FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1915 gchar *normalized_screenname;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1916 gchar *tmp;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1917
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1918 tmp = g_utf8_normalize(screenname, -1, G_NORMALIZE_DEFAULT);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1919 normalized_screenname = g_utf8_casefold(tmp, -1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1920 g_free(tmp);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1921
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1922 /* There's no sense listing things like: 'xxx "xxx"'
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1923 when the screenname and buddy alias match. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1924 if (buddy_alias && strcmp(buddy_alias, screenname)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1925 char *completion_entry = g_strdup_printf("%s \"%s\"", screenname, buddy_alias);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1926 char *tmp2 = g_utf8_normalize(buddy_alias, -1, G_NORMALIZE_DEFAULT);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1927
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1928 tmp = g_utf8_casefold(tmp2, -1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1929 g_free(tmp2);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1930
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1931 gtk_list_store_append(store, &iter);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1932 gtk_list_store_set(store, &iter,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1933 0, completion_entry,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1934 1, screenname,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1935 2, normalized_screenname,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1936 3, tmp,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1937 4, account,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1938 -1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1939 g_free(completion_entry);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1940 g_free(tmp);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1941 completion_added = TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1942 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1943
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1944 /* There's no sense listing things like: 'xxx "xxx"'
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1945 when the screenname and contact alias match. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1946 if (contact_alias && strcmp(contact_alias, screenname)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1947 /* We don't want duplicates when the contact and buddy alias match. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1948 if (!buddy_alias || strcmp(contact_alias, buddy_alias)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1949 char *completion_entry = g_strdup_printf("%s \"%s\"",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1950 screenname, contact_alias);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1951 char *tmp2 = g_utf8_normalize(contact_alias, -1, G_NORMALIZE_DEFAULT);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1952
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1953 tmp = g_utf8_casefold(tmp2, -1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1954 g_free(tmp2);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1955
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1956 gtk_list_store_append(store, &iter);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1957 gtk_list_store_set(store, &iter,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1958 0, completion_entry,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1959 1, screenname,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1960 2, normalized_screenname,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1961 3, tmp,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1962 4, account,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1963 -1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1964 g_free(completion_entry);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1965 g_free(tmp);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1966 completion_added = TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1967 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1968 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1969
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1970 if (completion_added == FALSE) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1971 /* Add the buddy's screenname. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1972 gtk_list_store_append(store, &iter);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1973 gtk_list_store_set(store, &iter,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1974 0, screenname,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1975 1, screenname,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1976 2, normalized_screenname,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1977 3, NULL,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1978 4, account,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1979 -1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1980 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1981
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1982 g_free(normalized_screenname);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1983 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1984 #endif /* NEW_STYLE_COMPLETION */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1985
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1986 static void get_log_set_name(GaimLogSet *set, gpointer value, gpointer **set_hash_data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1987 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1988 /* 1. Don't show buddies because we will have gotten them already.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1989 * 2. Only show those with non-NULL accounts that are currently connected.
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1990 * 3. The boxes that use this autocomplete code handle only IMs. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1991 if (!set->buddy &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1992 (GPOINTER_TO_INT(set_hash_data[1]) ||
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1993 (set->account != NULL && gaim_account_is_connected(set->account))) &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1994 set->type == GAIM_LOG_IM) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1995 #ifdef NEW_STYLE_COMPLETION
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1996 add_screenname_autocomplete_entry((GtkListStore *)set_hash_data[0],
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1997 NULL, NULL, set->account, set->name);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1998 #else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1999 GList **items = ((GList **)set_hash_data[0]);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2000 /* Steal the name for the GCompletion. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2001 *items = g_list_append(*items, set->name);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2002 set->name = set->normalized_name = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2003 #endif /* NEW_STYLE_COMPLETION */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2004 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2005 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2006
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2007 #ifdef NEW_STYLE_COMPLETION
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2008 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2009 add_completion_list(GtkListStore *store)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2010 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2011 GaimBlistNode *gnode, *cnode, *bnode;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2012 gboolean all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(store), "screenname-all"));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2013 GHashTable *sets;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2014 gpointer set_hash_data[] = {store, GINT_TO_POINTER(all)};
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2015
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2016 gtk_list_store_clear(store);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2017
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2018 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2019 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2020 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2021 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2022
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2023 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2024 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2025 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2026 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2027
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2028 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2029 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2030 GaimBuddy *buddy = (GaimBuddy *)bnode;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2031
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2032 if (!all && !gaim_account_is_connected(buddy->account))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2033 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2034
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2035 add_screenname_autocomplete_entry(store,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2036 ((GaimContact *)cnode)->alias,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2037 gaim_buddy_get_contact_alias(buddy),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2038 buddy->account,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2039 buddy->name
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2040 );
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2041 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2042 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2043 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2044
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2045 sets = gaim_log_get_log_sets();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2046 g_hash_table_foreach(sets, (GHFunc)get_log_set_name, &set_hash_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2047 g_hash_table_destroy(sets);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2048 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2049 #else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2050 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2051 add_completion_list(GaimGtkCompletionData *data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2052 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2053 GaimBlistNode *gnode, *cnode, *bnode;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2054 GCompletion *completion;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2055 GList *item = g_list_append(NULL, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2056 GHashTable *sets;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2057 gpointer set_hash_data[2];
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2058
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2059 completion = data->completion;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2060
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2061 g_list_foreach(completion->items, (GFunc)g_free, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2062 g_completion_clear_items(completion);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2063
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2064 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2065 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2066 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2067 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2068
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2069 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2070 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2071 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2072 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2073
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2074 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2075 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2076 GaimBuddy *buddy = (GaimBuddy *)bnode;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2077
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2078 if (!data->all && !gaim_account_is_connected(buddy->account))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2079 continue;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2080
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2081 item->data = g_strdup(buddy->name);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2082 g_completion_add_items(data->completion, item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2083 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2084 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2085 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2086 g_list_free(item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2087
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2088 sets = gaim_log_get_log_sets();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2089 item = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2090 set_hash_data[0] = &item;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2091 set_hash_data[1] = GINT_TO_POINTER(data->all);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2092 g_hash_table_foreach(sets, (GHFunc)get_log_set_name, &set_hash_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2093 g_hash_table_destroy(sets);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2094 g_completion_add_items(data->completion, item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2095 g_list_free(item);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2096 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2097 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2098
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2099 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2100 screenname_autocomplete_destroyed_cb(GtkWidget *widget, gpointer data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2101 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2102 gaim_signals_disconnect_by_handle(widget);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2103 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2104
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2105 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2106 repopulate_autocomplete(gpointer something, gpointer data)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2107 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2108 add_completion_list(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2109 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2110
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2111 void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2112 gaim_gtk_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *accountopt, gboolean all)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2113 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2114 gpointer cb_data = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2115
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2116 #ifdef NEW_STYLE_COMPLETION
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2117 /* Store the displayed completion value, the screenname, the UTF-8 normalized & casefolded screenname,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2118 * the UTF-8 normalized & casefolded value for comparison, and the account. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2119 GtkListStore *store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2120
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2121 GtkEntryCompletion *completion;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2122 gpointer *data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2123
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2124 g_object_set_data(G_OBJECT(store), "screenname-all", GINT_TO_POINTER(all));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2125 add_completion_list(store);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2126
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2127 cb_data = store;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2128
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2129 /* Sort the completion list by screenname. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2130 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2131 1, GTK_SORT_ASCENDING);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2132
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2133 completion = gtk_entry_completion_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2134 gtk_entry_completion_set_match_func(completion, screenname_completion_match_func, NULL, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2135
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2136 data = g_new0(gpointer, 2);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2137 data[0] = entry;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2138 data[1] = accountopt;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2139 g_signal_connect(G_OBJECT(completion), "match-selected",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2140 G_CALLBACK(screenname_completion_match_selected_cb), data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2141
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2142 gtk_entry_set_completion(GTK_ENTRY(entry), completion);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2143 g_object_unref(completion);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2144
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2145 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2146 g_object_unref(store);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2147
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2148 gtk_entry_completion_set_text_column(completion, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2149
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2150 #else /* !NEW_STYLE_COMPLETION */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2151 GaimGtkCompletionData *data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2152
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2153 data = g_new0(GaimGtkCompletionData, 1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2154
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2155 data->completion = g_completion_new(NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2156 data->all = all;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2157
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2158 g_completion_set_compare(data->completion, g_ascii_strncasecmp);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2159
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2160 add_completion_list(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2161 cb_data = data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2162
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2163 g_signal_connect(G_OBJECT(entry), "event",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2164 G_CALLBACK(completion_entry_event), data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2165 g_signal_connect(G_OBJECT(entry), "destroy",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2166 G_CALLBACK(destroy_completion_data), data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2167
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2168 #endif /* !NEW_STYLE_COMPLETION */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2169
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2170 if (!all)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2171 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2172 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", entry,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2173 GAIM_CALLBACK(repopulate_autocomplete), cb_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2174 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", entry,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2175 GAIM_CALLBACK(repopulate_autocomplete), cb_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2176 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2177
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2178 gaim_signal_connect(gaim_accounts_get_handle(), "account-added", entry,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2179 GAIM_CALLBACK(repopulate_autocomplete), cb_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2180 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", entry,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2181 GAIM_CALLBACK(repopulate_autocomplete), cb_data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2182
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2183 g_signal_connect(G_OBJECT(entry), "destroy", G_CALLBACK(screenname_autocomplete_destroyed_cb), NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2184 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2185
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2186 void gaim_gtk_set_cursor(GtkWidget *widget, GdkCursorType cursor_type)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2187 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2188 GdkCursor *cursor;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2189
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2190 g_return_if_fail(widget != NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2191 if (widget->window == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2192 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2193
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2194 cursor = gdk_cursor_new(GDK_WATCH);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2195 gdk_window_set_cursor(widget->window, cursor);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2196 gdk_cursor_unref(cursor);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2197
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2198 #if GTK_CHECK_VERSION(2,4,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2199 gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window)));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2200 #else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2201 gdk_flush();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2202 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2203 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2204
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2205 void gaim_gtk_clear_cursor(GtkWidget *widget)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2206 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2207 g_return_if_fail(widget != NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2208 if (widget->window == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2209 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2210
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2211 gdk_window_set_cursor(widget->window, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2212 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2213
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2214 struct _icon_chooser {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2215 GtkWidget *icon_filesel;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2216 GtkWidget *icon_preview;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2217 GtkWidget *icon_text;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2218
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2219 void (*callback)(const char*,gpointer);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2220 gpointer data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2221 };
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2222
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2223 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2224 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2225 icon_filesel_delete_cb(GtkWidget *w, struct _icon_chooser *dialog)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2226 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2227 if (dialog->icon_filesel != NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2228 gtk_widget_destroy(dialog->icon_filesel);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2229
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2230 if (dialog->callback)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2231 dialog->callback(NULL, data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2232
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2233 g_free(dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2234 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2235 #endif /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2236
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2237
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2238
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2239 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2240 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2241 icon_filesel_choose_cb(GtkWidget *widget, gint response, struct _icon_chooser *dialog)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2242 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2243 char *filename, *current_folder;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2244
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2245 if (response != GTK_RESPONSE_ACCEPT) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2246 if (response == GTK_RESPONSE_CANCEL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2247 gtk_widget_destroy(dialog->icon_filesel);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2248 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2249 dialog->icon_filesel = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2250 if (dialog->callback)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2251 dialog->callback(NULL, dialog->data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2252 g_free(dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2253 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2254 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2255
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2256 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2257 current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2258 if (current_folder != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2259 gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2260 g_free(current_folder);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2261 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2262
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2263 #else /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2264 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2265 icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2266 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2267 char *filename, *current_folder;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2268
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2269 filename = g_strdup(gtk_file_selection_get_filename(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2270 GTK_FILE_SELECTION(dialog->icon_filesel)));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2271
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2272 /* If they typed in a directory, change there */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2273 if (gaim_gtk_check_if_dir(filename,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2274 GTK_FILE_SELECTION(dialog->icon_filesel)))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2275 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2276 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2277 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2278 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2279
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2280 current_folder = g_path_get_dirname(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2281 if (current_folder != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2282 gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2283 g_free(current_folder);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2284 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2285
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2286 #endif /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2287 if (dialog->callback)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2288 dialog->callback(filename, dialog->data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2289 gtk_widget_destroy(dialog->icon_filesel);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2290 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2291 g_free(dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2292 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2293
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2294
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2295 static void
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2296 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2297 icon_preview_change_cb(GtkFileChooser *widget, struct _icon_chooser *dialog)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2298 #else /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2299 icon_preview_change_cb(GtkTreeSelection *sel, struct _icon_chooser *dialog)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2300 #endif /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2301 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2302 GdkPixbuf *pixbuf, *scale;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2303 int height, width;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2304 char *basename, *markup, *size;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2305 struct stat st;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2306 char *filename;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2307
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2308 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2309 filename = gtk_file_chooser_get_preview_filename(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2310 GTK_FILE_CHOOSER(dialog->icon_filesel));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2311 #else /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2312 filename = g_strdup(gtk_file_selection_get_filename(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2313 GTK_FILE_SELECTION(dialog->icon_filesel)));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2314 #endif /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2315
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2316 if (!filename || g_stat(filename, &st))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2317 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2318 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2319 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2320 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2321
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2322 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2323 if (!pixbuf) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2324 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2325 gtk_label_set_markup(GTK_LABEL(dialog->icon_text), "");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2326 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2327 gtk_file_chooser_set_preview_widget_active(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2328 GTK_FILE_CHOOSER(dialog->icon_filesel), FALSE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2329 #endif /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2330 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2331 return;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2332 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2333
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2334 width = gdk_pixbuf_get_width(pixbuf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2335 height = gdk_pixbuf_get_height(pixbuf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2336 basename = g_path_get_basename(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2337 size = gaim_str_size_to_units(st.st_size);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2338 markup = g_strdup_printf(_("<b>File:</b> %s\n"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2339 "<b>File size:</b> %s\n"
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2340 "<b>Image size:</b> %dx%d"),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2341 basename, size, width, height);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2342
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2343 scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2344 50, GDK_INTERP_BILINEAR);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2345 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), scale);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2346 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2347 gtk_file_chooser_set_preview_widget_active(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2348 GTK_FILE_CHOOSER(dialog->icon_filesel), TRUE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2349 #endif /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2350 gtk_label_set_markup(GTK_LABEL(dialog->icon_text), markup);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2351
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2352 g_object_unref(G_OBJECT(pixbuf));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2353 g_object_unref(G_OBJECT(scale));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2354 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2355 g_free(basename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2356 g_free(size);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2357 g_free(markup);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2358 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2359
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2360
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2361 GtkWidget *gaim_gtk_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2362 struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2363
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2364 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2365 GtkWidget *hbox;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2366 GtkWidget *tv;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2367 GtkTreeSelection *sel;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2368 #endif /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2369 const char *current_folder;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2370
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2371 dialog->callback = callback;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2372 dialog->data = data;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2373
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2374 if (dialog->icon_filesel != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2375 gtk_window_present(GTK_WINDOW(dialog->icon_filesel));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2376 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2377 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2378
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2379 current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_icon_folder");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2380 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2381
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2382 dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2383 parent,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2384 GTK_FILE_CHOOSER_ACTION_OPEN,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2385 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2386 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2387 NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2388 gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2389 if ((current_folder != NULL) && (*current_folder != '\0'))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2390 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2391 current_folder);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2392
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2393 dialog->icon_preview = gtk_image_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2394 dialog->icon_text = gtk_label_new(NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2395 gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2396 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2397 GTK_WIDGET(dialog->icon_preview));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2398 g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2399 G_CALLBACK(icon_preview_change_cb), dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2400 g_signal_connect(G_OBJECT(dialog->icon_filesel), "response",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2401 G_CALLBACK(icon_filesel_choose_cb), dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2402 icon_preview_change_cb(NULL, dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2403 #else /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2404 dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon"));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2405 dialog->icon_preview = gtk_image_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2406 dialog->icon_text = gtk_label_new(NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2407 if ((current_folder != NULL) && (*current_folder != '\0'))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2408 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->icon_filesel),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2409 current_folder);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2410
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2411 gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2412 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2413 gtk_box_pack_start(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2414 GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2415 hbox, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2416 gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_preview,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2417 FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2418 gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_text, FALSE, FALSE, 0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2419
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2420 tv = GTK_FILE_SELECTION(dialog->icon_filesel)->file_list;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2421 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2422
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2423 g_signal_connect(G_OBJECT(sel), "changed",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2424 G_CALLBACK(icon_preview_change_cb), dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2425 g_signal_connect(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2426 G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->ok_button),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2427 "clicked",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2428 G_CALLBACK(icon_filesel_choose_cb), dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2429 g_signal_connect(
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2430 G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->cancel_button),
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2431 "clicked",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2432 G_CALLBACK(icon_filesel_delete_cb), dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2433 g_signal_connect(G_OBJECT(dialog->icon_filesel), "destroy",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2434 G_CALLBACK(icon_filesel_delete_cb), dialog);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2435 #endif /* FILECHOOSER */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2436 return dialog->icon_filesel;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2437 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2438
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2439
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2440 #if GTK_CHECK_VERSION(2,2,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2441 static gboolean
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2442 str_array_match(char **a, char **b)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2443 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2444 int i, j;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2445
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2446 if (!a || !b)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2447 return FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2448 for (i = 0; a[i] != NULL; i++)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2449 for (j = 0; b[j] != NULL; j++)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2450 if (!g_ascii_strcasecmp(a[i], b[j]))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2451 return TRUE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2452 return FALSE;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2453 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2454 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2455
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2456 char *
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2457 gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2458 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2459 #if GTK_CHECK_VERSION(2,2,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2460 int width, height;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2461 char **pixbuf_formats = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2462 GdkPixbufFormat *format;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2463 GdkPixbuf *pixbuf;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2464 GaimPluginProtocolInfo *prpl_info;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2465 char **prpl_formats;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2466 #if !GTK_CHECK_VERSION(2,4,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2467 GdkPixbufLoader *loader;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2468 FILE *file;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2469 struct stat st;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2470 void *data = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2471 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2472 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2473 const char *dirname;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2474 char *random;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2475 char *filename;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2476
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2477 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2478
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2479 g_return_val_if_fail(prpl_info->icon_spec.format != NULL, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2480
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2481 prpl_formats = g_strsplit(prpl_info->icon_spec.format,",",0);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2482 dirname = gaim_buddy_icons_get_cache_dir();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2483 random = g_strdup_printf("%x", g_random_int());
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2484 filename = g_build_filename(dirname, random, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2485
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2486 if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2487 gaim_debug_info("buddyicon", "Creating icon cache directory.\n");
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2488
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2489 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2490 gaim_debug_error("buddyicon",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2491 "Unable to create directory %s: %s\n",
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2492 dirname, strerror(errno));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2493 #if GTK_CHECK_VERSION(2,2,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2494 g_strfreev(prpl_formats);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2495 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2496 g_free(random);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2497 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2498 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2499 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2500 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2501
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2502 #if GTK_CHECK_VERSION(2,2,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2503 #if GTK_CHECK_VERSION(2,4,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2504 format = gdk_pixbuf_get_file_info (path, &width, &height);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2505 #else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2506 loader = gdk_pixbuf_loader_new();
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2507 if (!g_stat(path, &st) && (file = g_fopen(path, "rb")) != NULL) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2508 data = g_malloc(st.st_size);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2509 fread(data, 1, st.st_size, file);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2510 fclose(file);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2511 gdk_pixbuf_loader_write(loader, data, st.st_size, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2512 g_free(data);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2513 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2514 gdk_pixbuf_loader_close(loader, NULL);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2515 pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2516 width = gdk_pixbuf_get_width(pixbuf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2517 height = gdk_pixbuf_get_height(pixbuf);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2518 format = gdk_pixbuf_loader_get_format(loader);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2519 g_object_unref(G_OBJECT(loader));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2520 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2521 if (format == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2522 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2523 pixbuf_formats = gdk_pixbuf_format_get_extensions(format);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2524
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2525 if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2526 (!(prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) || /* The prpl doesn't scale before it sends OR */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2527 (prpl_info->icon_spec.min_width <= width &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2528 prpl_info->icon_spec.max_width >= width &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2529 prpl_info->icon_spec.min_height <= height &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2530 prpl_info->icon_spec.max_height >= height))) /* The icon is the correct size */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2531 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2532 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2533 gchar *contents;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2534 gsize length;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2535 FILE *image;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2536
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2537 #if GTK_CHECK_VERSION(2,2,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2538 g_strfreev(prpl_formats);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2539 g_strfreev(pixbuf_formats);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2540 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2541
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2542 /* Copy the image to the cache folder as "filename". */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2543
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2544 if (!g_file_get_contents(path, &contents, &length, NULL) ||
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2545 (image = g_fopen(filename, "wb")) == NULL)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2546 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2547 g_free(random);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2548 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2549 #if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2550 g_object_unref(G_OBJECT(pixbuf));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2551 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2552 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2553 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2554
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2555 if (fwrite(contents, 1, length, image) != length)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2556 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2557 fclose(image);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2558 g_unlink(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2559
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2560 g_free(random);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2561 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2562 #if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2563 g_object_unref(G_OBJECT(pixbuf));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2564 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2565 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2566 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2567 fclose(image);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2568
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2569 #if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2570 g_object_unref(G_OBJECT(pixbuf));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2571 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2572
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2573 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2574 return random;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2575 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2576 #if GTK_CHECK_VERSION(2,2,0)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2577 else
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2578 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2579 int i;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2580 GError *error = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2581 GdkPixbuf *scale;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2582 pixbuf = gdk_pixbuf_new_from_file(path, &error);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2583 g_strfreev(pixbuf_formats);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2584 if (!error && (prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) &&
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2585 (width < prpl_info->icon_spec.min_width ||
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2586 width > prpl_info->icon_spec.max_width ||
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2587 height < prpl_info->icon_spec.min_height ||
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2588 height > prpl_info->icon_spec.max_height))
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2589 {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2590 int new_width = width;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2591 int new_height = height;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2592
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2593 if(new_width > prpl_info->icon_spec.max_width)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2594 new_width = prpl_info->icon_spec.max_width;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2595 else if(new_width < prpl_info->icon_spec.min_width)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2596 new_width = prpl_info->icon_spec.min_width;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2597 if(new_height > prpl_info->icon_spec.max_height)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2598 new_height = prpl_info->icon_spec.max_height;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2599 else if(new_height < prpl_info->icon_spec.min_height)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2600 new_height = prpl_info->icon_spec.min_height;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2601
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2602 /* preserve aspect ratio */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2603 if ((double)height * (double)new_width >
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2604 (double)width * (double)new_height) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2605 new_width = 0.5 + (double)width * (double)new_height / (double)height;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2606 } else {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2607 new_height = 0.5 + (double)height * (double)new_width / (double)width;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2608 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2609
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2610 scale = gdk_pixbuf_scale_simple (pixbuf, new_width, new_height,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2611 GDK_INTERP_HYPER);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2612 g_object_unref(G_OBJECT(pixbuf));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2613 pixbuf = scale;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2614 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2615 if (error) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2616 g_free(random);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2617 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2618 gaim_debug_error("buddyicon", "Could not open icon for conversion: %s\n", error->message);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2619 g_error_free(error);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2620 g_strfreev(prpl_formats);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2621 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2622 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2623
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2624 for (i = 0; prpl_formats[i]; i++) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2625 gaim_debug_info("buddyicon", "Converting buddy icon to %s as %s\n", prpl_formats[i], filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2626 /* The gdk-pixbuf documentation is wrong. gdk_pixbuf_save returns TRUE if it was successful,
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2627 * FALSE if an error was set. */
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2628 if (gdk_pixbuf_save (pixbuf, filename, prpl_formats[i], &error, NULL) == TRUE)
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2629 break;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2630 gaim_debug_warning("buddyicon", "Could not convert to %s: %s\n", prpl_formats[i], error->message);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2631 g_error_free(error);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2632 error = NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2633 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2634 g_strfreev(prpl_formats);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2635 if (!error) {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2636 g_object_unref(G_OBJECT(pixbuf));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2637 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2638 return random;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2639 } else {
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2640 gaim_debug_error("buddyicon", "Could not convert icon to usable format: %s\n", error->message);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2641 g_error_free(error);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2642 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2643 g_free(random);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2644 g_free(filename);
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2645 g_object_unref(G_OBJECT(pixbuf));
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2646 }
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2647 return NULL;
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2648 #endif
009db0b357b5 This is a hand-crafted commit to migrate across subversion revisions
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2649 }