Mercurial > pidgin
annotate src/gtkconv.c @ 12335:3726ff9022f3
[gaim-migrate @ 14639]
[ 1342462 ] [HEAD] Crash on some custom smilies
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Mon, 05 Dec 2005 02:56:55 +0000 |
parents | a532eccfc7bb |
children | f6fa5d742c76 |
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" |
12272 | 45 #include "idle.h" |
6982 | 46 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
47 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
48 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
49 #include "prpl.h" |
6038 | 50 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
52 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
53 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
54 #include "gtkblist.h" |
5717 | 55 #include "gtkconv.h" |
11583 | 56 #include "gtkconvwin.h" |
9709 | 57 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
58 #include "gtkimhtml.h" |
8317 | 59 #include "gtkimhtmltoolbar.h" |
7431 | 60 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
61 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
62 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
63 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
64 #include "gtkprivacy.h" |
11525 | 65 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
66 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
67 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
69 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
70 |
12190 | 71 #define SEND_COLOR "#204a87" |
72 #define RECV_COLOR "#cc0000" | |
7854 | 73 |
12335 | 74 /* Undef this to turn off "custom-smiley" debug messages */ |
75 #define DEBUG_CUSTOM_SMILEY | |
76 | |
10108 | 77 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
78 | |
79 /* These colors come from the default GNOME palette */ | |
80 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
81 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
84 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
86 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
90 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
94 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
95 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
96 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
97 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
98 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
99 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
100 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
101 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
102 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 103 }; |
6291 | 104 |
4359 | 105 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
106 | |
11581 | 107 typedef struct { |
4359 | 108 GtkWidget *window; |
109 | |
110 GtkWidget *entry; | |
111 GtkWidget *message; | |
112 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
113 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
114 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
115 } InviteBuddyInfo; |
4359 | 116 |
117 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
118 static GtkWidget *warn_close_dialog = NULL; |
4359 | 119 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
120 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
121 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
122 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
123 |
11594 | 124 static gboolean update_send_to_selection(GaimGtkWindow *win); |
125 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 126 |
4359 | 127 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 128 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 129 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
130 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
131 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 132 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 133 static gboolean tab_complete(GaimConversation *conv); |
11604 | 134 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 135 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 136 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
137 static char *item_factory_translate_func (const char *path, gpointer func_data); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
138 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12335 | 139 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data); |
140 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data); | |
4359 | 141 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
142 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
143 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
144 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
145 float scale; |
11454
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 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
148 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
149 (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
|
150 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
151 /* 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
|
152 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
153 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
154 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
155 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
156 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
157 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
158 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
159 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
160 |
4359 | 161 /************************************************************************** |
162 * Callbacks | |
163 **************************************************************************/ | |
10971 | 164 |
4359 | 165 static gint |
10810 | 166 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 167 { |
10810 | 168 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 169 |
10810 | 170 l = list; |
171 while (l) { | |
172 GaimConversation *conv = l->data; | |
173 gaim_conversation_destroy(conv); | |
174 l = l->next; | |
175 } | |
11508 | 176 |
10810 | 177 g_list_free(list); |
11508 | 178 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
179 return TRUE; |
4359 | 180 } |
181 | |
8914 | 182 static gboolean |
10810 | 183 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 184 { |
10810 | 185 GaimConversation *conv = gtkconv->active_conv; |
11508 | 186 |
8914 | 187 if (!GTK_WIDGET_VISIBLE(w)) |
188 return FALSE; | |
189 | |
190 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
191 return FALSE; | |
192 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
193 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
194 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
195 * if there is only one conversation in the window. This way we'll be setting new windows to the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
196 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
197 /* I think that the above justification is not the majority, and that the new tab resizing should |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
198 * negate it anyway. --luke */ |
11338 | 199 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 200 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
201 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
202 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
|
203 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
|
204 } |
8914 | 205 if (w == gtkconv->entry) |
206 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
207 } | |
11338 | 208 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 209 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
210 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
211 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
|
212 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
|
213 } |
8914 | 214 if (w == gtkconv->entry) |
215 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
216 } | |
217 | |
218 return FALSE; | |
219 } | |
220 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
221 static void |
10810 | 222 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
223 { |
10810 | 224 GaimConversation *conv = c->active_conv; |
11508 | 225 |
10665 | 226 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
227 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
228 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
229 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
230 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
231 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
|
232 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
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 (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
|
235 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
236 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
237 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
|
238 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
242 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
243 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
244 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
245 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 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
|
248 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
251 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 fg_color.blue / 256); |
8061 | 255 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 color = g_strdup(""); |
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 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 g_free(color); |
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 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
273 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
274 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
275 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
276 g_free(color); |
8677 | 277 |
9025 | 278 |
10665 | 279 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 280 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
281 else | |
282 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 283 } |
284 } | |
9130 | 285 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
286 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
287 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
288 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
289 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
290 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
291 |
9130 | 292 static const char * |
293 gaim_gtk_get_cmd_prefix(void) | |
294 { | |
295 return "/"; | |
296 } | |
297 | |
9167 | 298 static GaimCmdRet |
9829 | 299 say_command_cb(GaimConversation *conv, |
300 const char *cmd, char **args, char **error, void *data) | |
301 { | |
11338 | 302 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 303 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 304 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 305 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
306 | |
307 return GAIM_CMD_RET_OK; | |
308 } | |
309 | |
310 static GaimCmdRet | |
9167 | 311 me_command_cb(GaimConversation *conv, |
9597 | 312 const char *cmd, char **args, char **error, void *data) |
9167 | 313 { |
314 char *tmp; | |
315 | |
316 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 317 |
11338 | 318 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 319 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 320 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 321 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
322 | |
323 g_free(tmp); | |
324 return GAIM_CMD_RET_OK; | |
325 } | |
326 | |
9212 | 327 static GaimCmdRet |
328 debug_command_cb(GaimConversation *conv, | |
9597 | 329 const char *cmd, char **args, char **error, void *data) |
9212 | 330 { |
331 char *tmp, *markup; | |
332 GaimCmdStatus status; | |
333 | |
334 if (!g_ascii_strcasecmp(args[0], "version")) { | |
335 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
|
336 markup = g_markup_escape_text(tmp, -1); |
9212 | 337 |
338 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
339 | |
340 g_free(tmp); | |
341 g_free(markup); | |
342 return status; | |
343 } else { | |
344 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
345 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
346 return GAIM_CMD_STATUS_OK; | |
347 } | |
348 } | |
349 | |
9213 | 350 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
351 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
352 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
353 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
354 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
355 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
356 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
357 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
358 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
359 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
360 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
361 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
362 static GaimCmdRet |
9213 | 363 help_command_cb(GaimConversation *conv, |
9597 | 364 const char *cmd, char **args, char **error, void *data) |
9213 | 365 { |
9597 | 366 GList *l, *text; |
9213 | 367 GString *s; |
9597 | 368 |
369 if (args[0] != NULL) { | |
370 s = g_string_new(""); | |
371 text = gaim_cmd_help(conv, args[0]); | |
372 | |
373 if (text) { | |
374 for (l = text; l; l = l->next) | |
375 if (l->next) | |
9816 | 376 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 377 else |
9816 | 378 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 379 } else { |
380 g_string_append(s, _("No such command (in this context).")); | |
381 } | |
382 } else { | |
383 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
384 "The following commands are available in this context:\n")); | |
385 | |
386 text = gaim_cmd_list(conv); | |
387 for (l = text; l; l = l->next) | |
9213 | 388 if (l->next) |
9597 | 389 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 390 else |
9597 | 391 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 392 } |
393 | |
394 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
395 g_string_free(s, TRUE); | |
396 | |
397 return GAIM_CMD_STATUS_OK; | |
398 } | |
399 | |
4359 | 400 static void |
9374 | 401 send_history_add(GaimConversation *conv, const char *message) |
402 { | |
403 GList *first; | |
404 | |
405 first = g_list_first(conv->send_history); | |
406 | |
407 if (first->data) | |
408 g_free(first->data); | |
409 | |
410 first->data = g_strdup(message); | |
411 | |
412 conv->send_history = g_list_prepend(first, NULL); | |
413 } | |
414 | |
9832 | 415 static gboolean |
416 check_for_and_do_command(GaimConversation *conv) | |
417 { | |
418 GaimGtkConversation *gtkconv; | |
419 char *cmd; | |
420 const char *prefix; | |
421 GaimAccount *account; | |
422 GtkTextIter start; | |
423 | |
424 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
425 account = gaim_conversation_get_account(conv); | |
426 prefix = gaim_gtk_get_cmd_prefix(); | |
427 | |
428 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
429 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
430 | |
431 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
432 && !gtk_text_iter_get_child_anchor(&start)) { | |
433 GaimCmdStatus status; | |
434 char *error, *cmdline, *markup, *send_history; | |
435 GtkTextIter end; | |
436 | |
437 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
438 send_history_add(conv, send_history); | |
439 g_free(send_history); | |
440 | |
441 cmdline = cmd + strlen(prefix); | |
442 | |
443 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
444 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
445 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
446 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
447 g_free(cmd); | |
448 g_free(markup); | |
449 | |
450 switch (status) { | |
451 case GAIM_CMD_STATUS_OK: | |
452 return TRUE; | |
453 case GAIM_CMD_STATUS_NOT_FOUND: | |
454 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
455 gaim_conversation_write(conv, "", _("No such command."), | |
456 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
457 | |
458 return TRUE; | |
459 } | |
460 return FALSE; | |
461 case GAIM_CMD_STATUS_WRONG_ARGS: | |
462 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
463 "to that command."), | |
464 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
465 return TRUE; | |
466 case GAIM_CMD_STATUS_FAILED: | |
467 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
468 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
469 if(error) | |
470 g_free(error); | |
471 return TRUE; | |
472 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 473 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 474 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 475 GAIM_MESSAGE_NO_LOG, time(NULL)); |
476 else | |
10843 | 477 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 478 GAIM_MESSAGE_NO_LOG, time(NULL)); |
479 return TRUE; | |
480 case GAIM_CMD_STATUS_WRONG_PRPL: | |
481 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
482 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
483 return TRUE; | |
484 } | |
485 } | |
486 | |
487 g_free(cmd); | |
488 return FALSE; | |
489 } | |
490 | |
9374 | 491 static void |
10810 | 492 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 493 { |
10810 | 494 GaimConversation *conv = gtkconv->active_conv; |
8655 | 495 GaimAccount *account; |
8677 | 496 GaimConnection *gc; |
12216 | 497 GaimMessageFlags flags = 0; |
8448 | 498 char *buf, *clean; |
4359 | 499 |
8655 | 500 account = gaim_conversation_get_account(conv); |
9130 | 501 |
9471 | 502 if (!gaim_account_is_connected(account)) |
503 return; | |
504 | |
11338 | 505 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 506 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 507 return; |
508 | |
9832 | 509 if (check_for_and_do_command(conv)) { |
510 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
511 return; | |
9130 | 512 } |
513 | |
8442 | 514 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 515 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 516 |
4359 | 517 gtk_widget_grab_focus(gtkconv->entry); |
518 | |
8448 | 519 if (strlen(clean) == 0) { |
520 g_free(clean); | |
4359 | 521 return; |
522 } | |
523 | |
12272 | 524 gaim_idle_touch(); |
525 | |
12216 | 526 /* XXX: is there a better way to tell if the message has images? */ |
527 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
528 flags |= GAIM_MESSAGE_IMAGES; | |
529 | |
8677 | 530 gc = gaim_account_get_connection(account); |
10665 | 531 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 532 char **bufs; |
533 int i; | |
534 | |
535 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
536 for (i = 0; bufs[i]; i++) { | |
9374 | 537 send_history_add(conv, bufs[i]); |
11338 | 538 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 539 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 540 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 541 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 542 } |
543 | |
544 g_strfreev(bufs); | |
545 | |
546 } else { | |
9374 | 547 send_history_add(conv, buf); |
11338 | 548 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 549 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 550 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 551 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 552 } |
4359 | 553 |
8677 | 554 g_free(clean); |
4359 | 555 g_free(buf); |
556 | |
8061 | 557 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 558 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 559 } |
560 | |
561 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
562 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 563 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
564 GaimAccount *account; |
4359 | 565 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
566 GaimConversation *conv = gtkconv->active_conv; |
4359 | 567 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
568 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
569 name = gaim_conversation_get_name(conv); |
7879 | 570 |
11338 | 571 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 572 GaimBuddy *b; |
573 | |
574 b = gaim_find_buddy(account, name); | |
575 if (b != NULL) | |
9730 | 576 gaim_gtkdialogs_remove_buddy(b); |
7859 | 577 else if (account != NULL && gaim_account_is_connected(account)) |
578 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 579 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 580 GaimChat *c; |
581 | |
582 c = gaim_blist_find_chat(account, name); | |
583 if (c != NULL) | |
9730 | 584 gaim_gtkdialogs_remove_chat(c); |
7859 | 585 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 586 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 587 } |
4359 | 588 |
589 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
590 } | |
591 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
592 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 593 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
594 GaimConversation *conv = gtkconv->active_conv; |
7975 | 595 GaimPluginProtocolInfo *prpl_info = NULL; |
596 GaimConnection *gc; | |
597 | |
598 if ((gc = gaim_conversation_get_gc(conv))) { | |
599 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
600 | |
601 /* | |
602 * If there are special needs for getting info on users in | |
603 * buddy chat "rooms"... | |
604 */ | |
605 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
606 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
607 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
608 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
609 } |
7975 | 610 else |
611 prpl_info->get_info(gc, who); | |
612 } | |
613 } | |
614 | |
615 | |
4359 | 616 static void |
10810 | 617 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 618 { |
10810 | 619 GaimConversation *conv = gtkconv->active_conv; |
4359 | 620 |
11338 | 621 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 622 serv_get_info(gaim_conversation_get_gc(conv), |
623 gaim_conversation_get_name(conv)); | |
624 | |
625 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 626 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 627 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
628 GaimGtkChatPane *gtkchat; |
4359 | 629 GtkTreeIter iter; |
630 GtkTreeModel *model; | |
631 GtkTreeSelection *sel; | |
9554 | 632 char *name; |
4359 | 633 |
634 gtkchat = gtkconv->u.chat; | |
635 | |
636 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
637 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
638 | |
639 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 640 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 641 else |
642 return; | |
643 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
644 chat_do_info(gtkconv, name); |
9554 | 645 g_free(name); |
4359 | 646 } |
647 } | |
648 | |
649 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
650 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 651 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
652 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
653 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
654 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
655 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
656 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
657 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
658 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 659 |
660 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
661 } | |
662 | |
663 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
664 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 665 { |
666 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
667 GaimGtkConversation *gtkconv; |
4359 | 668 |
669 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
670 | |
671 if (resp == GTK_RESPONSE_OK) { | |
672 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
673 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
674 | |
10113 | 675 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 676 return; |
677 | |
678 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
679 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 680 message, buddy); |
681 } | |
682 | |
683 gtk_widget_destroy(invite_dialog); | |
684 invite_dialog = NULL; | |
685 | |
686 g_free(info); | |
687 } | |
688 | |
689 static void | |
9909 | 690 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
691 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
692 { | |
693 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
694 const char *convprotocol; | |
695 | |
696 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
697 | |
698 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
699 { | |
700 GaimBlistNode *node = NULL; | |
701 GaimBuddy *buddy; | |
702 | |
703 memcpy(&node, sd->data, sizeof(node)); | |
704 | |
705 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
706 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
707 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
708 buddy = (GaimBuddy *)node; | |
709 else | |
710 return; | |
711 | |
712 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
713 { | |
714 gaim_notify_error(NULL, NULL, | |
715 _("That buddy is not on the same protocol as this " | |
10843 | 716 "chat."), NULL); |
9909 | 717 } |
718 else | |
719 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
720 | |
721 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
722 } | |
723 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
724 { | |
725 char *protocol = NULL; | |
726 char *username = NULL; | |
727 GaimAccount *account; | |
728 | |
11137 | 729 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 730 &protocol, &username, NULL)) |
731 { | |
732 if (account == NULL) | |
733 { | |
734 gaim_notify_error(NULL, NULL, | |
735 _("You are not currently signed on with an account that " | |
736 "can invite that buddy."), NULL); | |
737 } | |
738 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
739 { | |
740 gaim_notify_error(NULL, NULL, | |
741 _("That buddy is not on the same protocol as this " | |
10843 | 742 "chat."), NULL); |
9909 | 743 } |
744 else | |
745 { | |
746 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
747 } | |
748 } | |
749 | |
750 if (username != NULL) g_free(username); | |
751 if (protocol != NULL) g_free(protocol); | |
752 | |
753 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
754 } | |
755 } | |
756 | |
757 static const GtkTargetEntry dnd_targets[] = | |
758 { | |
759 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
760 {"application/x-im-contact", 0, 1} | |
761 }; | |
762 | |
763 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
764 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 765 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
766 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
767 InviteBuddyInfo *info = NULL; |
4359 | 768 |
769 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
770 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
771 GaimGtkWindow *gtkwin; |
4359 | 772 GtkWidget *label; |
773 GtkWidget *vbox, *hbox; | |
774 GtkWidget *table; | |
775 GtkWidget *img; | |
776 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
777 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 778 GTK_ICON_SIZE_DIALOG); |
4359 | 779 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
780 info = g_new0(InviteBuddyInfo, 1); |
4359 | 781 info->conv = conv; |
782 | |
11581 | 783 gc = gaim_conversation_get_gc(conv); |
784 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 785 |
786 /* Create the new dialog. */ | |
787 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 788 _("Invite Buddy Into Chat Room"), |
7879 | 789 GTK_WINDOW(gtkwin->window), 0, |
790 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
791 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 792 |
793 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 794 GTK_RESPONSE_OK); |
11243 | 795 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 796 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
797 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
798 | |
9909 | 799 info->window = GTK_WIDGET(invite_dialog); |
800 | |
4359 | 801 /* Setup the outside spacing. */ |
802 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
803 | |
11243 | 804 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
805 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 806 |
807 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 808 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 809 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
810 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
811 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
812 | |
813 /* Setup the right vbox. */ | |
814 vbox = gtk_vbox_new(FALSE, 0); | |
815 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
816 | |
817 /* Put our happy label in it. */ | |
818 label = gtk_label_new(_("Please enter the name of the user you wish " | |
819 "to invite, along with an optional invite " | |
820 "message.")); | |
821 gtk_widget_set_size_request(label, 350, -1); | |
822 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
823 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
824 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
825 | |
826 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 827 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 828 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
829 | |
830 /* Setup the table we're going to use to lay stuff out. */ | |
831 table = gtk_table_new(2, 2, FALSE); | |
11243 | 832 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
833 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
834 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 835 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
836 | |
837 /* Now the Buddy label */ | |
838 label = gtk_label_new(NULL); | |
839 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
840 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
841 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
842 | |
843 /* Now the Buddy drop-down entry field. */ | |
844 info->entry = gtk_combo_new(); | |
845 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
846 gtk_entry_set_activates_default( | |
847 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
848 | |
849 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
850 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
851 | |
852 /* Fill in the names. */ | |
853 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
854 generate_invite_user_names(gc)); | |
855 | |
856 | |
857 /* Now the label for "Message" */ | |
858 label = gtk_label_new(NULL); | |
859 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
860 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
861 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
862 | |
863 | |
864 /* And finally, the Message entry field. */ | |
865 info->message = gtk_entry_new(); | |
866 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
867 | |
868 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
869 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
870 | |
871 /* Connect the signals. */ | |
872 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
873 G_CALLBACK(do_invite), info); | |
9909 | 874 /* Setup drag-and-drop */ |
875 gtk_drag_dest_set(info->window, | |
876 GTK_DEST_DEFAULT_MOTION | | |
877 GTK_DEST_DEFAULT_DROP, | |
878 dnd_targets, | |
879 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
880 GDK_ACTION_COPY); | |
881 gtk_drag_dest_set(info->entry, | |
882 GTK_DEST_DEFAULT_MOTION | | |
883 GTK_DEST_DEFAULT_DROP, | |
884 dnd_targets, | |
885 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
886 GDK_ACTION_COPY); | |
887 | |
888 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
889 G_CALLBACK(invite_dnd_recv), info); | |
890 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
891 G_CALLBACK(invite_dnd_recv), info); | |
892 | |
4359 | 893 } |
894 | |
895 gtk_widget_show_all(invite_dialog); | |
896 | |
897 if (info != NULL) | |
898 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
899 } | |
900 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
901 static void |
7748 | 902 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
903 { | |
9714 | 904 gaim_gtkdialogs_im(); |
7748 | 905 } |
906 | |
907 static void | |
9504 | 908 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 909 { |
9504 | 910 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 911 FILE *fp; |
912 const char *name; | |
10849 | 913 gchar *text; |
9489 | 914 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
915 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 916 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 917 return; |
918 } | |
919 | |
920 name = gaim_conversation_get_name(conv); | |
10849 | 921 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 922 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 923 |
924 text = gtk_imhtml_get_markup( | |
925 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
926 fprintf(fp, "%s", text); | |
927 g_free(text); | |
928 | |
929 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 930 fclose(fp); |
931 } | |
932 | |
10849 | 933 /* |
934 * It would be kinda cool if this gave the option of saving a | |
935 * plaintext v. HTML file. | |
936 */ | |
9489 | 937 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
938 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
939 { |
11581 | 940 GaimGtkWindow *win = data; |
941 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 942 gchar *buf; |
943 | |
944 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 945 |
10849 | 946 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
947 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 948 |
949 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
950 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
951 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
952 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
953 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
954 { |
11581 | 955 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
956 GaimConversation *conv; |
9917 | 957 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
958 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
959 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
960 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
961 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
962 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
963 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
964 |
11581 | 965 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
966 |
11338 | 967 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 968 type = GAIM_LOG_IM; |
11338 | 969 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 970 type = GAIM_LOG_CHAT; |
971 else | |
972 return; | |
973 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
974 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
975 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
976 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
977 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
978 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
979 gdk_cursor_unref(cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
980 while (gtk_events_pending()) |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
981 gtk_main_iteration(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
982 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
983 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
984 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
985 |
10845 | 986 buddies = gaim_find_buddies(account, name); |
987 for (cur = buddies; cur != NULL; cur = cur->next) | |
988 { | |
989 GaimBlistNode *node = cur->data; | |
10846 | 990 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 991 { |
992 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
993 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
994 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
995 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 996 return; |
997 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
998 } |
10845 | 999 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1000 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1001 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1002 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1003 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1004 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1005 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1006 |
8974 | 1007 static void |
1008 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1009 { | |
11581 | 1010 GaimGtkWindow *win = data; |
8974 | 1011 GaimConversation *conv; |
1012 GaimGtkConversation *gtkconv; | |
1013 | |
11581 | 1014 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1015 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1016 | |
1017 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1018 } | |
1019 | |
7295 | 1020 struct _search { |
1021 GaimGtkConversation *gtkconv; | |
1022 GtkWidget *entry; | |
1023 }; | |
1024 | |
7929 | 1025 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1026 { |
7929 | 1027 switch (resp) { |
1028 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1029 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1030 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1031 break; |
1032 | |
1033 case GTK_RESPONSE_DELETE_EVENT: | |
1034 case GTK_RESPONSE_CLOSE: | |
1035 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1036 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1037 s->gtkconv->dialogs.search = NULL; | |
1038 g_free(s); | |
1039 break; | |
1040 } | |
7295 | 1041 } |
1042 | |
1043 static void | |
7751 | 1044 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1045 { |
11581 | 1046 GaimGtkWindow *gtkwin = data; |
1047 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1048 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1049 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1050 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1051 GTK_ICON_SIZE_DIALOG); |
7929 | 1052 GtkWidget *label; |
7295 | 1053 struct _search *s; |
1054 | |
7798 | 1055 if (gtkconv->dialogs.search) { |
1056 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1057 return; |
7798 | 1058 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1059 |
7295 | 1060 s = g_malloc(sizeof(struct _search)); |
1061 s->gtkconv = gtkconv; | |
7929 | 1062 |
1063 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1064 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1065 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1066 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1067 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1068 GTK_RESPONSE_OK); |
7929 | 1069 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1070 G_CALLBACK(do_search_cb), s); | |
1071 | |
11243 | 1072 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1073 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1074 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1075 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
|
1076 gtk_container_set_border_width( |
11243 | 1077 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1078 | |
1079 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1080 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1081 hbox); |
7929 | 1082 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1083 | |
1084 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1085 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1086 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1087 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1088 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1089 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1090 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1091 | |
1092 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1093 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1094 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1095 g_signal_connect(G_OBJECT(s->entry), "changed", |
1096 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1097 gtkconv->dialogs.search); | |
1098 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
|
1099 |
7295 | 1100 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1101 gtk_widget_grab_focus(s->entry); |
7295 | 1102 } |
1103 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1104 static void |
9468 | 1105 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1106 { | |
11581 | 1107 GaimGtkWindow *win = data; |
1108 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1109 |
11338 | 1110 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1111 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1112 } | |
1113 | |
1114 } | |
1115 | |
1116 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1117 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1118 { |
11581 | 1119 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1120 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1121 |
11581 | 1122 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
|
1123 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1124 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1125 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1126 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1127 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1129 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1130 { |
11581 | 1131 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1132 GaimGtkConversation *gtkconv; |
8756 | 1133 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 |
11581 | 1135 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1136 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1137 | |
1138 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1139 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1140 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1141 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1142 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1143 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1144 { |
11581 | 1145 GaimGtkWindow *win = data; |
8756 | 1146 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1147 GaimGtkConversation *gtkconv; |
8756 | 1148 GtkIMHtmlToolbar *toolbar; |
1149 | |
11581 | 1150 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1151 conv = gtkconv->active_conv; | |
8756 | 1152 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1153 | |
1154 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1155 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1157 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1160 { |
11581 | 1161 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 GaimConversation *conv; |
7879 | 1163 GaimAccount *account; |
1164 const char *name; | |
1165 | |
11581 | 1166 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1167 account = gaim_conversation_get_account(conv); |
1168 name = gaim_conversation_get_name(conv); | |
1169 | |
11338 | 1170 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1171 GaimBuddy *b; |
1172 | |
1173 b = gaim_find_buddy(account, name); | |
1174 if (b != NULL) | |
9730 | 1175 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1176 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1177 GaimChat *c; |
1178 | |
1179 c = gaim_blist_find_chat(account, name); | |
1180 if (c != NULL) | |
9730 | 1181 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1182 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1185 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1187 { |
11581 | 1188 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 |
11581 | 1191 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 |
10810 | 1193 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1196 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1198 { |
11581 | 1199 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1200 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 |
11581 | 1202 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1204 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1205 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1206 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1207 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 { |
11581 | 1210 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 |
11581 | 1213 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1215 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1216 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 { |
11581 | 1221 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1223 |
11581 | 1224 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1226 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1229 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1231 { |
11581 | 1232 GaimGtkWindow *win = data; |
1233 | |
1234 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
|
1235 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1236 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1239 { |
11581 | 1240 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1242 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 |
11581 | 1244 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1245 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1246 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1247 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1248 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1249 logging = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1250 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1251 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1252 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1253 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1254 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1255 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1256 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1257 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1258 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1259 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1260 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1261 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1262 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1263 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1264 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1265 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1266 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1267 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1268 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1269 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1270 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1271 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1272 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1273 /* Disable the logging second, so that the above message can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1274 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1275 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1278 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1279 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1280 { |
11581 | 1281 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1282 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1283 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1284 |
11581 | 1285 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1286 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1287 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1288 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1289 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1290 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1291 |
10377 | 1292 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1293 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
|
1294 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1295 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1296 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1297 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1298 { |
11581 | 1299 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1300 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1301 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1302 |
11581 | 1303 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1304 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1305 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1306 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1309 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1310 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1311 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
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 |
7961 | 1314 static void |
9188 | 1315 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1316 { | |
11581 | 1317 GaimGtkWindow *win = data; |
9188 | 1318 GaimConversation *conv; |
1319 GaimGtkConversation *gtkconv; | |
1320 | |
11581 | 1321 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1322 |
1323 if (!conv) | |
1324 return; | |
1325 | |
1326 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1327 | |
12188 | 1328 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1329 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1330 } | |
1331 | |
1332 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1333 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1334 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1335 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1336 GaimAccount *account; |
1337 GaimConnection *gc; | |
7961 | 1338 GaimPluginProtocolInfo *prpl_info = NULL; |
1339 char *real_who; | |
1340 | |
1341 account = gaim_conversation_get_account(conv); | |
10431 | 1342 g_return_if_fail(account != NULL); |
1343 | |
1344 gc = gaim_account_get_connection(account); | |
1345 g_return_if_fail(gc != NULL); | |
1346 | |
1347 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1348 | |
1349 if (prpl_info && prpl_info->get_cb_real_name) | |
1350 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1351 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1352 else | |
1353 real_who = g_strdup(who); | |
1354 | |
1355 if(!real_who) | |
1356 return; | |
1357 | |
10431 | 1358 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1359 |
1360 g_free(real_who); | |
1361 } | |
1362 | |
1363 static void | |
10810 | 1364 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1365 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1366 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1367 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 GtkTreeSelection *sel; |
9554 | 1370 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1373 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1374 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1376 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1378 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
|
1379 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1381 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1382 chat_do_im(gtkconv, name); |
9554 | 1383 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1384 } |
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 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1387 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1389 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1390 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1391 GaimConvChat *chat; |
11869 | 1392 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 GtkTreeSelection *sel; |
10504 | 1396 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1397 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1399 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 gtkchat = gtkconv->u.chat; |
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 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1403 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
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 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1406 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1407 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1408 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1409 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1410 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1411 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1412 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1413 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1416 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1417 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1418 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1419 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 |
11869 | 1421 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1422 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1423 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1425 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1427 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1428 { |
1429 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1430 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1431 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 } |
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 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1435 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1436 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1437 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1438 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1439 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1440 | |
1441 serv_send_file(gc, who, NULL); | |
1442 } | |
1443 | |
1444 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1445 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1446 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1447 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1448 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1449 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1450 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1451 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1452 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1453 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1455 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1457 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1458 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1459 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1462 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1463 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1464 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1467 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1468 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1469 * 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
|
1470 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1471 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1472 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1473 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1474 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1475 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1476 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1477 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1478 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1479 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1480 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1481 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1482 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1483 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1484 GaimAccount *account; |
6695 | 1485 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1486 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1487 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1488 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1489 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1490 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1491 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1492 if (b != NULL) |
9730 | 1493 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1494 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1495 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1496 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1497 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1498 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1499 |
8143 | 1500 static GtkWidget * |
10504 | 1501 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1502 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1503 { | |
1504 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1505 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1506 gboolean is_me = FALSE; |
8143 | 1507 GtkWidget *button; |
1508 | |
1509 /* | |
1510 * If a menu already exists, destroy it before creating a new one, | |
1511 * thus freeing-up the memory it occupied. | |
1512 */ | |
1513 if (menu) | |
1514 gtk_widget_destroy(menu); | |
1515 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1516 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1517 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1518 |
8143 | 1519 menu = gtk_menu_new(); |
1520 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1521 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1522 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1523 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
|
1524 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
|
1525 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1526 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1527 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1528 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1529 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1530 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1531 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
|
1532 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1533 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1534 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
|
1535 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
|
1536 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1537 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1538 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1539 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1540 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1541 } |
9498 | 1542 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1543 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1544 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
|
1545 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1546 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1547 } |
1548 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1549 if (prpl_info->get_cb_away) { |
10221 | 1550 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
|
1551 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1552 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1553 } |
1554 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1555 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1556 if (gaim_find_buddy(gc->account, who)) |
10221 | 1557 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
|
1558 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1559 else |
10221 | 1560 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
|
1561 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1562 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1563 } |
1564 | |
1565 return menu; | |
1566 } | |
1567 | |
1568 | |
1569 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1570 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1571 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1572 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1573 GaimPluginProtocolInfo *prpl_info = NULL; |
1574 GaimGtkChatPane *gtkchat; | |
1575 GaimConnection *gc; | |
1576 GaimAccount *account; | |
1577 GtkTreeSelection *sel; | |
1578 GtkTreeIter iter; | |
1579 GtkTreeModel *model; | |
1580 GtkWidget *menu; | |
1581 gchar *who; | |
1582 | |
1583 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1584 gtkchat = gtkconv->u.chat; | |
1585 account = gaim_conversation_get_account(conv); | |
1586 gc = account->gc; | |
1587 | |
1588 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1589 | |
1590 if (gc != NULL) | |
1591 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1592 | |
1593 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1594 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1595 return FALSE; | |
1596 | |
9498 | 1597 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1598 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1599 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1600 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1601 0, GDK_CURRENT_TIME); |
10504 | 1602 g_free(who); |
8143 | 1603 |
1604 return TRUE; | |
1605 } | |
1606 | |
1607 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1608 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1609 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1610 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1611 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1612 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1613 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1614 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1615 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1616 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1617 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1618 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1620 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1621 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1622 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1623 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1624 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1625 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1626 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1627 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1628 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1629 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1630 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
|
1631 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1632 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1633 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1634 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1635 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1636 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1637 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1638 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1639 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1640 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1641 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1642 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1643 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
|
1644 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1645 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1646 chat_do_im(gtkconv, who); |
7398 | 1647 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1648 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1649 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1650 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1651 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1652 |
10504 | 1653 g_free(who); |
1654 gtk_tree_path_free(path); | |
1655 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1656 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1657 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1658 |
8133 | 1659 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1660 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1661 { |
10827 | 1662 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1663 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1664 int index, i, total, found = 0; |
8133 | 1665 |
11581 | 1666 win = gtkconv->win; |
1667 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1668 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1669 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1670 /* First check the tabs after (forward) or before (!forward) this position. */ |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1671 for (i = forward ? index + 1 : index - 1; |
11581 | 1672 !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
|
1673 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1674 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1675 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1676 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1677 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1678 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1679 found = 1; |
8133 | 1680 } |
11252 | 1681 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1682 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1683 /* 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
|
1684 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1685 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1686 (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
|
1687 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1688 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1689 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1690 found = 1; |
8133 | 1691 } |
10827 | 1692 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1693 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1694 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1695 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1696 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1697 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1698 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1699 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1700 } |
11581 | 1701 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1702 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1703 } |
8133 | 1704 } |
1705 | |
10827 | 1706 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1707 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1708 } |
1709 | |
4359 | 1710 static gboolean |
8105 | 1711 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1712 { |
11581 | 1713 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1714 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1715 GaimGtkConversation *gtkconv; |
8105 | 1716 int curconv; |
1717 | |
10810 | 1718 gtkconv = (GaimGtkConversation *)data; |
10849 | 1719 conv = gtkconv->active_conv; |
11581 | 1720 win = gtkconv->win; |
1721 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1722 |
8105 | 1723 /* If CTRL was held down... */ |
1724 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1725 switch (event->keyval) { |
1726 case GDK_Up: | |
1727 if (!conv->send_history) | |
1728 break; | |
1729 | |
1730 if (!conv->send_history->prev) { | |
1731 GtkTextIter start, end; | |
1732 | |
1733 if (conv->send_history->data) | |
1734 g_free(conv->send_history->data); | |
1735 | |
1736 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1737 &start); | |
1738 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1739 | |
1740 conv->send_history->data = | |
8506 | 1741 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1742 } |
8677 | 1743 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1744 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1745 GObject *object; |
8677 | 1746 GtkTextIter iter; |
1747 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1748 |
1749 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1750 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1751 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1752 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1753 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
|
1754 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1755 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1756 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1757 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1758 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
|
1759 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1760 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1761 |
8061 | 1762 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1763 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1764 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1765 0, NULL); |
8677 | 1766 /* this is mainly just a hack so the formatting at the |
1767 * cursor gets picked up. */ | |
1768 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1769 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1770 } |
1771 | |
8105 | 1772 return TRUE; |
4359 | 1773 break; |
1774 | |
1775 case GDK_Down: | |
1776 if (!conv->send_history) | |
1777 break; | |
1778 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1779 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1780 GObject *object; |
8677 | 1781 GtkTextIter iter; |
1782 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1783 |
4359 | 1784 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1785 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1786 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1787 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1788 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
|
1789 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1790 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1791 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1792 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1793 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
|
1794 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1795 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1796 |
8105 | 1797 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1798 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1799 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1800 0, NULL); |
8677 | 1801 /* this is mainly just a hack so the formatting at the |
1802 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1803 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1804 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1805 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1806 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1807 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1808 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1809 } |
4359 | 1810 } |
1811 | |
8105 | 1812 return TRUE; |
4359 | 1813 break; |
8105 | 1814 |
8108 | 1815 case GDK_Page_Down: |
8143 | 1816 case ']': |
11581 | 1817 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1818 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1819 else |
11581 | 1820 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1821 return TRUE; |
1822 break; | |
1823 | |
8108 | 1824 case GDK_Page_Up: |
8143 | 1825 case '[': |
11581 | 1826 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1827 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1828 else |
11581 | 1829 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1830 return TRUE; |
1831 break; | |
1832 | |
8108 | 1833 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1834 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1835 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1836 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1837 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1838 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1839 } |
8108 | 1840 |
1841 return TRUE; | |
1842 break; | |
1843 | |
11252 | 1844 case GDK_comma: |
11581 | 1845 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1846 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1847 curconv - 1); |
1848 break; | |
1849 | |
1850 case GDK_period: | |
11581 | 1851 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1852 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1853 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1854 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1855 #else |
1856 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1857 #endif | |
11252 | 1858 break; |
1859 | |
8105 | 1860 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1861 } |
8758 | 1862 |
8105 | 1863 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1864 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1865 { |
10864 | 1866 if (event->keyval > '0' && event->keyval <= '9') |
1867 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1868 guint switchto = event->keyval - '1'; |
11581 | 1869 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1870 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1871 |
1872 return TRUE; | |
1873 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1874 } |
8758 | 1875 |
8105 | 1876 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1877 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1878 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1879 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1880 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1881 case GDK_Tab: |
9605 | 1882 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1883 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1884 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1885 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1886 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1887 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1888 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1889 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1890 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1891 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1892 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1893 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1894 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1895 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1896 } |
4359 | 1897 return FALSE; |
1898 } | |
1899 | |
1900 /* | |
1901 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1902 * 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
|
1903 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1904 * 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
|
1905 * going all the way down to the notebook. I suspect a bug in |
4359 | 1906 * GtkTextView, but I'm not ready to point any fingers yet. |
1907 */ | |
1908 static gboolean | |
1909 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1910 { | |
1911 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1912 /* Right single click */ | |
1913 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1914 | |
1915 return TRUE; | |
1916 } | |
1917 | |
1918 return FALSE; | |
1919 } | |
1920 | |
8173 | 1921 /* |
1922 * If someone tries to type into the conversation backlog of a | |
1923 * conversation window then we yank focus from the conversation backlog | |
1924 * and give it to the text entry box so that people can type | |
1925 * all the live long day and it will get entered into the entry box. | |
1926 */ | |
6057 | 1927 static gboolean |
8105 | 1928 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1929 { |
1930 GaimGtkConversation *gtkconv = data; | |
1931 | |
8237 | 1932 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1933 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1934 (event->keyval == GDK_F10) || |
1935 (event->keyval == GDK_Shift_L) || | |
1936 (event->keyval == GDK_Shift_R) || | |
1937 (event->keyval == GDK_Escape) || | |
8177 | 1938 (event->keyval == GDK_Up) || |
1939 (event->keyval == GDK_Down) || | |
1940 (event->keyval == GDK_Left) || | |
8191 | 1941 (event->keyval == GDK_Right) || |
1942 (event->keyval == GDK_Home) || | |
9297 | 1943 (event->keyval == GDK_End) || |
1944 (event->keyval == GDK_Tab) || | |
1945 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1946 return FALSE; |
1947 | |
1948 if (event->type == GDK_KEY_RELEASE) | |
1949 gtk_widget_grab_focus(gtkconv->entry); | |
1950 | |
1951 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1952 | |
1953 return TRUE; | |
6057 | 1954 } |
1955 | |
4359 | 1956 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1957 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1958 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1959 GaimGtkConversation *gtkconv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1960 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1961 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1962 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1963 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1964 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1965 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1966 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1967 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1968 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1969 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1970 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1971 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1972 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1973 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1974 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1975 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1976 void |
11604 | 1977 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1978 { | |
1979 GaimGtkConversation *gtkconv; | |
1980 | |
1981 g_return_if_fail(conv != NULL); | |
1982 | |
1983 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1984 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1985 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1986 |
1987 gray_stuff_out(gtkconv); | |
1988 update_typing_icon(gtkconv); | |
1989 | |
1990 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
1991 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
1992 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
1993 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 1994 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
1995 gaim_account_get_protocol_name(conv->account)); | |
1996 } | |
1997 | |
1998 static void | |
4673 | 1999 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 2000 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2001 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 2002 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2003 GaimConversation *conv; |
4359 | 2004 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2005 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2006 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2007 |
11594 | 2008 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2009 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2010 } |
2011 | |
2012 static void | |
2013 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2014 gchar *new_text, gint new_text_length, gpointer user_data) | |
2015 { | |
10810 | 2016 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2017 GaimConversation *conv; | |
2018 | |
2019 g_return_if_fail(gtkconv != NULL); | |
11508 | 2020 |
10810 | 2021 conv = gtkconv->active_conv; |
4359 | 2022 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2023 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2024 return; |
2025 | |
10810 | 2026 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2027 gtk_text_iter_is_end(position))); | |
4359 | 2028 } |
2029 | |
2030 static void | |
2031 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2032 GtkTextIter *end_pos, gpointer user_data) | |
2033 { | |
10810 | 2034 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2035 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2036 GaimConvIm *im; |
4359 | 2037 |
10810 | 2038 g_return_if_fail(gtkconv != NULL); |
11508 | 2039 |
10810 | 2040 conv = gtkconv->active_conv; |
4359 | 2041 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2042 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2043 return; |
2044 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2045 im = GAIM_CONV_IM(conv); |
4359 | 2046 |
2047 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2048 | |
2049 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2050 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2051 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2052 |
2053 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2054 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2055 GAIM_NOT_TYPING); |
4359 | 2056 } |
2057 else { | |
2058 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2059 got_typing_keypress(gtkconv, FALSE); |
4359 | 2060 } |
2061 } | |
2062 | |
8189 | 2063 /************************************************************************** |
2064 * A bunch of buddy icon functions | |
2065 **************************************************************************/ | |
11581 | 2066 GdkPixbuf * |
2067 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2068 { |
10116 | 2069 GaimAccount *account = NULL; |
2070 const char *name = NULL; | |
7143 | 2071 GdkPixbuf *status = NULL; |
2072 | |
10116 | 2073 g_return_val_if_fail(conv != NULL, NULL); |
2074 | |
2075 account = gaim_conversation_get_account(conv); | |
2076 name = gaim_conversation_get_name(conv); | |
2077 | |
2078 g_return_val_if_fail(account != NULL, NULL); | |
2079 g_return_val_if_fail(name != NULL, NULL); | |
2080 | |
11338 | 2081 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2082 GaimBuddy *b = gaim_find_buddy(account, name); |
2083 if (b != NULL) { | |
2084 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2085 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2086 } |
2087 } | |
2088 | |
2089 if (!status) { | |
2090 GdkPixbuf *pixbuf; | |
10884 | 2091 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2092 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2093 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2094 { |
7143 | 2095 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2096 GDK_INTERP_BILINEAR); | |
2097 g_object_unref(pixbuf); | |
2098 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2099 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2100 status = pixbuf; |
7143 | 2101 } |
2102 return status; | |
2103 } | |
2104 | |
8189 | 2105 static void |
2106 update_tab_icon(GaimConversation *conv) | |
2107 { | |
2108 GaimGtkConversation *gtkconv; | |
11581 | 2109 GaimGtkWindow *win; |
8189 | 2110 GaimAccount *account; |
2111 const char *name; | |
2112 GdkPixbuf *status = NULL; | |
2113 | |
10116 | 2114 g_return_if_fail(conv != NULL); |
2115 | |
8189 | 2116 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2117 win = gtkconv->win; |
8189 | 2118 name = gaim_conversation_get_name(conv); |
2119 account = gaim_conversation_get_account(conv); | |
2120 | |
11581 | 2121 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2122 |
10116 | 2123 g_return_if_fail(status != NULL); |
2124 | |
8189 | 2125 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2126 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2127 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2128 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2129 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2130 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2131 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2132 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2133 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2134 { |
11581 | 2135 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2136 | |
2137 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2138 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2139 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2140 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2141 } |
8189 | 2142 } |
2143 | |
2144 static gboolean | |
2145 redraw_icon(gpointer data) | |
2146 { | |
10810 | 2147 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2148 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2149 GaimAccount *account; |
2150 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2151 |
2152 GdkPixbuf *buf; | |
2153 GdkPixbuf *scale; | |
2154 GdkPixmap *pm; | |
2155 GdkBitmap *bm; | |
2156 gint delay; | |
9318 | 2157 int scale_width, scale_height; |
8189 | 2158 |
2159 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2160 account = gaim_conversation_get_account(conv); |
2161 if(account && account->gc) | |
2162 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2163 |
2164 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2165 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2166 | |
10483 | 2167 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2168 NULL, &scale_width, &scale_height); |
2169 | |
2170 /* this code is ugly, and scares me */ | |
8189 | 2171 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2172 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2173 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2174 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2175 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2176 GDK_INTERP_BILINEAR); |
8189 | 2177 |
2178 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2179 g_object_unref(G_OBJECT(scale)); | |
2180 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2181 g_object_unref(G_OBJECT(pm)); | |
2182 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2183 | |
2184 if (bm) | |
2185 g_object_unref(G_OBJECT(bm)); | |
2186 | |
9131 | 2187 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2188 |
2189 if (delay < 100) | |
9131 | 2190 delay = 100; |
2191 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2192 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2193 |
2194 return FALSE; | |
2195 } | |
2196 | |
2197 static void | |
10810 | 2198 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2199 { |
2200 int delay; | |
2201 | |
8228 | 2202 if (gtkconv->u.im->anim == NULL) |
2203 return; | |
2204 | |
8202 | 2205 if (gtkconv->u.im->icon_timer != 0) |
2206 return; | |
2207 | |
8189 | 2208 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2209 return; | |
2210 | |
10639 | 2211 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2212 | |
2213 if (delay < 100) | |
2214 delay = 100; | |
2215 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2216 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2217 } |
2218 | |
2219 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2220 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2221 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2222 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2223 GaimGtkWindow *gtkwin; |
2224 | |
2225 g_return_if_fail(conv != NULL); | |
2226 | |
9887 | 2227 if (gtkconv->u.im->icon_container != NULL) |
2228 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2229 |
2230 if (gtkconv->u.im->anim != NULL) | |
2231 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2232 | |
2233 if (gtkconv->u.im->icon_timer != 0) | |
2234 g_source_remove(gtkconv->u.im->icon_timer); | |
2235 | |
2236 if (gtkconv->u.im->iter != NULL) | |
2237 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2238 | |
2239 gtkconv->u.im->icon_timer = 0; | |
2240 gtkconv->u.im->icon = NULL; | |
2241 gtkconv->u.im->anim = NULL; | |
2242 gtkconv->u.im->iter = NULL; | |
10456 | 2243 gtkconv->u.im->icon_container = NULL; |
9687 | 2244 gtkconv->u.im->show_icon = FALSE; |
10456 | 2245 |
11581 | 2246 gtkwin = gtkconv->win; |
10456 | 2247 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2248 } |
2249 | |
9497 | 2250 static void |
9504 | 2251 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2252 { |
10810 | 2253 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2254 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2255 FILE *fp; |
2256 GaimBuddyIcon *icon; | |
2257 const void *data; | |
2258 size_t len; | |
2259 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2260 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2261 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2262 return; |
2263 } | |
2264 | |
2265 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2266 data = gaim_buddy_icon_get_data(icon, &len); | |
2267 | |
2268 if ((len <= 0) || (data == NULL)) { | |
9504 | 2269 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2270 return; |
2271 } | |
2272 | |
2273 fwrite(data, 1, len, fp); | |
2274 fclose(fp); | |
2275 } | |
2276 | |
2277 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2278 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2279 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2280 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2281 const gchar *ext; |
9497 | 2282 gchar *buf; |
2283 | |
2284 g_return_if_fail(conv != NULL); | |
9504 | 2285 |
10953 | 2286 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2287 if (ext == NULL) | |
2288 ext = "icon"; | |
2289 | |
2290 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2291 |
2292 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2293 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2294 |
2295 g_free(buf); | |
2296 } | |
2297 | |
11581 | 2298 static void |
2299 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2300 { | |
2301 if (gtkconv->u.im->icon_timer != 0) | |
2302 g_source_remove(gtkconv->u.im->icon_timer); | |
2303 | |
2304 gtkconv->u.im->icon_timer = 0; | |
2305 } | |
2306 | |
2307 | |
2308 static void | |
2309 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2310 { | |
2311 gtkconv->u.im->animate = | |
2312 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2313 | |
2314 if (gtkconv->u.im->animate) | |
2315 start_anim(NULL, gtkconv); | |
2316 else | |
2317 stop_anim(NULL, gtkconv); | |
2318 } | |
2319 | |
8189 | 2320 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2321 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2322 { |
2323 static GtkWidget *menu = NULL; | |
2324 GtkWidget *button; | |
2325 | |
2326 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2327 return FALSE; | |
2328 | |
2329 /* | |
2330 * If a menu already exists, destroy it before creating a new one, | |
2331 * thus freeing-up the memory it occupied. | |
2332 */ | |
2333 if (menu != NULL) | |
2334 gtk_widget_destroy(menu); | |
2335 | |
2336 menu = gtk_menu_new(); | |
2337 | |
2338 if (gtkconv->u.im->anim && | |
2339 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2340 { | |
2341 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2342 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2343 gtkconv->u.im->icon_timer); |
2344 } | |
2345 | |
2346 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2347 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2348 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2349 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2350 gtk_widget_show(button); | |
2351 | |
2352 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
|
2353 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2354 0, 0, NULL); |
2355 | |
2356 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2357 | |
2358 return TRUE; | |
2359 } | |
10456 | 2360 |
2361 static void | |
2362 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2363 { | |
11581 | 2364 GaimGtkWindow *win = data; |
10456 | 2365 GaimConversation *conv; |
2366 GaimGtkConversation *gtkconv; | |
2367 gboolean active; | |
2368 | |
11581 | 2369 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2370 |
2371 if (!conv) | |
2372 return; | |
2373 | |
11338 | 2374 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2375 |
2376 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2377 | |
2378 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2379 gtkconv->u.im->show_icon = active; | |
2380 if (active) | |
2381 gaim_gtkconv_update_buddy_icon(conv); | |
2382 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2383 remove_icon(gtkconv); |
10456 | 2384 } |
2385 | |
8189 | 2386 /************************************************************************** |
2387 * End of the bunch of buddy icon functions | |
2388 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2389 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2390 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2391 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2392 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2393 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2394 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2395 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2396 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2397 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2398 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2399 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2400 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2401 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2402 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2403 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2404 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2405 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2406 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2407 GaimUnseenState min_state) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2408 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2409 GList *l; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2410 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2411 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2412 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2413 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2414 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2415 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2416 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2417 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2418 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2419 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2420 GaimConversation *conv = (GaimConversation*)l->data; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2421 if (GAIM_GTK_CONVERSATION(conv)->unseen_state >= min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2422 return conv; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2423 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2424 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2425 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2426 } |
8189 | 2427 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2428 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2429 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2430 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2431 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2432 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2433 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2434 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2435 guint |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2436 gaim_gtk_conversations_fill_unseen_menu(GtkWidget *menu, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2437 GaimConversationType type, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2438 GaimUnseenState min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2439 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2440 GList *l; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2441 guint ret = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2442 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2443 g_return_val_if_fail(menu != NULL, 0); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2444 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2445 if (type == GAIM_CONV_TYPE_IM) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2446 l = gaim_get_ims(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2447 } else if (type == GAIM_CONV_TYPE_CHAT) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2448 l = gaim_get_chats(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2449 } else { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2450 l = gaim_get_conversations(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2451 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2452 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2453 for (; l != NULL ; l = l->next) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2454 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2455 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2456 |
12239 | 2457 if (gtkconv->unseen_state >= min_state && gtkconv->win == hidden_convwin) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2458 GtkWidget *icon = gtk_image_new(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2459 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2460 GtkWidget *item; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2461 gchar *text = g_strdup_printf("%s (%d)", |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2462 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2463 gtkconv->unseen_count); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2464 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2465 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2466 g_object_unref(pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2467 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2468 item = gtk_image_menu_item_new_with_label(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2469 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), icon); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2470 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(unseen_conv_menu_cb), conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2471 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2472 g_free(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2473 ret++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2474 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2475 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2476 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2477 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2478 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2479 |
11581 | 2480 GaimGtkWindow * |
2481 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2482 { | |
2483 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2484 return gtkconv->win; | |
2485 } | |
2486 | |
2487 static GtkItemFactoryEntry menu_items[] = | |
2488 { | |
2489 /* Conversation menu */ | |
2490 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2491 | |
2492 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2493 0, "<StockItem>", GAIM_STOCK_IM }, | |
2494 | |
2495 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2496 | |
2497 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2498 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2499 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2500 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2501 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12240 | 2502 { N_("/Conversation/Clea_r"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2503 |
2504 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2505 | |
2506 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2507 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2508 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2509 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2510 "<StockItem>", GAIM_STOCK_INFO }, | |
2511 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2512 "<StockItem>", GAIM_STOCK_INVITE }, | |
2513 | |
2514 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2515 | |
2516 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2517 "<StockItem>", GAIM_STOCK_EDIT }, | |
2518 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2519 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2520 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2521 "<StockItem>", GTK_STOCK_ADD }, | |
2522 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2523 "<StockItem>", GTK_STOCK_REMOVE }, | |
2524 | |
2525 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2526 | |
2527 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2528 "<StockItem>", GAIM_STOCK_LINK }, | |
2529 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2530 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2531 | |
2532 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2533 | |
2534 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2535 "<StockItem>", GTK_STOCK_CLOSE }, | |
2536 | |
2537 /* Options */ | |
2538 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2539 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2540 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2541 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2542 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2543 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2544 }; | |
2545 | |
2546 static const int menu_item_count = | |
2547 sizeof(menu_items) / sizeof(*menu_items); | |
2548 | |
2549 static char * | |
2550 item_factory_translate_func (const char *path, gpointer func_data) | |
2551 { | |
2552 return _((char *)path); | |
2553 } | |
2554 | |
2555 static GtkWidget * | |
2556 setup_menubar(GaimGtkWindow *win) | |
2557 { | |
2558 GtkAccelGroup *accel_group; | |
2559 | |
2560 accel_group = gtk_accel_group_new (); | |
2561 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2562 g_object_unref(accel_group); | |
2563 | |
2564 win->menu.item_factory = | |
2565 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2566 | |
2567 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2568 item_factory_translate_func, | |
2569 NULL, NULL); | |
2570 | |
2571 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2572 menu_items, win); | |
2573 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2574 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2575 | |
2576 | |
2577 win->menu.menubar = | |
2578 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2579 | |
2580 | |
2581 win->menu.view_log = | |
2582 gtk_item_factory_get_widget(win->menu.item_factory, | |
2583 N_("/Conversation/View Log")); | |
2584 | |
2585 /* --- */ | |
2586 | |
2587 win->menu.send_file = | |
2588 gtk_item_factory_get_widget(win->menu.item_factory, | |
2589 N_("/Conversation/Send File...")); | |
2590 | |
2591 win->menu.add_pounce = | |
2592 gtk_item_factory_get_widget(win->menu.item_factory, | |
2593 N_("/Conversation/Add Buddy Pounce...")); | |
2594 | |
2595 /* --- */ | |
2596 | |
2597 win->menu.get_info = | |
2598 gtk_item_factory_get_widget(win->menu.item_factory, | |
2599 N_("/Conversation/Get Info")); | |
2600 | |
2601 win->menu.invite = | |
2602 gtk_item_factory_get_widget(win->menu.item_factory, | |
2603 N_("/Conversation/Invite...")); | |
2604 | |
2605 /* --- */ | |
2606 | |
2607 win->menu.alias = | |
2608 gtk_item_factory_get_widget(win->menu.item_factory, | |
2609 N_("/Conversation/Alias...")); | |
2610 | |
2611 win->menu.block = | |
2612 gtk_item_factory_get_widget(win->menu.item_factory, | |
2613 N_("/Conversation/Block...")); | |
2614 | |
2615 win->menu.add = | |
2616 gtk_item_factory_get_widget(win->menu.item_factory, | |
2617 N_("/Conversation/Add...")); | |
2618 | |
2619 win->menu.remove = | |
2620 gtk_item_factory_get_widget(win->menu.item_factory, | |
2621 N_("/Conversation/Remove...")); | |
2622 | |
2623 /* --- */ | |
2624 | |
2625 win->menu.insert_link = | |
2626 gtk_item_factory_get_widget(win->menu.item_factory, | |
2627 N_("/Conversation/Insert Link...")); | |
2628 | |
2629 win->menu.insert_image = | |
2630 gtk_item_factory_get_widget(win->menu.item_factory, | |
2631 N_("/Conversation/Insert Image...")); | |
2632 | |
2633 /* --- */ | |
2634 | |
2635 win->menu.logging = | |
2636 gtk_item_factory_get_widget(win->menu.item_factory, | |
2637 N_("/Options/Enable Logging")); | |
2638 win->menu.sounds = | |
2639 gtk_item_factory_get_widget(win->menu.item_factory, | |
2640 N_("/Options/Enable Sounds")); | |
2641 win->menu.show_formatting_toolbar = | |
2642 gtk_item_factory_get_widget(win->menu.item_factory, | |
2643 N_("/Options/Show Formatting Toolbars")); | |
2644 win->menu.show_timestamps = | |
2645 gtk_item_factory_get_widget(win->menu.item_factory, | |
2646 N_("/Options/Show Timestamps")); | |
2647 win->menu.show_icon = | |
2648 gtk_item_factory_get_widget(win->menu.item_factory, | |
2649 N_("/Options/Show Buddy Icon")); | |
2650 | |
2651 | |
2652 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2653 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2654 win->menu.tray); | |
2655 gtk_widget_show(win->menu.tray); | |
2656 | |
2657 gtk_widget_show(win->menu.menubar); | |
2658 | |
2659 return win->menu.menubar; | |
2660 } | |
2661 | |
4359 | 2662 |
2663 /************************************************************************** | |
2664 * Utility functions | |
2665 **************************************************************************/ | |
2666 | |
2667 static void | |
10810 | 2668 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2669 { |
10810 | 2670 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2671 GaimConvIm *im; |
4685 | 2672 |
4359 | 2673 /* |
2674 * 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
|
2675 * send GAIM_TYPED any time soon. |
4359 | 2676 */ |
2677 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2678 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2679 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2680 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2681 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2682 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2683 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2684 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2685 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2686 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2687 |
2688 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2689 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2690 GAIM_TYPING); |
4359 | 2691 |
2692 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2693 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2694 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2695 gaim_conv_im_set_type_again(im, 0); |
4359 | 2696 } |
2697 } | |
2698 | |
4736 | 2699 static void |
10810 | 2700 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2701 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2702 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2703 GaimConvIm *im = NULL; |
10810 | 2704 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2705 char *stock_id, *tooltip; |
11508 | 2706 |
11581 | 2707 gtkwin = gtkconv->win; |
4736 | 2708 |
12008 | 2709 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2710 im = GAIM_CONV_IM(conv); |
4736 | 2711 |
12008 | 2712 if (gtkwin->menu.typing_icon) { |
2713 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2714 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2715 |
12008 | 2716 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2717 return; | |
2718 | |
2719 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2720 stock_id = GAIM_STOCK_TYPING; | |
2721 tooltip = _("User is typing..."); | |
2722 } else { | |
2723 stock_id = GAIM_STOCK_TYPED; | |
2724 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2725 } |
12008 | 2726 |
2727 if (gtkwin->menu.typing_icon == NULL) | |
2728 { | |
2729 gtkwin->menu.typing_icon = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_MENU); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2730 gaim_gtk_menu_tray_append(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), |
11908
34ea75bdd0c9
[gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents:
11869
diff
changeset
|
2731 gtkwin->menu.typing_icon, |
12008 | 2732 tooltip); |
4736 | 2733 } |
12008 | 2734 else |
2735 { | |
2736 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2737 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2738 gtkwin->menu.typing_icon, | |
2739 tooltip); | |
2740 } | |
2741 | |
2742 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2743 } |
2744 | |
4685 | 2745 static gboolean |
11594 | 2746 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2747 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2748 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2749 GaimConversation *conv; |
4359 | 2750 GtkWidget *menu; |
2751 GList *child; | |
11594 | 2752 GaimBuddy *b; |
11581 | 2753 |
2754 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2755 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2756 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2757 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2758 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2759 account = gaim_conversation_get_account(conv); |
11581 | 2760 |
11594 | 2761 if (win->menu.send_to == NULL) |
4685 | 2762 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2763 |
11594 | 2764 if (!(b = gaim_find_buddy(account, conv->name))) |
2765 return FALSE; | |
2766 | |
2767 | |
2768 gtk_widget_show(win->menu.send_to); | |
4359 | 2769 |
2770 menu = gtk_menu_item_get_submenu( | |
11594 | 2771 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2772 |
2773 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2774 child != NULL; | |
2775 child = child->next) { | |
2776 | |
2777 GtkWidget *item = child->data; | |
11594 | 2778 GaimBuddy *item_buddy; |
2779 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2780 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2781 "gaim_buddy_name"); | |
2782 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2783 | |
2784 if (b == item_buddy) { | |
4359 | 2785 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2786 break; | |
2787 } | |
2788 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2789 |
4685 | 2790 return FALSE; |
4359 | 2791 } |
2792 | |
2793 static void | |
11594 | 2794 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2795 { | |
2796 GaimAccount *account; | |
2797 GtkWidget *box; | |
2798 GtkWidget *label; | |
2799 GtkWidget *image; | |
2800 GtkWidget *menuitem; | |
11625 | 2801 GdkPixbuf *pixbuf; |
11616 | 2802 gchar *text; |
11594 | 2803 |
2804 account = bud->account; | |
2805 | |
2806 /* Create a pixmap for the protocol icon. */ | |
11625 | 2807 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2808 /* Now convert it to GtkImage */ |
2809 if (pixbuf == NULL) | |
2810 image = gtk_image_new(); | |
2811 else | |
11625 | 2812 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2813 |
2814 gtk_size_group_add_widget(sg, image); | |
2815 | |
2816 g_object_unref(G_OBJECT(pixbuf)); | |
2817 | |
2818 /* Make our menu item */ | |
11616 | 2819 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2820 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2821 g_free(text); | |
11594 | 2822 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2823 | |
2824 /* Do some evil, see some evil, speak some evil. */ | |
2825 box = gtk_hbox_new(FALSE, 0); | |
2826 | |
2827 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2828 g_object_ref(label); | |
2829 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2830 | |
2831 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2832 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2833 | |
2834 g_object_unref(label); | |
2835 | |
2836 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2837 | |
2838 gtk_widget_show(label); | |
2839 gtk_widget_show(image); | |
2840 gtk_widget_show(box); | |
2841 | |
2842 /* Set our data and callbacks. */ | |
2843 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2844 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2845 | |
2846 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2847 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2848 | |
2849 gtk_widget_show(menuitem); | |
2850 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2851 } | |
2852 | |
2853 static void | |
2854 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2855 { |
4359 | 2856 GtkWidget *menu; |
2857 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2858 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2859 GaimGtkConversation *gtkconv; |
2860 GSList *l, *buds; | |
2861 | |
2862 g_return_if_fail(win != NULL); | |
2863 | |
2864 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2865 | |
11604 | 2866 g_return_if_fail(gtkconv != NULL); |
2867 | |
11594 | 2868 if (win->menu.send_to != NULL) |
2869 gtk_widget_destroy(win->menu.send_to); | |
2870 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
2871 /* Build the Send To menu */ |
11594 | 2872 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2873 gtk_widget_show(win->menu.send_to); | |
4359 | 2874 |
2875 menu = gtk_menu_new(); | |
11581 | 2876 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2877 win->menu.send_to, 2); |
2878 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2879 |
2880 gtk_widget_show(menu); | |
2881 | |
11604 | 2882 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2883 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2884 for (l = buds; l != NULL; l = l->next) { | |
2885 GaimBuddy *b; | |
2886 GaimBlistNode *node; | |
2887 | |
2888 b = l->data; | |
2889 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2890 | |
2891 for (node = node->child; node != NULL; node = node->next) | |
2892 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2893 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2894 } | |
2895 | |
2896 g_slist_free(buds); | |
4359 | 2897 } |
2898 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2899 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2900 |
11594 | 2901 gtk_widget_show(win->menu.send_to); |
2902 if (!group) | |
2903 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2904 update_send_to_selection(win); | |
4359 | 2905 } |
2906 | |
2907 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2908 generate_invite_user_names(GaimConnection *gc) |
4359 | 2909 { |
6695 | 2910 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2911 static GList *tmp = NULL; |
2912 | |
2913 if (tmp) | |
2914 g_list_free(tmp); | |
2915 | |
2916 tmp = g_list_append(NULL, ""); | |
2917 | |
2918 if (gc != NULL) { | |
4785 | 2919 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2920 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2921 continue; | |
6695 | 2922 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2923 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2924 continue; |
6695 | 2925 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2926 GaimBuddy *buddy; | |
2927 | |
2928 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2929 continue; | |
2930 | |
2931 buddy = (GaimBuddy *)bnode; | |
2932 | |
2933 if (buddy->account == gc->account && | |
2934 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2935 tmp = g_list_insert_sorted(tmp, buddy->name, |
2936 (GCompareFunc)g_utf8_collate); | |
6695 | 2937 } |
4359 | 2938 } |
2939 } | |
2940 } | |
2941 | |
2942 return tmp; | |
2943 } | |
2944 | |
9498 | 2945 static GdkPixbuf * |
9554 | 2946 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2947 { |
9554 | 2948 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2949 char *filename; |
10274 | 2950 const char *image = NULL; |
9554 | 2951 |
2952 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2953 image = "founder.png"; |
9554 | 2954 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2955 image = "op.png"; |
9554 | 2956 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2957 image = "halfop.png"; |
9554 | 2958 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2959 image = "voice.png"; |
9554 | 2960 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2961 image = "ignored.png"; |
2962 } else { | |
2963 return NULL; | |
9554 | 2964 } |
10274 | 2965 |
2966 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2967 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2968 g_free(filename); | |
2969 | |
2970 if (!pixbuf) | |
2971 return NULL; | |
2972 | |
2973 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2974 g_object_unref(pixbuf); | |
2975 | |
2976 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2977 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2978 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2979 g_free(filename); | |
10274 | 2980 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2981 g_object_unref(pixbuf); |
10274 | 2982 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2983 g_object_unref(scale2); | |
9498 | 2984 } |
2985 | |
10274 | 2986 return scale; |
9498 | 2987 } |
2988 | |
4359 | 2989 static void |
11869 | 2990 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 2991 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2992 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2993 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2994 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2995 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2996 GaimPluginProtocolInfo *prpl_info; |
4359 | 2997 GtkListStore *ls; |
9498 | 2998 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2999 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3000 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3001 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3002 GdkColor send_color; |
11508 | 3003 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3004 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 3005 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3006 chat = GAIM_CONV_CHAT(conv); |
4359 | 3007 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3008 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3009 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3010 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3011 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3012 return; |
4359 | 3013 |
3014 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3015 | |
9554 | 3016 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3017 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3018 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
|
3019 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3020 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3021 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3022 |
4359 | 3023 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3024 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3025 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3026 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3027 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3028 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3029 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
|
3030 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3031 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3032 |
9554 | 3033 if (pixbuf) |
3034 g_object_unref(pixbuf); | |
4359 | 3035 } |
3036 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3037 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3038 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
|
3039 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3040 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3041 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3042 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3043 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3044 return; |
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 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3047 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3048 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3049 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3050 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3051 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3052 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3053 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3054 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3055 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3056 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3057 char *tmp = g_strdup(name); |
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 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3060 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3061 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3062 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 (*most_matched)--; |
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 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3066 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3067 g_free(tmp); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3070 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3071 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3072 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3073 |
9605 | 3074 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3075 tab_complete(GaimConversation *conv) |
4359 | 3076 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3077 GaimGtkConversation *gtkconv; |
4359 | 3078 GtkTextIter cursor, word_start, start_buffer; |
3079 int start; | |
3080 int most_matched = -1; | |
3081 char *entered, *partial = NULL; | |
3082 char *text; | |
8021 | 3083 char *nick_partial; |
9605 | 3084 const char *prefix; |
4359 | 3085 GList *matches = NULL; |
9605 | 3086 gboolean command = FALSE; |
4359 | 3087 |
3088 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3089 | |
3090 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3091 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3092 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3093 | |
3094 word_start = cursor; | |
3095 | |
3096 /* if there's nothing there just return */ | |
3097 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3098 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
|
3099 |
4359 | 3100 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3101 &cursor, FALSE); | |
3102 | |
3103 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3104 start = strlen(text) - 1; | |
3105 | |
8021 | 3106 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3107 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3108 start-=2; |
3109 } | |
4359 | 3110 |
3111 /* find the start of the word that we're tabbing */ | |
3112 while (start >= 0 && text[start] != ' ') { | |
3113 gtk_text_iter_backward_char(&word_start); | |
3114 start--; | |
3115 } | |
3116 | |
9605 | 3117 prefix = gaim_gtk_get_cmd_prefix(); |
3118 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3119 command = TRUE; | |
3120 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3121 } | |
3122 | |
4359 | 3123 g_free(text); |
3124 | |
3125 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3126 &cursor, FALSE); | |
3127 | |
8021 | 3128 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3129 g_free(entered); |
11338 | 3130 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3131 } |
3132 | |
8021 | 3133 nick_partial = g_malloc(strlen(entered)+1); |
3134 | |
9605 | 3135 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3136 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3137 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3138 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3139 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3140 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3141 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3142 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3143 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3144 g_list_free(list); |
11338 | 3145 } 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
|
3146 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3147 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3148 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
|
3149 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3150 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3151 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3152 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3153 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3154 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3155 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3156 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3157 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3158 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3159 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3160 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
|
3161 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3162 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3163 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3164 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3165 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3166 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3167 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3168 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3169 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3170 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3171 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3172 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3173 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3174 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3175 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3176 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3177 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3178 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3179 } |
9605 | 3180 } else { |
3181 g_free(nick_partial); | |
3182 g_free(entered); | |
3183 return FALSE; | |
3184 } | |
3185 | |
8021 | 3186 g_free(nick_partial); |
3187 | |
4359 | 3188 /* we're only here if we're doing new style */ |
3189 | |
3190 /* if there weren't any matches, return */ | |
3191 if (!matches) { | |
3192 /* if matches isn't set partials won't be either */ | |
3193 g_free(entered); | |
11338 | 3194 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3195 } |
3196 | |
3197 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3198 | |
3199 if (!matches->next) { | |
3200 /* there was only one match. fill it in. */ | |
3201 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3202 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3203 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3204 | |
3205 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3206 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3207 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3208 g_free(tmp); | |
3209 } | |
3210 else | |
3211 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3212 matches->data, -1); | |
3213 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3214 g_free(matches->data); |
4359 | 3215 matches = g_list_remove(matches, matches->data); |
3216 } | |
3217 else { | |
3218 /* | |
3219 * there were lots of matches, fill in as much as possible | |
3220 * and display all of them | |
3221 */ | |
3222 char *addthis = g_malloc0(1); | |
3223 | |
3224 while (matches) { | |
3225 char *tmp = addthis; | |
3226 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3227 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3228 g_free(matches->data); |
4359 | 3229 matches = g_list_remove(matches, matches->data); |
3230 } | |
3231 | |
6982 | 3232 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3233 time(NULL)); |
3234 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3235 g_free(addthis); | |
3236 } | |
3237 | |
3238 g_free(entered); | |
3239 g_free(partial); | |
9605 | 3240 |
3241 return TRUE; | |
4359 | 3242 } |
3243 | |
10810 | 3244 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3245 { |
3246 GaimPluginProtocolInfo *prpl_info = NULL; | |
3247 GaimConnection *gc; | |
10810 | 3248 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3249 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3250 char *new_topic; |
8858 | 3251 const char *current_topic; |
7971 | 3252 |
3253 gc = gaim_conversation_get_gc(conv); | |
3254 | |
3255 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3256 return; | |
3257 | |
3258 if(prpl_info->set_chat_topic == NULL) | |
3259 return; | |
3260 | |
3261 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3262 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3263 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3264 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3265 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3266 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3267 g_free(new_topic); |
7971 | 3268 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3269 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3270 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3271 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3272 |
8858 | 3273 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3274 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3275 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3276 g_free(new_topic); |
7971 | 3277 } |
3278 | |
9554 | 3279 static gint |
3280 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3281 { | |
3282 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3283 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3284 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3285 gint ret = 0; |
3286 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3287 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3291 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3292 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3293 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3294 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3295 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3296 -1); |
9554 | 3297 |
3298 if (user1 == NULL || user2 == NULL) { | |
3299 if (!(user1 == NULL && user2 == NULL)) | |
3300 ret = (user1 == NULL) ? -1: 1; | |
3301 } else if (f1 != f2) { | |
3302 /* sort more important users first */ | |
3303 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3305 ret = buddy1 ? -1 : 1; |
9554 | 3306 } else { |
10904 | 3307 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3308 } |
3309 | |
3310 g_free(user1); | |
3311 g_free(user2); | |
3312 | |
3313 return ret; | |
3314 } | |
3315 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 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
|
3318 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3320 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3323 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3324 int f; |
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 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 /* 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
|
3330 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
|
3331 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 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
|
3333 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 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
|
3341 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3344 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3346 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3347 /* This user is not me, so look into updating the alias. */ |
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 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 alias = gaim_buddy_get_contact_alias(buddy2); |
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 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3355 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3358 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3360 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3361 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3362 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3363 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3366 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3367 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3369 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3370 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
|
3371 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3372 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3373 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3374 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3375 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3376 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3377 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3378 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3379 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3380 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3381 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3382 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3383 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3384 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3385 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3386 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3387 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3388 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3389 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3390 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3391 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3392 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3393 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3394 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3395 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3396 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3397 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3398 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3399 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3400 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3401 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3402 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3403 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3404 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3406 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3407 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3408 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3409 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3410 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3411 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3412 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3413 /* Do nothing if the buddy does not belong to the conv's account */ |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3414 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3415 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3416 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3417 /* 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
|
3418 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
|
3419 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3420 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
|
3421 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3422 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3423 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3424 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3425 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3426 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3427 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3428 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
|
3429 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3430 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 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
|
3432 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3433 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3435 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3436 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3437 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3438 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3439 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3440 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3441 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3442 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3443 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3444 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3445 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3446 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3447 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3448 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3449 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3450 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3451 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3452 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3453 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3454 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3455 /* 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
|
3456 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3457 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3458 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3459 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3460 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3461 |
4359 | 3462 static GtkWidget * |
10810 | 3463 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3464 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3465 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3466 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3467 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3468 GaimConnection *gc; |
4359 | 3469 GtkWidget *vpaned, *hpaned; |
10175 | 3470 GtkWidget *vbox, *hbox, *frame; |
4359 | 3471 GtkWidget *lbox, *bbox; |
3472 GtkWidget *label; | |
3473 GtkWidget *list; | |
3474 GtkWidget *button; | |
7949 | 3475 GtkWidget *sw; |
4359 | 3476 GtkListStore *ls; |
3477 GtkCellRenderer *rend; | |
3478 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3479 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3480 GList *focus_chain = NULL; |
4359 | 3481 |
3482 gtkchat = gtkconv->u.chat; | |
3483 gc = gaim_conversation_get_gc(conv); | |
3484 | |
3485 /* Setup the outer pane. */ | |
3486 vpaned = gtk_vpaned_new(); | |
3487 gtk_widget_show(vpaned); | |
3488 | |
3489 /* Setup the top part of the pane. */ | |
11243 | 3490 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3491 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3492 gtk_widget_show(vbox); |
3493 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3494 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3495 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3496 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3497 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3498 { |
11243 | 3499 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3500 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3501 gtk_widget_show(hbox); |
3502 | |
3503 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3504 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3505 gtk_widget_show(label); |
3506 | |
3507 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3508 |
7971 | 3509 if(prpl_info->set_chat_topic == NULL) { |
3510 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3511 } else { | |
3512 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3513 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3514 } |
3515 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3516 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3517 gtk_widget_show(gtkchat->topic_text); |
3518 } | |
3519 | |
3520 /* Setup the horizontal pane. */ | |
3521 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3522 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3523 gtk_widget_show(hpaned); |
3524 | |
10175 | 3525 /* Setup gtkihmtml. */ |
3526 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3527 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3528 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3529 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3530 gtk_widget_show(frame); | |
3531 | |
3532 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3533 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3534 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3535 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3536 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3537 |
4359 | 3538 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3539 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3540 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3541 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3542 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3543 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3544 |
3545 /* Build the right pane. */ | |
11243 | 3546 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3547 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3548 gtk_widget_show(lbox); |
3549 | |
3550 /* Setup the label telling how many people are in the room. */ | |
3551 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3552 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3553 gtk_widget_show(gtkchat->count); | |
3554 | |
3555 /* Setup the list of users. */ | |
7949 | 3556 sw = gtk_scrolled_window_new(NULL, NULL); |
3557 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3558 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3559 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3560 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3561 gtk_widget_show(sw); | |
4359 | 3562 |
9554 | 3563 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
|
3564 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
|
3565 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3566 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3567 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3568 GTK_SORT_ASCENDING); |
3569 | |
3570 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3571 | |
9498 | 3572 rend = gtk_cell_renderer_pixbuf_new(); |
3573 | |
4359 | 3574 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3575 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3576 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3577 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3578 |
3579 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3580 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3581 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3582 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3583 |
9498 | 3584 rend = gtk_cell_renderer_text_new(); |
3585 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3586 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3587 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3588 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3589 NULL); |
4359 | 3590 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3591 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3592 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3593 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3594 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3595 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3596 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3597 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3598 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3599 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3600 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3601 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3602 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3603 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3604 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3605 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3606 #endif |
4359 | 3607 |
3608 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3609 | |
3610 gtk_widget_set_size_request(list, 150, -1); | |
3611 | |
3612 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3613 gtk_widget_show(list); | |
3614 | |
3615 gtkchat->list = list; | |
3616 | |
7949 | 3617 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3618 |
3619 /* Setup the user list toolbar. */ | |
11243 | 3620 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3621 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3622 gtk_widget_show(bbox); | |
3623 | |
3624 /* IM */ | |
10221 | 3625 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3626 GAIM_BUTTON_VERTICAL); |
10500 | 3627 gtkchat->userlist_im = button; |
4359 | 3628 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3629 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
|
3630 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3631 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3632 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3633 |
3634 gtk_widget_show(button); | |
3635 | |
3636 /* Ignore */ | |
3637 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3638 GAIM_BUTTON_VERTICAL); | |
10500 | 3639 gtkchat->userlist_ignore = button; |
4359 | 3640 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3641 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
|
3642 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3643 _("Ignore the user"), NULL); |
4359 | 3644 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3645 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3646 gtk_widget_show(button); |
3647 | |
3648 /* Info */ | |
3649 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3650 GAIM_BUTTON_VERTICAL); | |
10500 | 3651 gtkchat->userlist_info = button; |
4359 | 3652 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3653 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3654 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3655 _("Get the user's information"), NULL); |
4359 | 3656 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3657 G_CALLBACK(info_cb), gtkconv); |
4359 | 3658 |
3659 gtk_widget_show(button); | |
3660 | |
10175 | 3661 /* Setup the bottom half of the conversation window */ |
11243 | 3662 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3663 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3664 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3665 |
11243 | 3666 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3667 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3668 gtk_widget_show(gtkconv->lower_hbox); | |
3669 | |
11243 | 3670 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3671 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3672 gtk_widget_show(vbox); | |
3673 | |
10175 | 3674 /* Setup the toolbar, entry widget and all signals */ |
3675 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3676 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3677 gtk_widget_show(frame); |
3678 | |
9005 | 3679 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3680 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3681 gaim_account_get_protocol_name(conv->account)); |
10175 | 3682 gtk_widget_set_size_request(gtkconv->entry, -1, |
3683 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3684 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3685 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3686 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3687 |
3688 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3689 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3690 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3691 G_CALLBACK(send_cb), gtkconv); |
4359 | 3692 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3693 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3694 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3695 G_CALLBACK(size_allocate_cb), gtkconv); |
3696 | |
3697 default_formatize(gtkconv); | |
4359 | 3698 |
9080 | 3699 /* |
3700 * Focus for chat windows should be as follows: | |
3701 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3702 * user list buttons -> entry -> buttons at bottom | |
3703 */ | |
9332 | 3704 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3705 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3706 | |
4359 | 3707 return vpaned; |
3708 } | |
3709 | |
3710 static GtkWidget * | |
10810 | 3711 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3712 { |
10810 | 3713 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3714 GtkWidget *frame; |
4359 | 3715 GtkWidget *paned; |
10175 | 3716 GtkWidget *vbox; |
3717 GtkWidget *vbox2; | |
9080 | 3718 GList *focus_chain = NULL; |
4359 | 3719 |
10175 | 3720 /* Setup the outer pane */ |
4359 | 3721 paned = gtk_vpaned_new(); |
3722 gtk_widget_show(paned); | |
3723 | |
10175 | 3724 /* Setup the top part of the pane */ |
11243 | 3725 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3726 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3727 gtk_widget_show(vbox); |
3728 | |
10175 | 3729 /* Setup the gtkimhtml widget */ |
3730 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3731 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3732 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3733 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3734 gtk_widget_show(frame); | |
3735 | |
3736 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3737 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3738 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3739 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3740 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3741 |
3742 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3743 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3744 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3745 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3746 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3747 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3748 |
10175 | 3749 /* Setup the bottom half of the conversation window */ |
11243 | 3750 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3751 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3752 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3753 |
11243 | 3754 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3755 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3756 gtk_widget_show(gtkconv->lower_hbox); | |
3757 | |
11243 | 3758 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3759 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3760 gtk_widget_show(vbox2); | |
8821 | 3761 |
10175 | 3762 /* Setup the toolbar, entry widget and all signals */ |
3763 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3764 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3765 gtk_widget_show(frame); |
3766 | |
9005 | 3767 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3768 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3769 gaim_account_get_protocol_name(conv->account)); |
10175 | 3770 gtk_widget_set_size_request(gtkconv->entry, -1, |
3771 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3772 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3773 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3774 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
|
3775 |
4359 | 3776 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3777 G_CALLBACK(entry_key_press_cb), gtkconv); |
3778 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3779 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3780 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3781 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3782 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3783 |
3784 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3785 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3786 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3787 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3788 |
8481 | 3789 /* had to move this after the imtoolbar is attached so that the |
3790 * signals get fired to toggle the buttons on the toolbar as well. | |
3791 */ | |
10810 | 3792 default_formatize(gtkconv); |
4359 | 3793 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3794 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3795 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3796 |
8758 | 3797 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3798 gtkconv->u.im->show_icon = TRUE; |
4359 | 3799 |
9080 | 3800 /* |
3801 * Focus for IM windows should be as follows: | |
10356 | 3802 * Tab title -> conversation scrollback -> entry |
9080 | 3803 */ |
9332 | 3804 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3805 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3806 |
4359 | 3807 return paned; |
3808 } | |
3809 | |
3810 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3811 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3812 GtkSelectionData *sd, guint info, guint t, |
3813 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3814 { |
10810 | 3815 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3816 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3817 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3818 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3819 { |
4781 | 3820 GaimBlistNode *n = NULL; |
6695 | 3821 GaimBuddy *b; |
11581 | 3822 GaimGtkConversation *gtkconv = NULL; |
9622 | 3823 |
11812 | 3824 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3825 |
6695 | 3826 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3827 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3828 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3829 b = (GaimBuddy*)n; | |
3830 else | |
4781 | 3831 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3832 |
9622 | 3833 /* |
3834 * If we already have an open conversation with this buddy, then | |
3835 * just move the conv to this window. Otherwise, create a new | |
3836 * conv and add it to this window. | |
3837 */ | |
11338 | 3838 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3839 if (c != NULL) { |
11581 | 3840 GaimGtkWindow *oldwin; |
3841 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3842 oldwin = gtkconv->win; | |
9622 | 3843 if (oldwin != win) { |
11581 | 3844 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3845 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3846 } |
3847 } else { | |
11338 | 3848 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3849 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3850 if (gtkconv->win != win) |
3851 { | |
3852 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3853 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3854 } | |
9622 | 3855 } |
3856 | |
3857 /* Make this conversation the active conversation */ | |
11581 | 3858 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3859 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3860 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3861 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3862 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
|
3863 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3864 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3865 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3866 GaimAccount *account; |
11581 | 3867 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3868 |
11137 | 3869 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3870 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3871 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3872 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3873 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3874 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3875 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3876 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3877 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3878 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3879 { |
11338 | 3880 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3881 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3882 if (gtkconv->win != win) |
3883 { | |
3884 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3885 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3886 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3887 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3888 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3889 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3890 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3891 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3892 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3893 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3894 } |
9525 | 3895 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3896 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3897 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3898 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3899 } |
10145 | 3900 else |
3901 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3902 } |
4359 | 3903 |
3904 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3905 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3906 { |
10145 | 3907 GTK_IMHTML_DND_TARGETS, |
3908 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3909 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3910 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3911 |
10810 | 3912 static GaimGtkConversation * |
3913 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3914 { | |
3915 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3916 GaimContact *c; | |
3917 GaimBlistNode *cn; | |
10935 | 3918 |
10810 | 3919 if (!bud) |
3920 return NULL; | |
10935 | 3921 |
10810 | 3922 if (!(c = gaim_buddy_get_contact(bud))) |
3923 return NULL; | |
10935 | 3924 |
10810 | 3925 cn = (GaimBlistNode *)c; |
3926 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3927 GaimConversation *conv; | |
11338 | 3928 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3929 if (conv->ui_data) |
3930 return conv->ui_data; | |
3931 } | |
3932 } | |
10935 | 3933 |
10810 | 3934 return NULL; |
3935 } | |
3936 | |
11855 | 3937 static void |
3938 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3939 { | |
3940 GList *list; | |
3941 | |
3942 g_return_if_fail(bnode); | |
3943 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3944 | |
3945 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3946 { | |
3947 GaimGtkWindow *win = list->data; | |
3948 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3949 | |
3950 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3951 continue; | |
3952 | |
3953 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3954 } | |
3955 } | |
3956 | |
11581 | 3957 /************************************************************************** |
3958 * Conversation UI operations | |
3959 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
3960 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
3961 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 3962 { |
3963 GaimGtkConversation *gtkconv; | |
3964 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3965 GtkWidget *pane = NULL; |
3966 GtkWidget *tab_cont; | |
11581 | 3967 |
3968 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3969 conv->ui_data = gtkconv; |
3970 if (!g_list_find(gtkconv->convs, conv)) | |
3971 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3972 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3973 return; |
4359 | 3974 } |
3975 | |
11581 | 3976 gtkconv = g_new0(GaimGtkConversation, 1); |
3977 conv->ui_data = gtkconv; | |
3978 gtkconv->active_conv = conv; | |
3979 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3980 | |
3981 /* Setup some initial variables. */ | |
3982 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3983 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3984 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3985 gtkconv->unseen_count = 0; |
11581 | 3986 |
3987 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3988 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3989 | |
3990 pane = setup_im_pane(gtkconv); | |
3991 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3992 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3993 pane = setup_chat_pane(gtkconv); | |
3994 } | |
3995 | |
12101 | 3996 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
3997 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
3998 | |
11581 | 3999 if (pane == NULL) { |
4000 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
4001 g_free(gtkconv->u.chat); | |
4002 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4003 g_free(gtkconv->u.im); | |
4004 | |
4005 g_free(gtkconv); | |
4006 conv->ui_data = NULL; | |
4007 return; | |
10449 | 4008 } |
11581 | 4009 |
4010 /* Setup drag-and-drop */ | |
4011 gtk_drag_dest_set(pane, | |
4012 GTK_DEST_DEFAULT_MOTION | | |
4013 GTK_DEST_DEFAULT_DROP, | |
4014 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4015 GDK_ACTION_COPY); | |
4016 gtk_drag_dest_set(pane, | |
4017 GTK_DEST_DEFAULT_MOTION | | |
4018 GTK_DEST_DEFAULT_DROP, | |
4019 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4020 GDK_ACTION_COPY); | |
4021 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4022 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4023 GDK_ACTION_COPY); | |
4024 | |
4025 gtk_drag_dest_set(gtkconv->entry, 0, | |
4026 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4027 GDK_ACTION_COPY); | |
4028 | |
4029 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4030 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4031 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4032 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4033 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4034 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4035 | |
4036 /* Setup the container for the tab. */ | |
4037 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4038 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4039 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4040 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4041 gtk_widget_show(pane); | |
4042 | |
4043 gtkconv->make_sound = TRUE; | |
4044 | |
4045 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4046 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4047 else |
11581 | 4048 gtk_widget_hide(gtkconv->toolbar); |
4049 | |
12188 | 4050 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4051 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4052 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4053 gaim_account_get_protocol_name(conv->account)); |
11581 | 4054 |
4055 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4056 G_CALLBACK(gtk_widget_grab_focus), | |
4057 gtkconv->entry); | |
4058 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4059 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4060 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4061 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4062 gaim_gtkconv_placement_place(gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4063 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4064 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4065 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4066 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4067 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4068 private_gtkconv_new(conv, TRUE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4069 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4070 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4071 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4072 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4073 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4074 private_gtkconv_new(conv, FALSE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4075 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4076 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4077 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4078 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4079 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4080 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4081 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4082 if(conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4083 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4084 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4085 /* create hidden conv if hide_new pref is always */ |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4086 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always")==0) { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4087 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4088 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4089 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4090 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4091 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4092 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4093 /* create hidden conv if hide_new pref is away and account is away */ |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4094 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")==0 |
12310 | 4095 && !gaim_status_is_available(gaim_account_get_active_status(account))) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4096 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4097 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4098 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4099 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4100 } |
11581 | 4101 } |
4102 | |
4359 | 4103 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4104 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4105 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4106 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4107 |
10810 | 4108 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4109 /* Don't destroy ourselves until all our convos are gone */ | |
4110 if (gtkconv->convs) | |
4111 return; | |
11508 | 4112 |
11581 | 4113 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4114 | |
9504 | 4115 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4116 gaim_request_close_with_handle(conv); | |
4359 | 4117 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4118 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4119 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4120 |
11338 | 4121 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4122 if (gtkconv->u.im->icon_timer != 0) |
4123 g_source_remove(gtkconv->u.im->icon_timer); | |
4124 | |
4359 | 4125 if (gtkconv->u.im->anim != NULL) |
4793 | 4126 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4127 |
4128 g_free(gtkconv->u.im); | |
11581 | 4129 } 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
|
4130 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4131 g_free(gtkconv->u.chat); |
4132 } | |
4133 | |
4633 | 4134 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4135 | |
4359 | 4136 g_free(gtkconv); |
4137 } | |
4138 | |
4139 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4140 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4141 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4142 time_t mtime) |
4359 | 4143 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4144 GaimGtkConversation *gtkconv; |
4359 | 4145 |
4146 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4147 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4148 |
6982 | 4149 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4150 } |
4151 | |
4152 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4153 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4154 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4155 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4156 GaimGtkConversation *gtkconv; |
4359 | 4157 |
4158 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4159 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4160 |
10398 | 4161 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4162 |
6982 | 4163 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4164 } |
4165 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4166 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4167 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4168 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4169 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4170 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4171 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4172 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4173 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4174 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4175 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4176 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4177 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4178 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4179 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4180 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4181 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4182 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4183 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4184 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4185 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4186 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4187 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4188 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4189 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4190 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4191 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4192 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4193 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4194 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4195 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4196 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4197 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4198 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4199 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4200 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4201 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4202 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4203 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4204 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4205 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4206 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4207 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4208 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4209 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4210 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4211 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4212 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4213 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4214 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4215 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4216 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4217 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4218 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4219 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4220 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4221 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4222 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4223 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4224 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4225 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4226 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4227 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4228 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4229 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4230 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4231 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4232 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4233 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4234 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4235 buddytag = gtk_text_buffer_create_tag( |
11096 | 4236 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4237 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4238 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4239 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4240 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4241 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4242 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4243 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4244 |
4359 | 4245 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4246 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4247 const char *message, GaimMessageFlags flags, |
4359 | 4248 time_t mtime) |
4249 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4250 GaimGtkConversation *gtkconv; |
11581 | 4251 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4252 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4253 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4254 GaimPluginProtocolInfo *prpl_info; |
4359 | 4255 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4256 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4257 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4258 int line_count; |
4359 | 4259 char buf2[BUF_LONG]; |
4260 char mdate[64]; | |
4261 char color[10]; | |
4262 char *str; | |
4263 char *with_font_tag; | |
4896 | 4264 char *sml_attrib = NULL; |
6982 | 4265 size_t length = strlen(message) + 1; |
4895 | 4266 |
4359 | 4267 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4268 |
4269 /* Set the active conversation to the one that just messaged us. */ | |
4270 /* TODO: consider not doing this if the account is offline or something */ | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4271 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4272 |
4359 | 4273 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4274 account = gaim_conversation_get_account(conv); |
11581 | 4275 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4276 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4277 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4278 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4279 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4280 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4281 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4282 /* 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
|
4283 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4284 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4285 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4286 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4287 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4288 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4289 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4290 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4291 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4292 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4293 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4294 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4295 |
8677 | 4296 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4297 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4298 | |
5133 | 4299 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4300 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4301 else | |
4302 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4303 |
4896 | 4304 if(gc) |
9699 | 4305 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4306 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4307 |
10503 | 4308 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4309 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4310 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4311 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4312 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4313 |
7956 | 4314 /* this is gonna crash one day, I can feel it. */ |
4315 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4316 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4317 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4318 } |
4359 | 4319 |
10737 | 4320 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4321 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4322 g_snprintf(buf2, sizeof(buf2), |
8690 | 4323 "<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
|
4324 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4325 |
8962 | 4326 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4327 |
8722 | 4328 } else if (flags & GAIM_MESSAGE_ERROR) { |
4329 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4330 "<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
|
4331 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4332 |
8962 | 4333 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4334 | |
7431 | 4335 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4336 g_snprintf(buf2, BUF_LONG, |
8690 | 4337 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4338 sml_attrib ? sml_attrib : "", message); |
7440 | 4339 |
10884 | 4340 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4341 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4342 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4343 } else { |
4895 | 4344 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4345 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
|
4346 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4347 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4348 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
|
4349 int tag_end_offset = 0; |
7440 | 4350 |
6621 | 4351 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4352 str = g_malloc(1024); |
7440 | 4353 |
4359 | 4354 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4355 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4356 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4357 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4358 tag_start_offset += 3; |
4359 | 4359 } |
4360 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4361 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4362 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4363 tag_end_offset = 2; |
4359 | 4364 strcpy(color, "#00FF00"); |
4365 } | |
7440 | 4366 } |
4359 | 4367 else { |
10504 | 4368 if (gaim_message_meify(new_message, -1)) { |
4359 | 4369 str = g_malloc(1024); |
7440 | 4370 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4371 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4372 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
|
4373 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4374 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4375 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4376 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4377 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4378 } |
7440 | 4379 |
6621 | 4380 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4381 strcpy(color, "#AF7F00"); |
4382 else | |
4383 strcpy(color, "#062585"); | |
4384 } | |
4385 else { | |
4386 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4387 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4388 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
|
4389 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4390 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4391 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4392 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4393 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4394 } |
6621 | 4395 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4396 strcpy(color, "#AF7F00"); |
6621 | 4397 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4398 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4399 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4400 |
10108 | 4401 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4402 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4403 } else |
7854 | 4404 strcpy(color, RECV_COLOR); |
4359 | 4405 } |
6621 | 4406 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4407 strcpy(color, SEND_COLOR); |
10892 | 4408 else { |
4409 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4410 strcpy(color, "#000000"); | |
4411 } | |
4359 | 4412 } |
4413 } | |
10892 | 4414 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4415 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4416 g_free(alias_escaped); |
11508 | 4417 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4418 /* 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
|
4419 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4420 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4421 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4422 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4423 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4424 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4425 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4426 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4427 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4428 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4429 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4430 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4431 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4432 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4433 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4434 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4435 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4436 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4437 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4438 /* 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
|
4439 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4440 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4441 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4442 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4443 } |
7440 | 4444 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4445 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4446 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4447 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4448 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4449 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4450 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4451 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4452 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4453 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4454 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4455 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4456 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4457 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4458 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4459 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4460 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4461 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4462 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4463 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4464 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4465 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4466 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4467 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4468 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4469 |
4359 | 4470 g_free(str); |
4471 | |
4895 | 4472 if(gc){ |
4896 | 4473 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4474 char *post = "</font>"; |
4475 int pre_len = strlen(pre); | |
4476 int post_len = strlen(post); | |
7440 | 4477 |
4895 | 4478 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4479 |
4895 | 4480 strcpy(with_font_tag, pre); |
4481 memcpy(with_font_tag + pre_len, new_message, length); | |
4482 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4483 |
4895 | 4484 length += pre_len + post_len; |
4485 g_free(pre); | |
4486 } | |
4608 | 4487 else |
4895 | 4488 with_font_tag = g_memdup(new_message, length); |
7440 | 4489 |
8962 | 4490 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4491 with_font_tag, gtk_font_options); | |
7440 | 4492 |
4493 g_free(with_font_tag); | |
7447 | 4494 g_free(new_message); |
7440 | 4495 } |
4496 | |
5012 | 4497 if(sml_attrib) |
4498 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4499 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4500 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4501 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4502 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4503 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4504 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4505 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4506 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4507 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4508 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4509 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4510 else if ((flags & GAIM_MESSAGE_NO_LOG) == GAIM_MESSAGE_NO_LOG) |
12132
95bffda9b762
[gaim-migrate @ 14432]
Richard Laager <rlaager@wiktel.com>
parents:
12131
diff
changeset
|
4511 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4512 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4513 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4514 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4515 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4516 } |
4359 | 4517 } |
4518 | |
4519 static void | |
11869 | 4520 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases) |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4521 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4522 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4523 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4524 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4525 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4526 GList *ll; |
11869 | 4527 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4528 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4529 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4530 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4531 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4532 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4533 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4534 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4535 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
|
4536 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4537 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4538 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4539 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4540 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4541 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4542 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4543 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4544 l = users; |
11869 | 4545 ll = flags; |
4546 lll = aliases; | |
4547 while (l != NULL && ll != NULL && lll != NULL) { | |
4548 add_chat_buddy_common(conv, (const char *)l->data, GPOINTER_TO_INT(ll->data), (const char *)lll->data, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4549 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4550 ll = ll->next; |
11869 | 4551 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4552 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4553 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4554 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4555 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4556 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
|
4557 const char *new_name, const char *new_alias) |
4359 | 4558 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4559 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4560 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4561 GaimGtkChatPane *gtkchat; |
11869 | 4562 GaimConvChatBuddyFlags flags; |
4359 | 4563 GtkTreeIter iter; |
4564 GtkTreeModel *model; | |
4565 int f = 1; | |
4566 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4567 chat = GAIM_CONV_CHAT(conv); |
4359 | 4568 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4569 gtkchat = gtkconv->u.chat; | |
4570 | |
9554 | 4571 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4572 | |
4573 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4574 return; | |
4575 | |
4576 while (f != 0) { | |
4577 char *val; | |
4578 | |
11869 | 4579 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4580 |
4581 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4582 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4583 g_free(val); | |
4359 | 4584 break; |
4585 } | |
9554 | 4586 |
4587 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4588 | |
4589 g_free(val); | |
4359 | 4590 } |
4591 | |
9554 | 4592 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4593 return; |
4594 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4595 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4596 |
11869 | 4597 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4598 } |
4599 | |
4600 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4601 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4602 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4603 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4604 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4605 GaimGtkChatPane *gtkchat; |
4359 | 4606 GtkTreeIter iter; |
4607 GtkTreeModel *model; | |
4608 char tmp[BUF_LONG]; | |
4609 int num_users; | |
4610 int f = 1; | |
4611 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4612 chat = GAIM_CONV_CHAT(conv); |
4359 | 4613 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4614 gtkchat = gtkconv->u.chat; | |
4615 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4616 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
|
4617 |
9554 | 4618 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4619 | |
4620 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4621 return; | |
4622 | |
4623 while (f != 0) { | |
4624 char *val; | |
4625 | |
4626 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4627 | |
4628 if (!gaim_utf8_strcasecmp(user, val)) { | |
4629 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4630 g_free(val); | |
4359 | 4631 break; |
4632 } | |
9554 | 4633 |
4634 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4635 | |
4636 g_free(val); | |
4359 | 4637 } |
4638 | |
9554 | 4639 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4640 return; |
4641 | |
4642 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4643 ngettext("%d person in room", "%d people in room", |
4644 num_users), num_users); | |
4359 | 4645 |
4646 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4647 | |
4648 } | |
4649 | |
4650 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4651 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4652 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4653 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4654 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4655 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4656 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4657 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4658 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4659 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4660 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4661 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4662 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4663 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4664 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4665 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4666 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4667 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
|
4668 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4669 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4670 for (l = users; l != NULL; l = l->next) { |
9554 | 4671 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4672 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4673 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4674 continue; |
4675 | |
4676 do { | |
4677 char *val; | |
4678 | |
4679 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4680 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4681 | |
9696 | 4682 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4683 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4684 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4685 #else |
4686 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4687 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4688 #endif | |
4689 } | |
9554 | 4690 else |
4691 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4692 | |
4693 g_free(val); | |
4694 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4695 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4696 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4697 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4698 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4699 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4700 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4701 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4702 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4703 |
9554 | 4704 static void |
4705 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4706 { | |
4707 GaimConvChat *chat; | |
11869 | 4708 GaimConvChatBuddyFlags flags; |
9554 | 4709 GaimGtkConversation *gtkconv; |
4710 GaimGtkChatPane *gtkchat; | |
4711 GtkTreeIter iter; | |
4712 GtkTreeModel *model; | |
4713 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4714 char *alias = NULL; |
9554 | 4715 |
4716 chat = GAIM_CONV_CHAT(conv); | |
4717 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4718 gtkchat = gtkconv->u.chat; | |
4719 | |
4720 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4721 | |
4722 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4723 return; | |
4724 | |
4725 while (f != 0) { | |
4726 char *val; | |
4727 | |
4728 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4729 | |
4730 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4731 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4732 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4733 g_free(val); | |
4734 break; | |
4735 } | |
4736 | |
4737 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4738 | |
4739 g_free(val); | |
4740 } | |
4741 | |
4742 if (!gaim_conv_chat_find_user(chat, user)) | |
4743 return; | |
4744 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4745 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4746 |
11869 | 4747 flags = gaim_conv_chat_user_get_flags(chat, user); |
4748 | |
4749 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4750 g_free(alias); |
9554 | 4751 } |
4752 | |
11581 | 4753 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4754 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4755 { |
11581 | 4756 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4757 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4758 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4759 |
11581 | 4760 win = gtkconv->win; |
4761 | |
4762 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
|
4763 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4764 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4765 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4766 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4767 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4768 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4769 |
12335 | 4770 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
4771 { | |
4772 GtkIMHtmlSmiley *smiley; | |
4773 | |
4774 smiley = (GtkIMHtmlSmiley *)user_data; | |
4775 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4776 | |
4777 if (smiley->icon) | |
4778 g_object_ref(G_OBJECT(smiley->icon)); | |
4779 #ifdef DEBUG_CUSTOM_SMILEY | |
4780 gaim_debug_info("custom-smiley", "%s(): got GdkPixbufAnimation %p for smiley '%s'\n", __FUNCTION__, smiley->icon, smiley->smile); | |
4781 #endif | |
4782 } | |
4783 | |
4784 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) | |
4785 { | |
4786 GtkIMHtmlSmiley *smiley; | |
4787 GtkWidget *icon = NULL; | |
4788 GtkTextChildAnchor *anchor = NULL; | |
4789 GSList *current = NULL; | |
4790 | |
4791 smiley = (GtkIMHtmlSmiley *)user_data; | |
4792 if (!smiley->imhtml) { | |
4793 #ifdef DEBUG_CUSTOM_SMILEY | |
4794 gaim_debug_error("custom-smiley", "%s(): orphan smiley found: %p\n", __FUNCTION__, smiley); | |
4795 #endif | |
4796 g_object_unref(G_OBJECT(loader)); | |
4797 smiley->loader = NULL; | |
4798 return; | |
4799 } | |
4800 | |
4801 for (current = smiley->anchors; current; current = g_slist_next(current)) { | |
4802 | |
4803 icon = gtk_image_new_from_animation(smiley->icon); | |
4804 | |
4805 #ifdef DEBUG_CUSTOM_SMILEY | |
4806 gaim_debug_info("custom-smiley", "%s(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", | |
4807 __FUNCTION__, icon, smiley->icon, smiley->smile); | |
4808 #endif | |
4809 if (icon) { | |
4810 gtk_widget_show(icon); | |
4811 | |
4812 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); | |
4813 | |
4814 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smiley->smile)), g_free); | |
4815 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); | |
4816 | |
4817 if (smiley->imhtml) | |
4818 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); | |
4819 } | |
4820 | |
4821 } | |
4822 | |
4823 g_slist_free(smiley->anchors); | |
4824 smiley->anchors = NULL; | |
4825 | |
4826 g_object_unref(G_OBJECT(loader)); | |
4827 smiley->loader = NULL; | |
4828 } | |
4829 | |
10526 | 4830 static gboolean |
4831 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4832 { | |
4833 GaimGtkConversation *gtkconv; | |
4834 GtkIMHtmlSmiley *smiley; | |
4835 GdkPixbufLoader *loader; | |
11525 | 4836 struct smiley_list *list; |
4837 const char *sml = NULL, *conv_sml; | |
4838 | |
4839 if (!conv || !smile || !*smile) { | |
10526 | 4840 return FALSE; |
4841 } | |
4842 | |
11525 | 4843 /* If smileys are off, return false */ |
4844 if (gaim_gtkthemes_smileys_disabled()) | |
4845 return FALSE; | |
4846 | |
4847 /* If possible add this smiley to the current theme. | |
4848 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4849 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4850 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4851 |
4852 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4853 if (!strcmp(list->sml, conv_sml)) { | |
4854 sml = list->sml; | |
4855 break; | |
4856 } | |
4857 } | |
4858 | |
10526 | 4859 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4860 | |
4861 if (smiley) { | |
11525 | 4862 |
4863 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4864 return FALSE; | |
4865 } | |
4866 | |
4867 /* Close the old GdkPixbufAnimation, then create a new one for | |
4868 * the smiley we are about to receive */ | |
4869 g_object_unref(G_OBJECT(smiley->icon)); | |
4870 | |
4871 smiley->loader = gdk_pixbuf_loader_new(); | |
12335 | 4872 smiley->icon = NULL; |
4873 | |
4874 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); | |
4875 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
4876 | |
11525 | 4877 return TRUE; |
10526 | 4878 } |
4879 | |
4880 loader = gdk_pixbuf_loader_new(); | |
4881 | |
4882 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4883 /* 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
|
4884 GtkIMHtmlSmiley by opaque */ |
10526 | 4885 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4886 smiley->file = NULL; | |
4887 smiley->smile = g_strdup(smile); | |
4888 smiley->loader = loader; | |
11525 | 4889 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4890 |
12335 | 4891 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); |
4892 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
11525 | 4893 |
10526 | 4894 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4895 |
10526 | 4896 return TRUE; |
4897 } | |
4898 | |
10537 | 4899 static void |
10526 | 4900 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4901 const guchar *data, gsize size) |
10526 | 4902 { |
4903 GaimGtkConversation *gtkconv; | |
4904 GtkIMHtmlSmiley *smiley; | |
10537 | 4905 GdkPixbufLoader *loader; |
10526 | 4906 const char *sml; |
4907 | |
4908 sml = gaim_account_get_protocol_name(conv->account); | |
4909 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4910 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4911 | |
10537 | 4912 if (!smiley) |
10526 | 4913 return; |
10537 | 4914 |
10526 | 4915 loader = smiley->loader; |
10537 | 4916 if (!loader) |
10526 | 4917 return; |
4918 | |
4919 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4920 } | |
4921 | |
4922 static void | |
4923 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4924 { | |
4925 GaimGtkConversation *gtkconv; | |
4926 GtkIMHtmlSmiley *smiley; | |
4927 GdkPixbufLoader *loader; | |
4928 const char *sml; | |
4929 | |
4930 g_return_if_fail(conv != NULL); | |
4931 g_return_if_fail(smile != NULL); | |
4932 | |
4933 sml = gaim_account_get_protocol_name(conv->account); | |
4934 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4935 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4936 | |
10537 | 4937 if (!smiley) |
10526 | 4938 return; |
4939 | |
4940 loader = smiley->loader; | |
4941 | |
10537 | 4942 if (!loader) |
10526 | 4943 return; |
10537 | 4944 |
12335 | 4945 |
11525 | 4946 |
10526 | 4947 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4948 | |
4949 gdk_pixbuf_loader_close(loader, NULL); | |
12335 | 4950 |
10526 | 4951 } |
4952 | |
11581 | 4953 /* |
4954 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4955 * sensitive/insensitive. This is called after changing tabs and when an | |
4956 * account signs on or off. | |
4957 */ | |
4958 static void | |
4959 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4960 { | |
4961 GaimGtkWindow *win; | |
4962 GaimConversation *conv = gtkconv->active_conv; | |
4963 GaimConnection *gc; | |
4964 GaimPluginProtocolInfo *prpl_info = NULL; | |
4965 GdkPixbuf *window_icon = NULL; | |
4966 GtkIMHtmlButtons buttons; | |
4967 GaimAccount *account; | |
4968 | |
4969 win = gaim_gtkconv_get_window(gtkconv); | |
4970 gc = gaim_conversation_get_gc(conv); | |
4971 account = gaim_conversation_get_account(conv); | |
4972 | |
4973 if (gc != NULL) | |
4974 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4975 | |
11594 | 4976 if (win->menu.send_to != NULL) |
11734 | 4977 update_send_to_selection(win); |
11581 | 4978 |
4979 /* | |
4980 * Handle hiding and showing stuff based on what type of conv this is. | |
4981 * Stuff that Gaim IMs support in general should be shown for IM | |
4982 * conversations. Stuff that Gaim chats support in general should be | |
4983 * shown for chat conversations. It doesn't matter whether the PRPL | |
4984 * supports it or not--that only affects if the button or menu item | |
4985 * is sensitive or not. | |
4986 */ | |
4987 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4988 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4989 | |
4990 /* Deal with menu items */ | |
4991 gtk_widget_show(win->menu.view_log); | |
4992 gtk_widget_show(win->menu.send_file); | |
4993 gtk_widget_show(win->menu.add_pounce); | |
4994 gtk_widget_show(win->menu.get_info); | |
4995 gtk_widget_hide(win->menu.invite); | |
4996 gtk_widget_show(win->menu.alias); | |
4997 gtk_widget_show(win->menu.block); | |
4998 | |
4999 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
5000 gtk_widget_show(win->menu.add); | |
5001 gtk_widget_hide(win->menu.remove); | |
5002 } else { | |
5003 gtk_widget_show(win->menu.remove); | |
5004 gtk_widget_hide(win->menu.add); | |
5005 } | |
5006 | |
5007 gtk_widget_show(win->menu.insert_link); | |
5008 gtk_widget_show(win->menu.insert_image); | |
5009 gtk_widget_show(win->menu.show_icon); | |
5010 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
5011 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
5012 | |
5013 /* Deal with menu items */ | |
5014 gtk_widget_show(win->menu.view_log); | |
5015 gtk_widget_hide(win->menu.send_file); | |
5016 gtk_widget_hide(win->menu.add_pounce); | |
5017 gtk_widget_hide(win->menu.get_info); | |
5018 gtk_widget_show(win->menu.invite); | |
5019 gtk_widget_show(win->menu.alias); | |
5020 gtk_widget_hide(win->menu.block); | |
5021 gtk_widget_hide(win->menu.show_icon); | |
5022 | |
5023 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
5024 /* If the chat is NOT in the buddy list */ | |
5025 gtk_widget_show(win->menu.add); | |
5026 gtk_widget_hide(win->menu.remove); | |
5027 } else { | |
5028 /* If the chat IS in the buddy list */ | |
5029 gtk_widget_hide(win->menu.add); | |
5030 gtk_widget_show(win->menu.remove); | |
5031 } | |
5032 | |
5033 gtk_widget_show(win->menu.insert_link); | |
5034 gtk_widget_hide(win->menu.insert_image); | |
5035 } | |
5036 | |
5037 /* | |
5038 * Handle graying stuff out based on whether an account is connected | |
5039 * and what features that account supports. | |
5040 */ | |
5041 if ((gc != NULL) && | |
12012 | 5042 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5043 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5044 { | |
11581 | 5045 /* Account is online */ |
5046 /* Deal with the toolbar */ | |
12012 | 5047 if (conv->features & GAIM_CONNECTION_HTML) |
5048 { | |
5049 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5050 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5051 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5052 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5053 { | |
5054 buttons &= ~GTK_IMHTML_GROW; | |
5055 buttons &= ~GTK_IMHTML_SHRINK; | |
5056 } | |
5057 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5058 buttons &= ~GTK_IMHTML_LINKDESC; | |
5059 } else { | |
12216 | 5060 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5061 } |
12216 | 5062 |
5063 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5064 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5065 buttons &= ~GTK_IMHTML_IMAGE; | |
5066 | |
12012 | 5067 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
5068 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5069 |
5070 /* Deal with menu items */ | |
12012 | 5071 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5072 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5073 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5074 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5075 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5076 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5077 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5078 |
5079 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5080 { | |
5081 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5082 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5083 gtk_widget_set_sensitive(win->menu.send_file, | |
5084 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5085 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5086 gtk_widget_set_sensitive(win->menu.alias, | |
5087 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
5088 } | |
5089 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5090 { | |
5091 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5092 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5093 gtk_widget_set_sensitive(win->menu.alias, | |
5094 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
5095 } | |
11581 | 5096 |
5097 /* Deal with chat userlist buttons */ | |
12012 | 5098 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5099 { | |
5100 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5101 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5102 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5103 } | |
5104 } else { | |
11581 | 5105 /* Account is offline */ |
5106 /* Or it's a chat that we've left. */ | |
5107 | |
5108 /* Then deal with menu items */ | |
12012 | 5109 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5110 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5111 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5112 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5113 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5114 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5115 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5116 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5117 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5118 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5119 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5120 |
5121 /* Deal with chat userlist buttons */ | |
12012 | 5122 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5123 { | |
5124 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5125 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5126 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5127 } | |
5128 } | |
11581 | 5129 |
5130 /* | |
5131 * Update the window's icon | |
5132 */ | |
12171 | 5133 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5134 { |
12171 | 5135 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5136 (gtkconv->u.im->anim)) | |
5137 { | |
5138 window_icon = | |
5139 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5140 g_object_ref(window_icon); | |
5141 } else { | |
5142 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5143 } | |
5144 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5145 if (window_icon != NULL) | |
5146 g_object_unref(G_OBJECT(window_icon)); | |
5147 } | |
11581 | 5148 } |
5149 | |
10526 | 5150 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5151 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5152 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5153 { |
11581 | 5154 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5155 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5156 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5157 GaimConvChat *chat; |
4359 | 5158 |
10116 | 5159 g_return_if_fail(conv != NULL); |
5160 | |
4359 | 5161 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5162 win = gtkconv->win; |
10810 | 5163 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5164 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5165 * instead of the gross hack? | |
5166 */ | |
4359 | 5167 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5168 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5169 { |
4359 | 5170 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5171 |
11338 | 5172 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5173 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5174 |
4359 | 5175 gaim_gtkconv_update_buttons_by_protocol(conv); |
5176 | |
11734 | 5177 update_send_to_selection(win); |
4359 | 5178 |
11525 | 5179 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5180 |
6395 | 5181 update_tab_icon(conv); |
4359 | 5182 } |
5183 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5184 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5185 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5186 { |
9472 | 5187 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5188 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5189 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5190 /* I think this is a little longer than it needs to be but I'm lazy. */ |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5191 char style[51]; |
4736 | 5192 |
11338 | 5193 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5194 im = GAIM_CONV_IM(conv); |
4359 | 5195 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5196 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5197 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5198 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5199 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5200 else | |
5201 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5202 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5203 *style = '\0'; |
4359 | 5204 |
5205 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5206 gtk_widget_realize(gtkconv->tab_label); | |
5207 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5208 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5209 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5210 { |
11759 | 5211 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5212 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5213 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5214 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5215 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5216 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5217 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5218 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5219 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5220 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5221 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5222 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5223 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5224 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5225 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5226 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5227 { |
11758 | 5228 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5229 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5230 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5231 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5232 { |
8536 | 5233 char *html_title,*label; |
5234 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5235 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5236 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5237 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5238 style, html_title); |
8536 | 5239 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5240 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5241 g_free(label); |
4359 | 5242 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5243 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5244 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5245 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5246 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5247 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5248 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5249 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5250 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5251 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5252 gtk_window_set_title(GTK_WINDOW(win->window), title); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5253 } |
9472 | 5254 |
5255 g_free(title); | |
4359 | 5256 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5257 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5258 { |
7154 | 5259 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5260 chat = GAIM_CONV_CHAT(conv); |
4359 | 5261 gtkchat = gtkconv->u.chat; |
5262 | |
7154 | 5263 topic = gaim_conv_chat_get_topic(chat); |
5264 | |
9554 | 5265 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5266 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5267 topic ? topic : "", NULL); |
4359 | 5268 } |
5269 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5270 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5271 { |
11581 | 5272 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5273 generate_send_to_items(win); |
8946 | 5274 update_tab_icon(conv); |
9472 | 5275 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5276 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5277 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5278 { |
8946 | 5279 update_tab_icon(conv); |
4359 | 5280 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5281 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
|
5282 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5283 { |
9472 | 5284 gaim_conversation_autoset_title(conv); |
10810 | 5285 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5286 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5287 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5288 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5289 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5290 } |
10665 | 5291 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5292 { | |
10810 | 5293 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5294 } |
4359 | 5295 } |
5296 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5297 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5298 { |
11581 | 5299 gaim_gtkconv_new, |
4359 | 5300 gaim_gtkconv_destroy, /* destroy_conversation */ |
5301 gaim_gtkconv_write_chat, /* write_chat */ | |
5302 gaim_gtkconv_write_im, /* write_im */ | |
5303 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5304 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5305 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5306 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5307 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5308 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5309 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5310 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5311 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5312 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5313 gaim_gtkconv_updated /* updated */ |
5314 }; | |
5315 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5316 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5317 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5318 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5319 return &conversation_ui_ops; |
4359 | 5320 } |
5321 | |
5322 /************************************************************************** | |
5323 * Public conversation utility functions | |
5324 **************************************************************************/ | |
5325 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5326 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5327 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5328 GaimGtkConversation *gtkconv; |
11581 | 5329 GaimGtkWindow *win; |
4359 | 5330 |
10381 | 5331 GdkPixbufLoader *loader; |
5332 GdkPixbufAnimation *anim; | |
4359 | 5333 GError *err = NULL; |
5334 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5335 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5336 size_t len; |
4359 | 5337 |
5338 GdkPixbuf *buf; | |
5339 | |
5340 GtkWidget *event; | |
5341 GtkWidget *frame; | |
5342 GdkPixbuf *scale; | |
5343 GdkPixmap *pm; | |
5344 GdkBitmap *bm; | |
9318 | 5345 int scale_width, scale_height; |
5346 | |
5347 GaimAccount *account; | |
5348 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5349 |
9324 | 5350 GaimBuddyIcon *icon; |
5351 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5352 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5353 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5354 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5355 |
5356 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5357 win = gtkconv->win; |
10175 | 5358 |
9687 | 5359 if (!gtkconv->u.im->show_icon) |
5360 return; | |
5361 | |
9318 | 5362 account = gaim_conversation_get_account(conv); |
5363 if(account && account->gc) | |
5364 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5365 |
9845 | 5366 /* Remove the current icon stuff */ |
9885 | 5367 if (gtkconv->u.im->icon_container != NULL) |
5368 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5369 gtkconv->u.im->icon_container = NULL; | |
9845 | 5370 |
5371 if (gtkconv->u.im->anim != NULL) | |
5372 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5373 | |
9887 | 5374 gtkconv->u.im->anim = NULL; |
5375 | |
9845 | 5376 if (gtkconv->u.im->icon_timer != 0) |
5377 g_source_remove(gtkconv->u.im->icon_timer); | |
5378 | |
5379 gtkconv->u.im->icon_timer = 0; | |
5380 | |
5381 if (gtkconv->u.im->iter != NULL) | |
5382 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5383 |
10116 | 5384 gtkconv->u.im->iter = NULL; |
5385 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5386 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5387 return; |
5388 | |
5389 if (gaim_conversation_get_gc(conv) == NULL) | |
5390 return; | |
5391 | |
9324 | 5392 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5393 | |
5394 if (icon == NULL) | |
5395 return; | |
5396 | |
5397 data = gaim_buddy_icon_get_data(icon, &len); | |
5398 | |
10381 | 5399 loader = gdk_pixbuf_loader_new(); |
5400 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5401 anim = gdk_pixbuf_loader_get_animation(loader); | |
5402 if (anim) | |
5403 g_object_ref(G_OBJECT(anim)); | |
5404 gdk_pixbuf_loader_close(loader, &err); | |
5405 g_object_unref(loader); | |
5406 | |
5407 if (!anim) | |
9324 | 5408 return; |
10381 | 5409 gtkconv->u.im->anim = anim; |
9324 | 5410 |
4359 | 5411 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5412 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5413 "Buddy icon error: %s\n", err->message); |
4359 | 5414 g_error_free(err); |
5415 } | |
5416 | |
5417 if (!gtkconv->u.im->anim) | |
5418 return; | |
5419 | |
5420 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5421 gtkconv->u.im->iter = NULL; | |
5422 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5423 } else { | |
5424 gtkconv->u.im->iter = | |
8496 | 5425 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5426 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5427 if (gtkconv->u.im->animate) |
10810 | 5428 start_anim(NULL, gtkconv); |
4359 | 5429 } |
5430 | |
10483 | 5431 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5432 NULL, &scale_width, &scale_height); |
4359 | 5433 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5434 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5435 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5436 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5437 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5438 GDK_INTERP_BILINEAR); |
4359 | 5439 |
5440 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5441 g_object_unref(G_OBJECT(scale)); |
4359 | 5442 |
8821 | 5443 |
9885 | 5444 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5445 |
4359 | 5446 frame = gtk_frame_new(NULL); |
5447 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5448 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5449 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5450 FALSE, FALSE, 0); | |
8821 | 5451 |
4359 | 5452 event = gtk_event_box_new(); |
5453 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5454 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5455 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5456 gtk_widget_show(event); |
5457 | |
4635 | 5458 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5459 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5460 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5461 gtk_widget_show(gtkconv->u.im->icon); | |
5462 | |
4793 | 5463 g_object_unref(G_OBJECT(pm)); |
4359 | 5464 |
5465 if (bm) | |
4793 | 5466 g_object_unref(G_OBJECT(bm)); |
7143 | 5467 |
10356 | 5468 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5469 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5470 |
9885 | 5471 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5472 gtk_widget_show(frame); |
5473 | |
7143 | 5474 /* The buddy icon code needs badly to be fixed. */ |
5475 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5476 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5477 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5478 } |
5479 | |
5480 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5481 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5482 { |
11581 | 5483 GaimGtkWindow *win; |
4359 | 5484 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5485 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5486 return; |
5487 | |
11581 | 5488 win = GAIM_GTK_CONVERSATION(conv)->win; |
5489 | |
5490 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5491 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5492 } |
5493 | |
5494 int | |
11614 | 5495 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5496 { |
4359 | 5497 gint nb_x, nb_y, x_rel, y_rel; |
5498 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5499 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5500 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5501 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5502 gboolean horiz; |
4359 | 5503 |
11614 | 5504 if (to_right) |
5505 *to_right = FALSE; | |
5506 | |
11581 | 5507 notebook = GTK_NOTEBOOK(win->notebook); |
5508 | |
5509 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5510 x_rel = x - nb_x; |
5511 y_rel = y - nb_y; | |
5512 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5513 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5514 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5515 |
11780 | 5516 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5517 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5518 #else |
5519 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5520 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5521 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5522 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5523 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5524 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5525 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5526 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5527 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5528 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5529 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5530 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
|
5531 page_num = i; |
11614 | 5532 |
5533 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5534 *to_right = TRUE; | |
5535 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5536 break; |
4359 | 5537 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5538 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5539 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5540 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
|
5541 page_num = i; |
11614 | 5542 |
5543 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5544 *to_right = TRUE; | |
5545 | |
4359 | 5546 break; |
5547 } | |
5548 } | |
5549 } | |
5550 | |
5551 return page_num; | |
5552 } | |
5553 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5554 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5555 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
|
5556 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5557 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5558 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5559 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5560 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5561 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5562 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5563 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5564 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5565 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5566 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5567 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5568 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5569 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5570 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5571 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5572 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5573 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5574 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5575 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5576 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5577 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5578 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5579 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5580 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5581 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5582 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5583 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5584 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5585 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5586 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5587 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5588 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5589 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5590 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5591 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5592 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5593 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5594 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5595 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5596 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5597 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5598 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5599 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5600 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5601 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5602 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5603 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5604 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5605 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5606 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5607 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5608 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5609 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5610 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5611 GtkPositionType pos; |
11581 | 5612 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5613 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5614 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5615 |
11581 | 5616 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5617 win = l->data; | |
5618 | |
11619 | 5619 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos&~8); |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5620 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5621 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5622 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5623 static void |
12188 | 5624 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
5625 gpointer value, gpointer data) | |
5626 { | |
5627 GList *l; | |
5628 GaimConversation *conv; | |
5629 GaimGtkConversation *gtkconv; | |
5630 GaimGtkWindow *win; | |
5631 | |
5632 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
5633 { | |
5634 conv = (GaimConversation *)l->data; | |
5635 | |
5636 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
5637 continue; | |
5638 | |
5639 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5640 win = gtkconv->win; | |
5641 | |
5642 gtk_check_menu_item_set_active( | |
5643 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
5644 (gboolean)GPOINTER_TO_INT(value)); | |
5645 | |
5646 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
5647 (gboolean)GPOINTER_TO_INT(value)); | |
5648 } | |
5649 } | |
5650 | |
5651 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5652 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5653 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5654 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5655 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5656 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5657 GaimGtkConversation *gtkconv; |
11581 | 5658 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5659 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5660 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5661 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5662 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5663 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5664 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5665 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5666 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5667 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5668 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5669 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5670 gtk_check_menu_item_set_active( |
11581 | 5671 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5672 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5673 |
5674 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5675 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5676 else |
8317 | 5677 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5678 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5679 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5680 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5681 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5682 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5683 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5684 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5685 GList *l; |
8189 | 5686 GaimConversation *conv; |
5687 GaimGtkConversation *gtkconv; | |
11581 | 5688 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5689 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5690 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
|
5691 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5692 |
8189 | 5693 /* Set the "animate" flag for each icon based on the new preference */ |
5694 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5695 conv = (GaimConversation *)l->data; | |
5696 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5697 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5698 } |
8189 | 5699 |
5700 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5701 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5702 win = l->data; | |
5703 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5704 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5705 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5706 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5707 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5708 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5709 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
|
5710 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5711 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5712 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5713 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5714 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5715 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5716 |
11338 | 5717 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5718 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5719 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5720 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5721 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5722 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5723 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5724 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5725 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5726 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5727 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5728 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5729 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5730 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5731 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5732 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5733 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5734 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5735 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5736 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5737 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")!=0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5738 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5739 |
12310 | 5740 if(gaim_status_is_available(oldstatus) || !gaim_status_is_available(newstatus)) |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5741 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5742 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5743 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5744 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5745 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5746 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5747 |
12310 | 5748 if(!gaim_status_is_available( |
5749 gaim_account_get_active_status( | |
5750 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5751 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5752 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5753 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5754 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5755 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5756 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5757 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5758 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5759 hide_new_pref_cb(const char *name, GaimPrefType type, gpointer value, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5760 gpointer data) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5761 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5762 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5763 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5764 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5765 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5766 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5767 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5768 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5769 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5770 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always")==0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5771 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5772 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5773 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")==0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5774 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5775 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5776 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5777 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5778 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5779 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5780 |
12310 | 5781 if(when_away && !gaim_status_is_available( |
5782 gaim_account_get_active_status( | |
5783 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5784 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5785 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5786 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5787 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5788 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5789 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5790 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5791 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5792 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5793 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5794 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5795 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5796 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5797 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5798 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5799 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5800 |
11581 | 5801 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5802 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5803 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5804 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5805 |
11581 | 5806 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5807 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5808 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5809 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5810 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5811 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5812 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5813 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5814 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5815 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5816 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5817 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5818 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5819 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5820 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5821 if (gaim_conversation_get_account(conv) == account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5822 gaim_conversation_update(conv, GPOINTER_TO_INT(event)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5823 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5824 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5825 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5826 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5827 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5828 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5829 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5830 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5831 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5832 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5833 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5834 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5835 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5836 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5837 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5838 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5839 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5840 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5841 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5842 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5843 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5844 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5845 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5846 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5847 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5848 |
12264 | 5849 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5850 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5851 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5852 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5853 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5854 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5855 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5856 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5857 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5858 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5859 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5860 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
|
5861 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5862 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5863 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5864 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5865 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5866 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5867 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5868 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5869 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5870 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5871 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5872 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5873 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5874 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5875 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5876 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5877 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
|
5878 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5879 /* convert old queuing prefs to hide_new 3-way pref */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5880 if(gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5881 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5882 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "always"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5883 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5884 else if(gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5885 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5886 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "away"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5887 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5888 else { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5889 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5890 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5891 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5892 /* Connect callbacks. */ |
10087 | 5893 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
|
5894 close_on_tabs_pref_cb, NULL); |
12188 | 5895 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
5896 show_timestamps_pref_cb, NULL); | |
10087 | 5897 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
|
5898 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5899 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5900 spellcheck_pref_cb, NULL); |
10087 | 5901 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5902 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5903 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5904 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5905 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5906 |
10087 | 5907 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5908 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5909 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5910 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5911 /* IM callbacks */ |
10087 | 5912 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
|
5913 animate_buddy_icons_pref_cb, NULL); |
10087 | 5914 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
|
5915 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5916 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5917 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5918 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5919 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5920 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5921 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5922 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5923 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5924 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5925 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5926 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5927 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5928 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5929 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5930 |
5931 /********************************************************************** | |
5932 * Register commands | |
5933 **********************************************************************/ | |
9829 | 5934 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5935 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5936 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5937 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5938 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5939 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5940 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5941 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5942 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
|
5943 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5944 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5945 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5946 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5947 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5948 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5949 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5950 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5951 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5952 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5953 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5954 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5955 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5956 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5957 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5958 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5959 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5960 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5961 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5962 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5963 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5964 G_CALLBACK(buddy_update_cb), NULL); |
5965 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5966 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5967 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5968 |
11581 | 5969 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5970 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5971 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5972 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5973 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5974 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5975 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5976 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5977 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5978 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5979 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5980 { |
10443 | 5981 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5982 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5983 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5984 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5985 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5986 } |
11581 | 5987 |
5988 | |
5989 | |
5990 | |
5991 | |
5992 | |
5993 | |
5994 | |
5995 | |
5996 | |
5997 | |
5998 | |
5999 | |
6000 | |
6001 | |
6002 | |
6003 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
6004 * and touch each others' private members all day long */ | |
6005 | |
6006 /** | |
6007 * @file gtkconvwin.c GTK+ Conversation Window API | |
6008 * @ingroup gtkui | |
6009 * | |
6010 * gaim | |
6011 * | |
6012 * Gaim is the legal property of its developers, whose names are too numerous | |
6013 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6014 * source distribution. | |
6015 * | |
6016 * This program is free software; you can redistribute it and/or modify | |
6017 * it under the terms of the GNU General Public License as published by | |
6018 * the Free Software Foundation; either version 2 of the License, or | |
6019 * (at your option) any later version. | |
6020 * | |
6021 * This program is distributed in the hope that it will be useful, | |
6022 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6024 * GNU General Public License for more details. | |
6025 * | |
6026 * You should have received a copy of the GNU General Public License | |
6027 * along with this program; if not, write to the Free Software | |
6028 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6029 * | |
6030 */ | |
6031 #include "internal.h" | |
6032 #include "gtkgaim.h" | |
6033 | |
6034 | |
6035 #include <gdk/gdkkeysyms.h> | |
6036 | |
6037 #include "account.h" | |
6038 #include "cmds.h" | |
6039 #include "debug.h" | |
6040 #include "imgstore.h" | |
6041 #include "log.h" | |
6042 #include "notify.h" | |
6043 #include "prpl.h" | |
6044 #include "request.h" | |
6045 #include "util.h" | |
6046 | |
6047 #include "gtkdnd-hints.h" | |
6048 #include "gtkblist.h" | |
6049 #include "gtkconv.h" | |
6050 #include "gtkdialogs.h" | |
6051 #include "gtkmenutray.h" | |
6052 #include "gtkpounce.h" | |
6053 #include "gtkprefs.h" | |
6054 #include "gtkprivacy.h" | |
6055 #include "gtkutils.h" | |
6056 #include "gtkstock.h" | |
6057 #include "gtkimhtml.h" | |
6058 #include "gtkimhtmltoolbar.h" | |
6059 | |
6060 static void | |
6061 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6062 { | |
6063 gtk_widget_destroy(warn_close_dialog); | |
6064 warn_close_dialog = NULL; | |
6065 | |
6066 if (resp == GTK_RESPONSE_OK) | |
6067 gaim_gtk_conv_window_destroy(win); | |
6068 } | |
6069 | |
6070 static void | |
6071 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6072 { | |
6073 GtkWidget *label; | |
6074 GtkWidget *vbox, *hbox; | |
6075 GtkWidget *img; | |
6076 | |
6077 g_return_if_fail(warn_close_dialog == NULL); | |
6078 | |
6079 | |
6080 warn_close_dialog = gtk_dialog_new_with_buttons( | |
6081 _("Confirm close"), | |
6082 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6083 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6084 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
6085 | |
6086 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6087 GTK_RESPONSE_OK); | |
6088 | |
6089 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6090 6); | |
6091 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6092 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6093 FALSE); | |
6094 | |
6095 /* Setup the outside spacing. */ | |
6096 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6097 | |
6098 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6099 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6100 | |
6101 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6102 GTK_ICON_SIZE_DIALOG); | |
6103 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6104 hbox = gtk_hbox_new(FALSE, 12); | |
6105 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6106 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6107 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6108 | |
6109 /* Setup the right vbox. */ | |
6110 vbox = gtk_vbox_new(FALSE, 12); | |
6111 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6112 | |
6113 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6114 gtk_widget_set_size_request(label, 350, -1); | |
6115 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6116 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6117 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6118 | |
6119 /* Connect the signals. */ | |
6120 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6121 G_CALLBACK(do_close), gtkwin); | |
6122 | |
6123 } | |
6124 | |
6125 /************************************************************************** | |
6126 * Callbacks | |
6127 **************************************************************************/ | |
6128 | |
6129 static gboolean | |
6130 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6131 { | |
6132 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6133 GList *l; |
11581 | 6134 |
6135 /* If there are unread messages then show a warning dialog */ | |
6136 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6137 l != NULL; l = l->next) | |
6138 { | |
6139 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6140 if (gaim_conversation_get_type(gtkconv->active_conv) == GAIM_CONV_TYPE_IM && |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6141 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6142 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6143 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6144 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6145 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6146 return TRUE; |
11581 | 6147 } |
6148 } | |
6149 | |
6150 gaim_gtk_conv_window_destroy(win); | |
6151 | |
6152 return TRUE; | |
6153 } | |
6154 | |
11604 | 6155 static void |
6156 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6157 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6158 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6159 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6160 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6161 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6162 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6163 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6164 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6165 gtkconv->unseen_count++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6166 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6167 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6168 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6169 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6170 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6171 /* emit update signal to notify of count and possible unseen state change */ |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6172 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6173 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6174 |
11581 | 6175 /* |
6176 * When a conversation window is focused, we know the user | |
6177 * has looked at it so we know there are no longer unseen | |
6178 * messages. | |
6179 */ | |
6180 static gint | |
6181 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6182 { | |
6183 GaimGtkWindow *win = d; | |
11604 | 6184 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6185 | |
6186 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6187 |
6188 return FALSE; | |
6189 } | |
6190 | |
11851 | 6191 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6192 /* Courtesy of Galeon! */ |
6193 static void | |
6194 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6195 { | |
6196 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6197 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6198 } | |
11851 | 6199 #endif |
11581 | 6200 |
6201 static void | |
6202 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6203 { | |
6204 static GdkCursor *cursor = NULL; | |
6205 | |
6206 gtkwin->in_drag = TRUE; | |
6207 | |
6208 if (gtkwin->drag_leave_signal) { | |
6209 g_signal_handler_disconnect(G_OBJECT(widget), | |
6210 gtkwin->drag_leave_signal); | |
6211 gtkwin->drag_leave_signal = 0; | |
6212 } | |
6213 | |
6214 if (cursor == NULL) | |
6215 cursor = gdk_cursor_new(GDK_FLEUR); | |
6216 | |
6217 /* Grab the pointer */ | |
6218 gtk_grab_add(gtkwin->notebook); | |
6219 #ifndef _WIN32 | |
6220 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6221 always be true after a button press. */ | |
6222 if (!gdk_pointer_is_grabbed()) | |
6223 #endif | |
6224 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6225 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6226 NULL, cursor, GDK_CURRENT_TIME); | |
6227 } | |
6228 | |
6229 static gboolean | |
6230 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6231 { | |
6232 | |
6233 /* | |
6234 * Make sure the user moved the mouse far enough for the | |
6235 * drag to be initiated. | |
6236 */ | |
6237 if (win->in_predrag) { | |
6238 if (e->x_root < win->drag_min_x || | |
6239 e->x_root >= win->drag_max_x || | |
6240 e->y_root < win->drag_min_y || | |
6241 e->y_root >= win->drag_max_y) { | |
6242 | |
6243 win->in_predrag = FALSE; | |
6244 notebook_init_grab(win, widget); | |
6245 } | |
6246 } | |
6247 else { /* Otherwise, draw the arrows. */ | |
6248 GaimGtkWindow *dest_win; | |
6249 GtkNotebook *dest_notebook; | |
6250 GtkWidget *tab; | |
6251 gint nb_x, nb_y, page_num; | |
6252 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6253 gboolean horiz_tabs = FALSE; | |
11614 | 6254 GaimGtkConversation *gtkconv; |
6255 gboolean to_right = FALSE; | |
11581 | 6256 |
6257 /* Get the window that the cursor is over. */ | |
6258 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6259 | |
6260 if (dest_win == NULL) { | |
6261 dnd_hints_hide_all(); | |
6262 | |
6263 return TRUE; | |
6264 } | |
6265 | |
6266 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6267 | |
6268 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6269 | |
6270 arrow1_x = arrow2_x = nb_x; | |
6271 arrow1_y = arrow2_y = nb_y; | |
6272 | |
6273 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6274 e->x_root, e->y_root, &to_right); |
6275 to_right = to_right && (win != dest_win); | |
11581 | 6276 |
6277 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6278 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6279 | |
6280 horiz_tabs = TRUE; | |
6281 } | |
6282 | |
11614 | 6283 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6284 tab = gtkconv->tabby; | |
11581 | 6285 |
6286 if (horiz_tabs) { | |
6287 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6288 | |
11614 | 6289 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6290 arrow1_x += tab->allocation.width; |
6291 arrow2_x += tab->allocation.width; | |
6292 } | |
6293 | |
6294 arrow1_y = nb_y + tab->allocation.y; | |
6295 arrow2_y = nb_y + tab->allocation.y + | |
6296 tab->allocation.height; | |
6297 } else { | |
6298 arrow1_x = nb_x + tab->allocation.x; | |
6299 arrow2_x = nb_x + tab->allocation.x + | |
6300 tab->allocation.width; | |
6301 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
6302 | |
6303 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
6304 arrow1_y += tab->allocation.height; | |
6305 arrow2_y += tab->allocation.height; | |
6306 } | |
6307 } | |
6308 | |
6309 if (horiz_tabs) { | |
6310 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6311 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6312 } else { | |
6313 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6314 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6315 } | |
6316 } | |
6317 | |
6318 return TRUE; | |
6319 } | |
6320 | |
6321 static gboolean | |
6322 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6323 { | |
6324 if (win->in_drag) | |
6325 return FALSE; | |
6326 | |
6327 if (e->x_root < win->drag_min_x || | |
6328 e->x_root >= win->drag_max_x || | |
6329 e->y_root < win->drag_min_y || | |
6330 e->y_root >= win->drag_max_y) { | |
6331 | |
6332 win->in_predrag = FALSE; | |
6333 notebook_init_grab(win, widget); | |
6334 } | |
6335 | |
6336 return TRUE; | |
6337 } | |
6338 | |
6339 /* | |
6340 * THANK YOU GALEON! | |
6341 */ | |
6342 static gboolean | |
6343 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6344 { | |
6345 gint nb_x, nb_y, x_rel, y_rel; | |
6346 int tab_clicked; | |
6347 GtkWidget *page; | |
6348 GtkWidget *tab; | |
6349 | |
6350 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6351 return FALSE; | |
6352 | |
6353 | |
6354 if (win->in_drag) { | |
6355 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6356 "Already in the middle of a window drag at tab_press_cb\n"); | |
6357 return TRUE; | |
6358 } | |
6359 | |
6360 /* | |
6361 * Make sure a tab was actually clicked. The arrow buttons | |
6362 * mess things up. | |
6363 */ | |
11614 | 6364 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6365 |
6366 if (tab_clicked == -1) | |
6367 return FALSE; | |
6368 | |
6369 /* | |
6370 * Get the relative position of the press event, with regards to | |
6371 * the position of the notebook. | |
6372 */ | |
6373 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6374 | |
6375 x_rel = e->x_root - nb_x; | |
6376 y_rel = e->y_root - nb_y; | |
6377 | |
6378 /* Reset the min/max x/y */ | |
6379 win->drag_min_x = 0; | |
6380 win->drag_min_y = 0; | |
6381 win->drag_max_x = 0; | |
6382 win->drag_max_y = 0; | |
6383 | |
6384 /* Find out which tab was dragged. */ | |
6385 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6386 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6387 | |
6388 win->drag_min_x = tab->allocation.x + nb_x; | |
6389 win->drag_min_y = tab->allocation.y + nb_y; | |
6390 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6391 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6392 | |
6393 /* Make sure the click occurred in the tab. */ | |
6394 if (e->x_root < win->drag_min_x || | |
6395 e->x_root >= win->drag_max_x || | |
6396 e->y_root < win->drag_min_y || | |
6397 e->y_root >= win->drag_max_y) { | |
6398 | |
6399 return FALSE; | |
6400 } | |
6401 | |
6402 win->in_predrag = TRUE; | |
6403 win->drag_tab = tab_clicked; | |
6404 | |
6405 /* Connect the new motion signals. */ | |
6406 win->drag_motion_signal = | |
6407 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6408 G_CALLBACK(notebook_motion_cb), win); | |
6409 | |
6410 win->drag_leave_signal = | |
6411 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6412 G_CALLBACK(notebook_leave_cb), win); | |
6413 | |
6414 return FALSE; | |
6415 } | |
6416 | |
6417 static gboolean | |
6418 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6419 { | |
6420 GaimGtkWindow *dest_win; | |
6421 GaimConversation *conv; | |
6422 GaimGtkConversation *gtkconv; | |
6423 gint dest_page_num = 0; | |
6424 gboolean new_window = FALSE; | |
11614 | 6425 gboolean to_right = FALSE; |
11581 | 6426 |
6427 /* | |
6428 * Don't check to make sure that the event's window matches the | |
6429 * widget's, because we may be getting an event passed on from the | |
6430 * close button. | |
6431 */ | |
6432 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6433 return FALSE; | |
6434 | |
6435 if (gdk_pointer_is_grabbed()) { | |
6436 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6437 gtk_grab_remove(widget); | |
6438 } | |
6439 | |
6440 if (!win->in_predrag && !win->in_drag) | |
6441 return FALSE; | |
6442 | |
6443 /* Disconnect the motion signal. */ | |
6444 if (win->drag_motion_signal) { | |
6445 g_signal_handler_disconnect(G_OBJECT(widget), | |
6446 win->drag_motion_signal); | |
6447 | |
6448 win->drag_motion_signal = 0; | |
6449 } | |
6450 | |
6451 /* | |
6452 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6453 * signal. | |
6454 */ | |
6455 if (win->in_predrag) { | |
6456 win->in_predrag = FALSE; | |
6457 | |
6458 if (win->drag_leave_signal) { | |
6459 g_signal_handler_disconnect(G_OBJECT(widget), | |
6460 win->drag_leave_signal); | |
6461 | |
6462 win->drag_leave_signal = 0; | |
6463 } | |
6464 } | |
6465 | |
6466 /* If we're not in drag... */ | |
6467 /* We're perfectly normal people! */ | |
6468 if (!win->in_drag) | |
6469 return FALSE; | |
6470 | |
6471 win->in_drag = FALSE; | |
6472 | |
6473 dnd_hints_hide_all(); | |
6474 | |
6475 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6476 | |
6477 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6478 | |
6479 if (dest_win == NULL) { | |
6480 /* If the current window doesn't have any other conversations, | |
6481 * there isn't much point transferring the conv to a new window. */ | |
6482 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6483 /* Make a new window to stick this to. */ | |
6484 dest_win = gaim_gtk_conv_window_new(); | |
6485 new_window = TRUE; | |
6486 } | |
6487 } | |
6488 | |
6489 if (dest_win == NULL) | |
6490 return FALSE; | |
6491 | |
6492 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6493 "conversation-dragging", win, dest_win); | |
6494 | |
6495 /* Get the destination page number. */ | |
6496 if (!new_window) | |
6497 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6498 e->x_root, e->y_root, &to_right); |
11581 | 6499 |
6500 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6501 | |
6502 if (win == dest_win) { | |
6503 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6504 } else { | |
6505 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6506 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6507 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6508 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6509 if (new_window) { | |
6510 gint win_width, win_height; | |
6511 | |
6512 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6513 &win_width, &win_height); | |
6514 | |
6515 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6516 e->x_root - (win_width / 2), | |
6517 e->y_root - (win_height / 2)); | |
6518 | |
6519 gaim_gtk_conv_window_show(dest_win); | |
6520 } | |
6521 } | |
6522 | |
6523 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6524 | |
6525 return TRUE; | |
6526 } | |
6527 | |
6528 | |
6529 static void | |
6530 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6531 gpointer user_data) | |
6532 { | |
6533 GaimGtkWindow *win; | |
6534 GaimConversation *conv; | |
6535 GaimGtkConversation *gtkconv; | |
6536 | |
6537 win = user_data; | |
6538 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6539 | |
6540 g_return_if_fail(conv != NULL); | |
6541 | |
6542 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6543 return; | |
6544 | |
6545 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6546 | |
6547 stop_anim(NULL, gtkconv); | |
6548 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6549 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6550 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6551 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6552 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6553 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6554 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6555 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6556 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6557 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6558 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6559 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6560 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6561 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6562 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6563 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6564 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6565 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6566 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6567 /* Nothing to do if there's only one tab in the window */ |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6568 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6569 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6570 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6571 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6572 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6573 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6574 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6575 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6576 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6577 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6578 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6579 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6580 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6581 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6582 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6583 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6584 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6585 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6586 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6587 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6588 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6589 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6590 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6591 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6592 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6593 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6594 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6595 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6596 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6597 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6598 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6599 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6600 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6601 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6602 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6603 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6604 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6605 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6606 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6607 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6608 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6609 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6610 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6611 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6612 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6613 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6614 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6615 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6616 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6617 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6618 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6619 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6620 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6621 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6622 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6623 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
6624 gaim_gtkconv_get_tab_at_xy(win, event->x_root, event->y_root, NULL)); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6625 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6626 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6627 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6628 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6629 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6630 } |
12188 | 6631 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6632 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6633 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6634 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6635 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6636 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6637 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6638 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6639 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6640 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6641 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6642 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6643 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6644 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6645 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6646 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6647 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6648 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6649 gaim_separator(menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6650 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6651 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6652 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6653 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6654 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6655 G_CALLBACK(close_others_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6656 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6657 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6658 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6659 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6660 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6661 G_CALLBACK(close_window), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6662 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6663 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6664 } |
11581 | 6665 |
6666 static void | |
6667 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6668 gpointer user_data) | |
6669 { | |
6670 GaimGtkWindow *win; | |
6671 GaimConversation *conv; | |
6672 GaimGtkConversation *gtkconv; | |
6673 | |
6674 win = user_data; | |
6675 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6676 conv = gtkconv->active_conv; | |
6677 | |
6678 g_return_if_fail(conv != NULL); | |
6679 | |
6680 /* | |
6681 * Only set "unseen" to "none" if the window has focus | |
6682 */ | |
6683 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6684 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6685 |
6686 /* Update the menubar */ | |
6687 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6688 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging), |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6689 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6690 |
11594 | 6691 generate_send_to_items(win); |
6692 | |
11604 | 6693 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6694 |
6695 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6696 gtkconv->make_sound); | |
6697 | |
6698 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6699 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6700 | |
6701 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 6702 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 6703 |
6704 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6705 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6706 gtkconv->u.im->show_icon); | |
11604 | 6707 |
11581 | 6708 /* |
6709 * We pause icons when they are not visible. If this icon should | |
6710 * be animated then start it back up again. | |
6711 */ | |
6712 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6713 (gtkconv->u.im->animate)) | |
6714 start_anim(NULL, gtkconv); | |
6715 } | |
6716 | |
6717 /************************************************************************** | |
6718 * GTK+ window ops | |
6719 **************************************************************************/ | |
6720 | |
6721 GList * | |
6722 gaim_gtk_conv_windows_get_list() | |
6723 { | |
6724 return window_list; | |
6725 } | |
6726 | |
6727 GaimGtkWindow * | |
6728 gaim_gtk_conv_window_new() | |
6729 { | |
6730 GaimGtkWindow *win; | |
6731 GtkPositionType pos; | |
6732 GtkWidget *testidea; | |
6733 GtkWidget *menubar; | |
6734 | |
6735 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6736 | |
6737 window_list = g_list_append(window_list, win); | |
6738 | |
6739 /* Create the window. */ | |
6740 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6741 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6742 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6743 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6744 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6745 | |
6746 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6747 G_CALLBACK(close_win_cb), win); | |
6748 | |
6749 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6750 G_CALLBACK(focus_win_cb), win); | |
6751 | |
6752 /* Create the notebook. */ | |
6753 win->notebook = gtk_notebook_new(); | |
6754 | |
6755 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6756 | |
6757 #if 0 | |
6758 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6759 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6760 #endif | |
6761 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6762 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6763 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6764 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6765 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6766 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6767 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6768 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6769 |
11581 | 6770 gtk_widget_show(win->notebook); |
6771 | |
6772 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6773 G_CALLBACK(before_switch_conv_cb), win); | |
6774 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6775 G_CALLBACK(switch_conv_cb), win); | |
6776 | |
6777 /* Setup the tab drag and drop signals. */ | |
6778 gtk_widget_add_events(win->notebook, | |
6779 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6780 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6781 G_CALLBACK(notebook_press_cb), win); | |
6782 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6783 G_CALLBACK(notebook_release_cb), win); | |
6784 | |
6785 testidea = gtk_vbox_new(FALSE, 0); | |
6786 | |
6787 /* Setup the menubar. */ | |
6788 menubar = setup_menubar(win); | |
6789 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6790 | |
6791 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6792 | |
6793 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6794 | |
6795 gtk_widget_show(testidea); | |
6796 | |
6797 return win; | |
6798 } | |
6799 | |
6800 void | |
6801 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6802 { | |
6803 window_list = g_list_remove(window_list, win); | |
6804 | |
11611 | 6805 if (win->gtkconvs) { |
6806 while (win->gtkconvs) { | |
6807 GList *nextgtk = win->gtkconvs->next; | |
6808 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6809 GList *nextcore = gtkconv->convs->next; | |
6810 GaimConversation *conv = gtkconv->convs->data; | |
6811 gaim_conversation_destroy(conv); | |
6812 if (!nextgtk && !nextcore) | |
6813 /* we'll end up invoking ourselves when we destroy our last child */ | |
6814 /* so don't destroy ourselves right now */ | |
6815 return; | |
6816 } | |
6817 return; | |
6818 } | |
11581 | 6819 gtk_widget_destroy(win->window); |
6820 | |
6821 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6822 | |
6823 g_free(win); | |
6824 } | |
6825 | |
6826 void | |
6827 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6828 { | |
6829 gtk_widget_show(win->window); | |
6830 } | |
6831 | |
6832 void | |
6833 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6834 { | |
6835 gtk_widget_hide(win->window); | |
6836 } | |
6837 | |
6838 void | |
6839 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6840 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6841 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6842 } |
6843 | |
6844 void | |
6845 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6846 { | |
6847 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6848 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6849 gtkconv->tab_cont)); | |
6850 } | |
6851 | |
6852 void | |
6853 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6854 { | |
6855 GaimConversation *conv = gtkconv->active_conv; | |
6856 GaimGtkConversation *focus_gtkconv; | |
6857 GtkWidget *tabby, *menu_tabby; | |
6858 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6859 GtkWidget *close_image; | |
6860 GaimConversationType conv_type; | |
6861 const char *name; | |
6862 const gchar *tmp_lab; | |
6863 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6864 gboolean tabs_side = FALSE; |
6865 gint angle = 0; | |
11581 | 6866 |
6867 name = gaim_conversation_get_name(conv); | |
6868 conv_type = gaim_conversation_get_type(conv); | |
6869 | |
6870 | |
6871 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6872 gtkconv->win = win; | |
6873 | |
11619 | 6874 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6875 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6876 tabs_side = TRUE; | |
6877 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6878 angle = 90; | |
6879 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6880 angle = 270; | |
6881 | |
6882 if (angle) | |
6883 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6884 else | |
6885 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6886 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6887 | |
6888 /* Close button. */ | |
6889 gtkconv->close = gtk_button_new(); | |
6890 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6891 if (gtk_check_version(2, 4, 2) == NULL) { | |
6892 /* Need to account for extra padding around the gtkbutton */ | |
6893 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6894 "focus-line-width", &focus_width, | |
6895 "focus-padding", &focus_pad, | |
6896 NULL); | |
6897 close_button_width += (focus_width + focus_pad) * 2; | |
6898 close_button_height += (focus_width + focus_pad) * 2; | |
6899 } | |
6900 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6901 close_button_width, close_button_height); | |
6902 | |
6903 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6904 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6905 gtk_widget_show(close_image); | |
6906 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6907 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6908 _("Close conversation"), NULL); | |
6909 | |
6910 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6911 G_CALLBACK(close_conv_cb), gtkconv); | |
6912 | |
11851 | 6913 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6914 /* |
6915 * I love Galeon. They have a fix for that stupid annoying visible | |
6916 * border bug. I love you guys! -- ChipX86 | |
6917 */ | |
11851 | 6918 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6919 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6920 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6921 #endif |
11581 | 6922 |
6923 /* Status icon. */ | |
6924 gtkconv->icon = gtk_image_new(); | |
6925 gtkconv->menu_icon = gtk_image_new(); | |
6926 update_tab_icon(conv); | |
6927 | |
6928 /* Tab label. */ | |
6929 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6930 |
11581 | 6931 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6932 if (!angle) |
6933 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6934 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6935 if (tabs_side) { |
6936 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6937 } | |
6938 if (angle) | |
6939 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6940 #endif |
6941 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6942 #if 0 | |
6943 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6944 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6945 #endif | |
6946 | |
6947 /* Pack it all together. */ | |
11619 | 6948 if (angle == 90) |
6949 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6950 else | |
6951 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6952 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6953 FALSE, FALSE, 0); | |
6954 | |
6955 gtk_widget_show_all(gtkconv->icon); | |
6956 gtk_widget_show_all(gtkconv->menu_icon); | |
6957 | |
6958 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6959 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6960 gtk_widget_show(gtkconv->tab_label); | |
6961 gtk_widget_show(gtkconv->menu_label); | |
6962 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6963 | |
11619 | 6964 if (angle == 90) |
6965 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6966 else | |
6967 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6968 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6969 gtk_widget_show(gtkconv->close); | |
6970 | |
6971 gtk_widget_show(tabby); | |
6972 gtk_widget_show(menu_tabby); | |
6973 | |
6974 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6975 gaim_gtkconv_update_buddy_icon(conv); | |
6976 | |
6977 /* Add this pane to the conversation's notebook. */ | |
6978 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6979 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6980 |
6981 | |
6982 gtk_widget_show(tab_cont); | |
6983 | |
6984 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6985 /* Er, bug in notebooks? Switch to the page manually. */ | |
6986 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6987 | |
6988 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6989 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6990 } else | |
6991 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6992 | |
6993 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6994 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6995 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6996 | |
6997 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6998 update_send_to_selection(win); |
11581 | 6999 } |
7000 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7001 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7002 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 7003 { |
7004 unsigned int index; | |
7005 GaimConversationType conv_type; | |
7006 | |
7007 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
7008 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
7009 | |
7010 g_object_ref(gtkconv->tab_cont); | |
7011 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
7012 | |
7013 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
7014 | |
7015 /* go back to tabless if need be */ | |
7016 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
7017 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7018 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7019 } | |
7020 | |
7021 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 7022 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7023 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7024 gaim_gtk_conv_window_destroy(win); |
11581 | 7025 } |
7026 | |
7027 GaimGtkConversation * | |
7028 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7029 { | |
7030 GtkWidget *tab_cont; | |
7031 | |
7032 if (index == -1) | |
7033 index = 0; | |
7034 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7035 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7036 } |
7037 | |
7038 GaimGtkConversation * | |
7039 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7040 { | |
7041 int index; | |
7042 GtkWidget *tab_cont; | |
7043 | |
7044 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7045 if (index == -1) | |
7046 index = 0; | |
7047 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7048 if (!tab_cont) | |
7049 return NULL; | |
7050 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7051 } | |
7052 | |
7053 | |
7054 GaimConversation * | |
7055 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7056 { | |
7057 GaimGtkConversation *gtkconv; | |
7058 | |
7059 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7060 return gtkconv ? gtkconv->active_conv : NULL; | |
7061 } | |
7062 | |
7063 gboolean | |
7064 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7065 { | |
7066 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7067 } | |
7068 | |
7069 gboolean | |
7070 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7071 { | |
7072 gboolean has_focus = FALSE; | |
7073 | |
7074 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7075 | |
7076 return has_focus; | |
7077 } | |
7078 | |
7079 GaimGtkWindow * | |
7080 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7081 { | |
7082 GaimGtkWindow *win; | |
7083 GdkWindow *gdkwin; | |
7084 GList *l; | |
7085 | |
7086 gdkwin = gdk_window_at_pointer(&x, &y); | |
7087 | |
7088 if (gdkwin) | |
7089 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7090 | |
7091 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7092 win = l->data; | |
7093 | |
7094 if (gdkwin == win->window->window) | |
7095 return win; | |
7096 } | |
7097 | |
7098 return NULL; | |
7099 } | |
7100 | |
7101 GList * | |
7102 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7103 { | |
7104 return win->gtkconvs; | |
7105 } | |
7106 | |
7107 guint | |
7108 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7109 { | |
7110 return g_list_length(win->gtkconvs); | |
7111 } | |
7112 | |
7113 GaimGtkWindow * | |
7114 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7115 { | |
7116 GList *wins, *convs; | |
7117 GaimGtkWindow *win; | |
7118 GaimGtkConversation *conv; | |
7119 | |
7120 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7121 return NULL; | |
7122 | |
7123 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7124 win = wins->data; | |
7125 | |
7126 for (convs = win->gtkconvs; | |
7127 convs != NULL; | |
7128 convs = convs->next) { | |
7129 | |
7130 conv = convs->data; | |
7131 | |
7132 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7133 return win; | |
7134 } | |
7135 } | |
7136 | |
7137 return NULL; | |
7138 } | |
7139 | |
7140 GaimGtkWindow * | |
7141 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7142 { | |
7143 GList *wins, *convs; | |
7144 GaimGtkWindow *win; | |
7145 GaimGtkConversation *conv; | |
7146 | |
7147 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7148 return NULL; | |
7149 | |
7150 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7151 wins != NULL; | |
7152 wins = wins->prev) { | |
7153 | |
7154 win = wins->data; | |
7155 | |
7156 for (convs = win->gtkconvs; | |
7157 convs != NULL; | |
7158 convs = convs->next) { | |
7159 | |
7160 conv = convs->data; | |
7161 | |
7162 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7163 return win; | |
7164 } | |
7165 } | |
7166 | |
7167 return NULL; | |
7168 } | |
7169 | |
7170 | |
7171 /************************************************************************** | |
7172 * Conversation placement functions | |
7173 **************************************************************************/ | |
7174 typedef struct | |
7175 { | |
7176 char *id; | |
7177 char *name; | |
7178 GaimConvPlacementFunc fnc; | |
7179 | |
7180 } ConvPlacementData; | |
7181 | |
7182 static GList *conv_placement_fncs = NULL; | |
7183 static GaimConvPlacementFunc place_conv = NULL; | |
7184 | |
7185 /* This one places conversations in the last made window. */ | |
7186 static void | |
7187 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7188 { | |
7189 GaimGtkWindow *win; | |
7190 | |
7191 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7192 win = l ? l->data : NULL;; | |
7193 | |
7194 if (win == NULL) { | |
7195 win = gaim_gtk_conv_window_new(); | |
7196 | |
7197 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7198 gaim_gtk_conv_window_show(win); | |
7199 } else { | |
7200 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7201 } | |
7202 } | |
7203 | |
7204 /* This one places conversations in the last made window of the same type. */ | |
7205 static void | |
7206 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7207 { | |
7208 GaimGtkWindow *win; | |
7209 | |
7210 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7211 | |
7212 if (win == NULL) { | |
7213 win = gaim_gtk_conv_window_new(); | |
7214 | |
7215 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7216 gaim_gtk_conv_window_show(win); | |
7217 } else | |
7218 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7219 } | |
7220 | |
7221 /* This one places each conversation in its own window. */ | |
7222 static void | |
7223 conv_placement_new_window(GaimGtkConversation *conv) | |
7224 { | |
7225 GaimGtkWindow *win; | |
7226 | |
7227 win = gaim_gtk_conv_window_new(); | |
7228 | |
7229 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7230 | |
7231 gaim_gtk_conv_window_show(win); | |
7232 } | |
7233 | |
7234 static GaimGroup * | |
7235 conv_get_group(GaimGtkConversation *conv) | |
7236 { | |
7237 GaimGroup *group = NULL; | |
7238 | |
7239 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7240 GaimBuddy *buddy; | |
7241 | |
7242 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7243 gaim_conversation_get_name(conv->active_conv)); | |
7244 | |
7245 if (buddy != NULL) | |
12088 | 7246 group = gaim_buddy_get_group(buddy); |
11581 | 7247 |
7248 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7249 GaimChat *chat; | |
7250 | |
7251 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7252 gaim_conversation_get_name(conv->active_conv)); | |
7253 | |
7254 if (chat != NULL) | |
7255 group = gaim_chat_get_group(chat); | |
7256 } | |
7257 | |
7258 return group; | |
7259 } | |
7260 | |
7261 /* | |
7262 * This groups things by, well, group. Buddies from groups will always be | |
7263 * grouped together, and a buddy from a group not belonging to any currently | |
7264 * open windows will get a new window. | |
7265 */ | |
7266 static void | |
7267 conv_placement_by_group(GaimGtkConversation *conv) | |
7268 { | |
7269 GaimConversationType type; | |
7270 GaimGroup *group = NULL; | |
7271 GList *wl, *cl; | |
7272 | |
7273 type = gaim_conversation_get_type(conv->active_conv); | |
7274 | |
7275 group = conv_get_group(conv); | |
7276 | |
7277 /* Go through the list of IMs and find one with this group. */ | |
7278 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7279 GaimGtkWindow *win2; | |
7280 GaimGtkConversation *conv2; | |
7281 GaimGroup *group2 = NULL; | |
7282 | |
7283 win2 = wl->data; | |
7284 | |
7285 for (cl = win2->gtkconvs; | |
7286 cl != NULL; | |
7287 cl = cl->next) { | |
7288 conv2 = cl->data; | |
7289 | |
7290 group2 = conv_get_group(conv2); | |
7291 | |
7292 if (group == group2) { | |
7293 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7294 | |
7295 return; | |
7296 } | |
7297 } | |
7298 } | |
7299 | |
7300 /* Make a new window. */ | |
7301 conv_placement_new_window(conv); | |
7302 } | |
7303 | |
7304 /* This groups things by account. Otherwise, the same semantics as above */ | |
7305 static void | |
7306 conv_placement_by_account(GaimGtkConversation *conv) | |
7307 { | |
7308 GaimConversationType type; | |
7309 GList *wins, *convs; | |
7310 GaimAccount *account; | |
7311 | |
7312 account = gaim_conversation_get_account(conv->active_conv); | |
7313 type = gaim_conversation_get_type(conv->active_conv); | |
7314 | |
7315 /* Go through the list of IMs and find one with this group. */ | |
7316 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7317 GaimGtkWindow *win2; | |
7318 GaimGtkConversation *conv2; | |
7319 | |
7320 win2 = wins->data; | |
7321 | |
7322 for (convs = win2->gtkconvs; | |
7323 convs != NULL; | |
7324 convs = convs->next) { | |
7325 conv2 = convs->data; | |
7326 | |
7327 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7328 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7329 return; | |
7330 } | |
7331 } | |
7332 } | |
7333 | |
7334 /* Make a new window. */ | |
7335 conv_placement_new_window(conv); | |
7336 } | |
7337 | |
7338 static ConvPlacementData * | |
7339 get_conv_placement_data(const char *id) | |
7340 { | |
7341 ConvPlacementData *data = NULL; | |
7342 GList *n; | |
7343 | |
7344 for (n = conv_placement_fncs; n; n = n->next) { | |
7345 data = n->data; | |
7346 if (!strcmp(data->id, id)) | |
7347 return data; | |
7348 } | |
7349 | |
7350 return NULL; | |
7351 } | |
7352 | |
7353 static void | |
7354 add_conv_placement_fnc(const char *id, const char *name, | |
7355 GaimConvPlacementFunc fnc) | |
7356 { | |
7357 ConvPlacementData *data; | |
7358 | |
7359 data = g_new(ConvPlacementData, 1); | |
7360 | |
7361 data->id = g_strdup(id); | |
7362 data->name = g_strdup(name); | |
7363 data->fnc = fnc; | |
7364 | |
7365 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7366 } | |
7367 | |
7368 static void | |
7369 ensure_default_funcs(void) | |
7370 { | |
7371 if (conv_placement_fncs == NULL) { | |
7372 add_conv_placement_fnc("last", _("Last created window"), | |
7373 conv_placement_last_created_win); | |
7374 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7375 conv_placement_last_created_win_type); | |
7376 add_conv_placement_fnc("new", _("New window"), | |
7377 conv_placement_new_window); | |
7378 add_conv_placement_fnc("group", _("By group"), | |
7379 conv_placement_by_group); | |
7380 add_conv_placement_fnc("account", _("By account"), | |
7381 conv_placement_by_account); | |
7382 } | |
7383 } | |
7384 | |
7385 GList * | |
7386 gaim_gtkconv_placement_get_options(void) | |
7387 { | |
7388 GList *n, *list = NULL; | |
7389 ConvPlacementData *data; | |
7390 | |
7391 ensure_default_funcs(); | |
7392 | |
7393 for (n = conv_placement_fncs; n; n = n->next) { | |
7394 data = n->data; | |
7395 list = g_list_append(list, data->name); | |
7396 list = g_list_append(list, data->id); | |
7397 } | |
7398 | |
7399 return list; | |
7400 } | |
7401 | |
7402 | |
7403 void | |
7404 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7405 GaimConvPlacementFunc fnc) | |
7406 { | |
7407 g_return_if_fail(id != NULL); | |
7408 g_return_if_fail(name != NULL); | |
7409 g_return_if_fail(fnc != NULL); | |
7410 | |
7411 ensure_default_funcs(); | |
7412 | |
7413 add_conv_placement_fnc(id, name, fnc); | |
7414 } | |
7415 | |
7416 void | |
7417 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7418 { | |
7419 ConvPlacementData *data = get_conv_placement_data(id); | |
7420 | |
7421 if (data == NULL) | |
7422 return; | |
7423 | |
7424 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7425 | |
7426 g_free(data->id); | |
7427 g_free(data->name); | |
7428 g_free(data); | |
7429 } | |
7430 | |
7431 const char * | |
7432 gaim_gtkconv_placement_get_name(const char *id) | |
7433 { | |
7434 ConvPlacementData *data; | |
7435 | |
7436 ensure_default_funcs(); | |
7437 | |
7438 data = get_conv_placement_data(id); | |
7439 | |
7440 if (data == NULL) | |
7441 return NULL; | |
7442 | |
7443 return data->name; | |
7444 } | |
7445 | |
7446 GaimConvPlacementFunc | |
7447 gaim_gtkconv_placement_get_fnc(const char *id) | |
7448 { | |
7449 ConvPlacementData *data; | |
7450 | |
7451 ensure_default_funcs(); | |
7452 | |
7453 data = get_conv_placement_data(id); | |
7454 | |
7455 if (data == NULL) | |
7456 return NULL; | |
7457 | |
7458 return data->fnc; | |
7459 } | |
7460 | |
7461 void | |
7462 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7463 { | |
7464 g_return_if_fail(func != NULL); | |
7465 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7466 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7467 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7468 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7469 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7470 place_conv = NULL; |
11581 | 7471 } |
7472 | |
7473 GaimConvPlacementFunc | |
7474 gaim_gtkconv_placement_get_current_func(void) | |
7475 { | |
7476 return place_conv; | |
7477 } | |
7478 | |
7479 void | |
7480 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7481 { | |
7482 if (place_conv) | |
7483 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7484 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7485 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7486 } |
12239 | 7487 |
7488 gboolean | |
7489 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
7490 { | |
7491 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
7492 | |
7493 return (gtkconv->win == hidden_convwin); | |
7494 } |