annotate src/gtkutils.c @ 6232:48022cc36114

[gaim-migrate @ 6725] Initial import committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Sat, 19 Jul 2003 18:26:53 +0000
parents 156953fe3e14
children 7ff81c01d238
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
1 /**
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
2 * @file gtkutils.h GTK+ utility functions
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
3 * @ingroup gtkui
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
4 *
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 * gaim
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 *
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * (at your option) any later version.
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * GNU General Public License for more details.
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
23 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
24
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #ifndef _WIN32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
26 # include <X11/Xlib.h>
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 #else
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
28 # ifdef small
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
29 # undef small
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
30 # endif
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 #endif /*_WIN32*/
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
32
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 #ifdef USE_GTKSPELL
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
34 # include <gtkspell/gtkspell.h>
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
36
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 #include <gdk/gdkkeysyms.h>
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
38
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
39 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
40 #include "notify.h"
5548
80e4ba770f97 [gaim-migrate @ 5949]
Nathan Walp <nwalp@pidgin.im>
parents: 5530
diff changeset
41 #include "prefs.h"
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 #include "prpl.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
43 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
44
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
45 #include "gtkconv.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
46 #include "gtkimhtml.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
47 #include "gtkutils.h"
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 #include "ui.h"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49
4859
a9a831508b43 [gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4793
diff changeset
50 #ifdef _WIN32
a9a831508b43 [gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4793
diff changeset
51 #include "wspell.h"
a9a831508b43 [gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4793
diff changeset
52 #endif
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 gaim_setup_imhtml(GtkWidget *imhtml)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 g_return_if_fail(imhtml != NULL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 g_return_if_fail(GTK_IS_IMHTML(imhtml));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59
5548
80e4ba770f97 [gaim-migrate @ 5949]
Nathan Walp <nwalp@pidgin.im>
parents: 5530
diff changeset
60 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_smileys"))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 gtk_imhtml_show_smileys(GTK_IMHTML(imhtml), FALSE);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 g_signal_connect(G_OBJECT(imhtml), "url_clicked",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 G_CALLBACK(open_url), NULL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 smiley_themeize(imhtml);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 gboolean sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 gtk_widget_set_sensitive(to_toggle, !sensitivity);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 static void
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
78 gaim_gtk_remove_tags(GaimGtkConversation *gtkconv, const char *tag)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 GtkTextIter start, end, m_start, m_end;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 if (gtkconv == NULL || tag == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 if (!gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 &start, &end))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 /* FIXMEif (strstr(tag, "<FONT SIZE=")) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 while ((t = strstr(t, "<FONT SIZE="))) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 if (((t - s) < finish) && ((t - s) >= start)) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 gtk_editable_delete_text(GTK_EDITABLE(entry), (t - s),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 (t - s) + strlen(tag));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 g_free(s);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 t = s;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 } else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 t++;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 } else*/ {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 while (gtk_text_iter_forward_search(&start, tag, 0, &m_start,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 &m_end, &end)) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 gtk_text_buffer_delete(gtkconv->entry_buffer, &m_start, &m_end);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 &start, &end);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 void
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
112 gaim_gtk_surround(GaimGtkConversation *gtkconv,
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 const char *pre, const char *post)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 GtkTextIter start, end;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 GtkTextMark *mark_start, *mark_end;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 GtkTextBuffer *entry_buffer;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 if (gtkconv == NULL || pre == NULL || post == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 entry_buffer = gtkconv->entry_buffer;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 if (gtk_text_buffer_get_selection_bounds(entry_buffer,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 &start, &end)) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 gaim_gtk_remove_tags(gtkconv, pre);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 gaim_gtk_remove_tags(gtkconv, post);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 mark_start = gtk_text_buffer_create_mark(entry_buffer, "m1",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 &start, TRUE);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 mark_end = gtk_text_buffer_create_mark(entry_buffer, "m2",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 &end, FALSE);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 gtk_text_buffer_insert(entry_buffer, &start, pre, -1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 gtk_text_buffer_get_selection_bounds(entry_buffer, &start, &end);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 gtk_text_buffer_insert(entry_buffer, &end, post, -1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 gtk_text_buffer_move_mark_by_name(entry_buffer, "selection_bound",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 &start);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 } else {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 gtk_text_buffer_insert(entry_buffer, &start, pre, -1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 gtk_text_buffer_insert(entry_buffer, &start, post, -1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 mark_start = gtk_text_buffer_get_insert(entry_buffer);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 gtk_text_iter_backward_chars(&start, strlen(post));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 gtk_text_buffer_place_cursor(entry_buffer, &start);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 gtk_widget_grab_focus(gtkconv->entry);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 static gboolean
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 invert_tags(GtkTextBuffer *buffer, const char *s1, const char *s2,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 gboolean really)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 GtkTextIter start1, start2, end1, end2;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 char *b1, *b2;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 if (gtk_text_buffer_get_selection_bounds(buffer, &start1, &end2)) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 start2 = start1;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 end1 = end2;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 if (!gtk_text_iter_forward_chars(&start2, strlen(s1)))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 return FALSE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 if (!gtk_text_iter_backward_chars(&end1, strlen(s2)))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 return FALSE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 b1 = gtk_text_buffer_get_text(buffer, &start1, &start2, FALSE);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 b2 = gtk_text_buffer_get_text(buffer, &end1, &end2, FALSE);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
171 if (!g_ascii_strncasecmp(b1, s1, strlen(s1)) &&
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
172 !g_ascii_strncasecmp(b2, s2, strlen(s2))) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 if (really) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 GtkTextMark *m_end1, *m_end2;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 m_end1= gtk_text_buffer_create_mark(buffer, "m1", &end1, TRUE);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 m_end2= gtk_text_buffer_create_mark(buffer, "m2", &end2, TRUE);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 gtk_text_buffer_delete(buffer, &start1, &start2);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 gtk_text_buffer_get_iter_at_mark(buffer, &end1, m_end1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 gtk_text_buffer_get_iter_at_mark(buffer, &end2, m_end2);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 gtk_text_buffer_delete(buffer, &end1, &end2);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 gtk_text_buffer_delete_mark(buffer, m_end1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 gtk_text_buffer_delete_mark(buffer, m_end2);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 g_free(b1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 g_free(b2);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 return TRUE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 g_free(b1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 g_free(b2);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 return FALSE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 void
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
202 gaim_gtk_advance_past(GaimGtkConversation *gtkconv,
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 const char *pre, const char *post)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 GtkTextIter current_pos, start, end;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 if (invert_tags(gtkconv->entry_buffer, pre, post, TRUE))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &current_pos,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 gtk_text_buffer_get_insert(gtkconv->entry_buffer));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 if (gtk_text_iter_forward_search(&current_pos, post, 0,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 &start, &end, NULL))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 gtk_text_buffer_place_cursor(gtkconv->entry_buffer, &end);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, post, -1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 gtk_widget_grab_focus(gtkconv->entry);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 void
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
223 gaim_gtk_set_font_face(GaimGtkConversation *gtkconv,
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 const char *font)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 char *pre_fontface;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 if (gtkconv == NULL || font == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 strncpy(gtkconv->fontface,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 (font && *font ? font : DEFAULT_FONT_FACE),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 sizeof(gtkconv->fontface));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 gtkconv->has_font = TRUE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 pre_fontface = g_strconcat("<FONT FACE=\"",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 gtkconv->fontface, "\">", NULL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 gaim_gtk_surround(gtkconv, pre_fontface, "</FONT>");
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 gtk_widget_grab_focus(gtkconv->entry);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 g_free(pre_fontface);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 static int
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 des_save_icon(GtkObject *obj, GdkEvent *e,
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
248 GaimGtkConversation *gtkconv)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 gtk_widget_destroy(gtkconv->u.im->save_icon);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 gtkconv->u.im->save_icon = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 return TRUE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 static void
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
257 do_save_icon(GtkObject *obj, GaimConversation *c)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 {
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
259 GaimGtkConversation *gtkconv;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 FILE *file;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 const char *f;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 gtkconv = GAIM_GTK_CONVERSATION(c);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 f = gtk_file_selection_get_filename(
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 GTK_FILE_SELECTION(gtkconv->u.im->save_icon));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
268 if (gaim_gtk_check_if_dir(f, GTK_FILE_SELECTION(gtkconv->u.im->save_icon)))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 if ((file = fopen(f, "w")) != NULL) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 int len;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 void *data = get_icon_data(gaim_conversation_get_gc(c),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 normalize(gaim_conversation_get_name(c)),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 &len);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 if (data)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 fwrite(data, 1, len, file);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 fclose(file);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 } else {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
282 gaim_notify_error(NULL, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5314
diff changeset
283 _("Can't save icon file to disk."), NULL);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286 gtk_widget_destroy(gtkconv->u.im->save_icon);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 gtkconv->u.im->save_icon = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290 static void
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
291 cancel_save_icon(GtkObject *obj, GaimGtkConversation *gtkconv)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 gtk_widget_destroy(gtkconv->u.im->save_icon);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294 gtkconv->u.im->save_icon = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 void
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
299 gaim_gtk_save_icon_dialog(GtkObject *obj, GaimConversation *conv)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 {
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5649
diff changeset
301 GaimGtkConversation *gtkconv;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 char buf[BUF_LEN];
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 if (conv == NULL || gaim_conversation_get_type(conv) != GAIM_CONV_IM)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306
4398
a8249a5250b6 [gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents: 4359
diff changeset
307 if (!GAIM_IS_GTK_CONVERSATION(conv))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 gtkconv = GAIM_GTK_CONVERSATION(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312 if (gtkconv->u.im->save_icon != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314 gdk_window_raise(gtkconv->u.im->save_icon->window);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 gtkconv->u.im->save_icon = gtk_file_selection_new(_("Gaim - Save Icon"));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 gtk_file_selection_hide_fileop_buttons(
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 GTK_FILE_SELECTION(gtkconv->u.im->save_icon));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 g_snprintf(buf, BUF_LEN - 1,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 "%s" G_DIR_SEPARATOR_S "%s.icon",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 gaim_home_dir(), gaim_conversation_get_name(conv));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 gtk_file_selection_set_filename(
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 GTK_FILE_SELECTION(gtkconv->u.im->save_icon), buf);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
330 g_signal_connect(G_OBJECT(gtkconv->u.im->save_icon), "delete_event",
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 G_CALLBACK(des_save_icon), gtkconv);
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
332 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->ok_button), "clicked",
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 G_CALLBACK(do_save_icon), conv);
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
334 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->cancel_button), "clicked",
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 G_CALLBACK(cancel_save_icon), gtkconv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 gtk_widget_show(gtkconv->u.im->save_icon);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 int
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 gaim_gtk_get_dispstyle(GaimConversationType type)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 int dispstyle = 2;
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
344 int value;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 if (type == GAIM_CONV_CHAT) {
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
347 value = gaim_prefs_get_int("/gaim/gtk/conversations/chat/button_type");
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
349 switch (value) {
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
350 case GAIM_BUTTON_TEXT: dispstyle = 1; break;
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
351 case GAIM_BUTTON_IMAGE: dispstyle = 0; break;
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
352 default: dispstyle = 2; break; /* both/neither */
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 else if (type == GAIM_CONV_IM) {
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
356 value = gaim_prefs_get_int("/gaim/gtk/conversations/im/button_type");
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
358 switch (value) {
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
359 case GAIM_BUTTON_TEXT: dispstyle = 1; break;
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
360 case GAIM_BUTTON_IMAGE: dispstyle = 0; break;
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5548
diff changeset
361 default: dispstyle = 2; break; /* both/neither */
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365 return dispstyle;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 GtkWidget *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 gaim_gtk_change_text(const char *text, GtkWidget *button,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 const char *stock, GaimConversationType type)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372 int dispstyle = gaim_gtk_get_dispstyle(type);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374 if (button != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 gtk_widget_destroy(button);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 button = gaim_pixbuf_button_from_stock((dispstyle == 0 ? NULL : text),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378 (dispstyle == 1 ? NULL : stock),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379 GAIM_BUTTON_VERTICAL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 gtk_widget_show(button);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 return button;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 gboolean sensitivity;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391 if (to_toggle == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 gtk_widget_set_sensitive(to_toggle, !sensitivity);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
399 void
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
400 gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data)
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
401 {
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
402 gboolean sensitivity;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
403 gpointer element;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
404 int i;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
405
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
406 for (i=0; i < data->len; i++) {
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
407 element = g_ptr_array_index(data,i);
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
408 if (element == NULL)
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
409 continue;
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
410
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
411 sensitivity = GTK_WIDGET_IS_SENSITIVE(element);
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
412
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
413 gtk_widget_set_sensitive(element, !sensitivity);
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
414 }
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
415 }
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
416
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
417 void gaim_separator(GtkWidget *menu)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
418 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
419 GtkWidget *menuitem;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
420
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
421 menuitem = gtk_separator_menu_item_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
422 gtk_widget_show(menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
423 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4398
diff changeset
424 }
5160
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
425
5162
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
426 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str)
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
427 {
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
428 GtkWidget *menuitem;
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
429 GtkWidget *label;
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
430
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
431 menuitem = gtk_menu_item_new();
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
432 if (menu)
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
433 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
434 gtk_widget_show(menuitem);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
435
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
436 label = gtk_label_new(str);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
437 gtk_label_set_pattern(GTK_LABEL(label), "_");
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
438 gtk_container_add(GTK_CONTAINER(menuitem), label);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
439 gtk_widget_show(label);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
440 /* FIXME: Go back and fix this
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
441 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0],
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
442 GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
443 */
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
444 return menuitem;
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
445 }
b8eafeb874a1 [gaim-migrate @ 5526]
Mark Doliner <mark@kingant.net>
parents: 5160
diff changeset
446
5906
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
447 GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str,
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
448 GtkSignalFunc sf, gpointer data, gboolean checked)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
449 {
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
450 GtkWidget *menuitem;
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
451 menuitem = gtk_check_menu_item_new_with_mnemonic(str);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
452
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
453 if(menu)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
454 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
455
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
456 if (sf)
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
457 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
458
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
459 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), checked);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
460
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
461 gtk_widget_show_all(menuitem);
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
462
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
463 return menuitem;
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
464 }
390d32a6b130 [gaim-migrate @ 6338]
Nathan Walp <nwalp@pidgin.im>
parents: 5880
diff changeset
465
5160
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
466 GtkWidget *gaim_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod)
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
467 {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
468 GtkWidget *menuitem;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
469 /*
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
470 GtkWidget *hbox;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
471 GtkWidget *label;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
472 */
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
473 GtkWidget *image;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
474
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
475 if (icon == NULL)
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
476 menuitem = gtk_menu_item_new_with_mnemonic(str);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
477 else
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
478 menuitem = gtk_image_menu_item_new_with_mnemonic(str);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
479
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
480 if (menu)
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
481 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
482
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
483 if (sf)
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5162
diff changeset
484 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data);
5160
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
485
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
486 if (icon != NULL) {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
487 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
488 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
489 }
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
490 /* FIXME: this isn't right
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
491 if (mod) {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
492 label = gtk_label_new(mod);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
493 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
494 gtk_widget_show(label);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
495 }
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
496 */
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
497 /*
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
498 if (accel_key) {
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
499 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
500 accel_mods, GTK_ACCEL_LOCKED);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
501 }
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
502 */
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
503
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
504 gtk_widget_show_all(menuitem);
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
505
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
506 return menuitem;
91ea5ef2278b [gaim-migrate @ 5524]
Mark Doliner <mark@kingant.net>
parents: 4859
diff changeset
507 }
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
508
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
509 GtkWidget *
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
510 gaim_gtk_make_frame(GtkWidget *parent, const char *title)
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
511 {
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
512 GtkWidget *vbox, *label, *hbox;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
513 char labeltitle[256];
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
514
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
515 vbox = gtk_vbox_new(FALSE, 6);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
516 gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
517 gtk_widget_show(vbox);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
518
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
519 label = gtk_label_new(NULL);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
520 g_snprintf(labeltitle, sizeof(labeltitle),
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
521 "<span weight=\"bold\">%s</span>", title);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
522
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
523 gtk_label_set_markup(GTK_LABEL(label), labeltitle);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
524 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
525 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
526 gtk_widget_show(label);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
527
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
528 hbox = gtk_hbox_new(FALSE, 6);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
529 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
530 gtk_widget_show(hbox);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
531
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
532 label = gtk_label_new(" ");
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
533 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
534 gtk_widget_show(label);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
535
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
536 vbox = gtk_vbox_new(FALSE, 6);
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
537 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
5641
5e9babc828c4 [gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents: 5554
diff changeset
538 gtk_widget_show(vbox);
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
539
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
540 return vbox;
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
541 }
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
542
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
543 static void
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5746
diff changeset
544 protocol_menu_cb(GtkWidget *optmenu, GCallback cb)
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
545 {
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
546 GtkWidget *menu;
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
547 GtkWidget *item;
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
548 GaimProtocol protocol;
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
549 gpointer user_data;
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
550
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
551 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
552 item = gtk_menu_get_active(GTK_MENU(menu));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
553
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
554 protocol = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), "protocol"));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
555 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data"));
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
556
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
557 if (cb != NULL)
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
558 ((void (*)(GtkWidget *, GaimProtocol, gpointer))cb)(item, protocol,
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
559 user_data);
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
560 }
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
561
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
562 GtkWidget *
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
563 gaim_gtk_protocol_option_menu_new(GaimProtocol protocol, GCallback cb,
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
564 gpointer user_data)
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
565 {
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
566 GaimPluginProtocolInfo *prpl_info;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
567 GaimPlugin *plugin;
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
568 GtkWidget *hbox;
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
569 GtkWidget *label;
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
570 GtkWidget *optmenu;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
571 GtkWidget *menu;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
572 GtkWidget *item;
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
573 GtkWidget *image;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
574 GdkPixbuf *pixbuf;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
575 GdkPixbuf *scale;
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
576 GList *p;
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
577 GtkSizeGroup *sg;
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
578 char *filename;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
579 const char *proto_name;
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
580 char buf[256];
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
581 int i, selected_index = -1;
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
582
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
583 optmenu = gtk_option_menu_new();
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
584 gtk_widget_show(optmenu);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
585
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
586 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
587
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
588 menu = gtk_menu_new();
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
589 gtk_widget_show(menu);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
590
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
591 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
592
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
593 for (p = gaim_plugins_get_protocols(), i = 0;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
594 p != NULL;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
595 p = p->next, i++) {
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
596
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
597 plugin = (GaimPlugin *)p->data;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
598 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
599
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
600 /* Create the item. */
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
601 item = gtk_menu_item_new();
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
602
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
603 /* Create the hbox. */
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
604 hbox = gtk_hbox_new(FALSE, 4);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
605 gtk_container_add(GTK_CONTAINER(item), hbox);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
606 gtk_widget_show(hbox);
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
607
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
608 /* Load the image. */
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
609 proto_name = prpl_info->list_icon(NULL, NULL);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
610 g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
611
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
612 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
613 "default", buf, NULL);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
614 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
615 g_free(filename);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
616
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
617 if (pixbuf != NULL) {
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
618 /* Scale and insert the image */
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
619 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
620 GDK_INTERP_BILINEAR);
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
621 image = gtk_image_new_from_pixbuf(scale);
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
622
5646
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
623 g_object_unref(G_OBJECT(pixbuf));
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
624 g_object_unref(G_OBJECT(scale));
48c63ee49961 [gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents: 5644
diff changeset
625 }
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
626 else
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
627 image = gtk_image_new();
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
628
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
629 gtk_size_group_add_widget(sg, image);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
630
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
631 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
632 gtk_widget_show(image);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
633
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
634 /* Create the label. */
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
635 label = gtk_label_new(plugin->info->name);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
636 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
637 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
638 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
639 gtk_widget_show(label);
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
640
5647
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
641 g_object_set_data(G_OBJECT(item), "protocol",
6e551616d051 [gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents: 5646
diff changeset
642 GINT_TO_POINTER(prpl_info->protocol));
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
643
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
644 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
645 gtk_widget_show(item);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
646
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
647 if (prpl_info->protocol == protocol)
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
648 selected_index = i;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
649 }
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
650
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
651 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
652
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
653 if (selected_index != -1)
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
654 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index);
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
655
5688
e43e1b8dca8b [gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
656 g_signal_connect(G_OBJECT(optmenu), "changed",
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5746
diff changeset
657 G_CALLBACK(protocol_menu_cb), cb);
5688
e43e1b8dca8b [gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
658
5649
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
659 g_object_unref(sg);
84221116b28e [gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents: 5647
diff changeset
660
5644
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
661 return optmenu;
213e999fa5cc [gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents: 5641
diff changeset
662 }
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
663
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
664 static void
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
665 account_menu_cb(GtkWidget *optmenu, GCallback cb)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
666 {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
667 GtkWidget *menu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
668 GtkWidget *item;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
669 GaimAccount *account;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
670 gpointer user_data;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
671
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
672 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
673 item = gtk_menu_get_active(GTK_MENU(menu));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
674
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
675 account = g_object_get_data(G_OBJECT(item), "account");
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
676 user_data = g_object_get_data(G_OBJECT(optmenu), "user_data");
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
677
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
678 if (cb != NULL)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
679 ((void (*)(GtkWidget *, GaimAccount *, gpointer))cb)(item, account,
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
680 user_data);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
681 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
682
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
683 GtkWidget *
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
684 gaim_gtk_account_option_menu_new(GaimAccount *default_account,
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
685 gboolean show_all, GCallback cb,
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
686 gpointer user_data)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
687 {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
688 GaimAccount *account;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
689 GList *list;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
690 GtkWidget *hbox;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
691 GtkWidget *label;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
692 GtkWidget *optmenu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
693 GtkWidget *menu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
694 GtkWidget *item;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
695 GtkWidget *image;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
696 GdkPixbuf *pixbuf;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
697 GdkPixbuf *scale;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
698 GList *p;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
699 GtkSizeGroup *sg;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
700 char *filename;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
701 const char *proto_name;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
702 char buf[256];
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
703 int i, selected_index = -1;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
704
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
705 optmenu = gtk_option_menu_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
706 gtk_widget_show(optmenu);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
707
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
708 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
709
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
710 menu = gtk_menu_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
711 gtk_widget_show(menu);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
712
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
713 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
714
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
715 if (show_all)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
716 list = gaim_accounts_get_all();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
717 else
5879
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
718 list = gaim_connections_get_all();
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
719
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
720 gaim_debug(GAIM_DEBUG_INFO, "gtkutils", "Populating menu\n");
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
721
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
722 for (p = list, i = 0; p != NULL; p = p->next, i++) {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
723 GaimPluginProtocolInfo *prpl_info = NULL;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
724 GaimPlugin *plugin;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
725
5879
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
726 if (show_all)
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
727 account = (GaimAccount *)p->data;
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
728 else {
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
729 GaimConnection *gc = (GaimConnection *)p->data;
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
730
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
731 account = gaim_connection_get_account(gc);
d58406d31a1a [gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents: 5877
diff changeset
732 }
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
733
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
734 gaim_debug(GAIM_DEBUG_INFO, "gtkutils", "Adding item.\n");
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
735
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
736 plugin = gaim_find_prpl(gaim_account_get_protocol(account));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
737
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
738 if (plugin != NULL)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
739 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
740
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
741 /* Create the item. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
742 item = gtk_menu_item_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
743
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
744 /* Create the hbox. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
745 hbox = gtk_hbox_new(FALSE, 4);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
746 gtk_container_add(GTK_CONTAINER(item), hbox);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
747 gtk_widget_show(hbox);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
748
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
749 /* Load the image. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
750 if (prpl_info != NULL) {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
751 proto_name = prpl_info->list_icon(NULL, NULL);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
752 g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
753
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
754 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
755 "default", buf, NULL);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
756 pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
757 g_free(filename);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
758
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
759 if (pixbuf != NULL) {
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
760 /* Scale and insert the image */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
761 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
762 GDK_INTERP_BILINEAR);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
763 image = gtk_image_new_from_pixbuf(scale);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
764
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
765 g_object_unref(G_OBJECT(pixbuf));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
766 g_object_unref(G_OBJECT(scale));
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
767 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
768 else
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
769 image = gtk_image_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
770 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
771 else
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
772 image = gtk_image_new();
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
773
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
774 gtk_size_group_add_widget(sg, image);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
775
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
776 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
777 gtk_widget_show(image);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
778
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
779 g_snprintf(buf, sizeof(buf), "%s (%s)",
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
780 gaim_account_get_username(account), plugin->info->name);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
781
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
782 /* Create the label. */
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
783 label = gtk_label_new(buf);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
784 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
785 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
786 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
787 gtk_widget_show(label);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
788
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
789 g_object_set_data(G_OBJECT(item), "account", account);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
790
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
791 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
792 gtk_widget_show(item);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
793
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
794 if (default_account != NULL && account == default_account)
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
795 selected_index = i;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
796 }
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
797
5880
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
798 gaim_debug(GAIM_DEBUG_INFO, "gtkutils", "Done populating menu\n");
1b85ff65be57 [gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents: 5879
diff changeset
799
5877
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
800 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
801
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
802 if (selected_index != -1)
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
803 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
804
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
805 g_signal_connect(G_OBJECT(optmenu), "changed",
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
806 G_CALLBACK(account_menu_cb), cb);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
807
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
808 g_object_unref(sg);
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
809
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
810 return optmenu;
f336fc0a7b8b [gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
811 }
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
812
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
813 gboolean gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel)
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
814 {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
815 char *dirname;
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
816
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
817 if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
818 /* append a / if needed */
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
819 if (path[strlen(path) - 1] != '/') {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
820 dirname = g_strconcat(path, "/", NULL);
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
821 } else {
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
822 dirname = g_strdup(path);
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
823 }
5967
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
824 gtk_file_selection_set_filename(filesel, dirname);
156953fe3e14 [gaim-migrate @ 6414]
Mark Doliner <mark@kingant.net>
parents: 5966
diff changeset
825 g_free(dirname);
5966
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
826 return TRUE;
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
827 }
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
828
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
829 return FALSE;
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
830 }
5fb6bd688a5b [gaim-migrate @ 6413]
Mark Doliner <mark@kingant.net>
parents: 5959
diff changeset
831
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
832 char *stylize(const gchar *text, int length)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
833 {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
834 gchar *buf;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
835 char *tmp = g_malloc(length);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
836
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
837 buf = g_malloc(length);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
838 g_snprintf(buf, length, "%s", text);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
839
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
840 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
841 g_snprintf(tmp, length, "<B>%s</B>", buf);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
842 strcpy(buf, tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
843 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
844
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
845 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
846 g_snprintf(tmp, length, "<I>%s</I>", buf);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
847 strcpy(buf, tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
848 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
849
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
850 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
851 g_snprintf(tmp, length, "<U>%s</U>", buf);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
852 strcpy(buf, tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
853 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
854
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
855 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_strikethrough")) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
856 g_snprintf(tmp, length, "<S>%s</S>", buf);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
857 strcpy(buf, tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
858 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
859
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
860 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_font")) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
861 const char *fontface;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
862
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
863 fontface = gaim_prefs_get_string("/gaim/gtk/conversations/font_face");
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
864
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
865 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
866 strcpy(buf, tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
867 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
868
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
869 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_size")) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
870 int fontsize = gaim_prefs_get_int("/gaim/gtk/conversations/font_size");
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
871
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
872 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>", fontsize, buf);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
873 strcpy(buf, tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
874 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
875
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
876 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_fgcolor")) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
877 GdkColor fgcolor;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
878
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
879 gdk_color_parse(
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
880 gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"),
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
881 &fgcolor);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
882
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
883 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>",
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
884 fgcolor.red/256, fgcolor.green/256, fgcolor.blue/256, buf);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
885 strcpy(buf, tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
886 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
887
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
888 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_bgcolor")) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
889 GdkColor bgcolor;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
890
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
891 gdk_color_parse(
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
892 gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"),
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
893 &bgcolor);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
894
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
895 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>",
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
896 bgcolor.red/256, bgcolor.green/256, bgcolor.blue/256, buf);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
897 strcpy(buf, tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
898 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
899
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
900 g_free(tmp);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
901 return buf;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
902 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
903
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
904 void show_usage(int mode, const char *name)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
905 {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
906 switch (mode) {
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
907 case 0: /* full help text */
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
908 printf(_("Gaim %s\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
909 "Usage: %s [OPTION]...\n\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
910 " -a, --acct display account editor window\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
911 " -w, --away[=MESG] make away on signon (optional argument MESG specifies\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
912 " name of away message to use)\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
913 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
914 " account(s) to use, seperated by commas)\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
915 " -n, --loginwin don't automatically login; show login window\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
916 " -u, --user=NAME use account NAME\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
917 " -f, --file=FILE use FILE as config\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
918 " -d, --debug print debugging messages to stdout\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
919 " -v, --version display the current version and exit\n"
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
920 " -h, --help display this help and exit\n"), VERSION, name);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
921 break;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
922 case 1: /* short message */
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
923 printf(_("Gaim %s. Try `%s -h' for more information.\n"), VERSION, name);
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
924 break;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
925 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
926 }
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
927
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5906
diff changeset
928