Mercurial > pidgin
annotate src/gtkconv.c @ 11589:30947631262d
[gaim-migrate @ 13859]
this at least lets the perl plugin compile on my amd64 box
i don't really think we need perl funcs that take va_list anyway
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 02 Oct 2005 18:28:29 +0000 |
parents | 690c0e967c04 |
children | 8ee38f9428d5 |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1 /** |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
2 * @file gtkconv.c GTK+ Conversation API |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3 * @ingroup gtkui |
4359 | 4 * |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
5 * gaim |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
6 * |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
10 * |
4359 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
28 |
4359 | 29 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
30 # include <X11/Xlib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
31 #endif |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
32 |
4359 | 33 #ifdef USE_GTKSPELL |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
34 # include <gtkspell/gtkspell.h> |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
35 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
36 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
37 # endif |
4359 | 38 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
39 |
4359 | 40 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
41 |
9699 | 42 #include "account.h" |
9130 | 43 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
44 #include "debug.h" |
6982 | 45 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
46 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
47 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
48 #include "prpl.h" |
6038 | 49 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
50 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
52 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
53 #include "gtkblist.h" |
5717 | 54 #include "gtkconv.h" |
11583 | 55 #include "gtkconvwin.h" |
9709 | 56 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
57 #include "gtkimhtml.h" |
8317 | 58 #include "gtkimhtmltoolbar.h" |
7431 | 59 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
60 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
61 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
62 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
63 #include "gtkprivacy.h" |
11525 | 64 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
65 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
66 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
67 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
69 |
10175 | 70 #define SEND_COLOR "#16569E" |
71 #define RECV_COLOR "#A82F2F" | |
7854 | 72 |
10108 | 73 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
74 | |
75 /* These colors come from the default GNOME palette */ | |
76 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
77 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
78 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
79 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
80 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
81 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
84 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
86 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
94 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
95 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
96 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
97 {0, 60928, 54784, 32768}, /* Accent Yellow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
98 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
99 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 100 }; |
6291 | 101 |
4359 | 102 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
103 | |
11581 | 104 typedef struct { |
4359 | 105 GtkWidget *window; |
106 | |
107 GtkWidget *entry; | |
108 GtkWidget *message; | |
109 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
110 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
111 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
112 } InviteBuddyInfo; |
4359 | 113 |
114 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
115 static GtkWidget *warn_close_dialog = NULL; |
4359 | 116 |
11581 | 117 static gboolean update_send_as_selection(GaimGtkWindow *win); |
118 static void generate_send_as_items(GaimGtkWindow *win, GaimConversation *deleted_conv); | |
119 | |
120 | |
121 | |
4359 | 122 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 123 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
124 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
125 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
126 const char *alias, const char *old_name); |
9605 | 127 static gboolean tab_complete(GaimConversation *conv); |
10810 | 128 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
129 static char *item_factory_translate_func (const char *path, gpointer func_data); |
4359 | 130 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
131 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
132 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
133 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
134 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
135 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
136 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
137 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
138 (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
139 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
140 /* The colors are chosen to look fine on white; we should never have to darken */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
141 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
142 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
143 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
144 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
145 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
146 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
147 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
148 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
149 |
4359 | 150 /************************************************************************** |
151 * Callbacks | |
152 **************************************************************************/ | |
10971 | 153 |
4359 | 154 static gint |
10810 | 155 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 156 { |
10810 | 157 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 158 |
10810 | 159 l = list; |
160 while (l) { | |
161 GaimConversation *conv = l->data; | |
162 gaim_conversation_destroy(conv); | |
163 l = l->next; | |
164 } | |
11508 | 165 |
10810 | 166 g_list_free(list); |
11508 | 167 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
168 return TRUE; |
4359 | 169 } |
170 | |
8914 | 171 static gboolean |
10810 | 172 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 173 { |
10810 | 174 GaimConversation *conv = gtkconv->active_conv; |
11508 | 175 |
8914 | 176 if (!GTK_WIDGET_VISIBLE(w)) |
177 return FALSE; | |
178 | |
179 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
180 return FALSE; | |
181 | |
9048 | 182 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the tab bar |
183 * will fit, but then I don't want new windows taking up the entire screen. I check to see if there is only one | |
184 * conversation in the window. This way we'll be setting new windows to the size of the last resized new window. */ | |
11452
7e671f619c3c
[gaim-migrate @ 13691]
Luke Schierer <lschiere@pidgin.im>
parents:
11447
diff
changeset
|
185 /* I think that the above justification is not the majority, and that the new tab resizing should negate it anyway. --luke*/ |
11338 | 186 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 187 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
188 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
189 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
190 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
191 } |
8914 | 192 if (w == gtkconv->entry) |
193 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
194 } | |
11338 | 195 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 196 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
197 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
198 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
199 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
200 } |
8914 | 201 if (w == gtkconv->entry) |
202 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
203 } | |
204 | |
205 return FALSE; | |
206 } | |
207 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
208 static void |
10810 | 209 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
210 { |
10810 | 211 GaimConversation *conv = c->active_conv; |
11508 | 212 |
10665 | 213 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
214 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
215 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
216 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
217 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
218 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
219 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
220 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
221 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
222 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
223 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
224 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline") != GTK_IMHTML(c->entry)->edit.underline) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
225 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
226 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
227 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
228 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
229 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
230 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
231 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
232 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
233 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
234 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
235 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
236 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
237 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
238 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 fg_color.blue / 256); |
8061 | 242 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
243 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
244 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
245 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
251 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 g_free(color); |
8677 | 264 |
9025 | 265 |
10665 | 266 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 267 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
268 else | |
269 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 270 } |
271 } | |
9130 | 272 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
273 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
274 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
275 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
276 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
277 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
278 |
9130 | 279 static const char * |
280 gaim_gtk_get_cmd_prefix(void) | |
281 { | |
282 return "/"; | |
283 } | |
284 | |
9167 | 285 static GaimCmdRet |
9829 | 286 say_command_cb(GaimConversation *conv, |
287 const char *cmd, char **args, char **error, void *data) | |
288 { | |
11338 | 289 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 290 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 291 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 292 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
293 | |
294 return GAIM_CMD_RET_OK; | |
295 } | |
296 | |
297 static GaimCmdRet | |
9167 | 298 me_command_cb(GaimConversation *conv, |
9597 | 299 const char *cmd, char **args, char **error, void *data) |
9167 | 300 { |
301 char *tmp; | |
302 | |
303 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 304 |
11338 | 305 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 306 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 307 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 308 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
309 | |
310 g_free(tmp); | |
311 return GAIM_CMD_RET_OK; | |
312 } | |
313 | |
9212 | 314 static GaimCmdRet |
315 debug_command_cb(GaimConversation *conv, | |
9597 | 316 const char *cmd, char **args, char **error, void *data) |
9212 | 317 { |
318 char *tmp, *markup; | |
319 GaimCmdStatus status; | |
320 | |
321 if (!g_ascii_strcasecmp(args[0], "version")) { | |
322 tmp = g_strdup_printf(_("me is using Gaim v%s."), VERSION); | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
323 markup = g_markup_escape_text(tmp, -1); |
9212 | 324 |
325 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
326 | |
327 g_free(tmp); | |
328 g_free(markup); | |
329 return status; | |
330 } else { | |
331 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
332 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
333 return GAIM_CMD_STATUS_OK; | |
334 } | |
335 } | |
336 | |
9213 | 337 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
338 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
339 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
340 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
341 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
342 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
343 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
344 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
345 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
346 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
347 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
348 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
349 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
350 static GaimCmdRet |
9213 | 351 help_command_cb(GaimConversation *conv, |
9597 | 352 const char *cmd, char **args, char **error, void *data) |
9213 | 353 { |
9597 | 354 GList *l, *text; |
9213 | 355 GString *s; |
9597 | 356 |
357 if (args[0] != NULL) { | |
358 s = g_string_new(""); | |
359 text = gaim_cmd_help(conv, args[0]); | |
360 | |
361 if (text) { | |
362 for (l = text; l; l = l->next) | |
363 if (l->next) | |
9816 | 364 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 365 else |
9816 | 366 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 367 } else { |
368 g_string_append(s, _("No such command (in this context).")); | |
369 } | |
370 } else { | |
371 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
372 "The following commands are available in this context:\n")); | |
373 | |
374 text = gaim_cmd_list(conv); | |
375 for (l = text; l; l = l->next) | |
9213 | 376 if (l->next) |
9597 | 377 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 378 else |
9597 | 379 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 380 } |
381 | |
382 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
383 g_string_free(s, TRUE); | |
384 | |
385 return GAIM_CMD_STATUS_OK; | |
386 } | |
387 | |
4359 | 388 static void |
9374 | 389 send_history_add(GaimConversation *conv, const char *message) |
390 { | |
391 GList *first; | |
392 | |
393 first = g_list_first(conv->send_history); | |
394 | |
395 if (first->data) | |
396 g_free(first->data); | |
397 | |
398 first->data = g_strdup(message); | |
399 | |
400 conv->send_history = g_list_prepend(first, NULL); | |
401 } | |
402 | |
9832 | 403 static gboolean |
404 check_for_and_do_command(GaimConversation *conv) | |
405 { | |
406 GaimGtkConversation *gtkconv; | |
407 char *cmd; | |
408 const char *prefix; | |
409 GaimAccount *account; | |
410 GtkTextIter start; | |
411 | |
412 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
413 account = gaim_conversation_get_account(conv); | |
414 prefix = gaim_gtk_get_cmd_prefix(); | |
415 | |
416 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
417 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
418 | |
419 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
420 && !gtk_text_iter_get_child_anchor(&start)) { | |
421 GaimCmdStatus status; | |
422 char *error, *cmdline, *markup, *send_history; | |
423 GtkTextIter end; | |
424 | |
425 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
426 send_history_add(conv, send_history); | |
427 g_free(send_history); | |
428 | |
429 cmdline = cmd + strlen(prefix); | |
430 | |
431 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
432 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
433 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
434 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
435 g_free(cmd); | |
436 g_free(markup); | |
437 | |
438 switch (status) { | |
439 case GAIM_CMD_STATUS_OK: | |
440 return TRUE; | |
441 case GAIM_CMD_STATUS_NOT_FOUND: | |
442 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
443 gaim_conversation_write(conv, "", _("No such command."), | |
444 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
445 | |
446 return TRUE; | |
447 } | |
448 return FALSE; | |
449 case GAIM_CMD_STATUS_WRONG_ARGS: | |
450 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
451 "to that command."), | |
452 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
453 return TRUE; | |
454 case GAIM_CMD_STATUS_FAILED: | |
455 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
456 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
457 if(error) | |
458 g_free(error); | |
459 return TRUE; | |
460 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 461 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 462 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 463 GAIM_MESSAGE_NO_LOG, time(NULL)); |
464 else | |
10843 | 465 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 466 GAIM_MESSAGE_NO_LOG, time(NULL)); |
467 return TRUE; | |
468 case GAIM_CMD_STATUS_WRONG_PRPL: | |
469 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
470 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
471 return TRUE; | |
472 } | |
473 } | |
474 | |
475 g_free(cmd); | |
476 return FALSE; | |
477 } | |
478 | |
9374 | 479 static void |
10810 | 480 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 481 { |
10810 | 482 GaimConversation *conv = gtkconv->active_conv; |
8655 | 483 GaimAccount *account; |
8677 | 484 GaimConnection *gc; |
8448 | 485 char *buf, *clean; |
4359 | 486 |
8655 | 487 account = gaim_conversation_get_account(conv); |
9130 | 488 |
9471 | 489 if (!gaim_account_is_connected(account)) |
490 return; | |
491 | |
11338 | 492 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 493 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 494 return; |
495 | |
9832 | 496 if (check_for_and_do_command(conv)) { |
497 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
498 return; | |
9130 | 499 } |
500 | |
8442 | 501 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 502 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 503 |
4359 | 504 gtk_widget_grab_focus(gtkconv->entry); |
505 | |
8448 | 506 if (strlen(clean) == 0) { |
507 g_free(clean); | |
4359 | 508 return; |
509 } | |
510 | |
8677 | 511 gc = gaim_account_get_connection(account); |
10665 | 512 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 513 char **bufs; |
514 int i; | |
515 | |
516 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
517 for (i = 0; bufs[i]; i++) { | |
9374 | 518 send_history_add(conv, bufs[i]); |
11338 | 519 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 520 gaim_conv_im_send(GAIM_CONV_IM(conv), bufs[i]); |
11338 | 521 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 522 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), bufs[i]); |
523 } | |
524 | |
525 g_strfreev(bufs); | |
526 | |
527 } else { | |
9374 | 528 send_history_add(conv, buf); |
11338 | 529 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 530 gaim_conv_im_send(GAIM_CONV_IM(conv), buf); |
11338 | 531 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 532 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), buf); |
533 } | |
4359 | 534 |
8677 | 535 g_free(clean); |
4359 | 536 g_free(buf); |
537 | |
8061 | 538 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
4359 | 539 } |
540 | |
541 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
542 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 543 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
544 GaimAccount *account; |
4359 | 545 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
546 GaimConversation *conv = gtkconv->active_conv; |
4359 | 547 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
548 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
549 name = gaim_conversation_get_name(conv); |
7879 | 550 |
11338 | 551 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 552 GaimBuddy *b; |
553 | |
554 b = gaim_find_buddy(account, name); | |
555 if (b != NULL) | |
9730 | 556 gaim_gtkdialogs_remove_buddy(b); |
7859 | 557 else if (account != NULL && gaim_account_is_connected(account)) |
558 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 559 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 560 GaimChat *c; |
561 | |
562 c = gaim_blist_find_chat(account, name); | |
563 if (c != NULL) | |
9730 | 564 gaim_gtkdialogs_remove_chat(c); |
7859 | 565 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 566 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 567 } |
4359 | 568 |
569 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
570 } | |
571 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
572 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 573 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
574 GaimConversation *conv = gtkconv->active_conv; |
7975 | 575 GaimPluginProtocolInfo *prpl_info = NULL; |
576 GaimConnection *gc; | |
577 | |
578 if ((gc = gaim_conversation_get_gc(conv))) { | |
579 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
580 | |
581 /* | |
582 * If there are special needs for getting info on users in | |
583 * buddy chat "rooms"... | |
584 */ | |
585 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
586 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
587 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
588 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
589 } |
7975 | 590 else |
591 prpl_info->get_info(gc, who); | |
592 } | |
593 } | |
594 | |
595 | |
4359 | 596 static void |
10810 | 597 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 598 { |
10810 | 599 GaimConversation *conv = gtkconv->active_conv; |
4359 | 600 |
11338 | 601 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 602 serv_get_info(gaim_conversation_get_gc(conv), |
603 gaim_conversation_get_name(conv)); | |
604 | |
605 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 606 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 607 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
608 GaimGtkChatPane *gtkchat; |
4359 | 609 GtkTreeIter iter; |
610 GtkTreeModel *model; | |
611 GtkTreeSelection *sel; | |
9554 | 612 char *name; |
4359 | 613 |
614 gtkchat = gtkconv->u.chat; | |
615 | |
616 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
617 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
618 | |
619 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 620 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 621 else |
622 return; | |
623 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
624 chat_do_info(gtkconv, name); |
9554 | 625 g_free(name); |
4359 | 626 } |
627 } | |
628 | |
629 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
630 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 631 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
632 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
633 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
634 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
635 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
636 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
637 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
638 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 639 |
640 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
641 } | |
642 | |
643 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
644 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 645 { |
646 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
647 GaimGtkConversation *gtkconv; |
4359 | 648 |
649 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
650 | |
651 if (resp == GTK_RESPONSE_OK) { | |
652 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
653 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
654 | |
10113 | 655 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 656 return; |
657 | |
658 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
659 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 660 message, buddy); |
661 } | |
662 | |
663 gtk_widget_destroy(invite_dialog); | |
664 invite_dialog = NULL; | |
665 | |
666 g_free(info); | |
667 } | |
668 | |
669 static void | |
9909 | 670 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
671 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
672 { | |
673 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
674 const char *convprotocol; | |
675 | |
676 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
677 | |
678 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
679 { | |
680 GaimBlistNode *node = NULL; | |
681 GaimBuddy *buddy; | |
682 | |
683 memcpy(&node, sd->data, sizeof(node)); | |
684 | |
685 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
686 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
687 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
688 buddy = (GaimBuddy *)node; | |
689 else | |
690 return; | |
691 | |
692 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
693 { | |
694 gaim_notify_error(NULL, NULL, | |
695 _("That buddy is not on the same protocol as this " | |
10843 | 696 "chat."), NULL); |
9909 | 697 } |
698 else | |
699 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
700 | |
701 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
702 } | |
703 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
704 { | |
705 char *protocol = NULL; | |
706 char *username = NULL; | |
707 GaimAccount *account; | |
708 | |
11137 | 709 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 710 &protocol, &username, NULL)) |
711 { | |
712 if (account == NULL) | |
713 { | |
714 gaim_notify_error(NULL, NULL, | |
715 _("You are not currently signed on with an account that " | |
716 "can invite that buddy."), NULL); | |
717 } | |
718 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
719 { | |
720 gaim_notify_error(NULL, NULL, | |
721 _("That buddy is not on the same protocol as this " | |
10843 | 722 "chat."), NULL); |
9909 | 723 } |
724 else | |
725 { | |
726 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
727 } | |
728 } | |
729 | |
730 if (username != NULL) g_free(username); | |
731 if (protocol != NULL) g_free(protocol); | |
732 | |
733 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
734 } | |
735 } | |
736 | |
737 static const GtkTargetEntry dnd_targets[] = | |
738 { | |
739 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
740 {"application/x-im-contact", 0, 1} | |
741 }; | |
742 | |
743 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
744 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 745 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
746 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
747 InviteBuddyInfo *info = NULL; |
4359 | 748 |
749 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
750 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
751 GaimGtkWindow *gtkwin; |
4359 | 752 GtkWidget *label; |
753 GtkWidget *vbox, *hbox; | |
754 GtkWidget *table; | |
755 GtkWidget *img; | |
756 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
757 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 758 GTK_ICON_SIZE_DIALOG); |
4359 | 759 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
760 info = g_new0(InviteBuddyInfo, 1); |
4359 | 761 info->conv = conv; |
762 | |
11581 | 763 gc = gaim_conversation_get_gc(conv); |
764 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 765 |
766 /* Create the new dialog. */ | |
767 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 768 _("Invite Buddy Into Chat Room"), |
7879 | 769 GTK_WINDOW(gtkwin->window), 0, |
770 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
771 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 772 |
773 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 774 GTK_RESPONSE_OK); |
11243 | 775 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 776 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
777 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
778 | |
9909 | 779 info->window = GTK_WIDGET(invite_dialog); |
780 | |
4359 | 781 /* Setup the outside spacing. */ |
782 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
783 | |
11243 | 784 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
785 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 786 |
787 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 788 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 789 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
790 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
791 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
792 | |
793 /* Setup the right vbox. */ | |
794 vbox = gtk_vbox_new(FALSE, 0); | |
795 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
796 | |
797 /* Put our happy label in it. */ | |
798 label = gtk_label_new(_("Please enter the name of the user you wish " | |
799 "to invite, along with an optional invite " | |
800 "message.")); | |
801 gtk_widget_set_size_request(label, 350, -1); | |
802 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
803 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
804 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
805 | |
806 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 807 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 808 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
809 | |
810 /* Setup the table we're going to use to lay stuff out. */ | |
811 table = gtk_table_new(2, 2, FALSE); | |
11243 | 812 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
813 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
814 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 815 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
816 | |
817 /* Now the Buddy label */ | |
818 label = gtk_label_new(NULL); | |
819 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
820 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
821 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
822 | |
823 /* Now the Buddy drop-down entry field. */ | |
824 info->entry = gtk_combo_new(); | |
825 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
826 gtk_entry_set_activates_default( | |
827 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
828 | |
829 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
830 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
831 | |
832 /* Fill in the names. */ | |
833 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
834 generate_invite_user_names(gc)); | |
835 | |
836 | |
837 /* Now the label for "Message" */ | |
838 label = gtk_label_new(NULL); | |
839 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
840 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
841 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
842 | |
843 | |
844 /* And finally, the Message entry field. */ | |
845 info->message = gtk_entry_new(); | |
846 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
847 | |
848 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
849 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
850 | |
851 /* Connect the signals. */ | |
852 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
853 G_CALLBACK(do_invite), info); | |
9909 | 854 /* Setup drag-and-drop */ |
855 gtk_drag_dest_set(info->window, | |
856 GTK_DEST_DEFAULT_MOTION | | |
857 GTK_DEST_DEFAULT_DROP, | |
858 dnd_targets, | |
859 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
860 GDK_ACTION_COPY); | |
861 gtk_drag_dest_set(info->entry, | |
862 GTK_DEST_DEFAULT_MOTION | | |
863 GTK_DEST_DEFAULT_DROP, | |
864 dnd_targets, | |
865 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
866 GDK_ACTION_COPY); | |
867 | |
868 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
869 G_CALLBACK(invite_dnd_recv), info); | |
870 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
871 G_CALLBACK(invite_dnd_recv), info); | |
872 | |
4359 | 873 } |
874 | |
875 gtk_widget_show_all(invite_dialog); | |
876 | |
877 if (info != NULL) | |
878 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
879 } | |
880 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
881 static void |
7748 | 882 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
883 { | |
9714 | 884 gaim_gtkdialogs_im(); |
7748 | 885 } |
886 | |
887 static void | |
9504 | 888 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 889 { |
9504 | 890 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 891 FILE *fp; |
892 const char *name; | |
10849 | 893 gchar *text; |
9489 | 894 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
895 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 896 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 897 return; |
898 } | |
899 | |
900 name = gaim_conversation_get_name(conv); | |
10849 | 901 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 902 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 903 |
904 text = gtk_imhtml_get_markup( | |
905 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
906 fprintf(fp, "%s", text); | |
907 g_free(text); | |
908 | |
909 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 910 fclose(fp); |
911 } | |
912 | |
10849 | 913 /* |
914 * It would be kinda cool if this gave the option of saving a | |
915 * plaintext v. HTML file. | |
916 */ | |
9489 | 917 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
918 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
919 { |
11581 | 920 GaimGtkWindow *win = data; |
921 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 922 gchar *buf; |
923 | |
924 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 925 |
10849 | 926 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
927 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 928 |
929 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
930 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
931 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
932 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
933 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
934 { |
11581 | 935 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
936 GaimConversation *conv; |
9917 | 937 GaimLogType type; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
938 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
939 GaimAccount *account; |
10845 | 940 GSList *buddies, *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
941 |
11581 | 942 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
943 |
11338 | 944 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 945 type = GAIM_LOG_IM; |
11338 | 946 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 947 type = GAIM_LOG_CHAT; |
948 else | |
949 return; | |
950 | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
951 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
952 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
953 |
10845 | 954 buddies = gaim_find_buddies(account, name); |
955 for (cur = buddies; cur != NULL; cur = cur->next) | |
956 { | |
957 GaimBlistNode *node = cur->data; | |
10846 | 958 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 959 { |
960 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
961 g_slist_free(buddies); | |
962 return; | |
963 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
964 } |
10845 | 965 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
966 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
967 gaim_gtk_log_show(type, name, account); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
968 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
969 |
8974 | 970 static void |
971 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
972 { | |
11581 | 973 GaimGtkWindow *win = data; |
8974 | 974 GaimConversation *conv; |
975 GaimGtkConversation *gtkconv; | |
976 | |
11581 | 977 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 978 gtkconv = GAIM_GTK_CONVERSATION(conv); |
979 | |
980 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
981 } | |
982 | |
7295 | 983 struct _search { |
984 GaimGtkConversation *gtkconv; | |
985 GtkWidget *entry; | |
986 }; | |
987 | |
7929 | 988 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 989 { |
7929 | 990 switch (resp) { |
991 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
992 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
993 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 994 break; |
995 | |
996 case GTK_RESPONSE_DELETE_EVENT: | |
997 case GTK_RESPONSE_CLOSE: | |
998 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
999 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1000 s->gtkconv->dialogs.search = NULL; | |
1001 g_free(s); | |
1002 break; | |
1003 } | |
7295 | 1004 } |
1005 | |
1006 static void | |
7751 | 1007 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1008 { |
11581 | 1009 GaimGtkWindow *gtkwin = data; |
1010 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1011 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1012 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1013 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1014 GTK_ICON_SIZE_DIALOG); |
7929 | 1015 GtkWidget *label; |
7295 | 1016 struct _search *s; |
1017 | |
7798 | 1018 if (gtkconv->dialogs.search) { |
1019 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1020 return; |
7798 | 1021 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1022 |
7295 | 1023 s = g_malloc(sizeof(struct _search)); |
1024 s->gtkconv = gtkconv; | |
7929 | 1025 |
1026 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1027 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1028 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1029 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1030 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1031 GTK_RESPONSE_OK); |
7929 | 1032 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1033 G_CALLBACK(do_search_cb), s); | |
1034 | |
11243 | 1035 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1036 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1037 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1038 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BORDER); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1039 gtk_container_set_border_width( |
11243 | 1040 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1041 | |
1042 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1043 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1044 hbox); |
7929 | 1045 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1046 | |
1047 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1048 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1049 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1050 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1051 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1052 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1053 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1054 | |
1055 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1056 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1057 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1058 g_signal_connect(G_OBJECT(s->entry), "changed", |
1059 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1060 gtkconv->dialogs.search); | |
1061 gtk_box_pack_start(GTK_BOX(hbox), s->entry, FALSE, FALSE, 0); | |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1062 |
7295 | 1063 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1064 gtk_widget_grab_focus(s->entry); |
7295 | 1065 } |
1066 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1067 static void |
9468 | 1068 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1069 { | |
11581 | 1070 GaimGtkWindow *win = data; |
1071 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1072 |
11338 | 1073 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1074 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1075 } | |
1076 | |
1077 } | |
1078 | |
1079 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1080 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1081 { |
11581 | 1082 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1083 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1084 |
11581 | 1085 conv = gaim_gtk_conv_window_get_active_gtkconv(win)->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1086 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1087 gaim_gtkpounce_dialog_show(gaim_conversation_get_account(conv), |
11581 | 1088 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1089 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1090 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1091 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1092 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1093 { |
11581 | 1094 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1095 GaimGtkConversation *gtkconv; |
8756 | 1096 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1097 |
11581 | 1098 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1099 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1100 | |
1101 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1102 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1103 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1104 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1105 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1106 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1107 { |
11581 | 1108 GaimGtkWindow *win = data; |
8756 | 1109 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1110 GaimGtkConversation *gtkconv; |
8756 | 1111 GtkIMHtmlToolbar *toolbar; |
1112 | |
11581 | 1113 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1114 conv = gtkconv->active_conv; | |
8756 | 1115 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1116 | |
1117 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1118 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1119 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1120 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1121 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1122 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1123 { |
11581 | 1124 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1125 GaimConversation *conv; |
7879 | 1126 GaimAccount *account; |
1127 const char *name; | |
1128 | |
11581 | 1129 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1130 account = gaim_conversation_get_account(conv); |
1131 name = gaim_conversation_get_name(conv); | |
1132 | |
11338 | 1133 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1134 GaimBuddy *b; |
1135 | |
1136 b = gaim_find_buddy(account, name); | |
1137 if (b != NULL) | |
9730 | 1138 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1139 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1140 GaimChat *c; |
1141 | |
1142 c = gaim_blist_find_chat(account, name); | |
1143 if (c != NULL) | |
9730 | 1144 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1145 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1146 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1147 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1148 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1149 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1150 { |
11581 | 1151 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1152 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 |
11581 | 1154 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 |
10810 | 1156 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1160 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 { |
11581 | 1162 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1163 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 |
11581 | 1165 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1166 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1167 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1168 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1170 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1171 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 { |
11581 | 1173 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1174 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1175 |
11581 | 1176 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1178 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1179 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1180 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1181 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1182 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 { |
11581 | 1184 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1185 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 |
11581 | 1187 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1189 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1193 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 { |
11581 | 1195 GaimGtkWindow *win = data; |
1196 | |
1197 close_conv_cb(NULL, GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1198 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1199 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1200 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1202 { |
11581 | 1203 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1204 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1205 |
11581 | 1206 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1207 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1210 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 gaim_conversation_set_logging(conv, |
11581 | 1212 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1216 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1217 { |
11581 | 1218 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1219 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1220 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1221 |
11581 | 1222 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1223 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1224 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1225 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1226 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1227 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1228 |
10377 | 1229 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1230 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1231 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1232 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1233 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1234 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1235 { |
11581 | 1236 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1239 |
11581 | 1240 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1244 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1245 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1246 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1247 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1248 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1249 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1250 |
7961 | 1251 static void |
9188 | 1252 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1253 { | |
11581 | 1254 GaimGtkWindow *win = data; |
9188 | 1255 GaimConversation *conv; |
1256 GaimGtkConversation *gtkconv; | |
1257 | |
11581 | 1258 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1259 |
1260 if (!conv) | |
1261 return; | |
1262 | |
1263 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1264 | |
1265 gtkconv->show_timestamps = | |
1266 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
1267 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
1268 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); | |
1269 } | |
1270 | |
1271 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1272 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1274 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1275 GaimAccount *account; |
1276 GaimConnection *gc; | |
7961 | 1277 GaimPluginProtocolInfo *prpl_info = NULL; |
1278 char *real_who; | |
1279 | |
1280 account = gaim_conversation_get_account(conv); | |
10431 | 1281 g_return_if_fail(account != NULL); |
1282 | |
1283 gc = gaim_account_get_connection(account); | |
1284 g_return_if_fail(gc != NULL); | |
1285 | |
1286 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1287 | |
1288 if (prpl_info && prpl_info->get_cb_real_name) | |
1289 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1290 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1291 else | |
1292 real_who = g_strdup(who); | |
1293 | |
1294 if(!real_who) | |
1295 return; | |
1296 | |
10431 | 1297 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1298 |
1299 g_free(real_who); | |
1300 } | |
1301 | |
1302 static void | |
10810 | 1303 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1304 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1305 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1306 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 GtkTreeSelection *sel; |
9554 | 1309 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1310 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1311 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1312 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1313 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1314 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1315 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1316 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1317 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1318 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1319 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1320 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1321 chat_do_im(gtkconv, name); |
9554 | 1322 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1323 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1324 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1325 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1326 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1327 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1328 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1329 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1330 GaimConvChat *chat; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1331 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1332 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1333 GtkTreeSelection *sel; |
10504 | 1334 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1335 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1336 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1337 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1338 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1339 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1343 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1344 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1345 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1346 CHAT_USERS_ALIAS_COLUMN, &alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1347 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1348 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1349 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1350 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1351 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1352 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1353 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1354 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1355 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1356 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1357 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1358 add_chat_buddy_common(conv, name, alias, NULL); |
10504 | 1359 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1360 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1361 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1363 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1364 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1365 { |
1366 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1367 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1368 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1372 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1373 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1374 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1375 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1376 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1377 | |
1378 serv_send_file(gc, who, NULL); | |
1379 } | |
1380 | |
1381 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1382 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1384 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1388 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1390 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1391 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1392 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1394 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1396 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1397 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1401 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1403 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1404 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1405 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1406 * May want to expand this to work similarly to menu_info_cb? |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1407 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1410 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1411 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1412 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1413 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1416 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1417 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1418 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1419 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1420 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1421 GaimAccount *account; |
6695 | 1422 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1425 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1426 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1427 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1429 if (b != NULL) |
9730 | 1430 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1431 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1432 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1433 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1434 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1435 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1436 |
8143 | 1437 static GtkWidget * |
10504 | 1438 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1439 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1440 { | |
1441 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1442 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1443 gboolean is_me = FALSE; |
8143 | 1444 GtkWidget *button; |
1445 | |
1446 /* | |
1447 * If a menu already exists, destroy it before creating a new one, | |
1448 * thus freeing-up the memory it occupied. | |
1449 */ | |
1450 if (menu) | |
1451 gtk_widget_destroy(menu); | |
1452 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1453 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1454 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1455 |
8143 | 1456 menu = gtk_menu_new(); |
1457 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1458 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1459 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1460 G_CALLBACK(menu_chat_im_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1461 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1462 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1463 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1464 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1465 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1466 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1467 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1468 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1469 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1470 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1471 if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), who)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1472 button = gaim_new_item_from_stock(menu, _("Un-Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1473 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1474 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1475 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1476 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1477 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1478 } |
9498 | 1479 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1480 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1481 button = gaim_new_item_from_stock(menu, _("Info"), GAIM_STOCK_INFO, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1482 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1483 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1484 } |
1485 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1486 if (prpl_info->get_cb_away) { |
10221 | 1487 button = gaim_new_item_from_stock(menu, _("Get Away Message"), GAIM_STOCK_AWAY, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1488 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1489 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1490 } |
1491 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1492 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1493 if (gaim_find_buddy(gc->account, who)) |
10221 | 1494 button = gaim_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1495 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1496 else |
10221 | 1497 button = gaim_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1498 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1499 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1500 } |
1501 | |
1502 return menu; | |
1503 } | |
1504 | |
1505 | |
1506 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1507 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1508 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1509 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1510 GaimPluginProtocolInfo *prpl_info = NULL; |
1511 GaimGtkChatPane *gtkchat; | |
1512 GaimConnection *gc; | |
1513 GaimAccount *account; | |
1514 GtkTreeSelection *sel; | |
1515 GtkTreeIter iter; | |
1516 GtkTreeModel *model; | |
1517 GtkWidget *menu; | |
1518 gchar *who; | |
1519 | |
1520 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1521 gtkchat = gtkconv->u.chat; | |
1522 account = gaim_conversation_get_account(conv); | |
1523 gc = account->gc; | |
1524 | |
1525 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1526 | |
1527 if (gc != NULL) | |
1528 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1529 | |
1530 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1531 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1532 return FALSE; | |
1533 | |
9498 | 1534 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1535 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1536 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1537 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1538 0, GDK_CURRENT_TIME); |
10504 | 1539 g_free(who); |
8143 | 1540 |
1541 return TRUE; | |
1542 } | |
1543 | |
1544 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1545 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1546 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1547 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1548 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1549 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1550 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1551 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1552 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1553 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1554 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1555 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1556 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1557 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1558 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1559 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1560 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1561 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1562 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1563 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1564 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1565 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1566 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1567 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1568 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1569 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1570 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1571 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1572 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1573 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1574 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1575 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1576 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1577 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1578 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1579 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1580 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1581 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1582 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1583 chat_do_im(gtkconv, who); |
7398 | 1584 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1585 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1586 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1587 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1588 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1589 |
10504 | 1590 g_free(who); |
1591 gtk_tree_path_free(path); | |
1592 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1593 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1594 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1595 |
8133 | 1596 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1597 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1598 { |
10827 | 1599 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1600 GaimGtkWindow *win; |
8133 | 1601 GList *l; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1602 int index, i, total, found = 0; |
8133 | 1603 |
11581 | 1604 win = gtkconv->win; |
1605 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1606 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1607 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1608 /* First check the tabs after (forward) or before (!forward) this position. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1609 for (i = index; |
11581 | 1610 !found && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1611 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1612 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1613 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1614 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1615 for (l = next_gtkconv->convs; l; l = forward ? l->next : l->prev) { |
10827 | 1616 GaimConversation *c = l->data; |
1617 if (gaim_conversation_get_unseen(c) > 0) | |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1618 { |
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1619 found = 1; |
10827 | 1620 break; |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1621 } |
10827 | 1622 } |
8133 | 1623 } |
11252 | 1624 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1625 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1626 /* Now check from the beginning up to (forward) or end back to (!forward) this position. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1627 for (i = forward ? 0 : total - 1; |
11581 | 1628 !found && (forward ? i < index : i >= 0) && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1629 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1630 for (l = next_gtkconv->convs; l; l = forward ? l->next : l->prev) { |
10827 | 1631 GaimConversation *c = l->data; |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1632 if (gaim_conversation_get_unseen(c) > 0) { |
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1633 found = 1; |
10827 | 1634 break; |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1635 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1636 } |
8133 | 1637 } |
10827 | 1638 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1639 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1640 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1641 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1642 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1643 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1644 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1645 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1646 } |
11581 | 1647 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1648 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1649 } |
8133 | 1650 } |
1651 | |
10827 | 1652 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1653 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1654 } |
1655 | |
4359 | 1656 static gboolean |
8105 | 1657 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1658 { |
11581 | 1659 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1660 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1661 GaimGtkConversation *gtkconv; |
8105 | 1662 int curconv; |
1663 | |
10810 | 1664 gtkconv = (GaimGtkConversation *)data; |
10849 | 1665 conv = gtkconv->active_conv; |
11581 | 1666 win = gtkconv->win; |
1667 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1668 |
8105 | 1669 /* If CTRL was held down... */ |
1670 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1671 switch (event->keyval) { |
1672 case GDK_Up: | |
1673 if (!conv->send_history) | |
1674 break; | |
1675 | |
1676 if (!conv->send_history->prev) { | |
1677 GtkTextIter start, end; | |
1678 | |
1679 if (conv->send_history->data) | |
1680 g_free(conv->send_history->data); | |
1681 | |
1682 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1683 &start); | |
1684 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1685 | |
1686 conv->send_history->data = | |
8506 | 1687 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1688 } |
8677 | 1689 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1690 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1691 GObject *object; |
8677 | 1692 GtkTextIter iter; |
1693 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1694 |
1695 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1696 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1697 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1698 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1699 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1700 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1701 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1702 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1703 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1704 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1705 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1706 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1707 |
8061 | 1708 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1709 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1710 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1711 0, NULL); |
8677 | 1712 /* this is mainly just a hack so the formatting at the |
1713 * cursor gets picked up. */ | |
1714 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1715 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1716 } |
1717 | |
8105 | 1718 return TRUE; |
4359 | 1719 break; |
1720 | |
1721 case GDK_Down: | |
1722 if (!conv->send_history) | |
1723 break; | |
1724 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1725 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1726 GObject *object; |
8677 | 1727 GtkTextIter iter; |
1728 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1729 |
4359 | 1730 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1731 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1732 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1733 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1734 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1735 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1736 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1737 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1738 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1739 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1740 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1741 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1742 |
8105 | 1743 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1744 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1745 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1746 0, NULL); |
8677 | 1747 /* this is mainly just a hack so the formatting at the |
1748 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1749 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1750 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1751 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1752 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1753 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1754 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1755 } |
4359 | 1756 } |
1757 | |
8105 | 1758 return TRUE; |
4359 | 1759 break; |
8105 | 1760 |
8108 | 1761 case GDK_Page_Down: |
8143 | 1762 case ']': |
11581 | 1763 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1764 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1765 else |
11581 | 1766 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1767 return TRUE; |
1768 break; | |
1769 | |
8108 | 1770 case GDK_Page_Up: |
8143 | 1771 case '[': |
11581 | 1772 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1773 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1774 else |
11581 | 1775 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1776 return TRUE; |
1777 break; | |
1778 | |
8108 | 1779 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1780 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1781 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1782 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1783 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1784 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1785 } |
8108 | 1786 |
1787 return TRUE; | |
1788 break; | |
1789 | |
11252 | 1790 case GDK_comma: |
11581 | 1791 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1792 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1793 curconv - 1); |
1794 break; | |
1795 | |
1796 case GDK_period: | |
11581 | 1797 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1798 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
1799 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); | |
11252 | 1800 break; |
1801 | |
8105 | 1802 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1803 } |
8758 | 1804 |
8105 | 1805 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1806 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1807 { |
10864 | 1808 if (event->keyval > '0' && event->keyval <= '9') |
1809 { | |
8105 | 1810 int switchto = event->keyval - '1'; |
11581 | 1811 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1812 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1813 |
1814 return TRUE; | |
1815 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1816 } |
8758 | 1817 |
8105 | 1818 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1819 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1820 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1821 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1822 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1823 case GDK_Tab: |
9605 | 1824 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1825 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1826 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1827 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1828 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1829 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1830 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1831 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1832 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1833 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1834 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1835 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1836 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1837 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1838 } |
4359 | 1839 return FALSE; |
1840 } | |
1841 | |
1842 /* | |
1843 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1844 * This guy just kills a single right click from being propagated any |
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1845 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1846 * prevents right clicks on the GtkTextView in a convo dialog from |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1847 * going all the way down to the notebook. I suspect a bug in |
4359 | 1848 * GtkTextView, but I'm not ready to point any fingers yet. |
1849 */ | |
1850 static gboolean | |
1851 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1852 { | |
1853 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1854 /* Right single click */ | |
1855 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1856 | |
1857 return TRUE; | |
1858 } | |
1859 | |
1860 return FALSE; | |
1861 } | |
1862 | |
8173 | 1863 /* |
1864 * If someone tries to type into the conversation backlog of a | |
1865 * conversation window then we yank focus from the conversation backlog | |
1866 * and give it to the text entry box so that people can type | |
1867 * all the live long day and it will get entered into the entry box. | |
1868 */ | |
6057 | 1869 static gboolean |
8105 | 1870 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1871 { |
1872 GaimGtkConversation *gtkconv = data; | |
1873 | |
8237 | 1874 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1875 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1876 (event->keyval == GDK_F10) || |
1877 (event->keyval == GDK_Shift_L) || | |
1878 (event->keyval == GDK_Shift_R) || | |
1879 (event->keyval == GDK_Escape) || | |
8177 | 1880 (event->keyval == GDK_Up) || |
1881 (event->keyval == GDK_Down) || | |
1882 (event->keyval == GDK_Left) || | |
8191 | 1883 (event->keyval == GDK_Right) || |
1884 (event->keyval == GDK_Home) || | |
9297 | 1885 (event->keyval == GDK_End) || |
1886 (event->keyval == GDK_Tab) || | |
1887 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1888 return FALSE; |
1889 | |
1890 if (event->type == GDK_KEY_RELEASE) | |
1891 gtk_widget_grab_focus(gtkconv->entry); | |
1892 | |
1893 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1894 | |
1895 return TRUE; | |
6057 | 1896 } |
1897 | |
4359 | 1898 static void |
4673 | 1899 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1900 { |
11581 | 1901 GaimGtkWindow *win = g_object_get_data(m, "user_data"); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1902 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1903 GaimConversation *conv; |
8456 | 1904 GaimGtkConversation *gtkconv; |
4359 | 1905 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1906 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1907 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1908 |
11581 | 1909 conv = gaim_gtk_conv_window_get_active_conversation(win); |
4359 | 1910 |
4491 | 1911 gaim_conversation_set_account(conv, account); |
8456 | 1912 |
1913 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1914 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), | |
10810 | 1915 gaim_account_get_protocol_name(conv->account)); |
4359 | 1916 } |
1917 | |
1918 static void | |
1919 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1920 gchar *new_text, gint new_text_length, gpointer user_data) | |
1921 { | |
10810 | 1922 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
1923 GaimConversation *conv; | |
1924 | |
1925 g_return_if_fail(gtkconv != NULL); | |
11508 | 1926 |
10810 | 1927 conv = gtkconv->active_conv; |
4359 | 1928 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1929 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1930 return; |
1931 | |
10810 | 1932 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
1933 gtk_text_iter_is_end(position))); | |
4359 | 1934 } |
1935 | |
1936 static void | |
1937 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
1938 GtkTextIter *end_pos, gpointer user_data) | |
1939 { | |
10810 | 1940 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
1941 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1942 GaimConvIm *im; |
4359 | 1943 |
10810 | 1944 g_return_if_fail(gtkconv != NULL); |
11508 | 1945 |
10810 | 1946 conv = gtkconv->active_conv; |
4359 | 1947 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1948 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1949 return; |
1950 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1951 im = GAIM_CONV_IM(conv); |
4359 | 1952 |
1953 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
1954 | |
1955 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1956 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1957 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 1958 |
1959 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 1960 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1961 GAIM_NOT_TYPING); |
4359 | 1962 } |
1963 else { | |
1964 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 1965 got_typing_keypress(gtkconv, FALSE); |
4359 | 1966 } |
1967 } | |
1968 | |
8189 | 1969 /************************************************************************** |
1970 * A bunch of buddy icon functions | |
1971 **************************************************************************/ | |
11581 | 1972 GdkPixbuf * |
1973 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 1974 { |
10116 | 1975 GaimAccount *account = NULL; |
1976 const char *name = NULL; | |
7143 | 1977 GdkPixbuf *status = NULL; |
1978 | |
10116 | 1979 g_return_val_if_fail(conv != NULL, NULL); |
1980 | |
1981 account = gaim_conversation_get_account(conv); | |
1982 name = gaim_conversation_get_name(conv); | |
1983 | |
1984 g_return_val_if_fail(account != NULL, NULL); | |
1985 g_return_val_if_fail(name != NULL, NULL); | |
1986 | |
11338 | 1987 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 1988 GaimBuddy *b = gaim_find_buddy(account, name); |
1989 if (b != NULL) { | |
1990 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
1991 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 1992 } |
1993 } | |
1994 | |
1995 if (!status) { | |
1996 GdkPixbuf *pixbuf; | |
10884 | 1997 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 1998 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
1999 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2000 { |
7143 | 2001 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2002 GDK_INTERP_BILINEAR); | |
2003 g_object_unref(pixbuf); | |
2004 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2005 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2006 status = pixbuf; |
7143 | 2007 } |
2008 return status; | |
2009 } | |
2010 | |
8189 | 2011 static void |
2012 update_tab_icon(GaimConversation *conv) | |
2013 { | |
2014 GaimGtkConversation *gtkconv; | |
11581 | 2015 GaimGtkWindow *win; |
8189 | 2016 GaimAccount *account; |
2017 const char *name; | |
2018 GdkPixbuf *status = NULL; | |
2019 | |
10116 | 2020 g_return_if_fail(conv != NULL); |
2021 | |
8189 | 2022 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2023 win = gtkconv->win; |
8189 | 2024 name = gaim_conversation_get_name(conv); |
2025 account = gaim_conversation_get_account(conv); | |
2026 | |
11581 | 2027 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2028 |
10116 | 2029 g_return_if_fail(status != NULL); |
2030 | |
8189 | 2031 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2032 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2033 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2034 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2035 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2036 |
11581 | 2037 if (gaim_gtk_conv_window_get_active_conversation(win) == conv && |
11338 | 2038 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2039 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2040 { |
11581 | 2041 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2042 | |
2043 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2044 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2045 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2046 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2047 } |
8189 | 2048 } |
2049 | |
2050 static gboolean | |
2051 redraw_icon(gpointer data) | |
2052 { | |
10810 | 2053 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2054 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2055 GaimAccount *account; |
2056 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2057 |
2058 GdkPixbuf *buf; | |
2059 GdkPixbuf *scale; | |
2060 GdkPixmap *pm; | |
2061 GdkBitmap *bm; | |
2062 gint delay; | |
9318 | 2063 int scale_width, scale_height; |
8189 | 2064 |
2065 if (!g_list_find(gaim_get_ims(), conv)) { | |
2066 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
2067 "Conversation not found in redraw_icon. I think this " | |
2068 "is a bug.\n"); | |
2069 return FALSE; | |
2070 } | |
2071 | |
2072 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2073 account = gaim_conversation_get_account(conv); |
2074 if(account && account->gc) | |
2075 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2076 |
2077 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2078 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2079 | |
10483 | 2080 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2081 NULL, &scale_width, &scale_height); |
2082 | |
2083 /* this code is ugly, and scares me */ | |
8189 | 2084 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2085 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2086 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2087 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2088 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2089 GDK_INTERP_BILINEAR); |
8189 | 2090 |
2091 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2092 g_object_unref(G_OBJECT(scale)); | |
2093 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2094 g_object_unref(G_OBJECT(pm)); | |
2095 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2096 | |
2097 if (bm) | |
2098 g_object_unref(G_OBJECT(bm)); | |
2099 | |
9131 | 2100 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2101 |
2102 if (delay < 100) | |
9131 | 2103 delay = 100; |
2104 | |
2105 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, conv); | |
8189 | 2106 |
2107 return FALSE; | |
2108 } | |
2109 | |
2110 static void | |
10810 | 2111 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2112 { |
10810 | 2113 GaimConversation *conv = gtkconv->active_conv; |
8189 | 2114 int delay; |
2115 | |
8228 | 2116 if (gtkconv->u.im->anim == NULL) |
2117 return; | |
2118 | |
8202 | 2119 if (gtkconv->u.im->icon_timer != 0) |
2120 return; | |
2121 | |
8189 | 2122 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2123 return; | |
2124 | |
10639 | 2125 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2126 | |
2127 if (delay < 100) | |
2128 delay = 100; | |
2129 | |
10810 | 2130 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, conv); |
8189 | 2131 } |
2132 | |
2133 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2134 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2135 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2136 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2137 GaimGtkWindow *gtkwin; |
2138 | |
2139 g_return_if_fail(conv != NULL); | |
2140 | |
9887 | 2141 if (gtkconv->u.im->icon_container != NULL) |
2142 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2143 |
2144 if (gtkconv->u.im->anim != NULL) | |
2145 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2146 | |
2147 if (gtkconv->u.im->icon_timer != 0) | |
2148 g_source_remove(gtkconv->u.im->icon_timer); | |
2149 | |
2150 if (gtkconv->u.im->iter != NULL) | |
2151 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2152 | |
2153 gtkconv->u.im->icon_timer = 0; | |
2154 gtkconv->u.im->icon = NULL; | |
2155 gtkconv->u.im->anim = NULL; | |
2156 gtkconv->u.im->iter = NULL; | |
10456 | 2157 gtkconv->u.im->icon_container = NULL; |
9687 | 2158 gtkconv->u.im->show_icon = FALSE; |
10456 | 2159 |
11581 | 2160 gtkwin = gtkconv->win; |
10456 | 2161 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2162 } |
2163 | |
9497 | 2164 static void |
9504 | 2165 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2166 { |
10810 | 2167 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2168 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2169 FILE *fp; |
2170 GaimBuddyIcon *icon; | |
2171 const void *data; | |
2172 size_t len; | |
2173 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2174 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2175 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2176 return; |
2177 } | |
2178 | |
2179 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2180 data = gaim_buddy_icon_get_data(icon, &len); | |
2181 | |
2182 if ((len <= 0) || (data == NULL)) { | |
9504 | 2183 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2184 return; |
2185 } | |
2186 | |
2187 fwrite(data, 1, len, fp); | |
2188 fclose(fp); | |
2189 } | |
2190 | |
2191 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2192 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2193 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2194 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2195 const gchar *ext; |
9497 | 2196 gchar *buf; |
2197 | |
2198 g_return_if_fail(conv != NULL); | |
9504 | 2199 |
10953 | 2200 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2201 if (ext == NULL) | |
2202 ext = "icon"; | |
2203 | |
2204 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2205 |
2206 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
2207 G_CALLBACK(saveicon_writefile_cb), NULL, conv); | |
9497 | 2208 |
2209 g_free(buf); | |
2210 } | |
2211 | |
11581 | 2212 static void |
2213 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2214 { | |
2215 if (gtkconv->u.im->icon_timer != 0) | |
2216 g_source_remove(gtkconv->u.im->icon_timer); | |
2217 | |
2218 gtkconv->u.im->icon_timer = 0; | |
2219 } | |
2220 | |
2221 | |
2222 static void | |
2223 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2224 { | |
2225 gtkconv->u.im->animate = | |
2226 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2227 | |
2228 if (gtkconv->u.im->animate) | |
2229 start_anim(NULL, gtkconv); | |
2230 else | |
2231 stop_anim(NULL, gtkconv); | |
2232 } | |
2233 | |
8189 | 2234 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2235 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2236 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2237 GaimConversation *conv = gtkconv->active_conv; |
8189 | 2238 static GtkWidget *menu = NULL; |
2239 GtkWidget *button; | |
2240 | |
2241 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2242 return FALSE; | |
2243 | |
2244 /* | |
2245 * If a menu already exists, destroy it before creating a new one, | |
2246 * thus freeing-up the memory it occupied. | |
2247 */ | |
2248 if (menu != NULL) | |
2249 gtk_widget_destroy(menu); | |
2250 | |
2251 menu = gtk_menu_new(); | |
2252 | |
2253 if (gtkconv->u.im->anim && | |
2254 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2255 { | |
2256 gaim_new_check_item(menu, _("Animate"), | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2257 G_CALLBACK(toggle_icon_animate_cb), conv, |
8189 | 2258 gtkconv->u.im->icon_timer); |
2259 } | |
2260 | |
2261 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2262 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2263 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2264 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2265 gtk_widget_show(button); | |
2266 | |
2267 gaim_new_item_from_stock(menu, _("Save Icon As..."), GTK_STOCK_SAVE_AS, | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2268 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2269 0, 0, NULL); |
2270 | |
2271 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2272 | |
2273 return TRUE; | |
2274 } | |
10456 | 2275 |
2276 static void | |
2277 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2278 { | |
11581 | 2279 GaimGtkWindow *win = data; |
10456 | 2280 GaimConversation *conv; |
2281 GaimGtkConversation *gtkconv; | |
2282 gboolean active; | |
2283 | |
11581 | 2284 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2285 |
2286 if (!conv) | |
2287 return; | |
2288 | |
11338 | 2289 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2290 |
2291 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2292 | |
2293 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2294 gtkconv->u.im->show_icon = active; | |
2295 if (active) | |
2296 gaim_gtkconv_update_buddy_icon(conv); | |
2297 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2298 remove_icon(gtkconv); |
10456 | 2299 } |
2300 | |
8189 | 2301 /************************************************************************** |
2302 * End of the bunch of buddy icon functions | |
2303 **************************************************************************/ | |
2304 | |
11581 | 2305 GaimGtkWindow * |
2306 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2307 { | |
2308 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2309 return gtkconv->win; | |
2310 } | |
2311 | |
2312 static GtkItemFactoryEntry menu_items[] = | |
2313 { | |
2314 /* Conversation menu */ | |
2315 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2316 | |
2317 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2318 0, "<StockItem>", GAIM_STOCK_IM }, | |
2319 | |
2320 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2321 | |
2322 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2323 "<StockItem>", GTK_STOCK_FIND }, | |
2324 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, | |
2325 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | |
2326 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
2327 { N_("/Conversation/Clear"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, | |
2328 | |
2329 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2330 | |
2331 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2332 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
2333 0, NULL }, | |
2334 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, | |
2335 "<StockItem>", GAIM_STOCK_INFO }, | |
2336 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2337 "<StockItem>", GAIM_STOCK_INVITE }, | |
2338 | |
2339 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2340 | |
2341 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2342 "<StockItem>", GAIM_STOCK_EDIT }, | |
2343 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2344 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2345 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2346 "<StockItem>", GTK_STOCK_ADD }, | |
2347 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2348 "<StockItem>", GTK_STOCK_REMOVE }, | |
2349 | |
2350 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2351 | |
2352 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2353 "<StockItem>", GAIM_STOCK_LINK }, | |
2354 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2355 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2356 | |
2357 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2358 | |
2359 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2360 "<StockItem>", GTK_STOCK_CLOSE }, | |
2361 | |
2362 /* Options */ | |
2363 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2364 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2365 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2366 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2367 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2368 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2369 }; | |
2370 | |
2371 static const int menu_item_count = | |
2372 sizeof(menu_items) / sizeof(*menu_items); | |
2373 | |
2374 static char * | |
2375 item_factory_translate_func (const char *path, gpointer func_data) | |
2376 { | |
2377 return _((char *)path); | |
2378 } | |
2379 | |
2380 static GtkWidget * | |
2381 setup_menubar(GaimGtkWindow *win) | |
2382 { | |
2383 GtkAccelGroup *accel_group; | |
2384 | |
2385 accel_group = gtk_accel_group_new (); | |
2386 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2387 g_object_unref(accel_group); | |
2388 | |
2389 win->menu.item_factory = | |
2390 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2391 | |
2392 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2393 item_factory_translate_func, | |
2394 NULL, NULL); | |
2395 | |
2396 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2397 menu_items, win); | |
2398 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2399 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2400 | |
2401 | |
2402 win->menu.menubar = | |
2403 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2404 | |
2405 | |
2406 win->menu.view_log = | |
2407 gtk_item_factory_get_widget(win->menu.item_factory, | |
2408 N_("/Conversation/View Log")); | |
2409 | |
2410 /* --- */ | |
2411 | |
2412 win->menu.send_file = | |
2413 gtk_item_factory_get_widget(win->menu.item_factory, | |
2414 N_("/Conversation/Send File...")); | |
2415 | |
2416 win->menu.add_pounce = | |
2417 gtk_item_factory_get_widget(win->menu.item_factory, | |
2418 N_("/Conversation/Add Buddy Pounce...")); | |
2419 | |
2420 /* --- */ | |
2421 | |
2422 win->menu.get_info = | |
2423 gtk_item_factory_get_widget(win->menu.item_factory, | |
2424 N_("/Conversation/Get Info")); | |
2425 | |
2426 win->menu.invite = | |
2427 gtk_item_factory_get_widget(win->menu.item_factory, | |
2428 N_("/Conversation/Invite...")); | |
2429 | |
2430 /* --- */ | |
2431 | |
2432 win->menu.alias = | |
2433 gtk_item_factory_get_widget(win->menu.item_factory, | |
2434 N_("/Conversation/Alias...")); | |
2435 | |
2436 win->menu.block = | |
2437 gtk_item_factory_get_widget(win->menu.item_factory, | |
2438 N_("/Conversation/Block...")); | |
2439 | |
2440 win->menu.add = | |
2441 gtk_item_factory_get_widget(win->menu.item_factory, | |
2442 N_("/Conversation/Add...")); | |
2443 | |
2444 win->menu.remove = | |
2445 gtk_item_factory_get_widget(win->menu.item_factory, | |
2446 N_("/Conversation/Remove...")); | |
2447 | |
2448 /* --- */ | |
2449 | |
2450 win->menu.insert_link = | |
2451 gtk_item_factory_get_widget(win->menu.item_factory, | |
2452 N_("/Conversation/Insert Link...")); | |
2453 | |
2454 win->menu.insert_image = | |
2455 gtk_item_factory_get_widget(win->menu.item_factory, | |
2456 N_("/Conversation/Insert Image...")); | |
2457 | |
2458 /* --- */ | |
2459 | |
2460 win->menu.logging = | |
2461 gtk_item_factory_get_widget(win->menu.item_factory, | |
2462 N_("/Options/Enable Logging")); | |
2463 win->menu.sounds = | |
2464 gtk_item_factory_get_widget(win->menu.item_factory, | |
2465 N_("/Options/Enable Sounds")); | |
2466 win->menu.show_formatting_toolbar = | |
2467 gtk_item_factory_get_widget(win->menu.item_factory, | |
2468 N_("/Options/Show Formatting Toolbars")); | |
2469 win->menu.show_timestamps = | |
2470 gtk_item_factory_get_widget(win->menu.item_factory, | |
2471 N_("/Options/Show Timestamps")); | |
2472 win->menu.show_icon = | |
2473 gtk_item_factory_get_widget(win->menu.item_factory, | |
2474 N_("/Options/Show Buddy Icon")); | |
2475 | |
2476 generate_send_as_items(win, NULL); | |
2477 | |
2478 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2479 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2480 win->menu.tray); | |
2481 gtk_widget_show(win->menu.tray); | |
2482 | |
2483 gtk_widget_show(win->menu.menubar); | |
2484 | |
2485 return win->menu.menubar; | |
2486 } | |
2487 | |
4359 | 2488 |
2489 /************************************************************************** | |
2490 * Utility functions | |
2491 **************************************************************************/ | |
2492 | |
2493 static void | |
10810 | 2494 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2495 { |
10810 | 2496 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2497 GaimConvIm *im; |
4685 | 2498 |
4359 | 2499 /* |
2500 * We know we got something, so we at least have to make sure we don't | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2501 * send GAIM_TYPED any time soon. |
4359 | 2502 */ |
2503 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2504 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2505 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2506 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2507 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2508 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2509 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2510 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2511 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2512 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2513 |
2514 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2515 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2516 GAIM_TYPING); |
4359 | 2517 |
2518 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2519 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2520 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2521 gaim_conv_im_set_type_again(im, 0); |
4359 | 2522 } |
2523 } | |
2524 | |
4736 | 2525 static void |
10810 | 2526 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2527 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2528 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2529 GaimConvIm *im = NULL; |
10810 | 2530 GaimConversation *conv = gtkconv->active_conv; |
11508 | 2531 |
11581 | 2532 gtkwin = gtkconv->win; |
4736 | 2533 |
11338 | 2534 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2535 im = GAIM_CONV_IM(conv); |
4736 | 2536 |
2537 if(gtkwin->menu.typing_icon) { | |
2538 gtk_widget_destroy(gtkwin->menu.typing_icon); | |
2539 gtkwin->menu.typing_icon = NULL; | |
2540 } | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2541 if(im && gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { |
10359 | 2542 gtkwin->menu.typing_icon = gtk_image_new_from_stock(GAIM_STOCK_TYPING, |
2543 GTK_ICON_SIZE_MENU); | |
4757 | 2544 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 2545 _("User is typing..."), NULL); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2546 } else if(im && gaim_conv_im_get_typing_state(im) == GAIM_TYPED) { |
10359 | 2547 gtkwin->menu.typing_icon = gtk_image_new_from_stock(GAIM_STOCK_TYPED, |
2548 GTK_ICON_SIZE_MENU); | |
4757 | 2549 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 2550 _("User has typed something and paused"), NULL); |
2551 } | |
2552 | |
2553 if(gtkwin->menu.typing_icon) { | |
10359 | 2554 gtk_widget_show(gtkwin->menu.typing_icon); |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
2555 gaim_gtk_menu_tray_append(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), |
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
2556 gtkwin->menu.typing_icon); |
4736 | 2557 } |
2558 } | |
2559 | |
4685 | 2560 static gboolean |
11581 | 2561 update_send_as_selection(GaimGtkWindow *win) |
4359 | 2562 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2563 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2564 GaimConversation *conv; |
4359 | 2565 GtkWidget *menu; |
2566 GList *child; | |
2567 | |
11581 | 2568 /* what does this do again? */ |
2569 /* | |
2570 if (g_list_find(gaim_gtk_get_windows(), win) == NULL) | |
7090
04f9f7440bc3
[gaim-migrate @ 7655]
Christian Hammond <chipx86@chipx86.com>
parents:
7089
diff
changeset
|
2571 return FALSE; |
11581 | 2572 */ |
2573 | |
2574 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2575 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2576 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2577 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2578 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2579 account = gaim_conversation_get_account(conv); |
11581 | 2580 |
2581 if (win->menu.send_as == NULL) | |
4685 | 2582 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2583 |
11581 | 2584 gtk_widget_show(win->menu.send_as); |
4359 | 2585 |
2586 menu = gtk_menu_item_get_submenu( | |
11581 | 2587 GTK_MENU_ITEM(win->menu.send_as)); |
4359 | 2588 |
2589 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2590 child != NULL; | |
2591 child = child->next) { | |
2592 | |
2593 GtkWidget *item = child->data; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2594 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), |
4673 | 2595 "gaim_account"); |
2596 | |
2597 if (account == item_account) { | |
4359 | 2598 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2599 break; | |
2600 } | |
2601 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2602 |
4685 | 2603 return FALSE; |
4359 | 2604 } |
2605 | |
2606 static void | |
11581 | 2607 generate_send_as_items(GaimGtkWindow *win, GaimConversation *deleted_conv) |
2608 { | |
4359 | 2609 GtkWidget *menu; |
2610 GtkWidget *menuitem; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2611 GList *gcs; |
4359 | 2612 GList *convs; |
2613 GSList *group = NULL; | |
2614 gboolean first_offline = TRUE; | |
2615 gboolean found_online = FALSE; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2616 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4359 | 2617 |
11581 | 2618 if (win->menu.send_as != NULL) |
2619 gtk_widget_destroy(win->menu.send_as); | |
4359 | 2620 |
2621 /* See if we have > 1 connection active. */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2622 if (g_list_length(gaim_connections_get_all()) < 2) { |
4359 | 2623 /* Now make sure we don't have any Offline entries. */ |
2624 gboolean found_offline = FALSE; | |
2625 | |
2626 for (convs = gaim_get_conversations(); | |
11581 | 2627 convs != NULL; |
2628 convs = convs->next) { | |
4359 | 2629 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2630 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2631 GaimAccount *account; |
4491 | 2632 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2633 conv = (GaimConversation *)convs->data; |
4491 | 2634 account = gaim_conversation_get_account(conv); |
2635 | |
6495
8ce66049ce68
[gaim-migrate @ 7010]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2636 if (account != NULL && account->gc == NULL) { |
4359 | 2637 found_offline = TRUE; |
2638 break; | |
2639 } | |
2640 } | |
2641 | |
2642 if (!found_offline) { | |
11581 | 2643 win->menu.send_as = NULL; |
4359 | 2644 return; |
2645 } | |
2646 } | |
2647 | |
2648 /* Build the Send As menu */ | |
11581 | 2649 win->menu.send_as = gtk_menu_item_new_with_mnemonic(_("_Send As")); |
2650 gtk_widget_show(win->menu.send_as); | |
4359 | 2651 |
2652 menu = gtk_menu_new(); | |
11581 | 2653 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
2654 win->menu.send_as, 2); | |
2655 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_as), menu); | |
4359 | 2656 |
2657 gtk_widget_show(menu); | |
2658 | |
2659 /* Fill it with entries. */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2660 for (gcs = gaim_connections_get_all(); gcs != NULL; gcs = gcs->next) { |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2661 |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2662 GaimConnection *gc; |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2663 GaimAccount *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2664 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2665 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2666 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2667 GdkPixbuf *pixbuf, *scale; |
4359 | 2668 |
2669 found_online = TRUE; | |
2670 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2671 gc = (GaimConnection *)gcs->data; |
4359 | 2672 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2673 /* Create a pixmap for the protocol icon. */ |
10884 | 2674 pixbuf = gaim_gtk_create_prpl_icon(gc->account); |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2675 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2676 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2677 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2678 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2679 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2680 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2681 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2682 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2683 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2684 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2685 g_object_unref(G_OBJECT(scale)); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2686 g_object_unref(G_OBJECT(pixbuf)); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2687 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2688 account = gaim_connection_get_account(gc); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2689 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2690 /* Make our menu item */ |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2691 menuitem = gtk_radio_menu_item_new_with_label(group, |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2692 gaim_account_get_username(account)); |
4793 | 2693 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 2694 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2695 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2696 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2697 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2698 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2699 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2700 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2701 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2702 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2703 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2704 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2705 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2706 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2707 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2708 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2709 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2710 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2711 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2712 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2713 /* Set our data and callbacks. */ |
4359 | 2714 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4673 | 2715 g_object_set_data(G_OBJECT(menuitem), "gaim_account", gc->account); |
4359 | 2716 |
4786 | 2717 g_signal_connect(G_OBJECT(menuitem), "activate", |
4673 | 2718 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4359 | 2719 |
2720 gtk_widget_show(menuitem); | |
2721 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2722 } | |
2723 | |
2724 /* | |
2725 * Fill it with any accounts that still has an open (yet disabled) window | |
2726 * (signed off accounts with a window open). | |
2727 */ | |
2728 for (convs = gaim_get_conversations(); | |
2729 convs != NULL; | |
2730 convs = convs->next) { | |
2731 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2732 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2733 GaimAccount *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2734 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2735 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2736 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2737 GdkPixbuf *pixbuf, *scale; |
4359 | 2738 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2739 conv = (GaimConversation *)convs->data; |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2740 |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2741 if (conv == deleted_conv) |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2742 continue; |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2743 |
4491 | 2744 account = gaim_conversation_get_account(conv); |
2745 | |
6495
8ce66049ce68
[gaim-migrate @ 7010]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2746 if (account != NULL && account->gc == NULL) { |
4359 | 2747 if (first_offline && found_online) { |
2748 menuitem = gtk_separator_menu_item_new(); | |
2749 gtk_widget_show(menuitem); | |
2750 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2751 | |
2752 first_offline = FALSE; | |
2753 } | |
2754 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2755 /* Create a pixmap for the protocol icon. */ |
10884 | 2756 pixbuf = gaim_gtk_create_prpl_icon(account); |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2757 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2758 GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2759 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2760 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2761 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2762 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2763 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2764 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2765 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2766 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2767 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2768 if (scale != NULL) g_object_unref(scale); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2769 if (pixbuf != NULL) g_object_unref(pixbuf); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2770 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2771 /* Make our menu item */ |
4359 | 2772 menuitem = gtk_radio_menu_item_new_with_label(group, |
4491 | 2773 account->username); |
4793 | 2774 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 2775 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2776 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2777 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2778 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2779 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2780 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2781 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2782 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2783 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2784 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2785 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2786 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2787 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2788 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2789 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2790 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2791 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2792 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2793 |
4359 | 2794 gtk_widget_set_sensitive(menuitem, FALSE); |
4786 | 2795 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4674 | 2796 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); |
4359 | 2797 |
4786 | 2798 g_signal_connect(G_OBJECT(menuitem), "activate", |
5902
6889b89cab90
[gaim-migrate @ 6334]
Christian Hammond <chipx86@chipx86.com>
parents:
5901
diff
changeset
|
2799 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4786 | 2800 |
4359 | 2801 gtk_widget_show(menuitem); |
2802 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2803 } | |
2804 } | |
2805 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2806 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2807 |
11581 | 2808 gtk_widget_show(win->menu.send_as); |
4359 | 2809 update_send_as_selection(win); |
2810 } | |
2811 | |
2812 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2813 generate_invite_user_names(GaimConnection *gc) |
4359 | 2814 { |
6695 | 2815 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2816 static GList *tmp = NULL; |
2817 | |
2818 if (tmp) | |
2819 g_list_free(tmp); | |
2820 | |
2821 tmp = g_list_append(NULL, ""); | |
2822 | |
2823 if (gc != NULL) { | |
4785 | 2824 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2825 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2826 continue; | |
6695 | 2827 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2828 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2829 continue; |
6695 | 2830 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2831 GaimBuddy *buddy; | |
2832 | |
2833 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2834 continue; | |
2835 | |
2836 buddy = (GaimBuddy *)bnode; | |
2837 | |
2838 if (buddy->account == gc->account && | |
2839 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2840 tmp = g_list_insert_sorted(tmp, buddy->name, |
2841 (GCompareFunc)g_utf8_collate); | |
6695 | 2842 } |
4359 | 2843 } |
2844 } | |
2845 } | |
2846 | |
2847 return tmp; | |
2848 } | |
2849 | |
9498 | 2850 static GdkPixbuf * |
9554 | 2851 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2852 { |
9554 | 2853 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2854 char *filename; |
10274 | 2855 const char *image = NULL; |
9554 | 2856 |
2857 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2858 image = "founder.png"; |
9554 | 2859 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2860 image = "op.png"; |
9554 | 2861 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2862 image = "halfop.png"; |
9554 | 2863 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2864 image = "voice.png"; |
9554 | 2865 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2866 image = "ignored.png"; |
2867 } else { | |
2868 return NULL; | |
9554 | 2869 } |
10274 | 2870 |
2871 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2872 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2873 g_free(filename); | |
2874 | |
2875 if (!pixbuf) | |
2876 return NULL; | |
2877 | |
2878 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2879 g_object_unref(pixbuf); | |
2880 | |
2881 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2882 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2883 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2884 g_free(filename); | |
10274 | 2885 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2886 g_object_unref(pixbuf); |
10274 | 2887 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2888 g_object_unref(scale2); | |
9498 | 2889 } |
2890 | |
10274 | 2891 return scale; |
9498 | 2892 } |
2893 | |
4359 | 2894 static void |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
2895 add_chat_buddy_common(GaimConversation *conv, const char *name, const char *alias, const char *old_name) |
4359 | 2896 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2897 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2898 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2899 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2900 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2901 GaimPluginProtocolInfo *prpl_info; |
9554 | 2902 GaimConvChatBuddyFlags flags; |
4359 | 2903 GtkListStore *ls; |
9498 | 2904 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2905 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2906 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2907 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2908 GdkColor send_color; |
11508 | 2909 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2910 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 2911 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2912 chat = GAIM_CONV_CHAT(conv); |
4359 | 2913 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2914 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2915 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2916 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2917 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2918 return; |
4359 | 2919 |
2920 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
2921 | |
9554 | 2922 flags = gaim_conv_chat_user_get_flags(chat, name); |
2923 pixbuf = get_chat_buddy_status_icon(chat, name, flags); | |
9498 | 2924 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
2925 if (!strcmp(chat->nick, gaim_normalize(conv->account, old_name != NULL ? old_name : name))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
2926 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2927 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2928 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2929 |
4359 | 2930 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2931 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2932 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2933 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2934 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2935 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2936 CHAT_USERS_COLOR_COLUMN, is_me ? &send_color : get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2937 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2938 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2939 |
9554 | 2940 if (pixbuf) |
2941 g_object_unref(pixbuf); | |
4359 | 2942 } |
2943 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2944 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2945 tab_complete_process_item(int *most_matched, char *entered, char **partial, char *nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2946 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2947 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2948 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2949 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2950 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2951 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2952 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2953 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2954 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2955 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2956 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2957 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2958 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2959 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2960 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2961 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2962 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2963 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2964 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2965 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2966 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2967 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2968 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2969 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2970 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2971 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2972 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2973 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2974 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2975 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2976 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2977 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2978 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2979 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2980 |
9605 | 2981 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2982 tab_complete(GaimConversation *conv) |
4359 | 2983 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2984 GaimGtkConversation *gtkconv; |
4359 | 2985 GtkTextIter cursor, word_start, start_buffer; |
2986 int start; | |
2987 int most_matched = -1; | |
2988 char *entered, *partial = NULL; | |
2989 char *text; | |
8021 | 2990 char *nick_partial; |
9605 | 2991 const char *prefix; |
4359 | 2992 GList *matches = NULL; |
9605 | 2993 gboolean command = FALSE; |
4359 | 2994 |
2995 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2996 | |
2997 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
2998 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2999 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3000 | |
3001 word_start = cursor; | |
3002 | |
3003 /* if there's nothing there just return */ | |
3004 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3005 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
3006 |
4359 | 3007 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3008 &cursor, FALSE); | |
3009 | |
3010 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3011 start = strlen(text) - 1; | |
3012 | |
8021 | 3013 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3014 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3015 start-=2; |
3016 } | |
4359 | 3017 |
3018 /* find the start of the word that we're tabbing */ | |
3019 while (start >= 0 && text[start] != ' ') { | |
3020 gtk_text_iter_backward_char(&word_start); | |
3021 start--; | |
3022 } | |
3023 | |
9605 | 3024 prefix = gaim_gtk_get_cmd_prefix(); |
3025 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3026 command = TRUE; | |
3027 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3028 } | |
3029 | |
4359 | 3030 g_free(text); |
3031 | |
3032 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3033 &cursor, FALSE); | |
3034 | |
8021 | 3035 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3036 g_free(entered); |
11338 | 3037 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3038 } |
3039 | |
8021 | 3040 nick_partial = g_malloc(strlen(entered)+1); |
3041 | |
9605 | 3042 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3043 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3044 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3045 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3046 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3047 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3048 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3049 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3050 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3051 g_list_free(list); |
11338 | 3052 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3053 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3054 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3055 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(GAIM_GTK_CONVERSATION(conv)->u.chat->list)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3056 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3057 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3058 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3059 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3060 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3061 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3062 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3064 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3065 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3066 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3067 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3068 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3069 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3070 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3071 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3072 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3073 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3074 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3075 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3076 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3077 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3078 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3079 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3080 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3081 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3082 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3083 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3084 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3085 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3086 } |
9605 | 3087 } else { |
3088 g_free(nick_partial); | |
3089 g_free(entered); | |
3090 return FALSE; | |
3091 } | |
3092 | |
8021 | 3093 g_free(nick_partial); |
3094 | |
4359 | 3095 /* we're only here if we're doing new style */ |
3096 | |
3097 /* if there weren't any matches, return */ | |
3098 if (!matches) { | |
3099 /* if matches isn't set partials won't be either */ | |
3100 g_free(entered); | |
11338 | 3101 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3102 } |
3103 | |
3104 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3105 | |
3106 if (!matches->next) { | |
3107 /* there was only one match. fill it in. */ | |
3108 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3109 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3110 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3111 | |
3112 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3113 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3114 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3115 g_free(tmp); | |
3116 } | |
3117 else | |
3118 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3119 matches->data, -1); | |
3120 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3121 g_free(matches->data); |
4359 | 3122 matches = g_list_remove(matches, matches->data); |
3123 } | |
3124 else { | |
3125 /* | |
3126 * there were lots of matches, fill in as much as possible | |
3127 * and display all of them | |
3128 */ | |
3129 char *addthis = g_malloc0(1); | |
3130 | |
3131 while (matches) { | |
3132 char *tmp = addthis; | |
3133 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3134 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3135 g_free(matches->data); |
4359 | 3136 matches = g_list_remove(matches, matches->data); |
3137 } | |
3138 | |
6982 | 3139 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3140 time(NULL)); |
3141 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3142 g_free(addthis); | |
3143 } | |
3144 | |
3145 g_free(entered); | |
3146 g_free(partial); | |
9605 | 3147 |
3148 return TRUE; | |
4359 | 3149 } |
3150 | |
10810 | 3151 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3152 { |
3153 GaimPluginProtocolInfo *prpl_info = NULL; | |
3154 GaimConnection *gc; | |
10810 | 3155 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3156 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3157 char *new_topic; |
8858 | 3158 const char *current_topic; |
7971 | 3159 |
3160 gc = gaim_conversation_get_gc(conv); | |
3161 | |
3162 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3163 return; | |
3164 | |
3165 if(prpl_info->set_chat_topic == NULL) | |
3166 return; | |
3167 | |
3168 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3169 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3170 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3171 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3172 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3173 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3174 g_free(new_topic); |
7971 | 3175 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3176 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3177 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3178 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3179 |
8858 | 3180 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3181 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3182 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3183 g_free(new_topic); |
7971 | 3184 } |
3185 | |
9554 | 3186 static gint |
3187 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3188 { | |
3189 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3190 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3191 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3192 gint ret = 0; |
3193 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3194 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3195 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3196 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3197 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3198 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3199 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3200 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3201 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3202 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3203 -1); |
9554 | 3204 |
3205 if (user1 == NULL || user2 == NULL) { | |
3206 if (!(user1 == NULL && user2 == NULL)) | |
3207 ret = (user1 == NULL) ? -1: 1; | |
3208 } else if (f1 != f2) { | |
3209 /* sort more important users first */ | |
3210 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3211 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3212 ret = buddy1 ? -1 : 1; |
9554 | 3213 } else { |
10904 | 3214 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3215 } |
3216 | |
3217 g_free(user1); | |
3218 g_free(user2); | |
3219 | |
3220 return ret; | |
3221 } | |
3222 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3223 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3224 update_chat_alias(GaimBuddy *buddy, GaimConversation *conv, GaimConnection *gc, GaimPluginProtocolInfo *prpl_info) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3225 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3226 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3227 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3228 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3229 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3230 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3231 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3232 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3233 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3234 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3235 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3236 /* This is safe because this callback is only used in chats, not IMs. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3237 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkconv->u.chat->list)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3238 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3239 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3240 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3241 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3242 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3243 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3244 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3245 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3246 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3247 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3248 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3249 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3250 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3251 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3252 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3253 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3254 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3255 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3256 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3257 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3258 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3259 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3260 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3261 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3262 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3263 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3264 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3265 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3266 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3267 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3268 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3269 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3270 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3271 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3272 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3273 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3274 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3275 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3276 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3277 blist_node_aliased_cb(GaimBlistNode *node, const char *old_alias, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3278 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3280 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3281 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3282 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3283 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3284 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3285 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3286 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3287 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3291 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3292 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3293 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3294 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3295 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3296 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3297 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3298 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3300 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3301 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3305 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3306 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3308 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3309 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3310 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3313 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3314 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 /* This is safe because this callback is only used in chats, not IMs. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 model = gtk_tree_view_get_model(GTK_TREE_VIEW(GAIM_GTK_CONVERSATION(conv)->u.chat->list)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3323 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3324 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3325 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3326 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3331 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 gtk_list_store_set(GTK_LIST_STORE(model), &iter, CHAT_USERS_BUDDY_COLUMN, is_buddy, -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3341 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3344 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3346 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3347 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3352 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3355 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3358 /* If there's another buddy for the same "dude" on the list, do nothing. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3360 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3361 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3362 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3363 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 |
4359 | 3365 static GtkWidget * |
10810 | 3366 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3367 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3368 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3369 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3370 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3371 GaimConnection *gc; |
4359 | 3372 GtkWidget *vpaned, *hpaned; |
10175 | 3373 GtkWidget *vbox, *hbox, *frame; |
4359 | 3374 GtkWidget *lbox, *bbox; |
3375 GtkWidget *label; | |
3376 GtkWidget *list; | |
3377 GtkWidget *button; | |
7949 | 3378 GtkWidget *sw; |
4359 | 3379 GtkListStore *ls; |
3380 GtkCellRenderer *rend; | |
3381 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3382 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3383 GList *focus_chain = NULL; |
4359 | 3384 |
3385 gtkchat = gtkconv->u.chat; | |
3386 gc = gaim_conversation_get_gc(conv); | |
3387 | |
3388 /* Setup the outer pane. */ | |
3389 vpaned = gtk_vpaned_new(); | |
3390 gtk_widget_show(vpaned); | |
3391 | |
3392 /* Setup the top part of the pane. */ | |
11243 | 3393 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3394 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3395 gtk_widget_show(vbox); |
3396 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3397 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3398 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3399 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3400 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3401 { |
11243 | 3402 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3403 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3404 gtk_widget_show(hbox); |
3405 | |
3406 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3407 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3408 gtk_widget_show(label); |
3409 | |
3410 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3411 |
7971 | 3412 if(prpl_info->set_chat_topic == NULL) { |
3413 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3414 } else { | |
3415 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3416 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3417 } |
3418 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3419 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3420 gtk_widget_show(gtkchat->topic_text); |
3421 } | |
3422 | |
3423 /* Setup the horizontal pane. */ | |
3424 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3425 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3426 gtk_widget_show(hpaned); |
3427 | |
10175 | 3428 /* Setup gtkihmtml. */ |
3429 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3430 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3431 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3432 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3433 gtk_widget_show(frame); | |
3434 | |
3435 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3436 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3437 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3438 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3439 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3440 |
4359 | 3441 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3442 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3443 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3444 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3445 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3446 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3447 |
3448 /* Build the right pane. */ | |
11243 | 3449 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3450 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3451 gtk_widget_show(lbox); |
3452 | |
3453 /* Setup the label telling how many people are in the room. */ | |
3454 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3455 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3456 gtk_widget_show(gtkchat->count); | |
3457 | |
3458 /* Setup the list of users. */ | |
7949 | 3459 sw = gtk_scrolled_window_new(NULL, NULL); |
3460 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3461 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3462 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3463 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3464 gtk_widget_show(sw); | |
4359 | 3465 |
9554 | 3466 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3467 G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_BOOLEAN); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3468 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3469 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3470 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3471 GTK_SORT_ASCENDING); |
3472 | |
3473 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3474 | |
9498 | 3475 rend = gtk_cell_renderer_pixbuf_new(); |
3476 | |
4359 | 3477 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3478 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3479 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3480 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3481 |
3482 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3483 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3484 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3485 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3486 |
9498 | 3487 rend = gtk_cell_renderer_text_new(); |
3488 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3489 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3490 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3491 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3492 NULL); |
4359 | 3493 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3494 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3495 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3496 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3497 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3498 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3499 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3500 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3501 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3502 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3503 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3504 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3505 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3506 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3507 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3508 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3509 #endif |
4359 | 3510 |
3511 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3512 | |
3513 gtk_widget_set_size_request(list, 150, -1); | |
3514 | |
3515 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3516 gtk_widget_show(list); | |
3517 | |
3518 gtkchat->list = list; | |
3519 | |
7949 | 3520 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3521 |
3522 /* Setup the user list toolbar. */ | |
11243 | 3523 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3524 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3525 gtk_widget_show(bbox); | |
3526 | |
3527 /* IM */ | |
10221 | 3528 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3529 GAIM_BUTTON_VERTICAL); |
10500 | 3530 gtkchat->userlist_im = button; |
4359 | 3531 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3532 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3533 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3534 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3535 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3536 |
3537 gtk_widget_show(button); | |
3538 | |
3539 /* Ignore */ | |
3540 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3541 GAIM_BUTTON_VERTICAL); | |
10500 | 3542 gtkchat->userlist_ignore = button; |
4359 | 3543 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3544 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3545 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3546 _("Ignore the user"), NULL); |
4359 | 3547 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3548 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3549 gtk_widget_show(button); |
3550 | |
3551 /* Info */ | |
3552 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3553 GAIM_BUTTON_VERTICAL); | |
10500 | 3554 gtkchat->userlist_info = button; |
4359 | 3555 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3556 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3557 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3558 _("Get the user's information"), NULL); |
4359 | 3559 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3560 G_CALLBACK(info_cb), gtkconv); |
4359 | 3561 |
3562 gtk_widget_show(button); | |
3563 | |
10175 | 3564 /* Setup the bottom half of the conversation window */ |
11243 | 3565 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3566 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3567 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3568 |
11243 | 3569 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3570 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3571 gtk_widget_show(gtkconv->lower_hbox); | |
3572 | |
11243 | 3573 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3574 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3575 gtk_widget_show(vbox); | |
3576 | |
10175 | 3577 /* Setup the toolbar, entry widget and all signals */ |
3578 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3579 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3580 gtk_widget_show(frame); |
3581 | |
9005 | 3582 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3583 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3584 gaim_account_get_protocol_name(conv->account)); |
10175 | 3585 gtk_widget_set_size_request(gtkconv->entry, -1, |
3586 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3587 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3588 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3589 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3590 |
3591 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3592 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3593 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3594 G_CALLBACK(send_cb), gtkconv); |
4359 | 3595 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3596 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3597 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3598 G_CALLBACK(size_allocate_cb), gtkconv); |
3599 | |
3600 default_formatize(gtkconv); | |
4359 | 3601 |
9080 | 3602 /* |
3603 * Focus for chat windows should be as follows: | |
3604 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3605 * user list buttons -> entry -> buttons at bottom | |
3606 */ | |
9332 | 3607 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3608 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3609 | |
4359 | 3610 return vpaned; |
3611 } | |
3612 | |
3613 static GtkWidget * | |
10810 | 3614 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3615 { |
10810 | 3616 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3617 GtkWidget *frame; |
4359 | 3618 GtkWidget *paned; |
10175 | 3619 GtkWidget *vbox; |
3620 GtkWidget *vbox2; | |
9080 | 3621 GList *focus_chain = NULL; |
4359 | 3622 |
10175 | 3623 /* Setup the outer pane */ |
4359 | 3624 paned = gtk_vpaned_new(); |
3625 gtk_widget_show(paned); | |
3626 | |
10175 | 3627 /* Setup the top part of the pane */ |
11243 | 3628 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3629 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3630 gtk_widget_show(vbox); |
3631 | |
10175 | 3632 /* Setup the gtkimhtml widget */ |
3633 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3634 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3635 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3636 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3637 gtk_widget_show(frame); | |
3638 | |
3639 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3640 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3641 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3642 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3643 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3644 |
3645 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3646 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3647 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3648 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3649 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3650 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3651 |
10175 | 3652 /* Setup the bottom half of the conversation window */ |
11243 | 3653 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3654 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3655 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3656 |
11243 | 3657 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3658 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3659 gtk_widget_show(gtkconv->lower_hbox); | |
3660 | |
11243 | 3661 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3662 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3663 gtk_widget_show(vbox2); | |
8821 | 3664 |
10175 | 3665 /* Setup the toolbar, entry widget and all signals */ |
3666 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3667 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3668 gtk_widget_show(frame); |
3669 | |
9005 | 3670 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3671 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3672 gaim_account_get_protocol_name(conv->account)); |
10175 | 3673 gtk_widget_set_size_request(gtkconv->entry, -1, |
3674 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3675 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3676 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3677 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3678 |
4359 | 3679 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3680 G_CALLBACK(entry_key_press_cb), gtkconv); |
3681 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3682 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3683 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3684 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3685 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3686 |
3687 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3688 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3689 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3690 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3691 |
8481 | 3692 /* had to move this after the imtoolbar is attached so that the |
3693 * signals get fired to toggle the buttons on the toolbar as well. | |
3694 */ | |
10810 | 3695 default_formatize(gtkconv); |
4359 | 3696 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3697 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3698 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3699 |
8758 | 3700 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3701 gtkconv->u.im->show_icon = TRUE; |
4359 | 3702 |
9080 | 3703 /* |
3704 * Focus for IM windows should be as follows: | |
10356 | 3705 * Tab title -> conversation scrollback -> entry |
9080 | 3706 */ |
9332 | 3707 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3708 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3709 |
4359 | 3710 return paned; |
3711 } | |
3712 | |
3713 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3714 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3715 GtkSelectionData *sd, guint info, guint t, |
3716 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3717 { |
10810 | 3718 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3719 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3720 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3721 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3722 { |
4781 | 3723 GaimBlistNode *n = NULL; |
6695 | 3724 GaimBuddy *b; |
11581 | 3725 GaimGtkConversation *gtkconv = NULL; |
9622 | 3726 |
4781 | 3727 memcpy(&n, sd->data, sizeof(n)); |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3728 |
6695 | 3729 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3730 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3731 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3732 b = (GaimBuddy*)n; | |
3733 else | |
4781 | 3734 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3735 |
9622 | 3736 /* |
3737 * If we already have an open conversation with this buddy, then | |
3738 * just move the conv to this window. Otherwise, create a new | |
3739 * conv and add it to this window. | |
3740 */ | |
11338 | 3741 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3742 if (c != NULL) { |
11581 | 3743 GaimGtkWindow *oldwin; |
3744 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3745 oldwin = gtkconv->win; | |
9622 | 3746 if (oldwin != win) { |
11581 | 3747 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3748 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3749 } |
3750 } else { | |
11338 | 3751 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3752 gtkconv = GAIM_GTK_CONVERSATION(c); |
3753 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3754 } |
3755 | |
3756 /* Make this conversation the active conversation */ | |
11581 | 3757 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3758 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3759 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3760 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3761 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3762 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3763 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3764 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3765 GaimAccount *account; |
11581 | 3766 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3767 |
11137 | 3768 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3769 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3770 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3771 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3772 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3773 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3774 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3775 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3776 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3777 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3778 { |
11338 | 3779 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3780 gtkconv = GAIM_GTK_CONVERSATION(c); |
3781 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3782 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3783 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3784 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3785 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3786 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3787 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3788 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3789 } |
9525 | 3790 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3791 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3792 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3793 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3794 } |
10145 | 3795 else |
3796 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3797 } |
4359 | 3798 |
3799 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3800 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3801 { |
10145 | 3802 GTK_IMHTML_DND_TARGETS, |
3803 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3804 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3805 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3806 |
10810 | 3807 static GaimGtkConversation * |
3808 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3809 { | |
3810 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3811 GaimContact *c; | |
3812 GaimBlistNode *cn; | |
10935 | 3813 |
10810 | 3814 if (!bud) |
3815 return NULL; | |
10935 | 3816 |
10810 | 3817 if (!(c = gaim_buddy_get_contact(bud))) |
3818 return NULL; | |
10935 | 3819 |
10810 | 3820 cn = (GaimBlistNode *)c; |
3821 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3822 GaimConversation *conv; | |
11338 | 3823 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3824 if (conv->ui_data) |
3825 return conv->ui_data; | |
3826 } | |
3827 } | |
10935 | 3828 |
10810 | 3829 return NULL; |
3830 } | |
3831 | |
11581 | 3832 /************************************************************************** |
3833 * Conversation UI operations | |
3834 **************************************************************************/ | |
3835 void | |
3836 gaim_gtkconv_new(GaimConversation *conv) | |
3837 { | |
3838 GaimGtkConversation *gtkconv; | |
3839 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3840 GtkWidget *pane = NULL; |
3841 GtkWidget *tab_cont; | |
11581 | 3842 |
3843 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3844 conv->ui_data = gtkconv; |
3845 gtkconv->active_conv = conv; | |
3846 if (!g_list_find(gtkconv->convs, conv)) | |
3847 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3848 return; | |
4359 | 3849 } |
3850 | |
11581 | 3851 gtkconv = g_new0(GaimGtkConversation, 1); |
3852 conv->ui_data = gtkconv; | |
3853 gtkconv->active_conv = conv; | |
3854 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3855 | |
3856 /* Setup some initial variables. */ | |
3857 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3858 gtkconv->tooltips = gtk_tooltips_new(); | |
3859 | |
3860 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3861 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3862 gtkconv->u.im->a_virgin = TRUE; | |
3863 | |
3864 pane = setup_im_pane(gtkconv); | |
3865 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3866 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3867 pane = setup_chat_pane(gtkconv); | |
3868 } | |
3869 | |
3870 if (pane == NULL) { | |
3871 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
3872 g_free(gtkconv->u.chat); | |
3873 else if (conv_type == GAIM_CONV_TYPE_IM) | |
3874 g_free(gtkconv->u.im); | |
3875 | |
3876 g_free(gtkconv); | |
3877 conv->ui_data = NULL; | |
3878 return; | |
10449 | 3879 } |
11581 | 3880 |
3881 /* Setup drag-and-drop */ | |
3882 gtk_drag_dest_set(pane, | |
3883 GTK_DEST_DEFAULT_MOTION | | |
3884 GTK_DEST_DEFAULT_DROP, | |
3885 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3886 GDK_ACTION_COPY); | |
3887 gtk_drag_dest_set(pane, | |
3888 GTK_DEST_DEFAULT_MOTION | | |
3889 GTK_DEST_DEFAULT_DROP, | |
3890 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3891 GDK_ACTION_COPY); | |
3892 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
3893 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3894 GDK_ACTION_COPY); | |
3895 | |
3896 gtk_drag_dest_set(gtkconv->entry, 0, | |
3897 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3898 GDK_ACTION_COPY); | |
3899 | |
3900 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
3901 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3902 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
3903 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3904 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
3905 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3906 | |
3907 /* Setup the container for the tab. */ | |
3908 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
3909 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
3910 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
3911 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
3912 gtk_widget_show(pane); | |
3913 | |
3914 gtkconv->make_sound = TRUE; | |
3915 | |
3916 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
3917 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
3918 else |
11581 | 3919 gtk_widget_hide(gtkconv->toolbar); |
3920 | |
3921 gtkconv->show_timestamps = TRUE; | |
3922 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); | |
3923 | |
3924 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
3925 G_CALLBACK(gtk_widget_grab_focus), | |
3926 gtkconv->entry); | |
3927 | |
3928 gaim_gtkconv_placement_place(gtkconv); | |
3929 } | |
3930 | |
4359 | 3931 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3932 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 3933 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3934 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 3935 |
10810 | 3936 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
3937 /* Don't destroy ourselves until all our convos are gone */ | |
3938 if (gtkconv->convs) | |
3939 return; | |
11508 | 3940 |
11581 | 3941 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
3942 | |
9504 | 3943 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
3944 gaim_request_close_with_handle(conv); | |
4359 | 3945 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3946 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 3947 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3948 |
11338 | 3949 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 3950 if (gtkconv->u.im->icon_timer != 0) |
3951 g_source_remove(gtkconv->u.im->icon_timer); | |
3952 | |
4359 | 3953 if (gtkconv->u.im->anim != NULL) |
4793 | 3954 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 3955 |
3956 g_free(gtkconv->u.im); | |
11581 | 3957 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3958 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 3959 g_free(gtkconv->u.chat); |
3960 } | |
3961 | |
4633 | 3962 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
3963 | |
4359 | 3964 g_free(gtkconv); |
3965 } | |
3966 | |
3967 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3968 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 3969 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3970 time_t mtime) |
4359 | 3971 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3972 GaimGtkConversation *gtkconv; |
4359 | 3973 |
3974 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10810 | 3975 gtkconv->active_conv = conv; |
4359 | 3976 |
3977 gtkconv->u.im->a_virgin = FALSE; | |
3978 | |
6982 | 3979 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 3980 } |
3981 | |
3982 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3983 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 3984 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 3985 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3986 GaimGtkConversation *gtkconv; |
4359 | 3987 |
3988 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10810 | 3989 gtkconv->active_conv = conv; |
4359 | 3990 |
10398 | 3991 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 3992 |
6982 | 3993 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 3994 } |
3995 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
3996 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
3997 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
3998 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
3999 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4000 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4001 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4002 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4003 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4004 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4005 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4006 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4007 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4008 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4009 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4010 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4011 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4012 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4013 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4014 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4015 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4016 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4017 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4018 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4019 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4020 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4021 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4022 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4023 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4024 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4025 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4026 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4027 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4028 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4029 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4030 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4031 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4032 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4033 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4034 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4035 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4036 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4037 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4038 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4039 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4040 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4041 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4042 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4043 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4044 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4045 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4046 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4047 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4048 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4049 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4050 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4051 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4052 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4053 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4054 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4055 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4056 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4057 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4058 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4059 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4060 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4061 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4062 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4063 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4064 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4065 buddytag = gtk_text_buffer_create_tag( |
11096 | 4066 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4067 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4068 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4069 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4070 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4071 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4072 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4073 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4074 |
4359 | 4075 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4076 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4077 const char *message, GaimMessageFlags flags, |
4359 | 4078 time_t mtime) |
4079 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4080 GaimGtkConversation *gtkconv; |
11581 | 4081 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4082 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4083 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4084 GaimPluginProtocolInfo *prpl_info; |
4359 | 4085 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4086 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4087 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4088 int line_count; |
4359 | 4089 char buf2[BUF_LONG]; |
4090 char mdate[64]; | |
4091 char color[10]; | |
4092 char *str; | |
4093 char *with_font_tag; | |
4896 | 4094 char *sml_attrib = NULL; |
6982 | 4095 size_t length = strlen(message) + 1; |
4895 | 4096 |
4359 | 4097 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4098 |
4099 /* Set the active conversation to the one that just messaged us. */ | |
4100 /* TODO: consider not doing this if the account is offline or something */ | |
10810 | 4101 gtkconv->active_conv = conv; |
11581 | 4102 |
4359 | 4103 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4104 account = gaim_conversation_get_account(conv); |
11581 | 4105 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4106 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4107 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4108 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4109 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4110 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4111 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4112 /* If we're sitting at more than 100 lines more than the |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4113 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4114 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4115 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4116 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4117 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4118 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4119 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4120 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4121 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4122 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4123 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4124 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4125 |
8677 | 4126 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4127 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4128 | |
5133 | 4129 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4130 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4131 else | |
4132 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4133 |
4896 | 4134 if(gc) |
9699 | 4135 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4136 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4137 |
10503 | 4138 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4139 |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
4140 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4141 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4142 |
7956 | 4143 /* this is gonna crash one day, I can feel it. */ |
4144 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4145 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4146 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4147 } |
4359 | 4148 |
10737 | 4149 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4150 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4151 g_snprintf(buf2, sizeof(buf2), |
8690 | 4152 "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4153 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4154 |
8962 | 4155 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4156 |
8722 | 4157 } else if (flags & GAIM_MESSAGE_ERROR) { |
4158 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4159 "<FONT COLOR=\"#ff0000\"><FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT></FONT>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4160 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4161 |
8962 | 4162 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4163 | |
7431 | 4164 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4165 g_snprintf(buf2, BUF_LONG, |
8690 | 4166 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4167 sml_attrib ? sml_attrib : "", message); |
7440 | 4168 |
10884 | 4169 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4170 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4171 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4172 } else { |
4895 | 4173 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4174 char *alias_escaped = (alias ? g_markup_escape_text(alias, strlen(alias)) : g_strdup("")); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4175 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4176 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4177 int tag_start_offset = alias ? (strlen(alias_escaped) - strlen(alias)) : 0; |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4178 int tag_end_offset = 0; |
7440 | 4179 |
6621 | 4180 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4181 str = g_malloc(1024); |
7440 | 4182 |
4359 | 4183 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4184 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4185 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4186 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4187 tag_start_offset += 3; |
4359 | 4188 } |
4189 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4190 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4191 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4192 tag_end_offset = 2; |
4359 | 4193 strcpy(color, "#00FF00"); |
4194 } | |
7440 | 4195 } |
4359 | 4196 else { |
10504 | 4197 if (gaim_message_meify(new_message, -1)) { |
4359 | 4198 str = g_malloc(1024); |
7440 | 4199 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4200 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4201 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4202 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4203 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4204 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4205 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4206 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4207 } |
7440 | 4208 |
6621 | 4209 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4210 strcpy(color, "#AF7F00"); |
4211 else | |
4212 strcpy(color, "#062585"); | |
4213 } | |
4214 else { | |
4215 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4216 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4217 g_snprintf(str, 1024, "%s %s", alias_escaped, AUTO_RESPONSE); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4218 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4219 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4220 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4221 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4222 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4223 } |
6621 | 4224 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4225 strcpy(color, "#AF7F00"); |
6621 | 4226 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4227 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4228 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4229 |
10108 | 4230 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4231 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4232 } else |
7854 | 4233 strcpy(color, RECV_COLOR); |
4359 | 4234 } |
6621 | 4235 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4236 strcpy(color, SEND_COLOR); |
10892 | 4237 else { |
4238 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4239 strcpy(color, "#000000"); | |
4240 } | |
4359 | 4241 } |
4242 } | |
10892 | 4243 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4244 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4245 g_free(alias_escaped); |
11508 | 4246 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4247 /* Are we in a chat where we can tell which users are buddies? */ |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4248 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4249 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4250 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4251 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4252 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4253 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4254 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4255 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4256 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4257 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4258 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4259 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4260 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4261 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4262 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4263 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4264 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4265 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4266 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4267 /* Bold everyone's name to make the name stand out from the message. */ |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4268 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4269 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4270 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4271 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4272 } |
7440 | 4273 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4274 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4275 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4276 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4277 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4278 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4279 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4280 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4281 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4282 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4283 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4284 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4285 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4286 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4287 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4288 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4289 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4290 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4291 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4292 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4293 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4294 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4295 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4296 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4297 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4298 |
4359 | 4299 g_free(str); |
4300 | |
4895 | 4301 if(gc){ |
4896 | 4302 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4303 char *post = "</font>"; |
4304 int pre_len = strlen(pre); | |
4305 int post_len = strlen(post); | |
7440 | 4306 |
4895 | 4307 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4308 |
4895 | 4309 strcpy(with_font_tag, pre); |
4310 memcpy(with_font_tag + pre_len, new_message, length); | |
4311 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4312 |
4895 | 4313 length += pre_len + post_len; |
4314 g_free(pre); | |
4315 } | |
4608 | 4316 else |
4895 | 4317 with_font_tag = g_memdup(new_message, length); |
7440 | 4318 |
8962 | 4319 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4320 with_font_tag, gtk_font_options); | |
7440 | 4321 |
4322 g_free(with_font_tag); | |
7447 | 4323 g_free(new_message); |
7440 | 4324 } |
4325 | |
5012 | 4326 if(sml_attrib) |
4327 g_free(sml_attrib); | |
4359 | 4328 } |
4329 | |
4330 static void | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4331 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *aliases) |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4332 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4333 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4334 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4335 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4336 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4337 GList *ll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4338 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4339 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4340 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4341 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4342 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4343 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4344 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4345 num_users = g_list_length(gaim_conv_chat_get_users(chat)); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4346 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4347 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4348 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4349 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4350 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4351 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4352 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4353 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4354 l = users; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4355 ll = aliases; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4356 while (l != NULL && ll != NULL) { |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4357 add_chat_buddy_common(conv, (const char *)l->data, (const char *)ll->data, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4358 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4359 ll = ll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4360 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4361 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4362 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4363 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4364 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name, |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4365 const char *new_name, const char *new_alias) |
4359 | 4366 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4367 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4368 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4369 GaimGtkChatPane *gtkchat; |
4359 | 4370 GtkTreeIter iter; |
4371 GtkTreeModel *model; | |
4372 int f = 1; | |
4373 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4374 chat = GAIM_CONV_CHAT(conv); |
4359 | 4375 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4376 gtkchat = gtkconv->u.chat; | |
4377 | |
9554 | 4378 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4379 | |
4380 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4381 return; | |
4382 | |
4383 while (f != 0) { | |
4384 char *val; | |
4385 | |
4386 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4387 | |
4388 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4389 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4390 g_free(val); | |
4359 | 4391 break; |
4392 } | |
9554 | 4393 |
4394 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4395 | |
4396 g_free(val); | |
4359 | 4397 } |
4398 | |
9554 | 4399 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4400 return; |
4401 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4402 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4403 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4404 add_chat_buddy_common(conv, new_name, new_alias, old_name); |
4359 | 4405 } |
4406 | |
4407 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4408 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4409 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4410 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4411 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4412 GaimGtkChatPane *gtkchat; |
4359 | 4413 GtkTreeIter iter; |
4414 GtkTreeModel *model; | |
4415 char tmp[BUF_LONG]; | |
4416 int num_users; | |
4417 int f = 1; | |
4418 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4419 chat = GAIM_CONV_CHAT(conv); |
4359 | 4420 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4421 gtkchat = gtkconv->u.chat; | |
4422 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4423 num_users = g_list_length(gaim_conv_chat_get_users(chat)) - 1; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4424 |
9554 | 4425 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4426 | |
4427 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4428 return; | |
4429 | |
4430 while (f != 0) { | |
4431 char *val; | |
4432 | |
4433 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4434 | |
4435 if (!gaim_utf8_strcasecmp(user, val)) { | |
4436 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4437 g_free(val); | |
4359 | 4438 break; |
4439 } | |
9554 | 4440 |
4441 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4442 | |
4443 g_free(val); | |
4359 | 4444 } |
4445 | |
9554 | 4446 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4447 return; |
4448 | |
4449 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4450 ngettext("%d person in room", "%d people in room", |
4451 num_users), num_users); | |
4359 | 4452 |
4453 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4454 | |
4455 } | |
4456 | |
4457 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4458 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4459 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4460 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4461 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4462 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4463 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4464 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4465 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4466 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4467 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4468 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4469 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4470 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4471 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4472 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4473 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4474 num_users = g_list_length(gaim_conv_chat_get_users(chat)) - |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4475 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4476 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4477 for (l = users; l != NULL; l = l->next) { |
9554 | 4478 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4479 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4480 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4481 continue; |
4482 | |
4483 do { | |
4484 char *val; | |
4485 | |
4486 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4487 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4488 | |
9696 | 4489 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4490 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4491 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4492 #else |
4493 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4494 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4495 #endif | |
4496 } | |
9554 | 4497 else |
4498 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4499 | |
4500 g_free(val); | |
4501 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4502 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4503 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4504 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4505 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4506 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4507 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4508 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4509 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4510 |
9554 | 4511 static void |
4512 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4513 { | |
4514 GaimConvChat *chat; | |
4515 GaimGtkConversation *gtkconv; | |
4516 GaimGtkChatPane *gtkchat; | |
4517 GtkTreeIter iter; | |
4518 GtkTreeModel *model; | |
4519 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4520 char *alias = NULL; |
9554 | 4521 |
4522 chat = GAIM_CONV_CHAT(conv); | |
4523 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4524 gtkchat = gtkconv->u.chat; | |
4525 | |
4526 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4527 | |
4528 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4529 return; | |
4530 | |
4531 while (f != 0) { | |
4532 char *val; | |
4533 | |
4534 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4535 | |
4536 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4537 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4538 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4539 g_free(val); | |
4540 break; | |
4541 } | |
4542 | |
4543 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4544 | |
4545 g_free(val); | |
4546 } | |
4547 | |
4548 if (!gaim_conv_chat_find_user(chat, user)) | |
4549 return; | |
4550 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4551 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4552 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4553 add_chat_buddy_common(conv, user, alias, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4554 g_free(alias); |
9554 | 4555 } |
4556 | |
11581 | 4557 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4558 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4559 { |
11581 | 4560 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4561 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4562 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4563 |
11581 | 4564 win = gtkconv->win; |
4565 | |
4566 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4567 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4568 return has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4569 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4570 |
10526 | 4571 static gboolean |
4572 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4573 { | |
4574 GaimGtkConversation *gtkconv; | |
4575 GtkIMHtmlSmiley *smiley; | |
4576 GdkPixbufLoader *loader; | |
11525 | 4577 struct smiley_list *list; |
4578 const char *sml = NULL, *conv_sml; | |
4579 | |
4580 if (!conv || !smile || !*smile) { | |
10526 | 4581 return FALSE; |
4582 } | |
4583 | |
11525 | 4584 /* If smileys are off, return false */ |
4585 if (gaim_gtkthemes_smileys_disabled()) | |
4586 return FALSE; | |
4587 | |
4588 /* If possible add this smiley to the current theme. | |
4589 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4590 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4591 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4592 |
4593 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4594 if (!strcmp(list->sml, conv_sml)) { | |
4595 sml = list->sml; | |
4596 break; | |
4597 } | |
4598 } | |
4599 | |
10526 | 4600 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4601 | |
4602 if (smiley) { | |
11525 | 4603 |
4604 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4605 return FALSE; | |
4606 } | |
4607 | |
4608 /* Close the old GdkPixbufAnimation, then create a new one for | |
4609 * the smiley we are about to receive */ | |
4610 g_object_unref(G_OBJECT(smiley->icon)); | |
4611 | |
4612 smiley->loader = gdk_pixbuf_loader_new(); | |
4613 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4614 if (smiley->icon) | |
4615 g_object_ref(G_OBJECT(smiley->icon)); | |
4616 | |
4617 /* A custom smiley is already associated */ | |
4618 return TRUE; | |
10526 | 4619 } |
4620 | |
4621 loader = gdk_pixbuf_loader_new(); | |
4622 | |
4623 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4624 /* Let gtk_imhtml have a gtk_imhtml_smiley_new function, and let | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4625 GtkIMHtmlSmiley by opaque */ |
10526 | 4626 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4627 smiley->file = NULL; | |
4628 smiley->smile = g_strdup(smile); | |
4629 smiley->loader = loader; | |
11525 | 4630 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4631 |
4632 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4633 if (smiley->icon) | |
4634 g_object_ref(G_OBJECT(smiley->icon)); | |
4635 | |
11525 | 4636 |
10526 | 4637 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4638 |
10526 | 4639 return TRUE; |
4640 } | |
4641 | |
10537 | 4642 static void |
10526 | 4643 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4644 const guchar *data, gsize size) |
10526 | 4645 { |
4646 GaimGtkConversation *gtkconv; | |
4647 GtkIMHtmlSmiley *smiley; | |
10537 | 4648 GdkPixbufLoader *loader; |
10526 | 4649 const char *sml; |
4650 | |
4651 sml = gaim_account_get_protocol_name(conv->account); | |
4652 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4653 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4654 | |
10537 | 4655 if (!smiley) |
10526 | 4656 return; |
10537 | 4657 |
10526 | 4658 loader = smiley->loader; |
10537 | 4659 if (!loader) |
10526 | 4660 return; |
4661 | |
4662 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4663 } | |
4664 | |
4665 static void | |
4666 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4667 { | |
4668 GaimGtkConversation *gtkconv; | |
4669 GtkIMHtmlSmiley *smiley; | |
4670 GdkPixbufLoader *loader; | |
4671 const char *sml; | |
11525 | 4672 GtkWidget *icon = NULL; |
4673 GtkTextChildAnchor *anchor = NULL; | |
4674 GtkTextIter end; | |
4675 GtkIMHtml *imhtml; | |
4676 GSList *current = NULL; | |
10526 | 4677 |
4678 g_return_if_fail(conv != NULL); | |
4679 g_return_if_fail(smile != NULL); | |
4680 | |
4681 sml = gaim_account_get_protocol_name(conv->account); | |
4682 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4683 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4684 | |
10537 | 4685 if (!smiley) |
10526 | 4686 return; |
4687 | |
4688 loader = smiley->loader; | |
4689 | |
10537 | 4690 if (!loader) |
10526 | 4691 return; |
10537 | 4692 |
11525 | 4693 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4694 if (smiley->icon) | |
4695 g_object_ref(G_OBJECT(smiley->icon)); | |
4696 | |
4697 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4698 | |
4699 icon = gtk_image_new_from_animation(smiley->icon); | |
4700 gtk_widget_show(icon); | |
4701 | |
4702 if (icon) { | |
4703 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); | |
4704 | |
4705 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4706 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4707 | |
4708 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4709 } | |
4710 | |
4711 } | |
4712 | |
4713 g_slist_free(smiley->anchors); | |
4714 smiley->anchors = NULL; | |
4715 | |
4716 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4717 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4718 * makes me question it */ | |
4719 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4720 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4721 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4722 | |
10526 | 4723 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4724 | |
4725 gdk_pixbuf_loader_close(loader, NULL); | |
4726 g_object_unref(G_OBJECT(loader)); | |
4727 smiley->loader = NULL; | |
4728 } | |
4729 | |
11581 | 4730 /* |
4731 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4732 * sensitive/insensitive. This is called after changing tabs and when an | |
4733 * account signs on or off. | |
4734 */ | |
4735 static void | |
4736 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4737 { | |
4738 GaimGtkWindow *win; | |
4739 GaimConversation *conv = gtkconv->active_conv; | |
4740 GaimConnection *gc; | |
4741 GaimPluginProtocolInfo *prpl_info = NULL; | |
4742 GdkPixbuf *window_icon = NULL; | |
4743 GtkIMHtmlButtons buttons; | |
4744 GaimAccount *account; | |
4745 | |
4746 win = gaim_gtkconv_get_window(gtkconv); | |
4747 gc = gaim_conversation_get_gc(conv); | |
4748 account = gaim_conversation_get_account(conv); | |
4749 | |
4750 if (gc != NULL) | |
4751 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4752 | |
4753 if (win->menu.send_as != NULL) | |
4754 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); | |
4755 | |
4756 /* | |
4757 * Handle hiding and showing stuff based on what type of conv this is. | |
4758 * Stuff that Gaim IMs support in general should be shown for IM | |
4759 * conversations. Stuff that Gaim chats support in general should be | |
4760 * shown for chat conversations. It doesn't matter whether the PRPL | |
4761 * supports it or not--that only affects if the button or menu item | |
4762 * is sensitive or not. | |
4763 */ | |
4764 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4765 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4766 | |
4767 /* Deal with menu items */ | |
4768 gtk_widget_show(win->menu.view_log); | |
4769 gtk_widget_show(win->menu.send_file); | |
4770 gtk_widget_show(win->menu.add_pounce); | |
4771 gtk_widget_show(win->menu.get_info); | |
4772 gtk_widget_hide(win->menu.invite); | |
4773 gtk_widget_show(win->menu.alias); | |
4774 gtk_widget_show(win->menu.block); | |
4775 | |
4776 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4777 gtk_widget_show(win->menu.add); | |
4778 gtk_widget_hide(win->menu.remove); | |
4779 } else { | |
4780 gtk_widget_show(win->menu.remove); | |
4781 gtk_widget_hide(win->menu.add); | |
4782 } | |
4783 | |
4784 gtk_widget_show(win->menu.insert_link); | |
4785 gtk_widget_show(win->menu.insert_image); | |
4786 gtk_widget_show(win->menu.show_icon); | |
4787 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4788 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4789 | |
4790 /* Deal with menu items */ | |
4791 gtk_widget_show(win->menu.view_log); | |
4792 gtk_widget_hide(win->menu.send_file); | |
4793 gtk_widget_hide(win->menu.add_pounce); | |
4794 gtk_widget_hide(win->menu.get_info); | |
4795 gtk_widget_show(win->menu.invite); | |
4796 gtk_widget_show(win->menu.alias); | |
4797 gtk_widget_hide(win->menu.block); | |
4798 gtk_widget_hide(win->menu.show_icon); | |
4799 | |
4800 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4801 /* If the chat is NOT in the buddy list */ | |
4802 gtk_widget_show(win->menu.add); | |
4803 gtk_widget_hide(win->menu.remove); | |
4804 } else { | |
4805 /* If the chat IS in the buddy list */ | |
4806 gtk_widget_hide(win->menu.add); | |
4807 gtk_widget_show(win->menu.remove); | |
4808 } | |
4809 | |
4810 gtk_widget_show(win->menu.insert_link); | |
4811 gtk_widget_hide(win->menu.insert_image); | |
4812 } | |
4813 | |
4814 /* | |
4815 * Handle graying stuff out based on whether an account is connected | |
4816 * and what features that account supports. | |
4817 */ | |
4818 if ((gc != NULL) && | |
4819 ( (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || | |
4820 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) { | |
4821 /* Account is online */ | |
4822 /* Deal with the toolbar */ | |
4823 if (conv->features & GAIM_CONNECTION_HTML) { | |
4824 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
4825 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
4826 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
4827 buttons &= ~GTK_IMHTML_IMAGE; | |
4828 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
4829 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
4830 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) { | |
4831 buttons &= ~GTK_IMHTML_GROW; | |
4832 buttons &= ~GTK_IMHTML_SHRINK; | |
4833 } | |
4834 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
4835 buttons &= ~GTK_IMHTML_LINKDESC; | |
4836 } else { | |
4837 buttons = GTK_IMHTML_SMILEY; | |
4838 } | |
4839 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
4840 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
4841 | |
4842 /* Deal with menu items */ | |
4843 gtk_widget_set_sensitive(win->menu.view_log, TRUE); | |
4844 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4845 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
4846 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
4847 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
4848 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
4849 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE)); | |
4850 | |
4851 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4852 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
4853 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
4854 gtk_widget_set_sensitive(win->menu.send_file, | |
4855 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
4856 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
4857 gtk_widget_set_sensitive(win->menu.alias, | |
4858 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
4859 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4860 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
4861 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
4862 gtk_widget_set_sensitive(win->menu.alias, | |
4863 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
4864 } | |
4865 | |
4866 /* Deal with chat userlist buttons */ | |
4867 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
4868 { | |
4869 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
4870 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
4871 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
4872 } | |
4873 } else { | |
4874 /* Account is offline */ | |
4875 /* Or it's a chat that we've left. */ | |
4876 | |
4877 /* Then deal with menu items */ | |
4878 gtk_widget_set_sensitive(win->menu.view_log, TRUE); | |
4879 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
4880 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4881 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
4882 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
4883 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
4884 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
4885 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
4886 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
4887 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
4888 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
4889 | |
4890 /* Deal with chat userlist buttons */ | |
4891 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
4892 { | |
4893 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
4894 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
4895 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
4896 } | |
4897 } | |
4898 | |
4899 /* | |
4900 * Update the window's icon | |
4901 */ | |
4902 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
4903 (gtkconv->u.im->anim)) | |
4904 { | |
4905 window_icon = | |
4906 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
4907 g_object_ref(window_icon); | |
4908 } else { | |
4909 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
4910 } | |
4911 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
4912 if (window_icon != NULL) | |
4913 g_object_unref(G_OBJECT(window_icon)); | |
4914 } | |
4915 | |
10526 | 4916 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4917 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4918 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 4919 { |
11581 | 4920 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4921 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4922 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4923 GaimConvChat *chat; |
4359 | 4924 |
10116 | 4925 g_return_if_fail(conv != NULL); |
4926 | |
4359 | 4927 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4928 win = gtkconv->win; |
10810 | 4929 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 4930 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
4931 * instead of the gross hack? | |
4932 */ | |
4359 | 4933 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4934 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4935 { |
4359 | 4936 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
4937 |
11338 | 4938 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
4939 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
4940 |
4359 | 4941 gaim_gtkconv_update_buttons_by_protocol(conv); |
4942 | |
4685 | 4943 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 4944 |
11525 | 4945 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 4946 |
6395 | 4947 update_tab_icon(conv); |
4359 | 4948 } |
4949 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
4950 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
4951 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4952 { |
9472 | 4953 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4954 GaimConvIm *im = NULL; |
9472 | 4955 GaimConnection *gc = gaim_conversation_get_gc(conv); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4956 char color[8]; |
4736 | 4957 |
11338 | 4958 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4959 im = GAIM_CONV_IM(conv); |
4359 | 4960 |
11338 | 4961 if (!gc || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 4962 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
4963 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
4964 | |
4965 else | |
4966 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4967 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4968 *color = '\0'; |
4359 | 4969 |
4970 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
4971 gtk_widget_realize(gtkconv->tab_label); | |
4972 | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4973 if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4974 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4975 strcpy(color, "#47A046"); |
4359 | 4976 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4977 else if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4978 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4979 strcpy(color, "#D1940C"); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4980 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4981 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4982 { |
10873 | 4983 strcpy(color, "#0D4E91"); |
4359 | 4984 } |
8252 | 4985 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) |
4986 { | |
4987 strcpy(color, "#DF421E"); | |
4988 } | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4989 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_EVENT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4990 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4991 strcpy(color, "#868272"); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4992 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4993 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4994 if (*color != '\0') |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4995 { |
8536 | 4996 char *html_title,*label; |
4997 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
4998 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
4999 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5000 label = g_strdup_printf("<span color=\"%s\">%s</span>", |
8536 | 5001 color, html_title); |
5002 g_free(html_title); | |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5003 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5004 g_free(label); |
4359 | 5005 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5006 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5007 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5008 |
11581 | 5009 if (conv == gaim_gtk_conv_window_get_active_conversation(win)) |
10810 | 5010 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5011 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5012 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5013 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
11581 | 5014 if (conv == gaim_gtk_conv_window_get_active_conversation(win)) |
5015 gtk_window_set_title(GTK_WINDOW(win->window), title); | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5016 } |
9472 | 5017 |
5018 g_free(title); | |
4359 | 5019 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5020 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5021 { |
7154 | 5022 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5023 chat = GAIM_CONV_CHAT(conv); |
4359 | 5024 gtkchat = gtkconv->u.chat; |
5025 | |
7154 | 5026 topic = gaim_conv_chat_get_topic(chat); |
5027 | |
9554 | 5028 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5029 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5030 topic ? topic : "", NULL); |
4359 | 5031 } |
5032 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5033 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5034 { |
11581 | 5035 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
5036 generate_send_as_items(win, NULL); |
8946 | 5037 update_tab_icon(conv); |
9472 | 5038 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5039 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5040 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5041 { |
8946 | 5042 update_tab_icon(conv); |
4359 | 5043 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5044 else if (type == GAIM_CONV_UPDATE_ADD || type == GAIM_CONV_UPDATE_REMOVE || |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5045 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5046 { |
9472 | 5047 gaim_conversation_autoset_title(conv); |
10810 | 5048 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5049 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5050 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5051 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5052 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5053 } |
10665 | 5054 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5055 { | |
10810 | 5056 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5057 } |
4359 | 5058 } |
5059 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5060 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5061 { |
11581 | 5062 gaim_gtkconv_new, |
4359 | 5063 gaim_gtkconv_destroy, /* destroy_conversation */ |
5064 gaim_gtkconv_write_chat, /* write_chat */ | |
5065 gaim_gtkconv_write_im, /* write_im */ | |
5066 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5067 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5068 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5069 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5070 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5071 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5072 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5073 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5074 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5075 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5076 gaim_gtkconv_updated /* updated */ |
5077 }; | |
5078 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5079 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5080 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5081 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5082 return &conversation_ui_ops; |
4359 | 5083 } |
5084 | |
5085 /************************************************************************** | |
5086 * Public conversation utility functions | |
5087 **************************************************************************/ | |
5088 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5089 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5090 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5091 GaimGtkConversation *gtkconv; |
11581 | 5092 GaimGtkWindow *win; |
4359 | 5093 |
10381 | 5094 GdkPixbufLoader *loader; |
5095 GdkPixbufAnimation *anim; | |
4359 | 5096 GError *err = NULL; |
5097 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5098 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5099 size_t len; |
4359 | 5100 |
5101 GdkPixbuf *buf; | |
5102 | |
5103 GtkWidget *event; | |
5104 GtkWidget *frame; | |
5105 GdkPixbuf *scale; | |
5106 GdkPixmap *pm; | |
5107 GdkBitmap *bm; | |
9318 | 5108 int scale_width, scale_height; |
5109 | |
5110 GaimAccount *account; | |
5111 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5112 |
9324 | 5113 GaimBuddyIcon *icon; |
5114 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5115 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5116 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5117 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5118 |
5119 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5120 win = gtkconv->win; |
10175 | 5121 |
9687 | 5122 if (!gtkconv->u.im->show_icon) |
5123 return; | |
5124 | |
9318 | 5125 account = gaim_conversation_get_account(conv); |
5126 if(account && account->gc) | |
5127 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5128 |
9845 | 5129 /* Remove the current icon stuff */ |
9885 | 5130 if (gtkconv->u.im->icon_container != NULL) |
5131 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5132 gtkconv->u.im->icon_container = NULL; | |
9845 | 5133 |
5134 if (gtkconv->u.im->anim != NULL) | |
5135 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5136 | |
9887 | 5137 gtkconv->u.im->anim = NULL; |
5138 | |
9845 | 5139 if (gtkconv->u.im->icon_timer != 0) |
5140 g_source_remove(gtkconv->u.im->icon_timer); | |
5141 | |
5142 gtkconv->u.im->icon_timer = 0; | |
5143 | |
5144 if (gtkconv->u.im->iter != NULL) | |
5145 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5146 |
10116 | 5147 gtkconv->u.im->iter = NULL; |
5148 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5149 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5150 return; |
5151 | |
5152 if (gaim_conversation_get_gc(conv) == NULL) | |
5153 return; | |
5154 | |
9324 | 5155 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5156 | |
5157 if (icon == NULL) | |
5158 return; | |
5159 | |
5160 data = gaim_buddy_icon_get_data(icon, &len); | |
5161 | |
10381 | 5162 loader = gdk_pixbuf_loader_new(); |
5163 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5164 anim = gdk_pixbuf_loader_get_animation(loader); | |
5165 if (anim) | |
5166 g_object_ref(G_OBJECT(anim)); | |
5167 gdk_pixbuf_loader_close(loader, &err); | |
5168 g_object_unref(loader); | |
5169 | |
5170 if (!anim) | |
9324 | 5171 return; |
10381 | 5172 gtkconv->u.im->anim = anim; |
9324 | 5173 |
4359 | 5174 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5175 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5176 "Buddy icon error: %s\n", err->message); |
4359 | 5177 g_error_free(err); |
5178 } | |
5179 | |
5180 if (!gtkconv->u.im->anim) | |
5181 return; | |
5182 | |
5183 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5184 gtkconv->u.im->iter = NULL; | |
5185 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5186 } else { | |
5187 gtkconv->u.im->iter = | |
8496 | 5188 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5189 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5190 if (gtkconv->u.im->animate) |
10810 | 5191 start_anim(NULL, gtkconv); |
4359 | 5192 } |
5193 | |
10483 | 5194 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5195 NULL, &scale_width, &scale_height); |
4359 | 5196 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5197 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5198 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5199 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5200 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5201 GDK_INTERP_BILINEAR); |
4359 | 5202 |
5203 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5204 g_object_unref(G_OBJECT(scale)); |
4359 | 5205 |
8821 | 5206 |
9885 | 5207 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5208 |
4359 | 5209 frame = gtk_frame_new(NULL); |
5210 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5211 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5212 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5213 FALSE, FALSE, 0); | |
8821 | 5214 |
4359 | 5215 event = gtk_event_box_new(); |
5216 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5217 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5218 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5219 gtk_widget_show(event); |
5220 | |
4635 | 5221 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5222 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5223 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5224 gtk_widget_show(gtkconv->u.im->icon); | |
5225 | |
4793 | 5226 g_object_unref(G_OBJECT(pm)); |
4359 | 5227 |
5228 if (bm) | |
4793 | 5229 g_object_unref(G_OBJECT(bm)); |
7143 | 5230 |
10356 | 5231 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5232 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5233 |
9885 | 5234 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5235 gtk_widget_show(frame); |
5236 | |
7143 | 5237 /* The buddy icon code needs badly to be fixed. */ |
5238 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
11581 | 5239 if(conv == gaim_gtk_conv_window_get_active_conversation(gtkconv->win)) |
5240 gtk_window_set_icon(GTK_WINDOW(win->window), buf); | |
4359 | 5241 } |
5242 | |
5243 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5244 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5245 { |
11581 | 5246 GaimGtkWindow *win; |
4359 | 5247 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5248 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5249 return; |
5250 | |
11581 | 5251 win = GAIM_GTK_CONVERSATION(conv)->win; |
5252 | |
5253 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5254 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5255 } |
5256 | |
5257 int | |
11581 | 5258 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y) |
5259 { | |
4359 | 5260 gint nb_x, nb_y, x_rel, y_rel; |
5261 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5262 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5263 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5264 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5265 gboolean horiz; |
4359 | 5266 |
11581 | 5267 notebook = GTK_NOTEBOOK(win->notebook); |
5268 | |
5269 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5270 x_rel = x - nb_x; |
5271 y_rel = y - nb_y; | |
5272 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5273 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5274 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5275 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5276 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5277 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5278 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5279 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5280 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5281 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5282 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5283 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5284 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5285 x_rel <= tab->allocation.x + tab->allocation.width + GAIM_HIG_BOX_SPACE) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5286 page_num = i; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5287 break; |
4359 | 5288 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5289 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5290 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5291 y_rel <= tab->allocation.y + tab->allocation.height + GAIM_HIG_BOX_SPACE) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5292 page_num = i; |
4359 | 5293 break; |
5294 } | |
5295 } | |
5296 } | |
5297 | |
5298 return page_num; | |
5299 } | |
5300 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5301 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5302 close_on_tabs_pref_cb(const char *name, GaimPrefType type, gpointer value, |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5303 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5304 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5305 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5306 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5307 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5308 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5309 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5310 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5311 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5312 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5313 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5314 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5315 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5316 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5317 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5318 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5319 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5320 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5321 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5322 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5323 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5324 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5325 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5326 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5327 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5328 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5329 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5330 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5331 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5332 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5333 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5334 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5335 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5336 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5337 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5338 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5339 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5340 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5341 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5342 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5343 if (value) |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
5344 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5345 else { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5346 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5347 gtkspell_detach(spell); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5348 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5349 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5350 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5351 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5352 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5353 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5354 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5355 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5356 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5357 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5358 GtkPositionType pos; |
11581 | 5359 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5360 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5361 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5362 |
11581 | 5363 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5364 win = l->data; | |
5365 | |
5366 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5367 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5368 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5369 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5370 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5371 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5372 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5373 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5374 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5375 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5376 GaimGtkConversation *gtkconv; |
11581 | 5377 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5378 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5379 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5380 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5381 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5382 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5383 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5384 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5385 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5386 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5387 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5388 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5389 gtk_check_menu_item_set_active( |
11581 | 5390 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5391 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5392 |
5393 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5394 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5395 else |
8317 | 5396 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5397 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5398 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5399 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5400 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5401 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5402 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5403 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5404 GList *l; |
8189 | 5405 GaimConversation *conv; |
5406 GaimGtkConversation *gtkconv; | |
11581 | 5407 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5408 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5409 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5410 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5411 |
8189 | 5412 /* Set the "animate" flag for each icon based on the new preference */ |
5413 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5414 conv = (GaimConversation *)l->data; | |
5415 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5416 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5417 } |
8189 | 5418 |
5419 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5420 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5421 win = l->data; | |
5422 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5423 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5424 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5425 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5426 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5427 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5428 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5429 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5430 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5431 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5432 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5433 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5434 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5435 |
11338 | 5436 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5437 gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5438 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5439 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5440 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5441 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5442 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5443 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5444 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5445 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5446 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5447 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5448 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5449 |
11581 | 5450 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5451 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5452 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5453 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5454 |
11581 | 5455 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5456 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5457 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5458 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5459 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5460 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5461 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5462 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5463 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5464 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5465 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5466 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5467 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5468 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5469 void *handle = gaim_gtk_conversations_get_handle(); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5470 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5471 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5472 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5473 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5474 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5475 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5476 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5477 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5478 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5479 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5480 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5481 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5482 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5483 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5484 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5485 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5486 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5487 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5488 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5489 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5490 gaim_prefs_add_int("/gaim/gtk/conversations/tab_side", GTK_POS_TOP); |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
5491 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5492 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5493 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5494 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5495 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5496 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5497 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5498 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5499 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5500 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5501 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5502 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5503 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5504 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5505 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5506 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5507 gaim_prefs_add_bool("/gaim/gtk/conversations/im/show_buddy_icons", TRUE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5508 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5509 /* Connect callbacks. */ |
10087 | 5510 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/close_on_tabs", |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5511 close_on_tabs_pref_cb, NULL); |
10087 | 5512 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_formatting_toolbar", |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5513 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5514 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5515 spellcheck_pref_cb, NULL); |
10087 | 5516 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5517 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5518 |
10087 | 5519 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5520 conv_placement_pref_cb, NULL); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5521 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5522 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5523 /* IM callbacks */ |
10087 | 5524 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/animate_buddy_icons", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5525 animate_buddy_icons_pref_cb, NULL); |
10087 | 5526 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/show_buddy_icons", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5527 show_buddy_icons_pref_cb, NULL); |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5528 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5529 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5530 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5531 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5532 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5533 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5534 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5535 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5536 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5537 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5538 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5539 |
5540 /********************************************************************** | |
5541 * Register commands | |
5542 **********************************************************************/ | |
9829 | 5543 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5544 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5545 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5546 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5547 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5548 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5549 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5550 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5551 debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5552 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5553 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5554 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5555 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5556 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5557 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5558 |
5559 gaim_conversations_set_ui_ops(&conversation_ui_ops); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5560 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5561 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5562 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5563 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5564 { |
10443 | 5565 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5566 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5567 } |
11581 | 5568 |
5569 | |
5570 | |
5571 | |
5572 | |
5573 | |
5574 | |
5575 | |
5576 | |
5577 | |
5578 | |
5579 | |
5580 | |
5581 | |
5582 | |
5583 | |
5584 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5585 * and touch each others' private members all day long */ | |
5586 | |
5587 /** | |
5588 * @file gtkconvwin.c GTK+ Conversation Window API | |
5589 * @ingroup gtkui | |
5590 * | |
5591 * gaim | |
5592 * | |
5593 * Gaim is the legal property of its developers, whose names are too numerous | |
5594 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5595 * source distribution. | |
5596 * | |
5597 * This program is free software; you can redistribute it and/or modify | |
5598 * it under the terms of the GNU General Public License as published by | |
5599 * the Free Software Foundation; either version 2 of the License, or | |
5600 * (at your option) any later version. | |
5601 * | |
5602 * This program is distributed in the hope that it will be useful, | |
5603 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
5604 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
5605 * GNU General Public License for more details. | |
5606 * | |
5607 * You should have received a copy of the GNU General Public License | |
5608 * along with this program; if not, write to the Free Software | |
5609 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5610 * | |
5611 */ | |
5612 #include "internal.h" | |
5613 #include "gtkgaim.h" | |
5614 | |
5615 | |
5616 #include <gdk/gdkkeysyms.h> | |
5617 | |
5618 #include "account.h" | |
5619 #include "cmds.h" | |
5620 #include "debug.h" | |
5621 #include "imgstore.h" | |
5622 #include "log.h" | |
5623 #include "notify.h" | |
5624 #include "prpl.h" | |
5625 #include "request.h" | |
5626 #include "util.h" | |
5627 | |
5628 #include "gtkdnd-hints.h" | |
5629 #include "gtkblist.h" | |
5630 #include "gtkconv.h" | |
5631 #include "gtkdialogs.h" | |
5632 #include "gtkmenutray.h" | |
5633 #include "gtkpounce.h" | |
5634 #include "gtkprefs.h" | |
5635 #include "gtkprivacy.h" | |
5636 #include "gtkutils.h" | |
5637 #include "gtkstock.h" | |
5638 #include "gtkimhtml.h" | |
5639 #include "gtkimhtmltoolbar.h" | |
5640 | |
5641 | |
5642 | |
5643 | |
5644 | |
5645 static void | |
5646 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
5647 { | |
5648 gtk_widget_destroy(warn_close_dialog); | |
5649 warn_close_dialog = NULL; | |
5650 | |
5651 if (resp == GTK_RESPONSE_OK) | |
5652 gaim_gtk_conv_window_destroy(win); | |
5653 } | |
5654 | |
5655 static void | |
5656 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
5657 { | |
5658 GtkWidget *label; | |
5659 GtkWidget *vbox, *hbox; | |
5660 GtkWidget *img; | |
5661 | |
5662 g_return_if_fail(warn_close_dialog == NULL); | |
5663 | |
5664 | |
5665 warn_close_dialog = gtk_dialog_new_with_buttons( | |
5666 _("Confirm close"), | |
5667 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
5668 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
5669 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
5670 | |
5671 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
5672 GTK_RESPONSE_OK); | |
5673 | |
5674 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
5675 6); | |
5676 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
5677 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
5678 FALSE); | |
5679 | |
5680 /* Setup the outside spacing. */ | |
5681 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
5682 | |
5683 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
5684 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
5685 | |
5686 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
5687 GTK_ICON_SIZE_DIALOG); | |
5688 /* Setup the inner hbox and put the dialog's icon in it. */ | |
5689 hbox = gtk_hbox_new(FALSE, 12); | |
5690 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
5691 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
5692 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
5693 | |
5694 /* Setup the right vbox. */ | |
5695 vbox = gtk_vbox_new(FALSE, 12); | |
5696 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
5697 | |
5698 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
5699 gtk_widget_set_size_request(label, 350, -1); | |
5700 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
5701 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
5702 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
5703 | |
5704 /* Connect the signals. */ | |
5705 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
5706 G_CALLBACK(do_close), gtkwin); | |
5707 | |
5708 } | |
5709 | |
5710 /************************************************************************** | |
5711 * Callbacks | |
5712 **************************************************************************/ | |
5713 | |
5714 static gboolean | |
5715 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
5716 { | |
5717 GaimGtkWindow *win = d; | |
5718 GList *l, *j; | |
5719 | |
5720 /* If there are unread messages then show a warning dialog */ | |
5721 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
5722 l != NULL; l = l->next) | |
5723 { | |
5724 GaimGtkConversation *gtkconv = l->data; | |
5725 | |
5726 for (j = gtkconv->convs; j != NULL; j = j->next) { | |
5727 GaimConversation *conv = j->data; | |
5728 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && | |
5729 gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) | |
5730 { | |
5731 build_warn_close_dialog(win); | |
5732 gtk_widget_show_all(warn_close_dialog); | |
5733 | |
5734 return TRUE; | |
5735 } | |
5736 } | |
5737 } | |
5738 | |
5739 gaim_gtk_conv_window_destroy(win); | |
5740 | |
5741 return TRUE; | |
5742 } | |
5743 | |
5744 /* | |
5745 * When a conversation window is focused, we know the user | |
5746 * has looked at it so we know there are no longer unseen | |
5747 * messages. | |
5748 */ | |
5749 static gint | |
5750 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
5751 { | |
5752 GaimGtkWindow *win = d; | |
5753 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
5754 | |
5755 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); | |
5756 | |
5757 return FALSE; | |
5758 } | |
5759 | |
5760 /* Courtesy of Galeon! */ | |
5761 static void | |
5762 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
5763 { | |
5764 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
5765 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
5766 } | |
5767 | |
5768 | |
5769 | |
5770 | |
5771 static void | |
5772 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
5773 { | |
5774 static GdkCursor *cursor = NULL; | |
5775 | |
5776 gtkwin->in_drag = TRUE; | |
5777 | |
5778 if (gtkwin->drag_leave_signal) { | |
5779 g_signal_handler_disconnect(G_OBJECT(widget), | |
5780 gtkwin->drag_leave_signal); | |
5781 gtkwin->drag_leave_signal = 0; | |
5782 } | |
5783 | |
5784 if (cursor == NULL) | |
5785 cursor = gdk_cursor_new(GDK_FLEUR); | |
5786 | |
5787 /* Grab the pointer */ | |
5788 gtk_grab_add(gtkwin->notebook); | |
5789 #ifndef _WIN32 | |
5790 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
5791 always be true after a button press. */ | |
5792 if (!gdk_pointer_is_grabbed()) | |
5793 #endif | |
5794 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
5795 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
5796 NULL, cursor, GDK_CURRENT_TIME); | |
5797 } | |
5798 | |
5799 static gboolean | |
5800 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
5801 { | |
5802 | |
5803 /* | |
5804 * Make sure the user moved the mouse far enough for the | |
5805 * drag to be initiated. | |
5806 */ | |
5807 if (win->in_predrag) { | |
5808 if (e->x_root < win->drag_min_x || | |
5809 e->x_root >= win->drag_max_x || | |
5810 e->y_root < win->drag_min_y || | |
5811 e->y_root >= win->drag_max_y) { | |
5812 | |
5813 win->in_predrag = FALSE; | |
5814 notebook_init_grab(win, widget); | |
5815 } | |
5816 } | |
5817 else { /* Otherwise, draw the arrows. */ | |
5818 GaimGtkWindow *dest_win; | |
5819 GtkNotebook *dest_notebook; | |
5820 GtkWidget *tab; | |
5821 gint nb_x, nb_y, page_num; | |
5822 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
5823 gboolean horiz_tabs = FALSE; | |
5824 | |
5825 /* Get the window that the cursor is over. */ | |
5826 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
5827 | |
5828 if (dest_win == NULL) { | |
5829 dnd_hints_hide_all(); | |
5830 | |
5831 return TRUE; | |
5832 } | |
5833 | |
5834 | |
5835 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
5836 | |
5837 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
5838 | |
5839 arrow1_x = arrow2_x = nb_x; | |
5840 arrow1_y = arrow2_y = nb_y; | |
5841 | |
5842 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
5843 e->x_root, e->y_root); | |
5844 | |
5845 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
5846 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
5847 | |
5848 horiz_tabs = TRUE; | |
5849 } | |
5850 | |
5851 tab = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num)->tabby; | |
5852 | |
5853 if (horiz_tabs) { | |
5854 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
5855 | |
5856 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
5857 arrow1_x += tab->allocation.width; | |
5858 arrow2_x += tab->allocation.width; | |
5859 } | |
5860 | |
5861 arrow1_y = nb_y + tab->allocation.y; | |
5862 arrow2_y = nb_y + tab->allocation.y + | |
5863 tab->allocation.height; | |
5864 } else { | |
5865 arrow1_x = nb_x + tab->allocation.x; | |
5866 arrow2_x = nb_x + tab->allocation.x + | |
5867 tab->allocation.width; | |
5868 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
5869 | |
5870 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
5871 arrow1_y += tab->allocation.height; | |
5872 arrow2_y += tab->allocation.height; | |
5873 } | |
5874 } | |
5875 | |
5876 if (horiz_tabs) { | |
5877 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
5878 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
5879 } else { | |
5880 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
5881 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
5882 } | |
5883 } | |
5884 | |
5885 return TRUE; | |
5886 } | |
5887 | |
5888 static gboolean | |
5889 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
5890 { | |
5891 if (win->in_drag) | |
5892 return FALSE; | |
5893 | |
5894 if (e->x_root < win->drag_min_x || | |
5895 e->x_root >= win->drag_max_x || | |
5896 e->y_root < win->drag_min_y || | |
5897 e->y_root >= win->drag_max_y) { | |
5898 | |
5899 win->in_predrag = FALSE; | |
5900 notebook_init_grab(win, widget); | |
5901 } | |
5902 | |
5903 return TRUE; | |
5904 } | |
5905 | |
5906 /* | |
5907 * THANK YOU GALEON! | |
5908 */ | |
5909 static gboolean | |
5910 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
5911 { | |
5912 gint nb_x, nb_y, x_rel, y_rel; | |
5913 int tab_clicked; | |
5914 GtkWidget *page; | |
5915 GtkWidget *tab; | |
5916 | |
5917 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
5918 return FALSE; | |
5919 | |
5920 | |
5921 if (win->in_drag) { | |
5922 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
5923 "Already in the middle of a window drag at tab_press_cb\n"); | |
5924 return TRUE; | |
5925 } | |
5926 | |
5927 /* | |
5928 * Make sure a tab was actually clicked. The arrow buttons | |
5929 * mess things up. | |
5930 */ | |
5931 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); | |
5932 | |
5933 if (tab_clicked == -1) | |
5934 return FALSE; | |
5935 | |
5936 /* | |
5937 * Get the relative position of the press event, with regards to | |
5938 * the position of the notebook. | |
5939 */ | |
5940 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
5941 | |
5942 x_rel = e->x_root - nb_x; | |
5943 y_rel = e->y_root - nb_y; | |
5944 | |
5945 /* Reset the min/max x/y */ | |
5946 win->drag_min_x = 0; | |
5947 win->drag_min_y = 0; | |
5948 win->drag_max_x = 0; | |
5949 win->drag_max_y = 0; | |
5950 | |
5951 /* Find out which tab was dragged. */ | |
5952 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
5953 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
5954 | |
5955 win->drag_min_x = tab->allocation.x + nb_x; | |
5956 win->drag_min_y = tab->allocation.y + nb_y; | |
5957 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
5958 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
5959 | |
5960 /* Make sure the click occurred in the tab. */ | |
5961 if (e->x_root < win->drag_min_x || | |
5962 e->x_root >= win->drag_max_x || | |
5963 e->y_root < win->drag_min_y || | |
5964 e->y_root >= win->drag_max_y) { | |
5965 | |
5966 return FALSE; | |
5967 } | |
5968 | |
5969 win->in_predrag = TRUE; | |
5970 win->drag_tab = tab_clicked; | |
5971 | |
5972 /* Connect the new motion signals. */ | |
5973 win->drag_motion_signal = | |
5974 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
5975 G_CALLBACK(notebook_motion_cb), win); | |
5976 | |
5977 win->drag_leave_signal = | |
5978 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
5979 G_CALLBACK(notebook_leave_cb), win); | |
5980 | |
5981 return FALSE; | |
5982 } | |
5983 | |
5984 static gboolean | |
5985 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
5986 { | |
5987 GaimGtkWindow *dest_win; | |
5988 GaimConversation *conv; | |
5989 GaimGtkConversation *gtkconv; | |
5990 gint dest_page_num = 0; | |
5991 gboolean new_window = FALSE; | |
5992 | |
5993 /* | |
5994 * Don't check to make sure that the event's window matches the | |
5995 * widget's, because we may be getting an event passed on from the | |
5996 * close button. | |
5997 */ | |
5998 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
5999 return FALSE; | |
6000 | |
6001 if (gdk_pointer_is_grabbed()) { | |
6002 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6003 gtk_grab_remove(widget); | |
6004 } | |
6005 | |
6006 if (!win->in_predrag && !win->in_drag) | |
6007 return FALSE; | |
6008 | |
6009 /* Disconnect the motion signal. */ | |
6010 if (win->drag_motion_signal) { | |
6011 g_signal_handler_disconnect(G_OBJECT(widget), | |
6012 win->drag_motion_signal); | |
6013 | |
6014 win->drag_motion_signal = 0; | |
6015 } | |
6016 | |
6017 /* | |
6018 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6019 * signal. | |
6020 */ | |
6021 if (win->in_predrag) { | |
6022 win->in_predrag = FALSE; | |
6023 | |
6024 if (win->drag_leave_signal) { | |
6025 g_signal_handler_disconnect(G_OBJECT(widget), | |
6026 win->drag_leave_signal); | |
6027 | |
6028 win->drag_leave_signal = 0; | |
6029 } | |
6030 } | |
6031 | |
6032 /* If we're not in drag... */ | |
6033 /* We're perfectly normal people! */ | |
6034 if (!win->in_drag) | |
6035 return FALSE; | |
6036 | |
6037 win->in_drag = FALSE; | |
6038 | |
6039 dnd_hints_hide_all(); | |
6040 | |
6041 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6042 | |
6043 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6044 | |
6045 if (dest_win == NULL) { | |
6046 /* If the current window doesn't have any other conversations, | |
6047 * there isn't much point transferring the conv to a new window. */ | |
6048 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6049 /* Make a new window to stick this to. */ | |
6050 dest_win = gaim_gtk_conv_window_new(); | |
6051 new_window = TRUE; | |
6052 } | |
6053 } | |
6054 | |
6055 if (dest_win == NULL) | |
6056 return FALSE; | |
6057 | |
6058 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6059 "conversation-dragging", win, dest_win); | |
6060 | |
6061 /* Get the destination page number. */ | |
6062 if (!new_window) | |
6063 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
6064 e->x_root, e->y_root); | |
6065 | |
6066 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6067 | |
6068 if (win == dest_win) { | |
6069 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6070 } else { | |
6071 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6072 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
6073 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num); | |
6074 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); | |
6075 if (new_window) { | |
6076 gint win_width, win_height; | |
6077 | |
6078 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6079 &win_width, &win_height); | |
6080 | |
6081 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6082 e->x_root - (win_width / 2), | |
6083 e->y_root - (win_height / 2)); | |
6084 | |
6085 gaim_gtk_conv_window_show(dest_win); | |
6086 } | |
6087 } | |
6088 | |
6089 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6090 | |
6091 return TRUE; | |
6092 } | |
6093 | |
6094 | |
6095 static void | |
6096 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6097 gpointer user_data) | |
6098 { | |
6099 GaimGtkWindow *win; | |
6100 GaimConversation *conv; | |
6101 GaimGtkConversation *gtkconv; | |
6102 | |
6103 win = user_data; | |
6104 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6105 | |
6106 g_return_if_fail(conv != NULL); | |
6107 | |
6108 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6109 return; | |
6110 | |
6111 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6112 | |
6113 stop_anim(NULL, gtkconv); | |
6114 } | |
6115 | |
6116 static void | |
6117 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6118 gpointer user_data) | |
6119 { | |
6120 GaimGtkWindow *win; | |
6121 GaimConversation *conv; | |
6122 GaimGtkConversation *gtkconv; | |
6123 | |
6124 win = user_data; | |
6125 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6126 conv = gtkconv->active_conv; | |
6127 | |
6128 g_return_if_fail(conv != NULL); | |
6129 | |
6130 /* | |
6131 * Only set "unseen" to "none" if the window has focus | |
6132 */ | |
6133 if (gaim_gtk_conv_window_has_focus(win)) | |
6134 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); | |
6135 | |
6136 /* Update the menubar */ | |
6137 gray_stuff_out(gtkconv); | |
6138 | |
6139 update_typing_icon(gtkconv); | |
6140 | |
6141 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.logging), | |
6142 gaim_conversation_is_logging(conv)); | |
6143 | |
6144 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6145 gtkconv->make_sound); | |
6146 | |
6147 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6148 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6149 | |
6150 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6151 gtkconv->show_timestamps); | |
6152 | |
6153 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6154 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6155 gtkconv->u.im->show_icon); | |
6156 /* | |
6157 * We pause icons when they are not visible. If this icon should | |
6158 * be animated then start it back up again. | |
6159 */ | |
6160 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6161 (gtkconv->u.im->animate)) | |
6162 start_anim(NULL, gtkconv); | |
6163 | |
6164 gtk_window_set_title(GTK_WINDOW(win->window), | |
6165 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
6166 } | |
6167 | |
6168 /************************************************************************** | |
6169 * GTK+ window ops | |
6170 **************************************************************************/ | |
6171 | |
6172 static GList *window_list = NULL; | |
6173 | |
6174 GList * | |
6175 gaim_gtk_conv_windows_get_list() | |
6176 { | |
6177 return window_list; | |
6178 } | |
6179 | |
6180 GaimGtkWindow * | |
6181 gaim_gtk_conv_window_new() | |
6182 { | |
6183 GaimGtkWindow *win; | |
6184 GtkPositionType pos; | |
6185 GtkWidget *testidea; | |
6186 GtkWidget *menubar; | |
6187 | |
6188 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6189 | |
6190 window_list = g_list_append(window_list, win); | |
6191 | |
6192 /* Create the window. */ | |
6193 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6194 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6195 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6196 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6197 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6198 | |
6199 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6200 G_CALLBACK(close_win_cb), win); | |
6201 | |
6202 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6203 G_CALLBACK(focus_win_cb), win); | |
6204 | |
6205 /* Create the notebook. */ | |
6206 win->notebook = gtk_notebook_new(); | |
6207 | |
6208 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6209 | |
6210 #if 0 | |
6211 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6212 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6213 #endif | |
6214 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6215 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6216 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6217 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6218 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6219 | |
6220 gtk_widget_show(win->notebook); | |
6221 | |
6222 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6223 G_CALLBACK(before_switch_conv_cb), win); | |
6224 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6225 G_CALLBACK(switch_conv_cb), win); | |
6226 | |
6227 /* Setup the tab drag and drop signals. */ | |
6228 gtk_widget_add_events(win->notebook, | |
6229 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6230 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6231 G_CALLBACK(notebook_press_cb), win); | |
6232 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6233 G_CALLBACK(notebook_release_cb), win); | |
6234 | |
6235 testidea = gtk_vbox_new(FALSE, 0); | |
6236 | |
6237 /* Setup the menubar. */ | |
6238 menubar = setup_menubar(win); | |
6239 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6240 | |
6241 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6242 | |
6243 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6244 | |
6245 gtk_widget_show(testidea); | |
6246 | |
6247 return win; | |
6248 } | |
6249 | |
6250 void | |
6251 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6252 { | |
6253 window_list = g_list_remove(window_list, win); | |
6254 | |
6255 gtk_widget_destroy(win->window); | |
6256 | |
6257 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6258 | |
6259 g_free(win); | |
6260 } | |
6261 | |
6262 void | |
6263 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6264 { | |
6265 gtk_widget_show(win->window); | |
6266 } | |
6267 | |
6268 void | |
6269 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6270 { | |
6271 gtk_widget_hide(win->window); | |
6272 } | |
6273 | |
6274 void | |
6275 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6276 { | |
6277 gtk_widget_show(win->window); | |
6278 gtk_window_deiconify(GTK_WINDOW(win->window)); | |
6279 gdk_window_raise(win->window->window); | |
6280 } | |
6281 | |
6282 void | |
6283 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6284 { | |
6285 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6286 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6287 gtkconv->tab_cont)); | |
6288 } | |
6289 | |
6290 void | |
6291 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6292 { | |
6293 GaimConversation *conv = gtkconv->active_conv; | |
6294 GaimGtkConversation *focus_gtkconv; | |
6295 GtkWidget *tabby, *menu_tabby; | |
6296 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6297 GtkWidget *close_image; | |
6298 GaimConversationType conv_type; | |
6299 const char *name; | |
6300 const gchar *tmp_lab; | |
6301 gint close_button_width, close_button_height, focus_width, focus_pad; | |
6302 | |
6303 name = gaim_conversation_get_name(conv); | |
6304 conv_type = gaim_conversation_get_type(conv); | |
6305 | |
6306 | |
6307 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6308 gtkconv->win = win; | |
6309 | |
6310 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6311 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6312 | |
6313 /* Close button. */ | |
6314 gtkconv->close = gtk_button_new(); | |
6315 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6316 if (gtk_check_version(2, 4, 2) == NULL) { | |
6317 /* Need to account for extra padding around the gtkbutton */ | |
6318 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6319 "focus-line-width", &focus_width, | |
6320 "focus-padding", &focus_pad, | |
6321 NULL); | |
6322 close_button_width += (focus_width + focus_pad) * 2; | |
6323 close_button_height += (focus_width + focus_pad) * 2; | |
6324 } | |
6325 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6326 close_button_width, close_button_height); | |
6327 | |
6328 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6329 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6330 gtk_widget_show(close_image); | |
6331 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6332 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6333 _("Close conversation"), NULL); | |
6334 | |
6335 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6336 G_CALLBACK(close_conv_cb), gtkconv); | |
6337 | |
6338 /* | |
6339 * I love Galeon. They have a fix for that stupid annoying visible | |
6340 * border bug. I love you guys! -- ChipX86 | |
6341 */ | |
6342 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", | |
6343 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
6344 | |
6345 /* Status icon. */ | |
6346 gtkconv->icon = gtk_image_new(); | |
6347 gtkconv->menu_icon = gtk_image_new(); | |
6348 update_tab_icon(conv); | |
6349 | |
6350 /* Tab label. */ | |
6351 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
6352 #if GTK_CHECK_VERSION(2,6,0) | |
6353 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
6354 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); | |
6355 #endif | |
6356 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6357 #if 0 | |
6358 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6359 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6360 #endif | |
6361 | |
6362 /* Pack it all together. */ | |
6363 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6364 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, | |
6365 FALSE, FALSE, 0); | |
6366 | |
6367 gtk_widget_show_all(gtkconv->icon); | |
6368 gtk_widget_show_all(gtkconv->menu_icon); | |
6369 | |
6370 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6371 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6372 gtk_widget_show(gtkconv->tab_label); | |
6373 gtk_widget_show(gtkconv->menu_label); | |
6374 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6375 | |
6376 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6377 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) | |
6378 gtk_widget_show(gtkconv->close); | |
6379 | |
6380 gtk_widget_show(tabby); | |
6381 gtk_widget_show(menu_tabby); | |
6382 | |
6383 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6384 gaim_gtkconv_update_buddy_icon(conv); | |
6385 | |
6386 /* Add this pane to the conversation's notebook. */ | |
6387 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
6388 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, TRUE, TRUE, GTK_PACK_START); | |
6389 | |
6390 | |
6391 gtk_widget_show(tab_cont); | |
6392 | |
6393 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6394 /* Er, bug in notebooks? Switch to the page manually. */ | |
6395 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6396 | |
6397 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6398 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6399 } else | |
6400 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6401 | |
6402 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6403 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6404 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6405 | |
6406 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
6407 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); | |
6408 } | |
6409 | |
6410 void | |
6411 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6412 { | |
6413 unsigned int index; | |
6414 GaimConversationType conv_type; | |
6415 | |
6416 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6417 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6418 | |
6419 g_object_ref(gtkconv->tab_cont); | |
6420 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6421 | |
6422 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6423 | |
6424 /* go back to tabless if need be */ | |
6425 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6426 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6427 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6428 } | |
6429 | |
6430 | |
6431 /* If this window is setup with an inactive gc, regenerate the menu. */ | |
6432 | |
6433 if (conv_type == GAIM_CONV_TYPE_IM && | |
6434 gaim_conversation_get_gc(gtkconv->active_conv) == NULL) { | |
6435 generate_send_as_items(win, gtkconv->active_conv); | |
6436 } | |
6437 | |
6438 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6439 |
6440 if (!win->gtkconvs) | |
6441 gaim_gtk_conv_window_destroy(win); | |
11581 | 6442 } |
6443 | |
6444 GaimGtkConversation * | |
6445 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
6446 { | |
6447 GtkWidget *tab_cont; | |
6448 | |
6449 if (index == -1) | |
6450 index = 0; | |
6451 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
6452 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
6453 } | |
6454 | |
6455 GaimGtkConversation * | |
6456 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
6457 { | |
6458 int index; | |
6459 GtkWidget *tab_cont; | |
6460 | |
6461 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
6462 if (index == -1) | |
6463 index = 0; | |
6464 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
6465 if (!tab_cont) | |
6466 return NULL; | |
6467 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
6468 } | |
6469 | |
6470 | |
6471 GaimConversation * | |
6472 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
6473 { | |
6474 GaimGtkConversation *gtkconv; | |
6475 | |
6476 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
6477 return gtkconv ? gtkconv->active_conv : NULL; | |
6478 } | |
6479 | |
6480 gboolean | |
6481 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
6482 { | |
6483 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
6484 } | |
6485 | |
6486 gboolean | |
6487 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
6488 { | |
6489 gboolean has_focus = FALSE; | |
6490 | |
6491 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
6492 | |
6493 return has_focus; | |
6494 } | |
6495 | |
6496 GaimGtkWindow * | |
6497 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
6498 { | |
6499 GaimGtkWindow *win; | |
6500 GdkWindow *gdkwin; | |
6501 GList *l; | |
6502 | |
6503 gdkwin = gdk_window_at_pointer(&x, &y); | |
6504 | |
6505 if (gdkwin) | |
6506 gdkwin = gdk_window_get_toplevel(gdkwin); | |
6507 | |
6508 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
6509 win = l->data; | |
6510 | |
6511 if (gdkwin == win->window->window) | |
6512 return win; | |
6513 } | |
6514 | |
6515 return NULL; | |
6516 } | |
6517 | |
6518 GList * | |
6519 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
6520 { | |
6521 return win->gtkconvs; | |
6522 } | |
6523 | |
6524 guint | |
6525 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
6526 { | |
6527 return g_list_length(win->gtkconvs); | |
6528 } | |
6529 | |
6530 GaimGtkWindow * | |
6531 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
6532 { | |
6533 GList *wins, *convs; | |
6534 GaimGtkWindow *win; | |
6535 GaimGtkConversation *conv; | |
6536 | |
6537 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6538 return NULL; | |
6539 | |
6540 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
6541 win = wins->data; | |
6542 | |
6543 for (convs = win->gtkconvs; | |
6544 convs != NULL; | |
6545 convs = convs->next) { | |
6546 | |
6547 conv = convs->data; | |
6548 | |
6549 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6550 return win; | |
6551 } | |
6552 } | |
6553 | |
6554 return NULL; | |
6555 } | |
6556 | |
6557 GaimGtkWindow * | |
6558 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
6559 { | |
6560 GList *wins, *convs; | |
6561 GaimGtkWindow *win; | |
6562 GaimGtkConversation *conv; | |
6563 | |
6564 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6565 return NULL; | |
6566 | |
6567 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6568 wins != NULL; | |
6569 wins = wins->prev) { | |
6570 | |
6571 win = wins->data; | |
6572 | |
6573 for (convs = win->gtkconvs; | |
6574 convs != NULL; | |
6575 convs = convs->next) { | |
6576 | |
6577 conv = convs->data; | |
6578 | |
6579 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6580 return win; | |
6581 } | |
6582 } | |
6583 | |
6584 return NULL; | |
6585 } | |
6586 | |
6587 | |
6588 /************************************************************************** | |
6589 * Conversation placement functions | |
6590 **************************************************************************/ | |
6591 typedef struct | |
6592 { | |
6593 char *id; | |
6594 char *name; | |
6595 GaimConvPlacementFunc fnc; | |
6596 | |
6597 } ConvPlacementData; | |
6598 | |
6599 static GList *conv_placement_fncs = NULL; | |
6600 static GaimConvPlacementFunc place_conv = NULL; | |
6601 | |
6602 /* This one places conversations in the last made window. */ | |
6603 static void | |
6604 conv_placement_last_created_win(GaimGtkConversation *conv) | |
6605 { | |
6606 GaimGtkWindow *win; | |
6607 | |
6608 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6609 win = l ? l->data : NULL;; | |
6610 | |
6611 if (win == NULL) { | |
6612 win = gaim_gtk_conv_window_new(); | |
6613 | |
6614 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6615 gaim_gtk_conv_window_show(win); | |
6616 } else { | |
6617 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6618 } | |
6619 } | |
6620 | |
6621 /* This one places conversations in the last made window of the same type. */ | |
6622 static void | |
6623 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
6624 { | |
6625 GaimGtkWindow *win; | |
6626 | |
6627 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
6628 | |
6629 if (win == NULL) { | |
6630 win = gaim_gtk_conv_window_new(); | |
6631 | |
6632 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6633 gaim_gtk_conv_window_show(win); | |
6634 } else | |
6635 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6636 } | |
6637 | |
6638 /* This one places each conversation in its own window. */ | |
6639 static void | |
6640 conv_placement_new_window(GaimGtkConversation *conv) | |
6641 { | |
6642 GaimGtkWindow *win; | |
6643 | |
6644 win = gaim_gtk_conv_window_new(); | |
6645 | |
6646 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6647 | |
6648 gaim_gtk_conv_window_show(win); | |
6649 } | |
6650 | |
6651 static GaimGroup * | |
6652 conv_get_group(GaimGtkConversation *conv) | |
6653 { | |
6654 GaimGroup *group = NULL; | |
6655 | |
6656 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
6657 GaimBuddy *buddy; | |
6658 | |
6659 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
6660 gaim_conversation_get_name(conv->active_conv)); | |
6661 | |
6662 if (buddy != NULL) | |
6663 group = gaim_find_buddys_group(buddy); | |
6664 | |
6665 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
6666 GaimChat *chat; | |
6667 | |
6668 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
6669 gaim_conversation_get_name(conv->active_conv)); | |
6670 | |
6671 if (chat != NULL) | |
6672 group = gaim_chat_get_group(chat); | |
6673 } | |
6674 | |
6675 return group; | |
6676 } | |
6677 | |
6678 /* | |
6679 * This groups things by, well, group. Buddies from groups will always be | |
6680 * grouped together, and a buddy from a group not belonging to any currently | |
6681 * open windows will get a new window. | |
6682 */ | |
6683 static void | |
6684 conv_placement_by_group(GaimGtkConversation *conv) | |
6685 { | |
6686 GaimConversationType type; | |
6687 GaimGroup *group = NULL; | |
6688 GList *wl, *cl; | |
6689 | |
6690 type = gaim_conversation_get_type(conv->active_conv); | |
6691 | |
6692 group = conv_get_group(conv); | |
6693 | |
6694 /* Go through the list of IMs and find one with this group. */ | |
6695 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
6696 GaimGtkWindow *win2; | |
6697 GaimGtkConversation *conv2; | |
6698 GaimGroup *group2 = NULL; | |
6699 | |
6700 win2 = wl->data; | |
6701 | |
6702 for (cl = win2->gtkconvs; | |
6703 cl != NULL; | |
6704 cl = cl->next) { | |
6705 conv2 = cl->data; | |
6706 | |
6707 group2 = conv_get_group(conv2); | |
6708 | |
6709 if (group == group2) { | |
6710 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
6711 | |
6712 return; | |
6713 } | |
6714 } | |
6715 } | |
6716 | |
6717 /* Make a new window. */ | |
6718 conv_placement_new_window(conv); | |
6719 } | |
6720 | |
6721 /* This groups things by account. Otherwise, the same semantics as above */ | |
6722 static void | |
6723 conv_placement_by_account(GaimGtkConversation *conv) | |
6724 { | |
6725 GaimConversationType type; | |
6726 GList *wins, *convs; | |
6727 GaimAccount *account; | |
6728 | |
6729 account = gaim_conversation_get_account(conv->active_conv); | |
6730 type = gaim_conversation_get_type(conv->active_conv); | |
6731 | |
6732 /* Go through the list of IMs and find one with this group. */ | |
6733 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
6734 GaimGtkWindow *win2; | |
6735 GaimGtkConversation *conv2; | |
6736 | |
6737 win2 = wins->data; | |
6738 | |
6739 for (convs = win2->gtkconvs; | |
6740 convs != NULL; | |
6741 convs = convs->next) { | |
6742 conv2 = convs->data; | |
6743 | |
6744 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
6745 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
6746 return; | |
6747 } | |
6748 } | |
6749 } | |
6750 | |
6751 /* Make a new window. */ | |
6752 conv_placement_new_window(conv); | |
6753 } | |
6754 | |
6755 static ConvPlacementData * | |
6756 get_conv_placement_data(const char *id) | |
6757 { | |
6758 ConvPlacementData *data = NULL; | |
6759 GList *n; | |
6760 | |
6761 for (n = conv_placement_fncs; n; n = n->next) { | |
6762 data = n->data; | |
6763 if (!strcmp(data->id, id)) | |
6764 return data; | |
6765 } | |
6766 | |
6767 return NULL; | |
6768 } | |
6769 | |
6770 static void | |
6771 add_conv_placement_fnc(const char *id, const char *name, | |
6772 GaimConvPlacementFunc fnc) | |
6773 { | |
6774 ConvPlacementData *data; | |
6775 | |
6776 data = g_new(ConvPlacementData, 1); | |
6777 | |
6778 data->id = g_strdup(id); | |
6779 data->name = g_strdup(name); | |
6780 data->fnc = fnc; | |
6781 | |
6782 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
6783 } | |
6784 | |
6785 static void | |
6786 ensure_default_funcs(void) | |
6787 { | |
6788 if (conv_placement_fncs == NULL) { | |
6789 add_conv_placement_fnc("last", _("Last created window"), | |
6790 conv_placement_last_created_win); | |
6791 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
6792 conv_placement_last_created_win_type); | |
6793 add_conv_placement_fnc("new", _("New window"), | |
6794 conv_placement_new_window); | |
6795 add_conv_placement_fnc("group", _("By group"), | |
6796 conv_placement_by_group); | |
6797 add_conv_placement_fnc("account", _("By account"), | |
6798 conv_placement_by_account); | |
6799 } | |
6800 } | |
6801 | |
6802 GList * | |
6803 gaim_gtkconv_placement_get_options(void) | |
6804 { | |
6805 GList *n, *list = NULL; | |
6806 ConvPlacementData *data; | |
6807 | |
6808 ensure_default_funcs(); | |
6809 | |
6810 for (n = conv_placement_fncs; n; n = n->next) { | |
6811 data = n->data; | |
6812 list = g_list_append(list, data->name); | |
6813 list = g_list_append(list, data->id); | |
6814 } | |
6815 | |
6816 return list; | |
6817 } | |
6818 | |
6819 | |
6820 void | |
6821 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
6822 GaimConvPlacementFunc fnc) | |
6823 { | |
6824 g_return_if_fail(id != NULL); | |
6825 g_return_if_fail(name != NULL); | |
6826 g_return_if_fail(fnc != NULL); | |
6827 | |
6828 ensure_default_funcs(); | |
6829 | |
6830 add_conv_placement_fnc(id, name, fnc); | |
6831 } | |
6832 | |
6833 void | |
6834 gaim_gtkconv_placement_remove_fnc(const char *id) | |
6835 { | |
6836 ConvPlacementData *data = get_conv_placement_data(id); | |
6837 | |
6838 if (data == NULL) | |
6839 return; | |
6840 | |
6841 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
6842 | |
6843 g_free(data->id); | |
6844 g_free(data->name); | |
6845 g_free(data); | |
6846 } | |
6847 | |
6848 const char * | |
6849 gaim_gtkconv_placement_get_name(const char *id) | |
6850 { | |
6851 ConvPlacementData *data; | |
6852 | |
6853 ensure_default_funcs(); | |
6854 | |
6855 data = get_conv_placement_data(id); | |
6856 | |
6857 if (data == NULL) | |
6858 return NULL; | |
6859 | |
6860 return data->name; | |
6861 } | |
6862 | |
6863 GaimConvPlacementFunc | |
6864 gaim_gtkconv_placement_get_fnc(const char *id) | |
6865 { | |
6866 ConvPlacementData *data; | |
6867 | |
6868 ensure_default_funcs(); | |
6869 | |
6870 data = get_conv_placement_data(id); | |
6871 | |
6872 if (data == NULL) | |
6873 return NULL; | |
6874 | |
6875 return data->fnc; | |
6876 } | |
6877 | |
6878 void | |
6879 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
6880 { | |
6881 g_return_if_fail(func != NULL); | |
6882 | |
6883 place_conv = func; | |
6884 } | |
6885 | |
6886 GaimConvPlacementFunc | |
6887 gaim_gtkconv_placement_get_current_func(void) | |
6888 { | |
6889 return place_conv; | |
6890 } | |
6891 | |
6892 void | |
6893 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
6894 { | |
6895 if (place_conv) | |
6896 place_conv(gtkconv); | |
6897 } |