Mercurial > pidgin
annotate src/gtkconv.c @ 12264:2be62353f708
[gaim-migrate @ 14566]
this was TRUE in oldstatus
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Tue, 29 Nov 2005 23:50:39 +0000 |
parents | 1c0fd404e07e |
children | 3ef381cdc47e |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1 /** |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
2 * @file gtkconv.c GTK+ Conversation API |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3 * @ingroup gtkui |
4359 | 4 * |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
5 * gaim |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
6 * |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
10 * |
4359 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
28 |
4359 | 29 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
30 # include <X11/Xlib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
31 #endif |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
32 |
4359 | 33 #ifdef USE_GTKSPELL |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
34 # include <gtkspell/gtkspell.h> |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
35 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
36 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
37 # endif |
4359 | 38 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
39 |
4359 | 40 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
41 |
9699 | 42 #include "account.h" |
9130 | 43 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
44 #include "debug.h" |
6982 | 45 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
46 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
47 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
48 #include "prpl.h" |
6038 | 49 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
50 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
52 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
53 #include "gtkblist.h" |
5717 | 54 #include "gtkconv.h" |
11583 | 55 #include "gtkconvwin.h" |
9709 | 56 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
57 #include "gtkimhtml.h" |
8317 | 58 #include "gtkimhtmltoolbar.h" |
7431 | 59 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
60 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
61 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
62 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
63 #include "gtkprivacy.h" |
11525 | 64 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
65 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
66 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
67 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
69 |
12190 | 70 #define SEND_COLOR "#204a87" |
71 #define RECV_COLOR "#cc0000" | |
7854 | 72 |
10108 | 73 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
74 | |
75 /* These colors come from the default GNOME palette */ | |
76 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
77 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
78 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
79 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
80 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
81 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
84 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
86 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
94 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
95 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
96 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
97 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
98 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 99 }; |
6291 | 100 |
4359 | 101 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
102 | |
11581 | 103 typedef struct { |
4359 | 104 GtkWidget *window; |
105 | |
106 GtkWidget *entry; | |
107 GtkWidget *message; | |
108 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
109 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
110 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
111 } InviteBuddyInfo; |
4359 | 112 |
113 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
114 static GtkWidget *warn_close_dialog = NULL; |
4359 | 115 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
116 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
117 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
118 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
119 |
11594 | 120 static gboolean update_send_to_selection(GaimGtkWindow *win); |
121 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 122 |
4359 | 123 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 124 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 125 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
126 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
127 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 128 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 129 static gboolean tab_complete(GaimConversation *conv); |
11604 | 130 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 131 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 132 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
133 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
|
134 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
135 static void private_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
136 gboolean destroy_empty); |
4359 | 137 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
138 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
139 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
140 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
141 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
142 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
143 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
144 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
145 (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
|
146 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
147 /* 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
|
148 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
149 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
150 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
151 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
152 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
153 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
154 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
155 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
156 |
4359 | 157 /************************************************************************** |
158 * Callbacks | |
159 **************************************************************************/ | |
10971 | 160 |
4359 | 161 static gint |
10810 | 162 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 163 { |
10810 | 164 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 165 |
10810 | 166 l = list; |
167 while (l) { | |
168 GaimConversation *conv = l->data; | |
169 gaim_conversation_destroy(conv); | |
170 l = l->next; | |
171 } | |
11508 | 172 |
10810 | 173 g_list_free(list); |
11508 | 174 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
175 return TRUE; |
4359 | 176 } |
177 | |
8914 | 178 static gboolean |
10810 | 179 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 180 { |
10810 | 181 GaimConversation *conv = gtkconv->active_conv; |
11508 | 182 |
8914 | 183 if (!GTK_WIDGET_VISIBLE(w)) |
184 return FALSE; | |
185 | |
186 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
187 return FALSE; | |
188 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
189 /* 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
|
190 * 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
|
191 * 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
|
192 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
193 /* 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
|
194 * negate it anyway. --luke */ |
11338 | 195 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 196 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
197 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
198 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
199 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
200 } |
8914 | 201 if (w == gtkconv->entry) |
202 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
203 } | |
11338 | 204 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 205 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
206 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
207 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
|
208 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
|
209 } |
8914 | 210 if (w == gtkconv->entry) |
211 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
212 } | |
213 | |
214 return FALSE; | |
215 } | |
216 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
217 static void |
10810 | 218 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
219 { |
10810 | 220 GaimConversation *conv = c->active_conv; |
11508 | 221 |
10665 | 222 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
223 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
224 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
225 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
226 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
227 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
|
228 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
229 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
230 if (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
|
231 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
232 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
233 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
|
234 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
235 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
236 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
237 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
238 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
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(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
244 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
245 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 fg_color.blue / 256); |
8061 | 251 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 g_free(color); |
8677 | 273 |
9025 | 274 |
10665 | 275 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 276 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
277 else | |
278 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 279 } |
280 } | |
9130 | 281 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
282 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
283 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
284 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
285 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
286 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
287 |
9130 | 288 static const char * |
289 gaim_gtk_get_cmd_prefix(void) | |
290 { | |
291 return "/"; | |
292 } | |
293 | |
9167 | 294 static GaimCmdRet |
9829 | 295 say_command_cb(GaimConversation *conv, |
296 const char *cmd, char **args, char **error, void *data) | |
297 { | |
11338 | 298 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 299 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 300 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 301 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
302 | |
303 return GAIM_CMD_RET_OK; | |
304 } | |
305 | |
306 static GaimCmdRet | |
9167 | 307 me_command_cb(GaimConversation *conv, |
9597 | 308 const char *cmd, char **args, char **error, void *data) |
9167 | 309 { |
310 char *tmp; | |
311 | |
312 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 313 |
11338 | 314 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 315 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 316 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 317 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
318 | |
319 g_free(tmp); | |
320 return GAIM_CMD_RET_OK; | |
321 } | |
322 | |
9212 | 323 static GaimCmdRet |
324 debug_command_cb(GaimConversation *conv, | |
9597 | 325 const char *cmd, char **args, char **error, void *data) |
9212 | 326 { |
327 char *tmp, *markup; | |
328 GaimCmdStatus status; | |
329 | |
330 if (!g_ascii_strcasecmp(args[0], "version")) { | |
331 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
|
332 markup = g_markup_escape_text(tmp, -1); |
9212 | 333 |
334 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
335 | |
336 g_free(tmp); | |
337 g_free(markup); | |
338 return status; | |
339 } else { | |
340 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
341 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
342 return GAIM_CMD_STATUS_OK; | |
343 } | |
344 } | |
345 | |
9213 | 346 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
347 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
348 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
349 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
350 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
351 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
352 gtkconv = GAIM_GTK_CONVERSATION(conv); |
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 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
355 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
356 } |
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 static GaimCmdRet |
9213 | 359 help_command_cb(GaimConversation *conv, |
9597 | 360 const char *cmd, char **args, char **error, void *data) |
9213 | 361 { |
9597 | 362 GList *l, *text; |
9213 | 363 GString *s; |
9597 | 364 |
365 if (args[0] != NULL) { | |
366 s = g_string_new(""); | |
367 text = gaim_cmd_help(conv, args[0]); | |
368 | |
369 if (text) { | |
370 for (l = text; l; l = l->next) | |
371 if (l->next) | |
9816 | 372 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 373 else |
9816 | 374 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 375 } else { |
376 g_string_append(s, _("No such command (in this context).")); | |
377 } | |
378 } else { | |
379 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
380 "The following commands are available in this context:\n")); | |
381 | |
382 text = gaim_cmd_list(conv); | |
383 for (l = text; l; l = l->next) | |
9213 | 384 if (l->next) |
9597 | 385 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 386 else |
9597 | 387 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 388 } |
389 | |
390 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
391 g_string_free(s, TRUE); | |
392 | |
393 return GAIM_CMD_STATUS_OK; | |
394 } | |
395 | |
4359 | 396 static void |
9374 | 397 send_history_add(GaimConversation *conv, const char *message) |
398 { | |
399 GList *first; | |
400 | |
401 first = g_list_first(conv->send_history); | |
402 | |
403 if (first->data) | |
404 g_free(first->data); | |
405 | |
406 first->data = g_strdup(message); | |
407 | |
408 conv->send_history = g_list_prepend(first, NULL); | |
409 } | |
410 | |
9832 | 411 static gboolean |
412 check_for_and_do_command(GaimConversation *conv) | |
413 { | |
414 GaimGtkConversation *gtkconv; | |
415 char *cmd; | |
416 const char *prefix; | |
417 GaimAccount *account; | |
418 GtkTextIter start; | |
419 | |
420 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
421 account = gaim_conversation_get_account(conv); | |
422 prefix = gaim_gtk_get_cmd_prefix(); | |
423 | |
424 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
425 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
426 | |
427 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
428 && !gtk_text_iter_get_child_anchor(&start)) { | |
429 GaimCmdStatus status; | |
430 char *error, *cmdline, *markup, *send_history; | |
431 GtkTextIter end; | |
432 | |
433 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
434 send_history_add(conv, send_history); | |
435 g_free(send_history); | |
436 | |
437 cmdline = cmd + strlen(prefix); | |
438 | |
439 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
440 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
441 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
442 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
443 g_free(cmd); | |
444 g_free(markup); | |
445 | |
446 switch (status) { | |
447 case GAIM_CMD_STATUS_OK: | |
448 return TRUE; | |
449 case GAIM_CMD_STATUS_NOT_FOUND: | |
450 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
451 gaim_conversation_write(conv, "", _("No such command."), | |
452 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
453 | |
454 return TRUE; | |
455 } | |
456 return FALSE; | |
457 case GAIM_CMD_STATUS_WRONG_ARGS: | |
458 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
459 "to that command."), | |
460 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
461 return TRUE; | |
462 case GAIM_CMD_STATUS_FAILED: | |
463 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
464 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
465 if(error) | |
466 g_free(error); | |
467 return TRUE; | |
468 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 469 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 470 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 471 GAIM_MESSAGE_NO_LOG, time(NULL)); |
472 else | |
10843 | 473 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 474 GAIM_MESSAGE_NO_LOG, time(NULL)); |
475 return TRUE; | |
476 case GAIM_CMD_STATUS_WRONG_PRPL: | |
477 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
478 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
479 return TRUE; | |
480 } | |
481 } | |
482 | |
483 g_free(cmd); | |
484 return FALSE; | |
485 } | |
486 | |
9374 | 487 static void |
10810 | 488 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 489 { |
10810 | 490 GaimConversation *conv = gtkconv->active_conv; |
8655 | 491 GaimAccount *account; |
8677 | 492 GaimConnection *gc; |
12216 | 493 GaimMessageFlags flags = 0; |
8448 | 494 char *buf, *clean; |
4359 | 495 |
8655 | 496 account = gaim_conversation_get_account(conv); |
9130 | 497 |
9471 | 498 if (!gaim_account_is_connected(account)) |
499 return; | |
500 | |
11338 | 501 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 502 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 503 return; |
504 | |
9832 | 505 if (check_for_and_do_command(conv)) { |
506 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
507 return; | |
9130 | 508 } |
509 | |
8442 | 510 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 511 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 512 |
4359 | 513 gtk_widget_grab_focus(gtkconv->entry); |
514 | |
8448 | 515 if (strlen(clean) == 0) { |
516 g_free(clean); | |
4359 | 517 return; |
518 } | |
519 | |
12216 | 520 /* XXX: is there a better way to tell if the message has images? */ |
521 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
522 flags |= GAIM_MESSAGE_IMAGES; | |
523 | |
8677 | 524 gc = gaim_account_get_connection(account); |
10665 | 525 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 526 char **bufs; |
527 int i; | |
528 | |
529 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
530 for (i = 0; bufs[i]; i++) { | |
9374 | 531 send_history_add(conv, bufs[i]); |
11338 | 532 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 533 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 534 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 535 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 536 } |
537 | |
538 g_strfreev(bufs); | |
539 | |
540 } else { | |
9374 | 541 send_history_add(conv, buf); |
11338 | 542 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 543 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 544 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 545 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 546 } |
4359 | 547 |
8677 | 548 g_free(clean); |
4359 | 549 g_free(buf); |
550 | |
8061 | 551 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 552 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 553 } |
554 | |
555 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
556 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 557 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
558 GaimAccount *account; |
4359 | 559 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
560 GaimConversation *conv = gtkconv->active_conv; |
4359 | 561 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
562 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
563 name = gaim_conversation_get_name(conv); |
7879 | 564 |
11338 | 565 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 566 GaimBuddy *b; |
567 | |
568 b = gaim_find_buddy(account, name); | |
569 if (b != NULL) | |
9730 | 570 gaim_gtkdialogs_remove_buddy(b); |
7859 | 571 else if (account != NULL && gaim_account_is_connected(account)) |
572 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 573 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 574 GaimChat *c; |
575 | |
576 c = gaim_blist_find_chat(account, name); | |
577 if (c != NULL) | |
9730 | 578 gaim_gtkdialogs_remove_chat(c); |
7859 | 579 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 580 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 581 } |
4359 | 582 |
583 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
584 } | |
585 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
586 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 587 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
588 GaimConversation *conv = gtkconv->active_conv; |
7975 | 589 GaimPluginProtocolInfo *prpl_info = NULL; |
590 GaimConnection *gc; | |
591 | |
592 if ((gc = gaim_conversation_get_gc(conv))) { | |
593 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
594 | |
595 /* | |
596 * If there are special needs for getting info on users in | |
597 * buddy chat "rooms"... | |
598 */ | |
599 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
600 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
601 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
602 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
603 } |
7975 | 604 else |
605 prpl_info->get_info(gc, who); | |
606 } | |
607 } | |
608 | |
609 | |
4359 | 610 static void |
10810 | 611 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 612 { |
10810 | 613 GaimConversation *conv = gtkconv->active_conv; |
4359 | 614 |
11338 | 615 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 616 serv_get_info(gaim_conversation_get_gc(conv), |
617 gaim_conversation_get_name(conv)); | |
618 | |
619 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 620 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 621 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
622 GaimGtkChatPane *gtkchat; |
4359 | 623 GtkTreeIter iter; |
624 GtkTreeModel *model; | |
625 GtkTreeSelection *sel; | |
9554 | 626 char *name; |
4359 | 627 |
628 gtkchat = gtkconv->u.chat; | |
629 | |
630 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
631 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
632 | |
633 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 634 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 635 else |
636 return; | |
637 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
638 chat_do_info(gtkconv, name); |
9554 | 639 g_free(name); |
4359 | 640 } |
641 } | |
642 | |
643 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
644 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 645 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
646 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
647 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
648 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
649 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
650 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
651 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
652 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 653 |
654 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
655 } | |
656 | |
657 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
658 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 659 { |
660 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
661 GaimGtkConversation *gtkconv; |
4359 | 662 |
663 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
664 | |
665 if (resp == GTK_RESPONSE_OK) { | |
666 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
667 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
668 | |
10113 | 669 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 670 return; |
671 | |
672 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
673 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 674 message, buddy); |
675 } | |
676 | |
677 gtk_widget_destroy(invite_dialog); | |
678 invite_dialog = NULL; | |
679 | |
680 g_free(info); | |
681 } | |
682 | |
683 static void | |
9909 | 684 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
685 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
686 { | |
687 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
688 const char *convprotocol; | |
689 | |
690 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
691 | |
692 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
693 { | |
694 GaimBlistNode *node = NULL; | |
695 GaimBuddy *buddy; | |
696 | |
697 memcpy(&node, sd->data, sizeof(node)); | |
698 | |
699 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
700 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
701 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
702 buddy = (GaimBuddy *)node; | |
703 else | |
704 return; | |
705 | |
706 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
707 { | |
708 gaim_notify_error(NULL, NULL, | |
709 _("That buddy is not on the same protocol as this " | |
10843 | 710 "chat."), NULL); |
9909 | 711 } |
712 else | |
713 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
714 | |
715 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
716 } | |
717 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
718 { | |
719 char *protocol = NULL; | |
720 char *username = NULL; | |
721 GaimAccount *account; | |
722 | |
11137 | 723 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 724 &protocol, &username, NULL)) |
725 { | |
726 if (account == NULL) | |
727 { | |
728 gaim_notify_error(NULL, NULL, | |
729 _("You are not currently signed on with an account that " | |
730 "can invite that buddy."), NULL); | |
731 } | |
732 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
733 { | |
734 gaim_notify_error(NULL, NULL, | |
735 _("That buddy is not on the same protocol as this " | |
10843 | 736 "chat."), NULL); |
9909 | 737 } |
738 else | |
739 { | |
740 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
741 } | |
742 } | |
743 | |
744 if (username != NULL) g_free(username); | |
745 if (protocol != NULL) g_free(protocol); | |
746 | |
747 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
748 } | |
749 } | |
750 | |
751 static const GtkTargetEntry dnd_targets[] = | |
752 { | |
753 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
754 {"application/x-im-contact", 0, 1} | |
755 }; | |
756 | |
757 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
758 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 759 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
760 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
761 InviteBuddyInfo *info = NULL; |
4359 | 762 |
763 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
764 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
765 GaimGtkWindow *gtkwin; |
4359 | 766 GtkWidget *label; |
767 GtkWidget *vbox, *hbox; | |
768 GtkWidget *table; | |
769 GtkWidget *img; | |
770 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
771 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 772 GTK_ICON_SIZE_DIALOG); |
4359 | 773 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
774 info = g_new0(InviteBuddyInfo, 1); |
4359 | 775 info->conv = conv; |
776 | |
11581 | 777 gc = gaim_conversation_get_gc(conv); |
778 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 779 |
780 /* Create the new dialog. */ | |
781 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 782 _("Invite Buddy Into Chat Room"), |
7879 | 783 GTK_WINDOW(gtkwin->window), 0, |
784 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
785 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 786 |
787 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 788 GTK_RESPONSE_OK); |
11243 | 789 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 790 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
791 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
792 | |
9909 | 793 info->window = GTK_WIDGET(invite_dialog); |
794 | |
4359 | 795 /* Setup the outside spacing. */ |
796 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
797 | |
11243 | 798 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
799 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 800 |
801 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 802 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 803 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
804 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
805 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
806 | |
807 /* Setup the right vbox. */ | |
808 vbox = gtk_vbox_new(FALSE, 0); | |
809 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
810 | |
811 /* Put our happy label in it. */ | |
812 label = gtk_label_new(_("Please enter the name of the user you wish " | |
813 "to invite, along with an optional invite " | |
814 "message.")); | |
815 gtk_widget_set_size_request(label, 350, -1); | |
816 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
817 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
818 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
819 | |
820 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 821 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 822 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
823 | |
824 /* Setup the table we're going to use to lay stuff out. */ | |
825 table = gtk_table_new(2, 2, FALSE); | |
11243 | 826 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
827 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
828 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 829 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
830 | |
831 /* Now the Buddy label */ | |
832 label = gtk_label_new(NULL); | |
833 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
834 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
835 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
836 | |
837 /* Now the Buddy drop-down entry field. */ | |
838 info->entry = gtk_combo_new(); | |
839 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
840 gtk_entry_set_activates_default( | |
841 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
842 | |
843 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
844 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
845 | |
846 /* Fill in the names. */ | |
847 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
848 generate_invite_user_names(gc)); | |
849 | |
850 | |
851 /* Now the label for "Message" */ | |
852 label = gtk_label_new(NULL); | |
853 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
854 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
855 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
856 | |
857 | |
858 /* And finally, the Message entry field. */ | |
859 info->message = gtk_entry_new(); | |
860 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
861 | |
862 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
863 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
864 | |
865 /* Connect the signals. */ | |
866 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
867 G_CALLBACK(do_invite), info); | |
9909 | 868 /* Setup drag-and-drop */ |
869 gtk_drag_dest_set(info->window, | |
870 GTK_DEST_DEFAULT_MOTION | | |
871 GTK_DEST_DEFAULT_DROP, | |
872 dnd_targets, | |
873 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
874 GDK_ACTION_COPY); | |
875 gtk_drag_dest_set(info->entry, | |
876 GTK_DEST_DEFAULT_MOTION | | |
877 GTK_DEST_DEFAULT_DROP, | |
878 dnd_targets, | |
879 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
880 GDK_ACTION_COPY); | |
881 | |
882 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
883 G_CALLBACK(invite_dnd_recv), info); | |
884 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
885 G_CALLBACK(invite_dnd_recv), info); | |
886 | |
4359 | 887 } |
888 | |
889 gtk_widget_show_all(invite_dialog); | |
890 | |
891 if (info != NULL) | |
892 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
893 } | |
894 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
895 static void |
7748 | 896 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
897 { | |
9714 | 898 gaim_gtkdialogs_im(); |
7748 | 899 } |
900 | |
901 static void | |
9504 | 902 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 903 { |
9504 | 904 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 905 FILE *fp; |
906 const char *name; | |
10849 | 907 gchar *text; |
9489 | 908 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
909 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 910 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 911 return; |
912 } | |
913 | |
914 name = gaim_conversation_get_name(conv); | |
10849 | 915 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 916 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 917 |
918 text = gtk_imhtml_get_markup( | |
919 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
920 fprintf(fp, "%s", text); | |
921 g_free(text); | |
922 | |
923 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 924 fclose(fp); |
925 } | |
926 | |
10849 | 927 /* |
928 * It would be kinda cool if this gave the option of saving a | |
929 * plaintext v. HTML file. | |
930 */ | |
9489 | 931 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
932 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
933 { |
11581 | 934 GaimGtkWindow *win = data; |
935 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 936 gchar *buf; |
937 | |
938 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 939 |
10849 | 940 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
941 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 942 |
943 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
944 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
945 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
946 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
947 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
948 { |
11581 | 949 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
950 GaimConversation *conv; |
9917 | 951 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
952 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
953 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
954 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
955 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
956 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
957 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
958 |
11581 | 959 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
960 |
11338 | 961 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 962 type = GAIM_LOG_IM; |
11338 | 963 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 964 type = GAIM_LOG_CHAT; |
965 else | |
966 return; | |
967 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
968 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
969 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
970 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
971 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
972 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
973 gdk_cursor_unref(cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
974 while (gtk_events_pending()) |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
975 gtk_main_iteration(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
976 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
977 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
978 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
979 |
10845 | 980 buddies = gaim_find_buddies(account, name); |
981 for (cur = buddies; cur != NULL; cur = cur->next) | |
982 { | |
983 GaimBlistNode *node = cur->data; | |
10846 | 984 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 985 { |
986 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
987 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
988 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
989 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 990 return; |
991 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
992 } |
10845 | 993 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
994 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
995 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
996 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
997 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
998 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
999 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1000 |
8974 | 1001 static void |
1002 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1003 { | |
11581 | 1004 GaimGtkWindow *win = data; |
8974 | 1005 GaimConversation *conv; |
1006 GaimGtkConversation *gtkconv; | |
1007 | |
11581 | 1008 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1009 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1010 | |
1011 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1012 } | |
1013 | |
7295 | 1014 struct _search { |
1015 GaimGtkConversation *gtkconv; | |
1016 GtkWidget *entry; | |
1017 }; | |
1018 | |
7929 | 1019 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1020 { |
7929 | 1021 switch (resp) { |
1022 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1023 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1024 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1025 break; |
1026 | |
1027 case GTK_RESPONSE_DELETE_EVENT: | |
1028 case GTK_RESPONSE_CLOSE: | |
1029 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1030 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1031 s->gtkconv->dialogs.search = NULL; | |
1032 g_free(s); | |
1033 break; | |
1034 } | |
7295 | 1035 } |
1036 | |
1037 static void | |
7751 | 1038 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1039 { |
11581 | 1040 GaimGtkWindow *gtkwin = data; |
1041 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1042 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1043 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1044 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1045 GTK_ICON_SIZE_DIALOG); |
7929 | 1046 GtkWidget *label; |
7295 | 1047 struct _search *s; |
1048 | |
7798 | 1049 if (gtkconv->dialogs.search) { |
1050 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1051 return; |
7798 | 1052 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1053 |
7295 | 1054 s = g_malloc(sizeof(struct _search)); |
1055 s->gtkconv = gtkconv; | |
7929 | 1056 |
1057 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1058 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1059 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1060 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1061 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1062 GTK_RESPONSE_OK); |
7929 | 1063 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1064 G_CALLBACK(do_search_cb), s); | |
1065 | |
11243 | 1066 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1067 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1068 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1069 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
|
1070 gtk_container_set_border_width( |
11243 | 1071 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1072 | |
1073 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1074 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1075 hbox); |
7929 | 1076 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1077 | |
1078 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1079 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1080 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1081 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1082 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1083 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1084 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1085 | |
1086 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1087 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1088 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1089 g_signal_connect(G_OBJECT(s->entry), "changed", |
1090 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1091 gtkconv->dialogs.search); | |
1092 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
|
1093 |
7295 | 1094 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1095 gtk_widget_grab_focus(s->entry); |
7295 | 1096 } |
1097 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1098 static void |
9468 | 1099 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1100 { | |
11581 | 1101 GaimGtkWindow *win = data; |
1102 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1103 |
11338 | 1104 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1105 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1106 } | |
1107 | |
1108 } | |
1109 | |
1110 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1111 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1112 { |
11581 | 1113 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1114 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1115 |
11581 | 1116 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
|
1117 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1118 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1119 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1120 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1121 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1122 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1123 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1124 { |
11581 | 1125 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1126 GaimGtkConversation *gtkconv; |
8756 | 1127 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 |
11581 | 1129 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1130 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1131 | |
1132 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1133 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1135 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1136 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1137 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1138 { |
11581 | 1139 GaimGtkWindow *win = data; |
8756 | 1140 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1141 GaimGtkConversation *gtkconv; |
8756 | 1142 GtkIMHtmlToolbar *toolbar; |
1143 | |
11581 | 1144 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1145 conv = gtkconv->active_conv; | |
8756 | 1146 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1147 | |
1148 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1149 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1150 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1151 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1152 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1154 { |
11581 | 1155 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 GaimConversation *conv; |
7879 | 1157 GaimAccount *account; |
1158 const char *name; | |
1159 | |
11581 | 1160 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1161 account = gaim_conversation_get_account(conv); |
1162 name = gaim_conversation_get_name(conv); | |
1163 | |
11338 | 1164 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1165 GaimBuddy *b; |
1166 | |
1167 b = gaim_find_buddy(account, name); | |
1168 if (b != NULL) | |
9730 | 1169 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1170 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1171 GaimChat *c; |
1172 | |
1173 c = gaim_blist_find_chat(account, name); | |
1174 if (c != NULL) | |
9730 | 1175 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1176 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1178 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1179 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1180 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1181 { |
11581 | 1182 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 |
11581 | 1185 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 |
10810 | 1187 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 { |
11581 | 1193 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 |
11581 | 1196 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1198 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1199 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1200 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1202 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 { |
11581 | 1204 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1205 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1206 |
11581 | 1207 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1209 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1210 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 { |
11581 | 1215 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1216 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 |
11581 | 1218 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1220 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1221 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1223 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1224 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 { |
11581 | 1226 GaimGtkWindow *win = data; |
1227 | |
1228 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
|
1229 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1231 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1232 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1233 { |
11581 | 1234 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1235 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1236 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 |
11581 | 1238 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1239 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1240 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1243 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
|
1244 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1245 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1246 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1247 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1248 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1249 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1250 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1251 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1252 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1253 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1254 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1255 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1256 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1257 time(NULL)); |
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 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1260 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1261 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1262 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1263 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1264 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1265 time(NULL)); |
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 /* 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
|
1268 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1269 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1270 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1271 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1272 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1273 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1274 { |
11581 | 1275 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1276 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1277 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1278 |
11581 | 1279 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1280 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1281 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1282 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1283 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1284 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1285 |
10377 | 1286 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1287 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
|
1288 } |
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 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1291 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1292 { |
11581 | 1293 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1294 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1295 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1296 |
11581 | 1297 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1298 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1299 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1300 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1301 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1302 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1303 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1304 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1305 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1306 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 |
7961 | 1308 static void |
9188 | 1309 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1310 { | |
11581 | 1311 GaimGtkWindow *win = data; |
9188 | 1312 GaimConversation *conv; |
1313 GaimGtkConversation *gtkconv; | |
1314 | |
11581 | 1315 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1316 |
1317 if (!conv) | |
1318 return; | |
1319 | |
1320 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1321 | |
12188 | 1322 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1323 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1324 } | |
1325 | |
1326 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1327 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1328 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1329 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1330 GaimAccount *account; |
1331 GaimConnection *gc; | |
7961 | 1332 GaimPluginProtocolInfo *prpl_info = NULL; |
1333 char *real_who; | |
1334 | |
1335 account = gaim_conversation_get_account(conv); | |
10431 | 1336 g_return_if_fail(account != NULL); |
1337 | |
1338 gc = gaim_account_get_connection(account); | |
1339 g_return_if_fail(gc != NULL); | |
1340 | |
1341 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1342 | |
1343 if (prpl_info && prpl_info->get_cb_real_name) | |
1344 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1345 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1346 else | |
1347 real_who = g_strdup(who); | |
1348 | |
1349 if(!real_who) | |
1350 return; | |
1351 | |
10431 | 1352 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1353 |
1354 g_free(real_who); | |
1355 } | |
1356 | |
1357 static void | |
10810 | 1358 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1359 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1360 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1361 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1363 GtkTreeSelection *sel; |
9554 | 1364 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1365 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1366 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1367 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1372 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
|
1373 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1374 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1376 chat_do_im(gtkconv, name); |
9554 | 1377 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1378 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1381 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1382 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1383 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1384 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1385 GaimConvChat *chat; |
11869 | 1386 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 GtkTreeSelection *sel; |
10504 | 1390 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1391 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1393 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1396 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1397 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1400 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1401 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1402 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1403 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1404 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1405 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1406 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1407 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1410 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1411 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1412 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1413 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 |
11869 | 1415 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1416 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1417 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1418 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1419 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1421 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1422 { |
1423 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1424 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1425 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1429 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1430 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1431 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1432 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1433 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1434 | |
1435 serv_send_file(gc, who, NULL); | |
1436 } | |
1437 | |
1438 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1439 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1441 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1442 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1443 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1444 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1445 chat_do_info(gtkconv, who); |
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1448 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1449 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
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 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1452 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1453 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1455 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1457 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1458 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1459 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1463 * 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
|
1464 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1467 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1468 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1469 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1470 } |
5908
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 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1473 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1474 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1475 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1476 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1477 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1478 GaimAccount *account; |
6695 | 1479 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1480 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1481 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1482 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1483 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1484 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1485 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1486 if (b != NULL) |
9730 | 1487 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1488 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1489 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1490 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1491 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1492 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1493 |
8143 | 1494 static GtkWidget * |
10504 | 1495 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1496 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1497 { | |
1498 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1499 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1500 gboolean is_me = FALSE; |
8143 | 1501 GtkWidget *button; |
1502 | |
1503 /* | |
1504 * If a menu already exists, destroy it before creating a new one, | |
1505 * thus freeing-up the memory it occupied. | |
1506 */ | |
1507 if (menu) | |
1508 gtk_widget_destroy(menu); | |
1509 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1510 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1511 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1512 |
8143 | 1513 menu = gtk_menu_new(); |
1514 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1515 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1516 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1517 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
|
1518 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
|
1519 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1520 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1521 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1522 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1523 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1524 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1525 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
|
1526 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1527 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1528 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
|
1529 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
|
1530 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1531 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1532 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1533 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1534 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1535 } |
9498 | 1536 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1537 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1538 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
|
1539 G_CALLBACK(menu_chat_info_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); |
8143 | 1541 } |
1542 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1543 if (prpl_info->get_cb_away) { |
10221 | 1544 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
|
1545 G_CALLBACK(menu_chat_get_away_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 (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1550 if (gaim_find_buddy(gc->account, who)) |
10221 | 1551 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
|
1552 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1553 else |
10221 | 1554 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
|
1555 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1556 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1557 } |
1558 | |
1559 return menu; | |
1560 } | |
1561 | |
1562 | |
1563 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1564 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1565 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1566 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1567 GaimPluginProtocolInfo *prpl_info = NULL; |
1568 GaimGtkChatPane *gtkchat; | |
1569 GaimConnection *gc; | |
1570 GaimAccount *account; | |
1571 GtkTreeSelection *sel; | |
1572 GtkTreeIter iter; | |
1573 GtkTreeModel *model; | |
1574 GtkWidget *menu; | |
1575 gchar *who; | |
1576 | |
1577 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1578 gtkchat = gtkconv->u.chat; | |
1579 account = gaim_conversation_get_account(conv); | |
1580 gc = account->gc; | |
1581 | |
1582 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1583 | |
1584 if (gc != NULL) | |
1585 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1586 | |
1587 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1588 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1589 return FALSE; | |
1590 | |
9498 | 1591 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1592 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1593 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1594 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1595 0, GDK_CURRENT_TIME); |
10504 | 1596 g_free(who); |
8143 | 1597 |
1598 return TRUE; | |
1599 } | |
1600 | |
1601 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1602 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1603 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1604 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1605 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1606 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1607 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1608 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1609 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1610 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1611 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1612 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1613 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1614 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1615 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1616 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1617 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1618 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1620 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1621 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1622 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
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 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
|
1625 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1626 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1627 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1628 return FALSE; |
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 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1631 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1634 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
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 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1637 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
|
1638 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1639 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1640 chat_do_im(gtkconv, who); |
7398 | 1641 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1642 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1643 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1644 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1645 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1646 |
10504 | 1647 g_free(who); |
1648 gtk_tree_path_free(path); | |
1649 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1650 return TRUE; |
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 |
8133 | 1653 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1654 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1655 { |
10827 | 1656 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1657 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1658 int index, i, total, found = 0; |
8133 | 1659 |
11581 | 1660 win = gtkconv->win; |
1661 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1662 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1663 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1664 /* 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
|
1665 for (i = forward ? index + 1 : index - 1; |
11581 | 1666 !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
|
1667 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1668 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1669 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1670 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1671 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1672 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1673 found = 1; |
8133 | 1674 } |
11252 | 1675 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1676 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1677 /* 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
|
1678 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1679 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1680 (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
|
1681 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1682 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1683 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1684 found = 1; |
8133 | 1685 } |
10827 | 1686 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1687 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1688 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1689 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1690 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1691 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1692 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1693 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1694 } |
11581 | 1695 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1696 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1697 } |
8133 | 1698 } |
1699 | |
10827 | 1700 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1701 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1702 } |
1703 | |
4359 | 1704 static gboolean |
8105 | 1705 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1706 { |
11581 | 1707 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1708 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1709 GaimGtkConversation *gtkconv; |
8105 | 1710 int curconv; |
1711 | |
10810 | 1712 gtkconv = (GaimGtkConversation *)data; |
10849 | 1713 conv = gtkconv->active_conv; |
11581 | 1714 win = gtkconv->win; |
1715 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1716 |
8105 | 1717 /* If CTRL was held down... */ |
1718 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1719 switch (event->keyval) { |
1720 case GDK_Up: | |
1721 if (!conv->send_history) | |
1722 break; | |
1723 | |
1724 if (!conv->send_history->prev) { | |
1725 GtkTextIter start, end; | |
1726 | |
1727 if (conv->send_history->data) | |
1728 g_free(conv->send_history->data); | |
1729 | |
1730 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1731 &start); | |
1732 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1733 | |
1734 conv->send_history->data = | |
8506 | 1735 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1736 } |
8677 | 1737 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1738 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1739 GObject *object; |
8677 | 1740 GtkTextIter iter; |
1741 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1742 |
1743 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1744 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1745 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1746 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1747 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
|
1748 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1749 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1750 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1751 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1752 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
|
1753 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1754 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1755 |
8061 | 1756 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1757 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1758 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1759 0, NULL); |
8677 | 1760 /* this is mainly just a hack so the formatting at the |
1761 * cursor gets picked up. */ | |
1762 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1763 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1764 } |
1765 | |
8105 | 1766 return TRUE; |
4359 | 1767 break; |
1768 | |
1769 case GDK_Down: | |
1770 if (!conv->send_history) | |
1771 break; | |
1772 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1773 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1774 GObject *object; |
8677 | 1775 GtkTextIter iter; |
1776 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1777 |
4359 | 1778 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1779 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1780 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1781 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1782 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
|
1783 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1784 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1785 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1786 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1787 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
|
1788 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1789 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1790 |
8105 | 1791 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1792 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1793 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1794 0, NULL); |
8677 | 1795 /* this is mainly just a hack so the formatting at the |
1796 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1797 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1798 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1799 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1800 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1801 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1802 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1803 } |
4359 | 1804 } |
1805 | |
8105 | 1806 return TRUE; |
4359 | 1807 break; |
8105 | 1808 |
8108 | 1809 case GDK_Page_Down: |
8143 | 1810 case ']': |
11581 | 1811 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1812 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1813 else |
11581 | 1814 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1815 return TRUE; |
1816 break; | |
1817 | |
8108 | 1818 case GDK_Page_Up: |
8143 | 1819 case '[': |
11581 | 1820 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1821 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1822 else |
11581 | 1823 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1824 return TRUE; |
1825 break; | |
1826 | |
8108 | 1827 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1828 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1829 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1830 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1831 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1832 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1833 } |
8108 | 1834 |
1835 return TRUE; | |
1836 break; | |
1837 | |
11252 | 1838 case GDK_comma: |
11581 | 1839 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1840 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1841 curconv - 1); |
1842 break; | |
1843 | |
1844 case GDK_period: | |
11581 | 1845 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1846 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1847 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1848 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1849 #else |
1850 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1851 #endif | |
11252 | 1852 break; |
1853 | |
8105 | 1854 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1855 } |
8758 | 1856 |
8105 | 1857 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1858 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1859 { |
10864 | 1860 if (event->keyval > '0' && event->keyval <= '9') |
1861 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1862 guint switchto = event->keyval - '1'; |
11581 | 1863 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1864 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1865 |
1866 return TRUE; | |
1867 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1868 } |
8758 | 1869 |
8105 | 1870 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1871 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1872 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1873 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1874 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1875 case GDK_Tab: |
9605 | 1876 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1877 break; |
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 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1880 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1881 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1882 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1883 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1884 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1885 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1886 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1887 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1888 |
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 } |
4359 | 1891 return FALSE; |
1892 } | |
1893 | |
1894 /* | |
1895 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1896 * 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
|
1897 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1898 * 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
|
1899 * going all the way down to the notebook. I suspect a bug in |
4359 | 1900 * GtkTextView, but I'm not ready to point any fingers yet. |
1901 */ | |
1902 static gboolean | |
1903 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1904 { | |
1905 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1906 /* Right single click */ | |
1907 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1908 | |
1909 return TRUE; | |
1910 } | |
1911 | |
1912 return FALSE; | |
1913 } | |
1914 | |
8173 | 1915 /* |
1916 * If someone tries to type into the conversation backlog of a | |
1917 * conversation window then we yank focus from the conversation backlog | |
1918 * and give it to the text entry box so that people can type | |
1919 * all the live long day and it will get entered into the entry box. | |
1920 */ | |
6057 | 1921 static gboolean |
8105 | 1922 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1923 { |
1924 GaimGtkConversation *gtkconv = data; | |
1925 | |
8237 | 1926 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1927 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1928 (event->keyval == GDK_F10) || |
1929 (event->keyval == GDK_Shift_L) || | |
1930 (event->keyval == GDK_Shift_R) || | |
1931 (event->keyval == GDK_Escape) || | |
8177 | 1932 (event->keyval == GDK_Up) || |
1933 (event->keyval == GDK_Down) || | |
1934 (event->keyval == GDK_Left) || | |
8191 | 1935 (event->keyval == GDK_Right) || |
1936 (event->keyval == GDK_Home) || | |
9297 | 1937 (event->keyval == GDK_End) || |
1938 (event->keyval == GDK_Tab) || | |
1939 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1940 return FALSE; |
1941 | |
1942 if (event->type == GDK_KEY_RELEASE) | |
1943 gtk_widget_grab_focus(gtkconv->entry); | |
1944 | |
1945 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1946 | |
1947 return TRUE; | |
6057 | 1948 } |
1949 | |
4359 | 1950 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1951 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1952 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1953 GaimGtkConversation *gtkconv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1954 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1955 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1956 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1957 gtkconv = GAIM_GTK_CONVERSATION(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 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1960 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1961 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1962 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1963 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1964 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1965 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1966 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1967 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
|
1968 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1969 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1970 void |
11604 | 1971 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1972 { | |
1973 GaimGtkConversation *gtkconv; | |
1974 | |
1975 g_return_if_fail(conv != NULL); | |
1976 | |
1977 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1978 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1979 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1980 |
1981 gray_stuff_out(gtkconv); | |
1982 update_typing_icon(gtkconv); | |
1983 | |
1984 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
1985 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
1986 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
1987 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 1988 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
1989 gaim_account_get_protocol_name(conv->account)); | |
1990 } | |
1991 | |
1992 static void | |
4673 | 1993 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1994 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1995 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 1996 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1997 GaimConversation *conv; |
4359 | 1998 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1999 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2000 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2001 |
11594 | 2002 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2003 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2004 } |
2005 | |
2006 static void | |
2007 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2008 gchar *new_text, gint new_text_length, gpointer user_data) | |
2009 { | |
10810 | 2010 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2011 GaimConversation *conv; | |
2012 | |
2013 g_return_if_fail(gtkconv != NULL); | |
11508 | 2014 |
10810 | 2015 conv = gtkconv->active_conv; |
4359 | 2016 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2017 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2018 return; |
2019 | |
10810 | 2020 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2021 gtk_text_iter_is_end(position))); | |
4359 | 2022 } |
2023 | |
2024 static void | |
2025 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2026 GtkTextIter *end_pos, gpointer user_data) | |
2027 { | |
10810 | 2028 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2029 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2030 GaimConvIm *im; |
4359 | 2031 |
10810 | 2032 g_return_if_fail(gtkconv != NULL); |
11508 | 2033 |
10810 | 2034 conv = gtkconv->active_conv; |
4359 | 2035 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2036 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2037 return; |
2038 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2039 im = GAIM_CONV_IM(conv); |
4359 | 2040 |
2041 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2042 | |
2043 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2044 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2045 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2046 |
2047 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2048 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2049 GAIM_NOT_TYPING); |
4359 | 2050 } |
2051 else { | |
2052 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2053 got_typing_keypress(gtkconv, FALSE); |
4359 | 2054 } |
2055 } | |
2056 | |
8189 | 2057 /************************************************************************** |
2058 * A bunch of buddy icon functions | |
2059 **************************************************************************/ | |
11581 | 2060 GdkPixbuf * |
2061 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2062 { |
10116 | 2063 GaimAccount *account = NULL; |
2064 const char *name = NULL; | |
7143 | 2065 GdkPixbuf *status = NULL; |
2066 | |
10116 | 2067 g_return_val_if_fail(conv != NULL, NULL); |
2068 | |
2069 account = gaim_conversation_get_account(conv); | |
2070 name = gaim_conversation_get_name(conv); | |
2071 | |
2072 g_return_val_if_fail(account != NULL, NULL); | |
2073 g_return_val_if_fail(name != NULL, NULL); | |
2074 | |
11338 | 2075 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2076 GaimBuddy *b = gaim_find_buddy(account, name); |
2077 if (b != NULL) { | |
2078 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2079 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2080 } |
2081 } | |
2082 | |
2083 if (!status) { | |
2084 GdkPixbuf *pixbuf; | |
10884 | 2085 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2086 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2087 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2088 { |
7143 | 2089 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2090 GDK_INTERP_BILINEAR); | |
2091 g_object_unref(pixbuf); | |
2092 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2093 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2094 status = pixbuf; |
7143 | 2095 } |
2096 return status; | |
2097 } | |
2098 | |
8189 | 2099 static void |
2100 update_tab_icon(GaimConversation *conv) | |
2101 { | |
2102 GaimGtkConversation *gtkconv; | |
11581 | 2103 GaimGtkWindow *win; |
8189 | 2104 GaimAccount *account; |
2105 const char *name; | |
2106 GdkPixbuf *status = NULL; | |
2107 | |
10116 | 2108 g_return_if_fail(conv != NULL); |
2109 | |
8189 | 2110 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2111 win = gtkconv->win; |
8189 | 2112 name = gaim_conversation_get_name(conv); |
2113 account = gaim_conversation_get_account(conv); | |
2114 | |
11581 | 2115 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2116 |
10116 | 2117 g_return_if_fail(status != NULL); |
2118 | |
8189 | 2119 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2120 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2121 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2122 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2123 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2124 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2125 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2126 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2127 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2128 { |
11581 | 2129 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2130 | |
2131 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2132 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2133 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2134 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2135 } |
8189 | 2136 } |
2137 | |
2138 static gboolean | |
2139 redraw_icon(gpointer data) | |
2140 { | |
10810 | 2141 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2142 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2143 GaimAccount *account; |
2144 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2145 |
2146 GdkPixbuf *buf; | |
2147 GdkPixbuf *scale; | |
2148 GdkPixmap *pm; | |
2149 GdkBitmap *bm; | |
2150 gint delay; | |
9318 | 2151 int scale_width, scale_height; |
8189 | 2152 |
2153 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2154 account = gaim_conversation_get_account(conv); |
2155 if(account && account->gc) | |
2156 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2157 |
2158 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2159 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2160 | |
10483 | 2161 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2162 NULL, &scale_width, &scale_height); |
2163 | |
2164 /* this code is ugly, and scares me */ | |
8189 | 2165 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2166 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2167 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2168 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2169 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2170 GDK_INTERP_BILINEAR); |
8189 | 2171 |
2172 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2173 g_object_unref(G_OBJECT(scale)); | |
2174 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2175 g_object_unref(G_OBJECT(pm)); | |
2176 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2177 | |
2178 if (bm) | |
2179 g_object_unref(G_OBJECT(bm)); | |
2180 | |
9131 | 2181 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2182 |
2183 if (delay < 100) | |
9131 | 2184 delay = 100; |
2185 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2186 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2187 |
2188 return FALSE; | |
2189 } | |
2190 | |
2191 static void | |
10810 | 2192 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2193 { |
2194 int delay; | |
2195 | |
8228 | 2196 if (gtkconv->u.im->anim == NULL) |
2197 return; | |
2198 | |
8202 | 2199 if (gtkconv->u.im->icon_timer != 0) |
2200 return; | |
2201 | |
8189 | 2202 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2203 return; | |
2204 | |
10639 | 2205 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2206 | |
2207 if (delay < 100) | |
2208 delay = 100; | |
2209 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2210 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2211 } |
2212 | |
2213 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2214 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2215 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2216 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2217 GaimGtkWindow *gtkwin; |
2218 | |
2219 g_return_if_fail(conv != NULL); | |
2220 | |
9887 | 2221 if (gtkconv->u.im->icon_container != NULL) |
2222 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2223 |
2224 if (gtkconv->u.im->anim != NULL) | |
2225 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2226 | |
2227 if (gtkconv->u.im->icon_timer != 0) | |
2228 g_source_remove(gtkconv->u.im->icon_timer); | |
2229 | |
2230 if (gtkconv->u.im->iter != NULL) | |
2231 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2232 | |
2233 gtkconv->u.im->icon_timer = 0; | |
2234 gtkconv->u.im->icon = NULL; | |
2235 gtkconv->u.im->anim = NULL; | |
2236 gtkconv->u.im->iter = NULL; | |
10456 | 2237 gtkconv->u.im->icon_container = NULL; |
9687 | 2238 gtkconv->u.im->show_icon = FALSE; |
10456 | 2239 |
11581 | 2240 gtkwin = gtkconv->win; |
10456 | 2241 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2242 } |
2243 | |
9497 | 2244 static void |
9504 | 2245 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2246 { |
10810 | 2247 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2248 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2249 FILE *fp; |
2250 GaimBuddyIcon *icon; | |
2251 const void *data; | |
2252 size_t len; | |
2253 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2254 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2255 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2256 return; |
2257 } | |
2258 | |
2259 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2260 data = gaim_buddy_icon_get_data(icon, &len); | |
2261 | |
2262 if ((len <= 0) || (data == NULL)) { | |
9504 | 2263 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2264 return; |
2265 } | |
2266 | |
2267 fwrite(data, 1, len, fp); | |
2268 fclose(fp); | |
2269 } | |
2270 | |
2271 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2272 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2273 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2274 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2275 const gchar *ext; |
9497 | 2276 gchar *buf; |
2277 | |
2278 g_return_if_fail(conv != NULL); | |
9504 | 2279 |
10953 | 2280 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2281 if (ext == NULL) | |
2282 ext = "icon"; | |
2283 | |
2284 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2285 |
2286 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2287 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2288 |
2289 g_free(buf); | |
2290 } | |
2291 | |
11581 | 2292 static void |
2293 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2294 { | |
2295 if (gtkconv->u.im->icon_timer != 0) | |
2296 g_source_remove(gtkconv->u.im->icon_timer); | |
2297 | |
2298 gtkconv->u.im->icon_timer = 0; | |
2299 } | |
2300 | |
2301 | |
2302 static void | |
2303 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2304 { | |
2305 gtkconv->u.im->animate = | |
2306 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2307 | |
2308 if (gtkconv->u.im->animate) | |
2309 start_anim(NULL, gtkconv); | |
2310 else | |
2311 stop_anim(NULL, gtkconv); | |
2312 } | |
2313 | |
8189 | 2314 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2315 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2316 { |
2317 static GtkWidget *menu = NULL; | |
2318 GtkWidget *button; | |
2319 | |
2320 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2321 return FALSE; | |
2322 | |
2323 /* | |
2324 * If a menu already exists, destroy it before creating a new one, | |
2325 * thus freeing-up the memory it occupied. | |
2326 */ | |
2327 if (menu != NULL) | |
2328 gtk_widget_destroy(menu); | |
2329 | |
2330 menu = gtk_menu_new(); | |
2331 | |
2332 if (gtkconv->u.im->anim && | |
2333 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2334 { | |
2335 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2336 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2337 gtkconv->u.im->icon_timer); |
2338 } | |
2339 | |
2340 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2341 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2342 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2343 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2344 gtk_widget_show(button); | |
2345 | |
2346 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
|
2347 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2348 0, 0, NULL); |
2349 | |
2350 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2351 | |
2352 return TRUE; | |
2353 } | |
10456 | 2354 |
2355 static void | |
2356 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2357 { | |
11581 | 2358 GaimGtkWindow *win = data; |
10456 | 2359 GaimConversation *conv; |
2360 GaimGtkConversation *gtkconv; | |
2361 gboolean active; | |
2362 | |
11581 | 2363 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2364 |
2365 if (!conv) | |
2366 return; | |
2367 | |
11338 | 2368 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2369 |
2370 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2371 | |
2372 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2373 gtkconv->u.im->show_icon = active; | |
2374 if (active) | |
2375 gaim_gtkconv_update_buddy_icon(conv); | |
2376 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2377 remove_icon(gtkconv); |
10456 | 2378 } |
2379 | |
8189 | 2380 /************************************************************************** |
2381 * End of the bunch of buddy icon functions | |
2382 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2383 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2384 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2385 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2386 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2387 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2388 if(gtkconv->win==hidden_convwin) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2389 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2390 gaim_gtkconv_placement_place(gtkconv); |
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 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2393 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2394 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2395 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2396 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
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 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2399 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2400 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2401 GaimUnseenState min_state) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2402 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2403 GList *l; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2404 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2405 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2406 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2407 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2408 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2409 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2410 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2411 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2412 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2413 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2414 GaimConversation *conv = (GaimConversation*)l->data; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2415 if (GAIM_GTK_CONVERSATION(conv)->unseen_state >= min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2416 return conv; |
12021
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 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2420 } |
8189 | 2421 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2422 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2423 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2424 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2425 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2426 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2427 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2428 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2429 guint |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2430 gaim_gtk_conversations_fill_unseen_menu(GtkWidget *menu, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2431 GaimConversationType type, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2432 GaimUnseenState min_state) |
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 GList *l; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2435 guint ret = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2436 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2437 g_return_val_if_fail(menu != NULL, 0); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2438 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2439 if (type == GAIM_CONV_TYPE_IM) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2440 l = gaim_get_ims(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2441 } else if (type == GAIM_CONV_TYPE_CHAT) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2442 l = gaim_get_chats(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2443 } else { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2444 l = gaim_get_conversations(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2445 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2446 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2447 for (; l != NULL ; l = l->next) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2448 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2449 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2450 |
12239 | 2451 if (gtkconv->unseen_state >= min_state && gtkconv->win == hidden_convwin) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2452 GtkWidget *icon = gtk_image_new(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2453 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2454 GtkWidget *item; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2455 gchar *text = g_strdup_printf("%s (%d)", |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2456 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2457 gtkconv->unseen_count); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2458 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2459 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2460 g_object_unref(pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2461 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2462 item = gtk_image_menu_item_new_with_label(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2463 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
|
2464 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
|
2465 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2466 g_free(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2467 ret++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2468 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2469 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2470 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2471 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2472 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2473 |
11581 | 2474 GaimGtkWindow * |
2475 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2476 { | |
2477 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2478 return gtkconv->win; | |
2479 } | |
2480 | |
2481 static GtkItemFactoryEntry menu_items[] = | |
2482 { | |
2483 /* Conversation menu */ | |
2484 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2485 | |
2486 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2487 0, "<StockItem>", GAIM_STOCK_IM }, | |
2488 | |
2489 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2490 | |
2491 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2492 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2493 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2494 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2495 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12240 | 2496 { N_("/Conversation/Clea_r"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2497 |
2498 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2499 | |
2500 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2501 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2502 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2503 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2504 "<StockItem>", GAIM_STOCK_INFO }, | |
2505 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2506 "<StockItem>", GAIM_STOCK_INVITE }, | |
2507 | |
2508 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2509 | |
2510 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2511 "<StockItem>", GAIM_STOCK_EDIT }, | |
2512 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2513 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2514 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2515 "<StockItem>", GTK_STOCK_ADD }, | |
2516 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2517 "<StockItem>", GTK_STOCK_REMOVE }, | |
2518 | |
2519 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2520 | |
2521 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2522 "<StockItem>", GAIM_STOCK_LINK }, | |
2523 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2524 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2525 | |
2526 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2527 | |
2528 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2529 "<StockItem>", GTK_STOCK_CLOSE }, | |
2530 | |
2531 /* Options */ | |
2532 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2533 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2534 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2535 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2536 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2537 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2538 }; | |
2539 | |
2540 static const int menu_item_count = | |
2541 sizeof(menu_items) / sizeof(*menu_items); | |
2542 | |
2543 static char * | |
2544 item_factory_translate_func (const char *path, gpointer func_data) | |
2545 { | |
2546 return _((char *)path); | |
2547 } | |
2548 | |
2549 static GtkWidget * | |
2550 setup_menubar(GaimGtkWindow *win) | |
2551 { | |
2552 GtkAccelGroup *accel_group; | |
2553 | |
2554 accel_group = gtk_accel_group_new (); | |
2555 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2556 g_object_unref(accel_group); | |
2557 | |
2558 win->menu.item_factory = | |
2559 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2560 | |
2561 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2562 item_factory_translate_func, | |
2563 NULL, NULL); | |
2564 | |
2565 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2566 menu_items, win); | |
2567 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2568 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2569 | |
2570 | |
2571 win->menu.menubar = | |
2572 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2573 | |
2574 | |
2575 win->menu.view_log = | |
2576 gtk_item_factory_get_widget(win->menu.item_factory, | |
2577 N_("/Conversation/View Log")); | |
2578 | |
2579 /* --- */ | |
2580 | |
2581 win->menu.send_file = | |
2582 gtk_item_factory_get_widget(win->menu.item_factory, | |
2583 N_("/Conversation/Send File...")); | |
2584 | |
2585 win->menu.add_pounce = | |
2586 gtk_item_factory_get_widget(win->menu.item_factory, | |
2587 N_("/Conversation/Add Buddy Pounce...")); | |
2588 | |
2589 /* --- */ | |
2590 | |
2591 win->menu.get_info = | |
2592 gtk_item_factory_get_widget(win->menu.item_factory, | |
2593 N_("/Conversation/Get Info")); | |
2594 | |
2595 win->menu.invite = | |
2596 gtk_item_factory_get_widget(win->menu.item_factory, | |
2597 N_("/Conversation/Invite...")); | |
2598 | |
2599 /* --- */ | |
2600 | |
2601 win->menu.alias = | |
2602 gtk_item_factory_get_widget(win->menu.item_factory, | |
2603 N_("/Conversation/Alias...")); | |
2604 | |
2605 win->menu.block = | |
2606 gtk_item_factory_get_widget(win->menu.item_factory, | |
2607 N_("/Conversation/Block...")); | |
2608 | |
2609 win->menu.add = | |
2610 gtk_item_factory_get_widget(win->menu.item_factory, | |
2611 N_("/Conversation/Add...")); | |
2612 | |
2613 win->menu.remove = | |
2614 gtk_item_factory_get_widget(win->menu.item_factory, | |
2615 N_("/Conversation/Remove...")); | |
2616 | |
2617 /* --- */ | |
2618 | |
2619 win->menu.insert_link = | |
2620 gtk_item_factory_get_widget(win->menu.item_factory, | |
2621 N_("/Conversation/Insert Link...")); | |
2622 | |
2623 win->menu.insert_image = | |
2624 gtk_item_factory_get_widget(win->menu.item_factory, | |
2625 N_("/Conversation/Insert Image...")); | |
2626 | |
2627 /* --- */ | |
2628 | |
2629 win->menu.logging = | |
2630 gtk_item_factory_get_widget(win->menu.item_factory, | |
2631 N_("/Options/Enable Logging")); | |
2632 win->menu.sounds = | |
2633 gtk_item_factory_get_widget(win->menu.item_factory, | |
2634 N_("/Options/Enable Sounds")); | |
2635 win->menu.show_formatting_toolbar = | |
2636 gtk_item_factory_get_widget(win->menu.item_factory, | |
2637 N_("/Options/Show Formatting Toolbars")); | |
2638 win->menu.show_timestamps = | |
2639 gtk_item_factory_get_widget(win->menu.item_factory, | |
2640 N_("/Options/Show Timestamps")); | |
2641 win->menu.show_icon = | |
2642 gtk_item_factory_get_widget(win->menu.item_factory, | |
2643 N_("/Options/Show Buddy Icon")); | |
2644 | |
2645 | |
2646 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2647 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2648 win->menu.tray); | |
2649 gtk_widget_show(win->menu.tray); | |
2650 | |
2651 gtk_widget_show(win->menu.menubar); | |
2652 | |
2653 return win->menu.menubar; | |
2654 } | |
2655 | |
4359 | 2656 |
2657 /************************************************************************** | |
2658 * Utility functions | |
2659 **************************************************************************/ | |
2660 | |
2661 static void | |
10810 | 2662 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2663 { |
10810 | 2664 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2665 GaimConvIm *im; |
4685 | 2666 |
4359 | 2667 /* |
2668 * 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
|
2669 * send GAIM_TYPED any time soon. |
4359 | 2670 */ |
2671 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2672 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2673 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2674 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2675 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2676 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2677 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2678 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2679 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2680 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2681 |
2682 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2683 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2684 GAIM_TYPING); |
4359 | 2685 |
2686 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2687 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2688 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2689 gaim_conv_im_set_type_again(im, 0); |
4359 | 2690 } |
2691 } | |
2692 | |
4736 | 2693 static void |
10810 | 2694 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2695 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2696 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2697 GaimConvIm *im = NULL; |
10810 | 2698 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2699 char *stock_id, *tooltip; |
11508 | 2700 |
11581 | 2701 gtkwin = gtkconv->win; |
4736 | 2702 |
12008 | 2703 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2704 im = GAIM_CONV_IM(conv); |
4736 | 2705 |
12008 | 2706 if (gtkwin->menu.typing_icon) { |
2707 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2708 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2709 |
12008 | 2710 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2711 return; | |
2712 | |
2713 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2714 stock_id = GAIM_STOCK_TYPING; | |
2715 tooltip = _("User is typing..."); | |
2716 } else { | |
2717 stock_id = GAIM_STOCK_TYPED; | |
2718 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2719 } |
12008 | 2720 |
2721 if (gtkwin->menu.typing_icon == NULL) | |
2722 { | |
2723 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
|
2724 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
|
2725 gtkwin->menu.typing_icon, |
12008 | 2726 tooltip); |
4736 | 2727 } |
12008 | 2728 else |
2729 { | |
2730 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2731 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2732 gtkwin->menu.typing_icon, | |
2733 tooltip); | |
2734 } | |
2735 | |
2736 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2737 } |
2738 | |
4685 | 2739 static gboolean |
11594 | 2740 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2741 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2742 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2743 GaimConversation *conv; |
4359 | 2744 GtkWidget *menu; |
2745 GList *child; | |
11594 | 2746 GaimBuddy *b; |
11581 | 2747 |
2748 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2749 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2750 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2751 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2752 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2753 account = gaim_conversation_get_account(conv); |
11581 | 2754 |
11594 | 2755 if (win->menu.send_to == NULL) |
4685 | 2756 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2757 |
11594 | 2758 if (!(b = gaim_find_buddy(account, conv->name))) |
2759 return FALSE; | |
2760 | |
2761 | |
2762 gtk_widget_show(win->menu.send_to); | |
4359 | 2763 |
2764 menu = gtk_menu_item_get_submenu( | |
11594 | 2765 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2766 |
2767 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2768 child != NULL; | |
2769 child = child->next) { | |
2770 | |
2771 GtkWidget *item = child->data; | |
11594 | 2772 GaimBuddy *item_buddy; |
2773 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2774 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2775 "gaim_buddy_name"); | |
2776 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2777 | |
2778 if (b == item_buddy) { | |
4359 | 2779 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2780 break; | |
2781 } | |
2782 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2783 |
4685 | 2784 return FALSE; |
4359 | 2785 } |
2786 | |
2787 static void | |
11594 | 2788 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2789 { | |
2790 GaimAccount *account; | |
2791 GtkWidget *box; | |
2792 GtkWidget *label; | |
2793 GtkWidget *image; | |
2794 GtkWidget *menuitem; | |
11625 | 2795 GdkPixbuf *pixbuf; |
11616 | 2796 gchar *text; |
11594 | 2797 |
2798 account = bud->account; | |
2799 | |
2800 /* Create a pixmap for the protocol icon. */ | |
11625 | 2801 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2802 /* Now convert it to GtkImage */ |
2803 if (pixbuf == NULL) | |
2804 image = gtk_image_new(); | |
2805 else | |
11625 | 2806 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2807 |
2808 gtk_size_group_add_widget(sg, image); | |
2809 | |
2810 g_object_unref(G_OBJECT(pixbuf)); | |
2811 | |
2812 /* Make our menu item */ | |
11616 | 2813 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2814 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2815 g_free(text); | |
11594 | 2816 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2817 | |
2818 /* Do some evil, see some evil, speak some evil. */ | |
2819 box = gtk_hbox_new(FALSE, 0); | |
2820 | |
2821 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2822 g_object_ref(label); | |
2823 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2824 | |
2825 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2826 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2827 | |
2828 g_object_unref(label); | |
2829 | |
2830 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2831 | |
2832 gtk_widget_show(label); | |
2833 gtk_widget_show(image); | |
2834 gtk_widget_show(box); | |
2835 | |
2836 /* Set our data and callbacks. */ | |
2837 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2838 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2839 | |
2840 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2841 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2842 | |
2843 gtk_widget_show(menuitem); | |
2844 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2845 } | |
2846 | |
2847 static void | |
2848 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2849 { |
4359 | 2850 GtkWidget *menu; |
2851 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2852 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2853 GaimGtkConversation *gtkconv; |
2854 GSList *l, *buds; | |
2855 | |
2856 g_return_if_fail(win != NULL); | |
2857 | |
2858 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2859 | |
11604 | 2860 g_return_if_fail(gtkconv != NULL); |
2861 | |
11594 | 2862 if (win->menu.send_to != NULL) |
2863 gtk_widget_destroy(win->menu.send_to); | |
2864 | |
4359 | 2865 |
2866 /* Build the Send As menu */ | |
11594 | 2867 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2868 gtk_widget_show(win->menu.send_to); | |
4359 | 2869 |
2870 menu = gtk_menu_new(); | |
11581 | 2871 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2872 win->menu.send_to, 2); |
2873 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2874 |
2875 gtk_widget_show(menu); | |
2876 | |
11604 | 2877 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2878 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2879 for (l = buds; l != NULL; l = l->next) { | |
2880 GaimBuddy *b; | |
2881 GaimBlistNode *node; | |
2882 | |
2883 b = l->data; | |
2884 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2885 | |
2886 for (node = node->child; node != NULL; node = node->next) | |
2887 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2888 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2889 } | |
2890 | |
2891 g_slist_free(buds); | |
4359 | 2892 } |
2893 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2894 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2895 |
11594 | 2896 gtk_widget_show(win->menu.send_to); |
2897 if (!group) | |
2898 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2899 update_send_to_selection(win); | |
4359 | 2900 } |
2901 | |
2902 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2903 generate_invite_user_names(GaimConnection *gc) |
4359 | 2904 { |
6695 | 2905 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2906 static GList *tmp = NULL; |
2907 | |
2908 if (tmp) | |
2909 g_list_free(tmp); | |
2910 | |
2911 tmp = g_list_append(NULL, ""); | |
2912 | |
2913 if (gc != NULL) { | |
4785 | 2914 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2915 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2916 continue; | |
6695 | 2917 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2918 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2919 continue; |
6695 | 2920 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2921 GaimBuddy *buddy; | |
2922 | |
2923 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2924 continue; | |
2925 | |
2926 buddy = (GaimBuddy *)bnode; | |
2927 | |
2928 if (buddy->account == gc->account && | |
2929 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2930 tmp = g_list_insert_sorted(tmp, buddy->name, |
2931 (GCompareFunc)g_utf8_collate); | |
6695 | 2932 } |
4359 | 2933 } |
2934 } | |
2935 } | |
2936 | |
2937 return tmp; | |
2938 } | |
2939 | |
9498 | 2940 static GdkPixbuf * |
9554 | 2941 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2942 { |
9554 | 2943 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2944 char *filename; |
10274 | 2945 const char *image = NULL; |
9554 | 2946 |
2947 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2948 image = "founder.png"; |
9554 | 2949 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2950 image = "op.png"; |
9554 | 2951 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2952 image = "halfop.png"; |
9554 | 2953 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2954 image = "voice.png"; |
9554 | 2955 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2956 image = "ignored.png"; |
2957 } else { | |
2958 return NULL; | |
9554 | 2959 } |
10274 | 2960 |
2961 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2962 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2963 g_free(filename); | |
2964 | |
2965 if (!pixbuf) | |
2966 return NULL; | |
2967 | |
2968 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2969 g_object_unref(pixbuf); | |
2970 | |
2971 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2972 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2973 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2974 g_free(filename); | |
10274 | 2975 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2976 g_object_unref(pixbuf); |
10274 | 2977 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2978 g_object_unref(scale2); | |
9498 | 2979 } |
2980 | |
10274 | 2981 return scale; |
9498 | 2982 } |
2983 | |
4359 | 2984 static void |
11869 | 2985 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 2986 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2987 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2988 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2989 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2990 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2991 GaimPluginProtocolInfo *prpl_info; |
4359 | 2992 GtkListStore *ls; |
9498 | 2993 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2994 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2995 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2996 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2997 GdkColor send_color; |
11508 | 2998 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2999 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 3000 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3001 chat = GAIM_CONV_CHAT(conv); |
4359 | 3002 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3003 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3004 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3005 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3006 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3007 return; |
4359 | 3008 |
3009 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3010 | |
9554 | 3011 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3012 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3013 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
|
3014 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3015 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3016 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3017 |
4359 | 3018 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3019 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3020 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3021 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3022 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3023 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3024 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
|
3025 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3026 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3027 |
9554 | 3028 if (pixbuf) |
3029 g_object_unref(pixbuf); | |
4359 | 3030 } |
3031 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3032 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3033 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
|
3034 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3035 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3036 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3037 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3038 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3039 return; |
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 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3042 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3043 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3044 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3045 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3046 * on *most_matched is >= 0 |
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 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3049 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3050 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3051 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3052 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3053 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3054 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3055 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3056 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3057 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3058 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3059 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3060 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3061 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3062 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3064 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3065 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3066 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3067 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3068 |
9605 | 3069 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3070 tab_complete(GaimConversation *conv) |
4359 | 3071 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3072 GaimGtkConversation *gtkconv; |
4359 | 3073 GtkTextIter cursor, word_start, start_buffer; |
3074 int start; | |
3075 int most_matched = -1; | |
3076 char *entered, *partial = NULL; | |
3077 char *text; | |
8021 | 3078 char *nick_partial; |
9605 | 3079 const char *prefix; |
4359 | 3080 GList *matches = NULL; |
9605 | 3081 gboolean command = FALSE; |
4359 | 3082 |
3083 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3084 | |
3085 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3086 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3087 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3088 | |
3089 word_start = cursor; | |
3090 | |
3091 /* if there's nothing there just return */ | |
3092 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3093 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
|
3094 |
4359 | 3095 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3096 &cursor, FALSE); | |
3097 | |
3098 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3099 start = strlen(text) - 1; | |
3100 | |
8021 | 3101 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3102 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3103 start-=2; |
3104 } | |
4359 | 3105 |
3106 /* find the start of the word that we're tabbing */ | |
3107 while (start >= 0 && text[start] != ' ') { | |
3108 gtk_text_iter_backward_char(&word_start); | |
3109 start--; | |
3110 } | |
3111 | |
9605 | 3112 prefix = gaim_gtk_get_cmd_prefix(); |
3113 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3114 command = TRUE; | |
3115 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3116 } | |
3117 | |
4359 | 3118 g_free(text); |
3119 | |
3120 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3121 &cursor, FALSE); | |
3122 | |
8021 | 3123 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3124 g_free(entered); |
11338 | 3125 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3126 } |
3127 | |
8021 | 3128 nick_partial = g_malloc(strlen(entered)+1); |
3129 | |
9605 | 3130 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3131 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3132 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3133 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3134 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3135 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3136 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3137 &matches, TRUE, l->data); |
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 g_list_free(list); |
11338 | 3140 } 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
|
3141 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3142 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3143 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
|
3144 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3145 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3146 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3147 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3148 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3149 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3150 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3153 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3154 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3155 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
|
3156 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3157 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3158 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3159 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3160 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3161 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3162 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3163 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3164 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3165 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3166 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3167 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3168 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3169 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3170 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3171 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3172 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3173 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3174 } |
9605 | 3175 } else { |
3176 g_free(nick_partial); | |
3177 g_free(entered); | |
3178 return FALSE; | |
3179 } | |
3180 | |
8021 | 3181 g_free(nick_partial); |
3182 | |
4359 | 3183 /* we're only here if we're doing new style */ |
3184 | |
3185 /* if there weren't any matches, return */ | |
3186 if (!matches) { | |
3187 /* if matches isn't set partials won't be either */ | |
3188 g_free(entered); | |
11338 | 3189 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3190 } |
3191 | |
3192 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3193 | |
3194 if (!matches->next) { | |
3195 /* there was only one match. fill it in. */ | |
3196 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3197 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3198 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3199 | |
3200 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3201 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3202 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3203 g_free(tmp); | |
3204 } | |
3205 else | |
3206 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3207 matches->data, -1); | |
3208 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3209 g_free(matches->data); |
4359 | 3210 matches = g_list_remove(matches, matches->data); |
3211 } | |
3212 else { | |
3213 /* | |
3214 * there were lots of matches, fill in as much as possible | |
3215 * and display all of them | |
3216 */ | |
3217 char *addthis = g_malloc0(1); | |
3218 | |
3219 while (matches) { | |
3220 char *tmp = addthis; | |
3221 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3222 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3223 g_free(matches->data); |
4359 | 3224 matches = g_list_remove(matches, matches->data); |
3225 } | |
3226 | |
6982 | 3227 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3228 time(NULL)); |
3229 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3230 g_free(addthis); | |
3231 } | |
3232 | |
3233 g_free(entered); | |
3234 g_free(partial); | |
9605 | 3235 |
3236 return TRUE; | |
4359 | 3237 } |
3238 | |
10810 | 3239 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3240 { |
3241 GaimPluginProtocolInfo *prpl_info = NULL; | |
3242 GaimConnection *gc; | |
10810 | 3243 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3244 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3245 char *new_topic; |
8858 | 3246 const char *current_topic; |
7971 | 3247 |
3248 gc = gaim_conversation_get_gc(conv); | |
3249 | |
3250 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3251 return; | |
3252 | |
3253 if(prpl_info->set_chat_topic == NULL) | |
3254 return; | |
3255 | |
3256 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3257 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3258 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3259 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3260 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3261 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3262 g_free(new_topic); |
7971 | 3263 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3264 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3265 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3266 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3267 |
8858 | 3268 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3269 new_topic); | |
11261
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 g_free(new_topic); |
7971 | 3272 } |
3273 | |
9554 | 3274 static gint |
3275 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3276 { | |
3277 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3278 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3280 gint ret = 0; |
3281 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3282 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3283 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3284 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3285 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3286 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3287 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3291 -1); |
9554 | 3292 |
3293 if (user1 == NULL || user2 == NULL) { | |
3294 if (!(user1 == NULL && user2 == NULL)) | |
3295 ret = (user1 == NULL) ? -1: 1; | |
3296 } else if (f1 != f2) { | |
3297 /* sort more important users first */ | |
3298 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3300 ret = buddy1 ? -1 : 1; |
9554 | 3301 } else { |
10904 | 3302 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3303 } |
3304 | |
3305 g_free(user1); | |
3306 g_free(user2); | |
3307 | |
3308 return ret; | |
3309 } | |
3310 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 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
|
3313 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3314 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3315 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3323 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3324 /* 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
|
3325 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
|
3326 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 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
|
3328 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 char *name; |
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 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
|
3336 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3341 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3344 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3346 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3347 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 -1); |
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 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3355 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3358 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 } while (f != 0); |
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 g_free(normalized_name); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 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
|
3366 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3367 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3369 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3370 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3371 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3372 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3373 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3374 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3375 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3376 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3379 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3380 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3381 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
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 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3384 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3385 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3386 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3387 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3388 continue; |
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 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
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 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3393 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3394 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3395 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3398 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3399 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3400 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3401 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3402 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3403 int f; |
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 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3406 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3407 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3408 /* 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
|
3409 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3410 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3411 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3412 /* 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
|
3413 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
|
3414 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3415 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
|
3416 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3417 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3418 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3421 char *name; |
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 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
|
3424 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3425 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3426 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
|
3427 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3428 break; |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3432 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3433 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 } while (f != 0); |
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 g_free(normalized_name); |
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 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3439 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3442 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3443 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3444 buddy_cb_common(buddy, conv, TRUE); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3447 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3448 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3449 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3450 /* 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
|
3451 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3452 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3453 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3454 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3455 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3456 |
4359 | 3457 static GtkWidget * |
10810 | 3458 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3459 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3460 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3461 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3462 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3463 GaimConnection *gc; |
4359 | 3464 GtkWidget *vpaned, *hpaned; |
10175 | 3465 GtkWidget *vbox, *hbox, *frame; |
4359 | 3466 GtkWidget *lbox, *bbox; |
3467 GtkWidget *label; | |
3468 GtkWidget *list; | |
3469 GtkWidget *button; | |
7949 | 3470 GtkWidget *sw; |
4359 | 3471 GtkListStore *ls; |
3472 GtkCellRenderer *rend; | |
3473 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3474 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3475 GList *focus_chain = NULL; |
4359 | 3476 |
3477 gtkchat = gtkconv->u.chat; | |
3478 gc = gaim_conversation_get_gc(conv); | |
3479 | |
3480 /* Setup the outer pane. */ | |
3481 vpaned = gtk_vpaned_new(); | |
3482 gtk_widget_show(vpaned); | |
3483 | |
3484 /* Setup the top part of the pane. */ | |
11243 | 3485 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3486 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3487 gtk_widget_show(vbox); |
3488 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3489 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3490 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3491 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3492 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3493 { |
11243 | 3494 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3495 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3496 gtk_widget_show(hbox); |
3497 | |
3498 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3499 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3500 gtk_widget_show(label); |
3501 | |
3502 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3503 |
7971 | 3504 if(prpl_info->set_chat_topic == NULL) { |
3505 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3506 } else { | |
3507 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3508 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3509 } |
3510 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3511 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3512 gtk_widget_show(gtkchat->topic_text); |
3513 } | |
3514 | |
3515 /* Setup the horizontal pane. */ | |
3516 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3517 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3518 gtk_widget_show(hpaned); |
3519 | |
10175 | 3520 /* Setup gtkihmtml. */ |
3521 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3522 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3523 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3524 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3525 gtk_widget_show(frame); | |
3526 | |
3527 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3528 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3529 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3530 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3531 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3532 |
4359 | 3533 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3534 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3535 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3536 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3537 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3538 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3539 |
3540 /* Build the right pane. */ | |
11243 | 3541 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3542 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3543 gtk_widget_show(lbox); |
3544 | |
3545 /* Setup the label telling how many people are in the room. */ | |
3546 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3547 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3548 gtk_widget_show(gtkchat->count); | |
3549 | |
3550 /* Setup the list of users. */ | |
7949 | 3551 sw = gtk_scrolled_window_new(NULL, NULL); |
3552 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3553 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3554 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3555 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3556 gtk_widget_show(sw); | |
4359 | 3557 |
9554 | 3558 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
|
3559 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
|
3560 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3561 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3562 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3563 GTK_SORT_ASCENDING); |
3564 | |
3565 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3566 | |
9498 | 3567 rend = gtk_cell_renderer_pixbuf_new(); |
3568 | |
4359 | 3569 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3570 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3571 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3572 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3573 |
3574 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3575 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3576 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3577 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3578 |
9498 | 3579 rend = gtk_cell_renderer_text_new(); |
3580 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3581 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3582 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3583 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3584 NULL); |
4359 | 3585 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3586 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3587 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3588 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3589 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3590 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3591 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3592 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3593 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3594 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3595 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3596 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3597 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3598 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3599 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3600 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3601 #endif |
4359 | 3602 |
3603 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3604 | |
3605 gtk_widget_set_size_request(list, 150, -1); | |
3606 | |
3607 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3608 gtk_widget_show(list); | |
3609 | |
3610 gtkchat->list = list; | |
3611 | |
7949 | 3612 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3613 |
3614 /* Setup the user list toolbar. */ | |
11243 | 3615 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3616 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3617 gtk_widget_show(bbox); | |
3618 | |
3619 /* IM */ | |
10221 | 3620 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3621 GAIM_BUTTON_VERTICAL); |
10500 | 3622 gtkchat->userlist_im = button; |
4359 | 3623 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3624 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
|
3625 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3626 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3627 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3628 |
3629 gtk_widget_show(button); | |
3630 | |
3631 /* Ignore */ | |
3632 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3633 GAIM_BUTTON_VERTICAL); | |
10500 | 3634 gtkchat->userlist_ignore = button; |
4359 | 3635 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3636 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
|
3637 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3638 _("Ignore the user"), NULL); |
4359 | 3639 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3640 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3641 gtk_widget_show(button); |
3642 | |
3643 /* Info */ | |
3644 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3645 GAIM_BUTTON_VERTICAL); | |
10500 | 3646 gtkchat->userlist_info = button; |
4359 | 3647 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3648 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3649 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3650 _("Get the user's information"), NULL); |
4359 | 3651 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3652 G_CALLBACK(info_cb), gtkconv); |
4359 | 3653 |
3654 gtk_widget_show(button); | |
3655 | |
10175 | 3656 /* Setup the bottom half of the conversation window */ |
11243 | 3657 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3658 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3659 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3660 |
11243 | 3661 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3662 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3663 gtk_widget_show(gtkconv->lower_hbox); | |
3664 | |
11243 | 3665 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3666 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3667 gtk_widget_show(vbox); | |
3668 | |
10175 | 3669 /* Setup the toolbar, entry widget and all signals */ |
3670 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3671 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3672 gtk_widget_show(frame); |
3673 | |
9005 | 3674 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3675 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3676 gaim_account_get_protocol_name(conv->account)); |
10175 | 3677 gtk_widget_set_size_request(gtkconv->entry, -1, |
3678 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3679 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3680 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3681 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3682 |
3683 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3684 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3685 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3686 G_CALLBACK(send_cb), gtkconv); |
4359 | 3687 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3688 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3689 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3690 G_CALLBACK(size_allocate_cb), gtkconv); |
3691 | |
3692 default_formatize(gtkconv); | |
4359 | 3693 |
9080 | 3694 /* |
3695 * Focus for chat windows should be as follows: | |
3696 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3697 * user list buttons -> entry -> buttons at bottom | |
3698 */ | |
9332 | 3699 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3700 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3701 | |
4359 | 3702 return vpaned; |
3703 } | |
3704 | |
3705 static GtkWidget * | |
10810 | 3706 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3707 { |
10810 | 3708 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3709 GtkWidget *frame; |
4359 | 3710 GtkWidget *paned; |
10175 | 3711 GtkWidget *vbox; |
3712 GtkWidget *vbox2; | |
9080 | 3713 GList *focus_chain = NULL; |
4359 | 3714 |
10175 | 3715 /* Setup the outer pane */ |
4359 | 3716 paned = gtk_vpaned_new(); |
3717 gtk_widget_show(paned); | |
3718 | |
10175 | 3719 /* Setup the top part of the pane */ |
11243 | 3720 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3721 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3722 gtk_widget_show(vbox); |
3723 | |
10175 | 3724 /* Setup the gtkimhtml widget */ |
3725 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3726 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3727 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3728 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3729 gtk_widget_show(frame); | |
3730 | |
3731 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3732 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3733 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3734 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3735 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3736 |
3737 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3738 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3739 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3740 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3741 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3742 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3743 |
10175 | 3744 /* Setup the bottom half of the conversation window */ |
11243 | 3745 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3746 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3747 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3748 |
11243 | 3749 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3750 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3751 gtk_widget_show(gtkconv->lower_hbox); | |
3752 | |
11243 | 3753 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3754 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3755 gtk_widget_show(vbox2); | |
8821 | 3756 |
10175 | 3757 /* Setup the toolbar, entry widget and all signals */ |
3758 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3759 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3760 gtk_widget_show(frame); |
3761 | |
9005 | 3762 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3763 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3764 gaim_account_get_protocol_name(conv->account)); |
10175 | 3765 gtk_widget_set_size_request(gtkconv->entry, -1, |
3766 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3767 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3768 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3769 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
|
3770 |
4359 | 3771 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3772 G_CALLBACK(entry_key_press_cb), gtkconv); |
3773 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3774 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3775 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3776 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3777 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3778 |
3779 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3780 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3781 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3782 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3783 |
8481 | 3784 /* had to move this after the imtoolbar is attached so that the |
3785 * signals get fired to toggle the buttons on the toolbar as well. | |
3786 */ | |
10810 | 3787 default_formatize(gtkconv); |
4359 | 3788 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3789 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3790 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3791 |
8758 | 3792 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3793 gtkconv->u.im->show_icon = TRUE; |
4359 | 3794 |
9080 | 3795 /* |
3796 * Focus for IM windows should be as follows: | |
10356 | 3797 * Tab title -> conversation scrollback -> entry |
9080 | 3798 */ |
9332 | 3799 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3800 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3801 |
4359 | 3802 return paned; |
3803 } | |
3804 | |
3805 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3806 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3807 GtkSelectionData *sd, guint info, guint t, |
3808 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3809 { |
10810 | 3810 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3811 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3812 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3813 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3814 { |
4781 | 3815 GaimBlistNode *n = NULL; |
6695 | 3816 GaimBuddy *b; |
11581 | 3817 GaimGtkConversation *gtkconv = NULL; |
9622 | 3818 |
11812 | 3819 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3820 |
6695 | 3821 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3822 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3823 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3824 b = (GaimBuddy*)n; | |
3825 else | |
4781 | 3826 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3827 |
9622 | 3828 /* |
3829 * If we already have an open conversation with this buddy, then | |
3830 * just move the conv to this window. Otherwise, create a new | |
3831 * conv and add it to this window. | |
3832 */ | |
11338 | 3833 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3834 if (c != NULL) { |
11581 | 3835 GaimGtkWindow *oldwin; |
3836 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3837 oldwin = gtkconv->win; | |
9622 | 3838 if (oldwin != win) { |
11581 | 3839 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3840 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3841 } |
3842 } else { | |
11338 | 3843 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3844 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3845 if (gtkconv->win != win) |
3846 { | |
3847 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3848 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3849 } | |
9622 | 3850 } |
3851 | |
3852 /* Make this conversation the active conversation */ | |
11581 | 3853 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3854 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3855 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3856 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3857 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
|
3858 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3859 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3860 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3861 GaimAccount *account; |
11581 | 3862 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3863 |
11137 | 3864 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3865 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3866 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3867 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3868 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3869 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3870 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3871 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3872 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3873 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3874 { |
11338 | 3875 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3876 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3877 if (gtkconv->win != win) |
3878 { | |
3879 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3880 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3881 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3882 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3883 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3884 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3885 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3886 if (protocol != NULL) g_free(protocol); |
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 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3889 } |
9525 | 3890 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3891 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3892 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3893 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3894 } |
10145 | 3895 else |
3896 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3897 } |
4359 | 3898 |
3899 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3900 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3901 { |
10145 | 3902 GTK_IMHTML_DND_TARGETS, |
3903 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3904 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3905 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3906 |
10810 | 3907 static GaimGtkConversation * |
3908 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3909 { | |
3910 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3911 GaimContact *c; | |
3912 GaimBlistNode *cn; | |
10935 | 3913 |
10810 | 3914 if (!bud) |
3915 return NULL; | |
10935 | 3916 |
10810 | 3917 if (!(c = gaim_buddy_get_contact(bud))) |
3918 return NULL; | |
10935 | 3919 |
10810 | 3920 cn = (GaimBlistNode *)c; |
3921 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3922 GaimConversation *conv; | |
11338 | 3923 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3924 if (conv->ui_data) |
3925 return conv->ui_data; | |
3926 } | |
3927 } | |
10935 | 3928 |
10810 | 3929 return NULL; |
3930 } | |
3931 | |
11855 | 3932 static void |
3933 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3934 { | |
3935 GList *list; | |
3936 | |
3937 g_return_if_fail(bnode); | |
3938 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3939 | |
3940 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3941 { | |
3942 GaimGtkWindow *win = list->data; | |
3943 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3944 | |
3945 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3946 continue; | |
3947 | |
3948 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3949 } | |
3950 } | |
3951 | |
11581 | 3952 /************************************************************************** |
3953 * Conversation UI operations | |
3954 **************************************************************************/ | |
3955 void | |
3956 gaim_gtkconv_new(GaimConversation *conv) | |
3957 { | |
3958 GaimGtkConversation *gtkconv; | |
3959 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3960 GtkWidget *pane = NULL; |
3961 GtkWidget *tab_cont; | |
11581 | 3962 |
3963 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3964 conv->ui_data = gtkconv; |
3965 if (!g_list_find(gtkconv->convs, conv)) | |
3966 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3967 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3968 return; |
4359 | 3969 } |
3970 | |
11581 | 3971 gtkconv = g_new0(GaimGtkConversation, 1); |
3972 conv->ui_data = gtkconv; | |
3973 gtkconv->active_conv = conv; | |
3974 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3975 | |
3976 /* Setup some initial variables. */ | |
3977 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3978 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3979 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3980 gtkconv->unseen_count = 0; |
11581 | 3981 |
3982 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3983 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3984 | |
3985 pane = setup_im_pane(gtkconv); | |
3986 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3987 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3988 pane = setup_chat_pane(gtkconv); | |
3989 } | |
3990 | |
12101 | 3991 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
3992 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
3993 | |
11581 | 3994 if (pane == NULL) { |
3995 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
3996 g_free(gtkconv->u.chat); | |
3997 else if (conv_type == GAIM_CONV_TYPE_IM) | |
3998 g_free(gtkconv->u.im); | |
3999 | |
4000 g_free(gtkconv); | |
4001 conv->ui_data = NULL; | |
4002 return; | |
10449 | 4003 } |
11581 | 4004 |
4005 /* Setup drag-and-drop */ | |
4006 gtk_drag_dest_set(pane, | |
4007 GTK_DEST_DEFAULT_MOTION | | |
4008 GTK_DEST_DEFAULT_DROP, | |
4009 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4010 GDK_ACTION_COPY); | |
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(gtkconv->imhtml, 0, | |
4017 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4018 GDK_ACTION_COPY); | |
4019 | |
4020 gtk_drag_dest_set(gtkconv->entry, 0, | |
4021 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4022 GDK_ACTION_COPY); | |
4023 | |
4024 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4025 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4026 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4027 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4028 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4029 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4030 | |
4031 /* Setup the container for the tab. */ | |
4032 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4033 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4034 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4035 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4036 gtk_widget_show(pane); | |
4037 | |
4038 gtkconv->make_sound = TRUE; | |
4039 | |
4040 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4041 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4042 else |
11581 | 4043 gtk_widget_hide(gtkconv->toolbar); |
4044 | |
12188 | 4045 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4046 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4047 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4048 gaim_account_get_protocol_name(conv->account)); |
11581 | 4049 |
4050 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4051 G_CALLBACK(gtk_widget_grab_focus), | |
4052 gtkconv->entry); | |
4053 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4054 if (conv_type == GAIM_CONV_TYPE_IM) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4055 /* put conv in hidden_convwin if hide_new pref is always */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4056 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
|
4057 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4058 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4059 } |
12188 | 4060 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4061 /* put conv in hidden_convwin if hide_new pref is away and account is away */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4062 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
|
4063 && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4064 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4065 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4066 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4067 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4068 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4069 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4070 |
11581 | 4071 gaim_gtkconv_placement_place(gtkconv); |
4072 } | |
4073 | |
4359 | 4074 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4075 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4076 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4077 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4078 |
10810 | 4079 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4080 /* Don't destroy ourselves until all our convos are gone */ | |
4081 if (gtkconv->convs) | |
4082 return; | |
11508 | 4083 |
11581 | 4084 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4085 | |
9504 | 4086 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4087 gaim_request_close_with_handle(conv); | |
4359 | 4088 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4089 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4090 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4091 |
11338 | 4092 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4093 if (gtkconv->u.im->icon_timer != 0) |
4094 g_source_remove(gtkconv->u.im->icon_timer); | |
4095 | |
4359 | 4096 if (gtkconv->u.im->anim != NULL) |
4793 | 4097 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4098 |
4099 g_free(gtkconv->u.im); | |
11581 | 4100 } 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
|
4101 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4102 g_free(gtkconv->u.chat); |
4103 } | |
4104 | |
4633 | 4105 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4106 | |
4359 | 4107 g_free(gtkconv); |
4108 } | |
4109 | |
4110 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4111 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4112 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4113 time_t mtime) |
4359 | 4114 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4115 GaimGtkConversation *gtkconv; |
4359 | 4116 |
4117 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4118 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4119 |
6982 | 4120 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4121 } |
4122 | |
4123 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4124 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4125 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4126 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4127 GaimGtkConversation *gtkconv; |
4359 | 4128 |
4129 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4130 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4131 |
10398 | 4132 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4133 |
6982 | 4134 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4135 } |
4136 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4137 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4138 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4139 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4140 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4141 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4142 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4143 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4144 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4145 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4146 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4147 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4148 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4149 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4150 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4151 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4152 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4153 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4154 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4155 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4156 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4157 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4158 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4159 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4160 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4161 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4162 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4163 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4164 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4165 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4166 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4167 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4168 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4169 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4170 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4171 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4172 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4173 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4174 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4175 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4176 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4177 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4178 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4179 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4180 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4181 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4182 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4183 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4184 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4185 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4186 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4187 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4188 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4189 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4190 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4191 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4192 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4193 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4194 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4195 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4196 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4197 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4198 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4199 str[sizeof(str)] = '\0'; |
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 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4202 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4203 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
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 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4206 buddytag = gtk_text_buffer_create_tag( |
11096 | 4207 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4208 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4209 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4210 G_CALLBACK(buddytag_event), conv); |
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 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4213 return buddytag; |
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 |
4359 | 4216 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4217 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4218 const char *message, GaimMessageFlags flags, |
4359 | 4219 time_t mtime) |
4220 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4221 GaimGtkConversation *gtkconv; |
11581 | 4222 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4223 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4224 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4225 GaimPluginProtocolInfo *prpl_info; |
4359 | 4226 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4227 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4228 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4229 int line_count; |
4359 | 4230 char buf2[BUF_LONG]; |
4231 char mdate[64]; | |
4232 char color[10]; | |
4233 char *str; | |
4234 char *with_font_tag; | |
4896 | 4235 char *sml_attrib = NULL; |
6982 | 4236 size_t length = strlen(message) + 1; |
4895 | 4237 |
4359 | 4238 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4239 |
4240 /* Set the active conversation to the one that just messaged us. */ | |
4241 /* 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
|
4242 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4243 |
4359 | 4244 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4245 account = gaim_conversation_get_account(conv); |
11581 | 4246 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4247 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4248 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4249 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4250 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4251 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4252 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4253 /* 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
|
4254 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4255 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4256 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4257 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4258 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4259 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4260 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4261 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4262 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4263 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4264 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4265 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4266 |
8677 | 4267 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4268 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4269 | |
5133 | 4270 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4271 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4272 else | |
4273 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4274 |
4896 | 4275 if(gc) |
9699 | 4276 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4277 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4278 |
10503 | 4279 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4280 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4281 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4282 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4283 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4284 |
7956 | 4285 /* this is gonna crash one day, I can feel it. */ |
4286 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4287 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4288 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4289 } |
4359 | 4290 |
10737 | 4291 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4292 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4293 g_snprintf(buf2, sizeof(buf2), |
8690 | 4294 "<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
|
4295 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4296 |
8962 | 4297 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4298 |
8722 | 4299 } else if (flags & GAIM_MESSAGE_ERROR) { |
4300 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4301 "<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
|
4302 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4303 |
8962 | 4304 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4305 | |
7431 | 4306 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4307 g_snprintf(buf2, BUF_LONG, |
8690 | 4308 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4309 sml_attrib ? sml_attrib : "", message); |
7440 | 4310 |
10884 | 4311 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4312 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4313 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4314 } else { |
4895 | 4315 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4316 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
|
4317 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4318 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4319 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
|
4320 int tag_end_offset = 0; |
7440 | 4321 |
6621 | 4322 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4323 str = g_malloc(1024); |
7440 | 4324 |
4359 | 4325 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4326 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4327 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4328 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4329 tag_start_offset += 3; |
4359 | 4330 } |
4331 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4332 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4333 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4334 tag_end_offset = 2; |
4359 | 4335 strcpy(color, "#00FF00"); |
4336 } | |
7440 | 4337 } |
4359 | 4338 else { |
10504 | 4339 if (gaim_message_meify(new_message, -1)) { |
4359 | 4340 str = g_malloc(1024); |
7440 | 4341 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4342 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4343 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
|
4344 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4345 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4346 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4347 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4348 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4349 } |
7440 | 4350 |
6621 | 4351 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4352 strcpy(color, "#AF7F00"); |
4353 else | |
4354 strcpy(color, "#062585"); | |
4355 } | |
4356 else { | |
4357 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4358 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4359 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
|
4360 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4361 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4362 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4363 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4364 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4365 } |
6621 | 4366 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4367 strcpy(color, "#AF7F00"); |
6621 | 4368 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4369 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4370 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4371 |
10108 | 4372 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4373 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4374 } else |
7854 | 4375 strcpy(color, RECV_COLOR); |
4359 | 4376 } |
6621 | 4377 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4378 strcpy(color, SEND_COLOR); |
10892 | 4379 else { |
4380 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4381 strcpy(color, "#000000"); | |
4382 } | |
4359 | 4383 } |
4384 } | |
10892 | 4385 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4386 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4387 g_free(alias_escaped); |
11508 | 4388 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4389 /* 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
|
4390 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4391 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4392 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4393 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4394 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4395 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4396 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4397 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4398 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4399 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4400 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4401 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4402 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4403 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4404 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4405 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4406 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4407 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4408 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4409 /* 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
|
4410 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4411 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4412 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4413 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4414 } |
7440 | 4415 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4416 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4417 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4418 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4419 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4420 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4421 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4422 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4423 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4424 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4425 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4426 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4427 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4428 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4429 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4430 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4431 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4432 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4433 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4434 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4435 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4436 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4437 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4438 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4439 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4440 |
4359 | 4441 g_free(str); |
4442 | |
4895 | 4443 if(gc){ |
4896 | 4444 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4445 char *post = "</font>"; |
4446 int pre_len = strlen(pre); | |
4447 int post_len = strlen(post); | |
7440 | 4448 |
4895 | 4449 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4450 |
4895 | 4451 strcpy(with_font_tag, pre); |
4452 memcpy(with_font_tag + pre_len, new_message, length); | |
4453 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4454 |
4895 | 4455 length += pre_len + post_len; |
4456 g_free(pre); | |
4457 } | |
4608 | 4458 else |
4895 | 4459 with_font_tag = g_memdup(new_message, length); |
7440 | 4460 |
8962 | 4461 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4462 with_font_tag, gtk_font_options); | |
7440 | 4463 |
4464 g_free(with_font_tag); | |
7447 | 4465 g_free(new_message); |
7440 | 4466 } |
4467 | |
5012 | 4468 if(sml_attrib) |
4469 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4470 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4471 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4472 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4473 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4474 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4475 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4476 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4477 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4478 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4479 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4480 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4481 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
|
4482 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4483 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4484 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4485 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4486 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4487 } |
4359 | 4488 } |
4489 | |
4490 static void | |
11869 | 4491 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
|
4492 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4493 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4494 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4495 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4496 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4497 GList *ll; |
11869 | 4498 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4499 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4500 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4501 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4502 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4503 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4504 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4505 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4506 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
|
4507 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4508 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4509 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4510 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4511 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4512 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4513 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4514 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4515 l = users; |
11869 | 4516 ll = flags; |
4517 lll = aliases; | |
4518 while (l != NULL && ll != NULL && lll != NULL) { | |
4519 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
|
4520 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4521 ll = ll->next; |
11869 | 4522 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4523 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4524 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4525 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4526 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4527 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
|
4528 const char *new_name, const char *new_alias) |
4359 | 4529 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4530 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4531 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4532 GaimGtkChatPane *gtkchat; |
11869 | 4533 GaimConvChatBuddyFlags flags; |
4359 | 4534 GtkTreeIter iter; |
4535 GtkTreeModel *model; | |
4536 int f = 1; | |
4537 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4538 chat = GAIM_CONV_CHAT(conv); |
4359 | 4539 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4540 gtkchat = gtkconv->u.chat; | |
4541 | |
9554 | 4542 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4543 | |
4544 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4545 return; | |
4546 | |
4547 while (f != 0) { | |
4548 char *val; | |
4549 | |
11869 | 4550 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4551 |
4552 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4553 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4554 g_free(val); | |
4359 | 4555 break; |
4556 } | |
9554 | 4557 |
4558 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4559 | |
4560 g_free(val); | |
4359 | 4561 } |
4562 | |
9554 | 4563 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4564 return; |
4565 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4566 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4567 |
11869 | 4568 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4569 } |
4570 | |
4571 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4572 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4573 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4574 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4575 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4576 GaimGtkChatPane *gtkchat; |
4359 | 4577 GtkTreeIter iter; |
4578 GtkTreeModel *model; | |
4579 char tmp[BUF_LONG]; | |
4580 int num_users; | |
4581 int f = 1; | |
4582 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4583 chat = GAIM_CONV_CHAT(conv); |
4359 | 4584 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4585 gtkchat = gtkconv->u.chat; | |
4586 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4587 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
|
4588 |
9554 | 4589 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4590 | |
4591 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4592 return; | |
4593 | |
4594 while (f != 0) { | |
4595 char *val; | |
4596 | |
4597 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4598 | |
4599 if (!gaim_utf8_strcasecmp(user, val)) { | |
4600 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4601 g_free(val); | |
4359 | 4602 break; |
4603 } | |
9554 | 4604 |
4605 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4606 | |
4607 g_free(val); | |
4359 | 4608 } |
4609 | |
9554 | 4610 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4611 return; |
4612 | |
4613 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4614 ngettext("%d person in room", "%d people in room", |
4615 num_users), num_users); | |
4359 | 4616 |
4617 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4618 | |
4619 } | |
4620 | |
4621 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4622 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4623 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4624 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4625 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4626 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4627 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4628 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4629 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4630 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4631 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4632 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4633 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4634 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4635 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4636 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4637 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4638 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
|
4639 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4640 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4641 for (l = users; l != NULL; l = l->next) { |
9554 | 4642 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4643 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4644 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4645 continue; |
4646 | |
4647 do { | |
4648 char *val; | |
4649 | |
4650 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4651 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4652 | |
9696 | 4653 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4654 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4655 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4656 #else |
4657 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4658 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4659 #endif | |
4660 } | |
9554 | 4661 else |
4662 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4663 | |
4664 g_free(val); | |
4665 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4666 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4667 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4668 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4669 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4670 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4671 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4672 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4673 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4674 |
9554 | 4675 static void |
4676 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4677 { | |
4678 GaimConvChat *chat; | |
11869 | 4679 GaimConvChatBuddyFlags flags; |
9554 | 4680 GaimGtkConversation *gtkconv; |
4681 GaimGtkChatPane *gtkchat; | |
4682 GtkTreeIter iter; | |
4683 GtkTreeModel *model; | |
4684 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4685 char *alias = NULL; |
9554 | 4686 |
4687 chat = GAIM_CONV_CHAT(conv); | |
4688 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4689 gtkchat = gtkconv->u.chat; | |
4690 | |
4691 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4692 | |
4693 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4694 return; | |
4695 | |
4696 while (f != 0) { | |
4697 char *val; | |
4698 | |
4699 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4700 | |
4701 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4702 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4703 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4704 g_free(val); | |
4705 break; | |
4706 } | |
4707 | |
4708 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4709 | |
4710 g_free(val); | |
4711 } | |
4712 | |
4713 if (!gaim_conv_chat_find_user(chat, user)) | |
4714 return; | |
4715 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4716 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4717 |
11869 | 4718 flags = gaim_conv_chat_user_get_flags(chat, user); |
4719 | |
4720 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4721 g_free(alias); |
9554 | 4722 } |
4723 | |
11581 | 4724 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4725 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4726 { |
11581 | 4727 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4728 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4729 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4730 |
11581 | 4731 win = gtkconv->win; |
4732 | |
4733 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
|
4734 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4735 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4736 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4737 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4738 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4739 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4740 |
10526 | 4741 static gboolean |
4742 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4743 { | |
4744 GaimGtkConversation *gtkconv; | |
4745 GtkIMHtmlSmiley *smiley; | |
4746 GdkPixbufLoader *loader; | |
11525 | 4747 struct smiley_list *list; |
4748 const char *sml = NULL, *conv_sml; | |
4749 | |
4750 if (!conv || !smile || !*smile) { | |
10526 | 4751 return FALSE; |
4752 } | |
4753 | |
11525 | 4754 /* If smileys are off, return false */ |
4755 if (gaim_gtkthemes_smileys_disabled()) | |
4756 return FALSE; | |
4757 | |
4758 /* If possible add this smiley to the current theme. | |
4759 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4760 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4761 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4762 |
4763 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4764 if (!strcmp(list->sml, conv_sml)) { | |
4765 sml = list->sml; | |
4766 break; | |
4767 } | |
4768 } | |
4769 | |
10526 | 4770 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4771 | |
4772 if (smiley) { | |
11525 | 4773 |
4774 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4775 return FALSE; | |
4776 } | |
4777 | |
4778 /* Close the old GdkPixbufAnimation, then create a new one for | |
4779 * the smiley we are about to receive */ | |
4780 g_object_unref(G_OBJECT(smiley->icon)); | |
4781 | |
4782 smiley->loader = gdk_pixbuf_loader_new(); | |
4783 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4784 if (smiley->icon) | |
4785 g_object_ref(G_OBJECT(smiley->icon)); | |
4786 | |
4787 /* A custom smiley is already associated */ | |
4788 return TRUE; | |
10526 | 4789 } |
4790 | |
4791 loader = gdk_pixbuf_loader_new(); | |
4792 | |
4793 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4794 /* 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
|
4795 GtkIMHtmlSmiley by opaque */ |
10526 | 4796 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4797 smiley->file = NULL; | |
4798 smiley->smile = g_strdup(smile); | |
4799 smiley->loader = loader; | |
11525 | 4800 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4801 |
4802 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4803 if (smiley->icon) | |
4804 g_object_ref(G_OBJECT(smiley->icon)); | |
4805 | |
11525 | 4806 |
10526 | 4807 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4808 |
10526 | 4809 return TRUE; |
4810 } | |
4811 | |
10537 | 4812 static void |
10526 | 4813 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4814 const guchar *data, gsize size) |
10526 | 4815 { |
4816 GaimGtkConversation *gtkconv; | |
4817 GtkIMHtmlSmiley *smiley; | |
10537 | 4818 GdkPixbufLoader *loader; |
10526 | 4819 const char *sml; |
4820 | |
4821 sml = gaim_account_get_protocol_name(conv->account); | |
4822 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4823 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4824 | |
10537 | 4825 if (!smiley) |
10526 | 4826 return; |
10537 | 4827 |
10526 | 4828 loader = smiley->loader; |
10537 | 4829 if (!loader) |
10526 | 4830 return; |
4831 | |
4832 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4833 } | |
4834 | |
4835 static void | |
4836 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4837 { | |
4838 GaimGtkConversation *gtkconv; | |
4839 GtkIMHtmlSmiley *smiley; | |
4840 GdkPixbufLoader *loader; | |
4841 const char *sml; | |
11525 | 4842 GtkWidget *icon = NULL; |
4843 GtkTextChildAnchor *anchor = NULL; | |
4844 GtkTextIter end; | |
4845 GtkIMHtml *imhtml; | |
4846 GSList *current = NULL; | |
10526 | 4847 |
4848 g_return_if_fail(conv != NULL); | |
4849 g_return_if_fail(smile != NULL); | |
4850 | |
4851 sml = gaim_account_get_protocol_name(conv->account); | |
4852 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4853 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4854 | |
10537 | 4855 if (!smiley) |
10526 | 4856 return; |
4857 | |
4858 loader = smiley->loader; | |
4859 | |
10537 | 4860 if (!loader) |
10526 | 4861 return; |
10537 | 4862 |
11525 | 4863 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4864 if (smiley->icon) | |
4865 g_object_ref(G_OBJECT(smiley->icon)); | |
4866 | |
4867 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4868 | |
4869 icon = gtk_image_new_from_animation(smiley->icon); | |
4870 | |
4871 if (icon) { | |
12047 | 4872 gtk_widget_show(icon); |
4873 | |
11525 | 4874 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
4875 | |
4876 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4877 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4878 | |
4879 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4880 } | |
4881 | |
4882 } | |
4883 | |
4884 g_slist_free(smiley->anchors); | |
4885 smiley->anchors = NULL; | |
4886 | |
4887 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4888 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4889 * makes me question it */ | |
4890 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4891 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4892 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4893 | |
10526 | 4894 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4895 | |
4896 gdk_pixbuf_loader_close(loader, NULL); | |
4897 g_object_unref(G_OBJECT(loader)); | |
4898 smiley->loader = NULL; | |
4899 } | |
4900 | |
11581 | 4901 /* |
4902 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4903 * sensitive/insensitive. This is called after changing tabs and when an | |
4904 * account signs on or off. | |
4905 */ | |
4906 static void | |
4907 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4908 { | |
4909 GaimGtkWindow *win; | |
4910 GaimConversation *conv = gtkconv->active_conv; | |
4911 GaimConnection *gc; | |
4912 GaimPluginProtocolInfo *prpl_info = NULL; | |
4913 GdkPixbuf *window_icon = NULL; | |
4914 GtkIMHtmlButtons buttons; | |
4915 GaimAccount *account; | |
4916 | |
4917 win = gaim_gtkconv_get_window(gtkconv); | |
4918 gc = gaim_conversation_get_gc(conv); | |
4919 account = gaim_conversation_get_account(conv); | |
4920 | |
4921 if (gc != NULL) | |
4922 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4923 | |
11594 | 4924 if (win->menu.send_to != NULL) |
11734 | 4925 update_send_to_selection(win); |
11581 | 4926 |
4927 /* | |
4928 * Handle hiding and showing stuff based on what type of conv this is. | |
4929 * Stuff that Gaim IMs support in general should be shown for IM | |
4930 * conversations. Stuff that Gaim chats support in general should be | |
4931 * shown for chat conversations. It doesn't matter whether the PRPL | |
4932 * supports it or not--that only affects if the button or menu item | |
4933 * is sensitive or not. | |
4934 */ | |
4935 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4936 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4937 | |
4938 /* Deal with menu items */ | |
4939 gtk_widget_show(win->menu.view_log); | |
4940 gtk_widget_show(win->menu.send_file); | |
4941 gtk_widget_show(win->menu.add_pounce); | |
4942 gtk_widget_show(win->menu.get_info); | |
4943 gtk_widget_hide(win->menu.invite); | |
4944 gtk_widget_show(win->menu.alias); | |
4945 gtk_widget_show(win->menu.block); | |
4946 | |
4947 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4948 gtk_widget_show(win->menu.add); | |
4949 gtk_widget_hide(win->menu.remove); | |
4950 } else { | |
4951 gtk_widget_show(win->menu.remove); | |
4952 gtk_widget_hide(win->menu.add); | |
4953 } | |
4954 | |
4955 gtk_widget_show(win->menu.insert_link); | |
4956 gtk_widget_show(win->menu.insert_image); | |
4957 gtk_widget_show(win->menu.show_icon); | |
4958 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4959 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4960 | |
4961 /* Deal with menu items */ | |
4962 gtk_widget_show(win->menu.view_log); | |
4963 gtk_widget_hide(win->menu.send_file); | |
4964 gtk_widget_hide(win->menu.add_pounce); | |
4965 gtk_widget_hide(win->menu.get_info); | |
4966 gtk_widget_show(win->menu.invite); | |
4967 gtk_widget_show(win->menu.alias); | |
4968 gtk_widget_hide(win->menu.block); | |
4969 gtk_widget_hide(win->menu.show_icon); | |
4970 | |
4971 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4972 /* If the chat is NOT in the buddy list */ | |
4973 gtk_widget_show(win->menu.add); | |
4974 gtk_widget_hide(win->menu.remove); | |
4975 } else { | |
4976 /* If the chat IS in the buddy list */ | |
4977 gtk_widget_hide(win->menu.add); | |
4978 gtk_widget_show(win->menu.remove); | |
4979 } | |
4980 | |
4981 gtk_widget_show(win->menu.insert_link); | |
4982 gtk_widget_hide(win->menu.insert_image); | |
4983 } | |
4984 | |
4985 /* | |
4986 * Handle graying stuff out based on whether an account is connected | |
4987 * and what features that account supports. | |
4988 */ | |
4989 if ((gc != NULL) && | |
12012 | 4990 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
4991 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
4992 { | |
11581 | 4993 /* Account is online */ |
4994 /* Deal with the toolbar */ | |
12012 | 4995 if (conv->features & GAIM_CONNECTION_HTML) |
4996 { | |
4997 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
4998 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
4999 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5000 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5001 { | |
5002 buttons &= ~GTK_IMHTML_GROW; | |
5003 buttons &= ~GTK_IMHTML_SHRINK; | |
5004 } | |
5005 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5006 buttons &= ~GTK_IMHTML_LINKDESC; | |
5007 } else { | |
12216 | 5008 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5009 } |
12216 | 5010 |
5011 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5012 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5013 buttons &= ~GTK_IMHTML_IMAGE; | |
5014 | |
12012 | 5015 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
5016 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5017 |
5018 /* Deal with menu items */ | |
12012 | 5019 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5020 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5021 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5022 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5023 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5024 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5025 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5026 |
5027 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5028 { | |
5029 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5030 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5031 gtk_widget_set_sensitive(win->menu.send_file, | |
5032 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5033 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5034 gtk_widget_set_sensitive(win->menu.alias, | |
5035 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
5036 } | |
5037 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5038 { | |
5039 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5040 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5041 gtk_widget_set_sensitive(win->menu.alias, | |
5042 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
5043 } | |
11581 | 5044 |
5045 /* Deal with chat userlist buttons */ | |
12012 | 5046 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5047 { | |
5048 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5049 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5050 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5051 } | |
5052 } else { | |
11581 | 5053 /* Account is offline */ |
5054 /* Or it's a chat that we've left. */ | |
5055 | |
5056 /* Then deal with menu items */ | |
12012 | 5057 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5058 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5059 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5060 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5061 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5062 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5063 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5064 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5065 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5066 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5067 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5068 |
5069 /* Deal with chat userlist buttons */ | |
12012 | 5070 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5071 { | |
5072 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5073 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5074 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5075 } | |
5076 } | |
11581 | 5077 |
5078 /* | |
5079 * Update the window's icon | |
5080 */ | |
12171 | 5081 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5082 { |
12171 | 5083 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5084 (gtkconv->u.im->anim)) | |
5085 { | |
5086 window_icon = | |
5087 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5088 g_object_ref(window_icon); | |
5089 } else { | |
5090 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5091 } | |
5092 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5093 if (window_icon != NULL) | |
5094 g_object_unref(G_OBJECT(window_icon)); | |
5095 } | |
11581 | 5096 } |
5097 | |
10526 | 5098 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5099 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5100 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5101 { |
11581 | 5102 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5103 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5104 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5105 GaimConvChat *chat; |
4359 | 5106 |
10116 | 5107 g_return_if_fail(conv != NULL); |
5108 | |
4359 | 5109 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5110 win = gtkconv->win; |
10810 | 5111 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5112 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5113 * instead of the gross hack? | |
5114 */ | |
4359 | 5115 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5116 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5117 { |
4359 | 5118 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5119 |
11338 | 5120 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5121 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5122 |
4359 | 5123 gaim_gtkconv_update_buttons_by_protocol(conv); |
5124 | |
11734 | 5125 update_send_to_selection(win); |
4359 | 5126 |
11525 | 5127 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5128 |
6395 | 5129 update_tab_icon(conv); |
4359 | 5130 } |
5131 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5132 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5133 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5134 { |
9472 | 5135 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5136 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5137 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5138 /* 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
|
5139 char style[51]; |
4736 | 5140 |
11338 | 5141 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5142 im = GAIM_CONV_IM(conv); |
4359 | 5143 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5144 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5145 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5146 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5147 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5148 else | |
5149 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5150 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5151 *style = '\0'; |
4359 | 5152 |
5153 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5154 gtk_widget_realize(gtkconv->tab_label); | |
5155 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5156 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5157 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5158 { |
11759 | 5159 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5160 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5161 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5162 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5163 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5164 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5165 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5166 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5167 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5168 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5169 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5170 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5171 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5172 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5173 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5174 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5175 { |
11758 | 5176 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5177 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5178 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5179 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5180 { |
8536 | 5181 char *html_title,*label; |
5182 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5183 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5184 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5185 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5186 style, html_title); |
8536 | 5187 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5188 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5189 g_free(label); |
4359 | 5190 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5191 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5192 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5193 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5194 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5195 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5196 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5197 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5198 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5199 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5200 gtk_window_set_title(GTK_WINDOW(win->window), title); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5201 } |
9472 | 5202 |
5203 g_free(title); | |
4359 | 5204 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5205 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5206 { |
7154 | 5207 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5208 chat = GAIM_CONV_CHAT(conv); |
4359 | 5209 gtkchat = gtkconv->u.chat; |
5210 | |
7154 | 5211 topic = gaim_conv_chat_get_topic(chat); |
5212 | |
9554 | 5213 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5214 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5215 topic ? topic : "", NULL); |
4359 | 5216 } |
5217 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5218 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5219 { |
11581 | 5220 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5221 generate_send_to_items(win); |
8946 | 5222 update_tab_icon(conv); |
9472 | 5223 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5224 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5225 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5226 { |
8946 | 5227 update_tab_icon(conv); |
4359 | 5228 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5229 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
|
5230 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5231 { |
9472 | 5232 gaim_conversation_autoset_title(conv); |
10810 | 5233 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5234 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5235 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5236 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5237 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5238 } |
10665 | 5239 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5240 { | |
10810 | 5241 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5242 } |
4359 | 5243 } |
5244 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5245 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5246 { |
11581 | 5247 gaim_gtkconv_new, |
4359 | 5248 gaim_gtkconv_destroy, /* destroy_conversation */ |
5249 gaim_gtkconv_write_chat, /* write_chat */ | |
5250 gaim_gtkconv_write_im, /* write_im */ | |
5251 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5252 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5253 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5254 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5255 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5256 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5257 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5258 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5259 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5260 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5261 gaim_gtkconv_updated /* updated */ |
5262 }; | |
5263 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5264 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5265 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5266 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5267 return &conversation_ui_ops; |
4359 | 5268 } |
5269 | |
5270 /************************************************************************** | |
5271 * Public conversation utility functions | |
5272 **************************************************************************/ | |
5273 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5274 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5275 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5276 GaimGtkConversation *gtkconv; |
11581 | 5277 GaimGtkWindow *win; |
4359 | 5278 |
10381 | 5279 GdkPixbufLoader *loader; |
5280 GdkPixbufAnimation *anim; | |
4359 | 5281 GError *err = NULL; |
5282 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5283 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5284 size_t len; |
4359 | 5285 |
5286 GdkPixbuf *buf; | |
5287 | |
5288 GtkWidget *event; | |
5289 GtkWidget *frame; | |
5290 GdkPixbuf *scale; | |
5291 GdkPixmap *pm; | |
5292 GdkBitmap *bm; | |
9318 | 5293 int scale_width, scale_height; |
5294 | |
5295 GaimAccount *account; | |
5296 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5297 |
9324 | 5298 GaimBuddyIcon *icon; |
5299 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5300 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5301 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5302 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5303 |
5304 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5305 win = gtkconv->win; |
10175 | 5306 |
9687 | 5307 if (!gtkconv->u.im->show_icon) |
5308 return; | |
5309 | |
9318 | 5310 account = gaim_conversation_get_account(conv); |
5311 if(account && account->gc) | |
5312 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5313 |
9845 | 5314 /* Remove the current icon stuff */ |
9885 | 5315 if (gtkconv->u.im->icon_container != NULL) |
5316 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5317 gtkconv->u.im->icon_container = NULL; | |
9845 | 5318 |
5319 if (gtkconv->u.im->anim != NULL) | |
5320 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5321 | |
9887 | 5322 gtkconv->u.im->anim = NULL; |
5323 | |
9845 | 5324 if (gtkconv->u.im->icon_timer != 0) |
5325 g_source_remove(gtkconv->u.im->icon_timer); | |
5326 | |
5327 gtkconv->u.im->icon_timer = 0; | |
5328 | |
5329 if (gtkconv->u.im->iter != NULL) | |
5330 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5331 |
10116 | 5332 gtkconv->u.im->iter = NULL; |
5333 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5334 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5335 return; |
5336 | |
5337 if (gaim_conversation_get_gc(conv) == NULL) | |
5338 return; | |
5339 | |
9324 | 5340 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5341 | |
5342 if (icon == NULL) | |
5343 return; | |
5344 | |
5345 data = gaim_buddy_icon_get_data(icon, &len); | |
5346 | |
10381 | 5347 loader = gdk_pixbuf_loader_new(); |
5348 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5349 anim = gdk_pixbuf_loader_get_animation(loader); | |
5350 if (anim) | |
5351 g_object_ref(G_OBJECT(anim)); | |
5352 gdk_pixbuf_loader_close(loader, &err); | |
5353 g_object_unref(loader); | |
5354 | |
5355 if (!anim) | |
9324 | 5356 return; |
10381 | 5357 gtkconv->u.im->anim = anim; |
9324 | 5358 |
4359 | 5359 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5360 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5361 "Buddy icon error: %s\n", err->message); |
4359 | 5362 g_error_free(err); |
5363 } | |
5364 | |
5365 if (!gtkconv->u.im->anim) | |
5366 return; | |
5367 | |
5368 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5369 gtkconv->u.im->iter = NULL; | |
5370 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5371 } else { | |
5372 gtkconv->u.im->iter = | |
8496 | 5373 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5374 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5375 if (gtkconv->u.im->animate) |
10810 | 5376 start_anim(NULL, gtkconv); |
4359 | 5377 } |
5378 | |
10483 | 5379 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5380 NULL, &scale_width, &scale_height); |
4359 | 5381 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5382 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5383 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5384 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5385 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5386 GDK_INTERP_BILINEAR); |
4359 | 5387 |
5388 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5389 g_object_unref(G_OBJECT(scale)); |
4359 | 5390 |
8821 | 5391 |
9885 | 5392 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5393 |
4359 | 5394 frame = gtk_frame_new(NULL); |
5395 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5396 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5397 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5398 FALSE, FALSE, 0); | |
8821 | 5399 |
4359 | 5400 event = gtk_event_box_new(); |
5401 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5402 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5403 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5404 gtk_widget_show(event); |
5405 | |
4635 | 5406 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5407 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5408 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5409 gtk_widget_show(gtkconv->u.im->icon); | |
5410 | |
4793 | 5411 g_object_unref(G_OBJECT(pm)); |
4359 | 5412 |
5413 if (bm) | |
4793 | 5414 g_object_unref(G_OBJECT(bm)); |
7143 | 5415 |
10356 | 5416 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5417 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5418 |
9885 | 5419 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5420 gtk_widget_show(frame); |
5421 | |
7143 | 5422 /* The buddy icon code needs badly to be fixed. */ |
5423 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
|
5424 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5425 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5426 } |
5427 | |
5428 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5429 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5430 { |
11581 | 5431 GaimGtkWindow *win; |
4359 | 5432 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5433 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5434 return; |
5435 | |
11581 | 5436 win = GAIM_GTK_CONVERSATION(conv)->win; |
5437 | |
5438 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5439 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5440 } |
5441 | |
5442 int | |
11614 | 5443 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5444 { |
4359 | 5445 gint nb_x, nb_y, x_rel, y_rel; |
5446 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5447 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5448 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5449 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5450 gboolean horiz; |
4359 | 5451 |
11614 | 5452 if (to_right) |
5453 *to_right = FALSE; | |
5454 | |
11581 | 5455 notebook = GTK_NOTEBOOK(win->notebook); |
5456 | |
5457 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5458 x_rel = x - nb_x; |
5459 y_rel = y - nb_y; | |
5460 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5461 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5462 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5463 |
11780 | 5464 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5465 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5466 #else |
5467 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5468 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5469 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5470 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5471 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5472 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5473 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5474 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5475 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5476 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5477 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5478 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
|
5479 page_num = i; |
11614 | 5480 |
5481 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5482 *to_right = TRUE; | |
5483 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5484 break; |
4359 | 5485 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5486 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5487 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5488 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
|
5489 page_num = i; |
11614 | 5490 |
5491 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5492 *to_right = TRUE; | |
5493 | |
4359 | 5494 break; |
5495 } | |
5496 } | |
5497 } | |
5498 | |
5499 return page_num; | |
5500 } | |
5501 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5502 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5503 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
|
5504 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5505 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5506 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5507 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5508 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5509 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5510 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5511 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5512 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5513 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5514 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5515 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5516 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5517 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5518 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5519 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5520 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5521 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5522 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5523 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5524 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5525 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5526 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5527 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5528 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5529 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5530 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5531 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5532 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5533 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5534 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5535 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5536 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5537 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5538 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5539 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5540 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5541 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5542 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5543 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5544 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5545 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5546 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5547 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5548 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5549 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5550 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5551 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5552 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5553 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5554 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5555 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5556 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5557 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5558 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5559 GtkPositionType pos; |
11581 | 5560 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5561 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5562 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5563 |
11581 | 5564 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5565 win = l->data; | |
5566 | |
11619 | 5567 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
|
5568 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5569 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5570 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5571 static void |
12188 | 5572 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
5573 gpointer value, gpointer data) | |
5574 { | |
5575 GList *l; | |
5576 GaimConversation *conv; | |
5577 GaimGtkConversation *gtkconv; | |
5578 GaimGtkWindow *win; | |
5579 | |
5580 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
5581 { | |
5582 conv = (GaimConversation *)l->data; | |
5583 | |
5584 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
5585 continue; | |
5586 | |
5587 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5588 win = gtkconv->win; | |
5589 | |
5590 gtk_check_menu_item_set_active( | |
5591 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
5592 (gboolean)GPOINTER_TO_INT(value)); | |
5593 | |
5594 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
5595 (gboolean)GPOINTER_TO_INT(value)); | |
5596 } | |
5597 } | |
5598 | |
5599 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5600 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5601 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5602 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5603 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5604 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5605 GaimGtkConversation *gtkconv; |
11581 | 5606 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5607 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5608 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5609 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5610 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5611 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5612 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5613 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5614 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5615 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5616 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5617 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5618 gtk_check_menu_item_set_active( |
11581 | 5619 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5620 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5621 |
5622 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5623 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5624 else |
8317 | 5625 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5626 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5627 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5628 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5629 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5630 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5631 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5632 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5633 GList *l; |
8189 | 5634 GaimConversation *conv; |
5635 GaimGtkConversation *gtkconv; | |
11581 | 5636 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5637 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5638 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
|
5639 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5640 |
8189 | 5641 /* Set the "animate" flag for each icon based on the new preference */ |
5642 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5643 conv = (GaimConversation *)l->data; | |
5644 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5645 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5646 } |
8189 | 5647 |
5648 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5649 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5650 win = l->data; | |
5651 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5652 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5653 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5654 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5655 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5656 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5657 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
|
5658 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5659 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5660 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5661 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5662 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5663 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5664 |
11338 | 5665 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5666 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5667 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5668 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5669 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5670 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5671 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5672 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5673 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5674 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5675 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5676 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5677 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5678 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5679 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5680 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5681 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5682 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5683 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5684 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5685 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
|
5686 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5687 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5688 if(gaim_status_type_get_primitive(gaim_status_get_type(oldstatus))!=GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5689 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5690 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5691 if(gaim_status_type_get_primitive(gaim_status_get_type(newstatus))==GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5692 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5693 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5694 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5695 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5696 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5697 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5698 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5699 if(gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5700 gaim_status_get_type(gaim_account_get_active_status( |
12239 | 5701 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5702 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5703 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5704 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5705 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5706 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5707 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5708 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5709 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5710 hide_new_pref_cb(const char *name, GaimPrefType type, gpointer value, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5711 gpointer data) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5712 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5713 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5714 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5715 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5716 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5717 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5718 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5719 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5720 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5721 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
|
5722 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5723 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5724 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
|
5725 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5726 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5727 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5728 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5729 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5730 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5731 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5732 if(when_away && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5733 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5734 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5735 continue; |
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 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5738 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5739 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5740 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5741 |
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 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5744 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5745 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5746 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5747 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5748 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5749 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5750 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5751 |
11581 | 5752 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5753 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5754 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5755 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5756 |
11581 | 5757 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5758 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5759 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5760 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5761 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5762 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5763 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5764 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5765 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5766 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5767 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5768 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5769 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5770 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5771 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5772 if (gaim_conversation_get_account(conv) == account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5773 gaim_conversation_update(conv, GPOINTER_TO_INT(event)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5774 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5775 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5776 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5777 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5778 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5779 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5780 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5781 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5782 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5783 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5784 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5785 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5786 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5787 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5788 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5789 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5790 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5791 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5792 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5793 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5794 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5795 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5796 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5797 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5798 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5799 |
12264 | 5800 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5801 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5802 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5803 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5804 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5805 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5806 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5807 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5808 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5809 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5810 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5811 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
|
5812 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5813 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5814 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5815 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5816 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5817 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5818 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5819 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5820 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5821 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5822 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5823 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5824 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5825 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5826 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5827 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5828 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
|
5829 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5830 /* convert old queuing prefs to hide_new 3-way pref */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5831 if(gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5832 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5833 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "always"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5834 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5835 else if(gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5836 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5837 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "away"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5838 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5839 else { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5840 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5841 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5842 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5843 /* Connect callbacks. */ |
10087 | 5844 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
|
5845 close_on_tabs_pref_cb, NULL); |
12188 | 5846 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
5847 show_timestamps_pref_cb, NULL); | |
10087 | 5848 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
|
5849 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5850 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5851 spellcheck_pref_cb, NULL); |
10087 | 5852 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5853 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5854 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5855 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5856 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5857 |
10087 | 5858 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5859 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5860 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5861 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5862 /* IM callbacks */ |
10087 | 5863 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
|
5864 animate_buddy_icons_pref_cb, NULL); |
10087 | 5865 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
|
5866 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5867 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5868 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5869 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5870 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5871 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5872 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5873 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5874 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5875 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5876 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5877 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5878 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5879 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5880 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5881 |
5882 /********************************************************************** | |
5883 * Register commands | |
5884 **********************************************************************/ | |
9829 | 5885 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5886 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5887 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5888 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5889 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5890 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5891 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5892 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5893 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
|
5894 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5895 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5896 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5897 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5898 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5899 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5900 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5901 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5902 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5903 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5904 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5905 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5906 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5907 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5908 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5909 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5910 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5911 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5912 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5913 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5914 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5915 G_CALLBACK(buddy_update_cb), NULL); |
5916 | |
11581 | 5917 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5918 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5919 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5920 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5921 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5922 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5923 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5924 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5925 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5926 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5927 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5928 { |
10443 | 5929 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5930 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5931 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5932 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5933 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5934 } |
11581 | 5935 |
5936 | |
5937 | |
5938 | |
5939 | |
5940 | |
5941 | |
5942 | |
5943 | |
5944 | |
5945 | |
5946 | |
5947 | |
5948 | |
5949 | |
5950 | |
5951 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5952 * and touch each others' private members all day long */ | |
5953 | |
5954 /** | |
5955 * @file gtkconvwin.c GTK+ Conversation Window API | |
5956 * @ingroup gtkui | |
5957 * | |
5958 * gaim | |
5959 * | |
5960 * Gaim is the legal property of its developers, whose names are too numerous | |
5961 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5962 * source distribution. | |
5963 * | |
5964 * This program is free software; you can redistribute it and/or modify | |
5965 * it under the terms of the GNU General Public License as published by | |
5966 * the Free Software Foundation; either version 2 of the License, or | |
5967 * (at your option) any later version. | |
5968 * | |
5969 * This program is distributed in the hope that it will be useful, | |
5970 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
5971 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
5972 * GNU General Public License for more details. | |
5973 * | |
5974 * You should have received a copy of the GNU General Public License | |
5975 * along with this program; if not, write to the Free Software | |
5976 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5977 * | |
5978 */ | |
5979 #include "internal.h" | |
5980 #include "gtkgaim.h" | |
5981 | |
5982 | |
5983 #include <gdk/gdkkeysyms.h> | |
5984 | |
5985 #include "account.h" | |
5986 #include "cmds.h" | |
5987 #include "debug.h" | |
5988 #include "imgstore.h" | |
5989 #include "log.h" | |
5990 #include "notify.h" | |
5991 #include "prpl.h" | |
5992 #include "request.h" | |
5993 #include "util.h" | |
5994 | |
5995 #include "gtkdnd-hints.h" | |
5996 #include "gtkblist.h" | |
5997 #include "gtkconv.h" | |
5998 #include "gtkdialogs.h" | |
5999 #include "gtkmenutray.h" | |
6000 #include "gtkpounce.h" | |
6001 #include "gtkprefs.h" | |
6002 #include "gtkprivacy.h" | |
6003 #include "gtkutils.h" | |
6004 #include "gtkstock.h" | |
6005 #include "gtkimhtml.h" | |
6006 #include "gtkimhtmltoolbar.h" | |
6007 | |
6008 static void | |
6009 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6010 { | |
6011 gtk_widget_destroy(warn_close_dialog); | |
6012 warn_close_dialog = NULL; | |
6013 | |
6014 if (resp == GTK_RESPONSE_OK) | |
6015 gaim_gtk_conv_window_destroy(win); | |
6016 } | |
6017 | |
6018 static void | |
6019 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6020 { | |
6021 GtkWidget *label; | |
6022 GtkWidget *vbox, *hbox; | |
6023 GtkWidget *img; | |
6024 | |
6025 g_return_if_fail(warn_close_dialog == NULL); | |
6026 | |
6027 | |
6028 warn_close_dialog = gtk_dialog_new_with_buttons( | |
6029 _("Confirm close"), | |
6030 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6031 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6032 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
6033 | |
6034 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6035 GTK_RESPONSE_OK); | |
6036 | |
6037 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6038 6); | |
6039 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6040 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6041 FALSE); | |
6042 | |
6043 /* Setup the outside spacing. */ | |
6044 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6045 | |
6046 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6047 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6048 | |
6049 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6050 GTK_ICON_SIZE_DIALOG); | |
6051 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6052 hbox = gtk_hbox_new(FALSE, 12); | |
6053 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6054 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6055 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6056 | |
6057 /* Setup the right vbox. */ | |
6058 vbox = gtk_vbox_new(FALSE, 12); | |
6059 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6060 | |
6061 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6062 gtk_widget_set_size_request(label, 350, -1); | |
6063 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6064 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6065 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6066 | |
6067 /* Connect the signals. */ | |
6068 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6069 G_CALLBACK(do_close), gtkwin); | |
6070 | |
6071 } | |
6072 | |
6073 /************************************************************************** | |
6074 * Callbacks | |
6075 **************************************************************************/ | |
6076 | |
6077 static gboolean | |
6078 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6079 { | |
6080 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6081 GList *l; |
11581 | 6082 |
6083 /* If there are unread messages then show a warning dialog */ | |
6084 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6085 l != NULL; l = l->next) | |
6086 { | |
6087 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6088 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
|
6089 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6090 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6091 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6092 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6093 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6094 return TRUE; |
11581 | 6095 } |
6096 } | |
6097 | |
6098 gaim_gtk_conv_window_destroy(win); | |
6099 | |
6100 return TRUE; | |
6101 } | |
6102 | |
11604 | 6103 static void |
6104 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6105 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6106 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6107 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6108 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6109 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6110 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6111 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6112 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6113 gtkconv->unseen_count++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6114 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6115 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6116 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6117 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6118 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6119 /* 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
|
6120 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
|
6121 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6122 |
11581 | 6123 /* |
6124 * When a conversation window is focused, we know the user | |
6125 * has looked at it so we know there are no longer unseen | |
6126 * messages. | |
6127 */ | |
6128 static gint | |
6129 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6130 { | |
6131 GaimGtkWindow *win = d; | |
11604 | 6132 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6133 | |
6134 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6135 |
6136 return FALSE; | |
6137 } | |
6138 | |
11851 | 6139 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6140 /* Courtesy of Galeon! */ |
6141 static void | |
6142 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6143 { | |
6144 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6145 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6146 } | |
11851 | 6147 #endif |
11581 | 6148 |
6149 static void | |
6150 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6151 { | |
6152 static GdkCursor *cursor = NULL; | |
6153 | |
6154 gtkwin->in_drag = TRUE; | |
6155 | |
6156 if (gtkwin->drag_leave_signal) { | |
6157 g_signal_handler_disconnect(G_OBJECT(widget), | |
6158 gtkwin->drag_leave_signal); | |
6159 gtkwin->drag_leave_signal = 0; | |
6160 } | |
6161 | |
6162 if (cursor == NULL) | |
6163 cursor = gdk_cursor_new(GDK_FLEUR); | |
6164 | |
6165 /* Grab the pointer */ | |
6166 gtk_grab_add(gtkwin->notebook); | |
6167 #ifndef _WIN32 | |
6168 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6169 always be true after a button press. */ | |
6170 if (!gdk_pointer_is_grabbed()) | |
6171 #endif | |
6172 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6173 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6174 NULL, cursor, GDK_CURRENT_TIME); | |
6175 } | |
6176 | |
6177 static gboolean | |
6178 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6179 { | |
6180 | |
6181 /* | |
6182 * Make sure the user moved the mouse far enough for the | |
6183 * drag to be initiated. | |
6184 */ | |
6185 if (win->in_predrag) { | |
6186 if (e->x_root < win->drag_min_x || | |
6187 e->x_root >= win->drag_max_x || | |
6188 e->y_root < win->drag_min_y || | |
6189 e->y_root >= win->drag_max_y) { | |
6190 | |
6191 win->in_predrag = FALSE; | |
6192 notebook_init_grab(win, widget); | |
6193 } | |
6194 } | |
6195 else { /* Otherwise, draw the arrows. */ | |
6196 GaimGtkWindow *dest_win; | |
6197 GtkNotebook *dest_notebook; | |
6198 GtkWidget *tab; | |
6199 gint nb_x, nb_y, page_num; | |
6200 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6201 gboolean horiz_tabs = FALSE; | |
11614 | 6202 GaimGtkConversation *gtkconv; |
6203 gboolean to_right = FALSE; | |
11581 | 6204 |
6205 /* Get the window that the cursor is over. */ | |
6206 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6207 | |
6208 if (dest_win == NULL) { | |
6209 dnd_hints_hide_all(); | |
6210 | |
6211 return TRUE; | |
6212 } | |
6213 | |
6214 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6215 | |
6216 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6217 | |
6218 arrow1_x = arrow2_x = nb_x; | |
6219 arrow1_y = arrow2_y = nb_y; | |
6220 | |
6221 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6222 e->x_root, e->y_root, &to_right); |
6223 to_right = to_right && (win != dest_win); | |
11581 | 6224 |
6225 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6226 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6227 | |
6228 horiz_tabs = TRUE; | |
6229 } | |
6230 | |
11614 | 6231 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6232 tab = gtkconv->tabby; | |
11581 | 6233 |
6234 if (horiz_tabs) { | |
6235 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6236 | |
11614 | 6237 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6238 arrow1_x += tab->allocation.width; |
6239 arrow2_x += tab->allocation.width; | |
6240 } | |
6241 | |
6242 arrow1_y = nb_y + tab->allocation.y; | |
6243 arrow2_y = nb_y + tab->allocation.y + | |
6244 tab->allocation.height; | |
6245 } else { | |
6246 arrow1_x = nb_x + tab->allocation.x; | |
6247 arrow2_x = nb_x + tab->allocation.x + | |
6248 tab->allocation.width; | |
6249 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
6250 | |
6251 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
6252 arrow1_y += tab->allocation.height; | |
6253 arrow2_y += tab->allocation.height; | |
6254 } | |
6255 } | |
6256 | |
6257 if (horiz_tabs) { | |
6258 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6259 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6260 } else { | |
6261 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6262 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6263 } | |
6264 } | |
6265 | |
6266 return TRUE; | |
6267 } | |
6268 | |
6269 static gboolean | |
6270 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6271 { | |
6272 if (win->in_drag) | |
6273 return FALSE; | |
6274 | |
6275 if (e->x_root < win->drag_min_x || | |
6276 e->x_root >= win->drag_max_x || | |
6277 e->y_root < win->drag_min_y || | |
6278 e->y_root >= win->drag_max_y) { | |
6279 | |
6280 win->in_predrag = FALSE; | |
6281 notebook_init_grab(win, widget); | |
6282 } | |
6283 | |
6284 return TRUE; | |
6285 } | |
6286 | |
6287 /* | |
6288 * THANK YOU GALEON! | |
6289 */ | |
6290 static gboolean | |
6291 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6292 { | |
6293 gint nb_x, nb_y, x_rel, y_rel; | |
6294 int tab_clicked; | |
6295 GtkWidget *page; | |
6296 GtkWidget *tab; | |
6297 | |
6298 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6299 return FALSE; | |
6300 | |
6301 | |
6302 if (win->in_drag) { | |
6303 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6304 "Already in the middle of a window drag at tab_press_cb\n"); | |
6305 return TRUE; | |
6306 } | |
6307 | |
6308 /* | |
6309 * Make sure a tab was actually clicked. The arrow buttons | |
6310 * mess things up. | |
6311 */ | |
11614 | 6312 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6313 |
6314 if (tab_clicked == -1) | |
6315 return FALSE; | |
6316 | |
6317 /* | |
6318 * Get the relative position of the press event, with regards to | |
6319 * the position of the notebook. | |
6320 */ | |
6321 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6322 | |
6323 x_rel = e->x_root - nb_x; | |
6324 y_rel = e->y_root - nb_y; | |
6325 | |
6326 /* Reset the min/max x/y */ | |
6327 win->drag_min_x = 0; | |
6328 win->drag_min_y = 0; | |
6329 win->drag_max_x = 0; | |
6330 win->drag_max_y = 0; | |
6331 | |
6332 /* Find out which tab was dragged. */ | |
6333 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6334 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6335 | |
6336 win->drag_min_x = tab->allocation.x + nb_x; | |
6337 win->drag_min_y = tab->allocation.y + nb_y; | |
6338 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6339 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6340 | |
6341 /* Make sure the click occurred in the tab. */ | |
6342 if (e->x_root < win->drag_min_x || | |
6343 e->x_root >= win->drag_max_x || | |
6344 e->y_root < win->drag_min_y || | |
6345 e->y_root >= win->drag_max_y) { | |
6346 | |
6347 return FALSE; | |
6348 } | |
6349 | |
6350 win->in_predrag = TRUE; | |
6351 win->drag_tab = tab_clicked; | |
6352 | |
6353 /* Connect the new motion signals. */ | |
6354 win->drag_motion_signal = | |
6355 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6356 G_CALLBACK(notebook_motion_cb), win); | |
6357 | |
6358 win->drag_leave_signal = | |
6359 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6360 G_CALLBACK(notebook_leave_cb), win); | |
6361 | |
6362 return FALSE; | |
6363 } | |
6364 | |
6365 static gboolean | |
6366 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6367 { | |
6368 GaimGtkWindow *dest_win; | |
6369 GaimConversation *conv; | |
6370 GaimGtkConversation *gtkconv; | |
6371 gint dest_page_num = 0; | |
6372 gboolean new_window = FALSE; | |
11614 | 6373 gboolean to_right = FALSE; |
11581 | 6374 |
6375 /* | |
6376 * Don't check to make sure that the event's window matches the | |
6377 * widget's, because we may be getting an event passed on from the | |
6378 * close button. | |
6379 */ | |
6380 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6381 return FALSE; | |
6382 | |
6383 if (gdk_pointer_is_grabbed()) { | |
6384 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6385 gtk_grab_remove(widget); | |
6386 } | |
6387 | |
6388 if (!win->in_predrag && !win->in_drag) | |
6389 return FALSE; | |
6390 | |
6391 /* Disconnect the motion signal. */ | |
6392 if (win->drag_motion_signal) { | |
6393 g_signal_handler_disconnect(G_OBJECT(widget), | |
6394 win->drag_motion_signal); | |
6395 | |
6396 win->drag_motion_signal = 0; | |
6397 } | |
6398 | |
6399 /* | |
6400 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6401 * signal. | |
6402 */ | |
6403 if (win->in_predrag) { | |
6404 win->in_predrag = FALSE; | |
6405 | |
6406 if (win->drag_leave_signal) { | |
6407 g_signal_handler_disconnect(G_OBJECT(widget), | |
6408 win->drag_leave_signal); | |
6409 | |
6410 win->drag_leave_signal = 0; | |
6411 } | |
6412 } | |
6413 | |
6414 /* If we're not in drag... */ | |
6415 /* We're perfectly normal people! */ | |
6416 if (!win->in_drag) | |
6417 return FALSE; | |
6418 | |
6419 win->in_drag = FALSE; | |
6420 | |
6421 dnd_hints_hide_all(); | |
6422 | |
6423 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6424 | |
6425 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6426 | |
6427 if (dest_win == NULL) { | |
6428 /* If the current window doesn't have any other conversations, | |
6429 * there isn't much point transferring the conv to a new window. */ | |
6430 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6431 /* Make a new window to stick this to. */ | |
6432 dest_win = gaim_gtk_conv_window_new(); | |
6433 new_window = TRUE; | |
6434 } | |
6435 } | |
6436 | |
6437 if (dest_win == NULL) | |
6438 return FALSE; | |
6439 | |
6440 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6441 "conversation-dragging", win, dest_win); | |
6442 | |
6443 /* Get the destination page number. */ | |
6444 if (!new_window) | |
6445 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6446 e->x_root, e->y_root, &to_right); |
11581 | 6447 |
6448 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6449 | |
6450 if (win == dest_win) { | |
6451 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6452 } else { | |
6453 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6454 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6455 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6456 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6457 if (new_window) { | |
6458 gint win_width, win_height; | |
6459 | |
6460 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6461 &win_width, &win_height); | |
6462 | |
6463 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6464 e->x_root - (win_width / 2), | |
6465 e->y_root - (win_height / 2)); | |
6466 | |
6467 gaim_gtk_conv_window_show(dest_win); | |
6468 } | |
6469 } | |
6470 | |
6471 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6472 | |
6473 return TRUE; | |
6474 } | |
6475 | |
6476 | |
6477 static void | |
6478 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6479 gpointer user_data) | |
6480 { | |
6481 GaimGtkWindow *win; | |
6482 GaimConversation *conv; | |
6483 GaimGtkConversation *gtkconv; | |
6484 | |
6485 win = user_data; | |
6486 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6487 | |
6488 g_return_if_fail(conv != NULL); | |
6489 | |
6490 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6491 return; | |
6492 | |
6493 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6494 | |
6495 stop_anim(NULL, gtkconv); | |
6496 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6497 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6498 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6499 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6500 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6501 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6502 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6503 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6504 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6505 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6506 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6507 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6508 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6509 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6510 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6511 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6512 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6513 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6514 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6515 /* 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
|
6516 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6517 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6518 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6519 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6520 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6521 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6522 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6523 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6524 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6525 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6526 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6527 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6528 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6529 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6530 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6531 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6532 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6533 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6534 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6535 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6536 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6537 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6538 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6539 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6540 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6541 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6542 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6543 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6544 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6545 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6546 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6547 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6548 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6549 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6550 } |
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 static void close_tab_cb(GtkWidget *w, GObject *menu) |
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 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6555 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6556 gtkconv = g_object_get_data(menu, "clicked_tab"); |
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 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6559 close_conv_cb(NULL, 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 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6562 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6563 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6564 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6565 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6566 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6567 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6568 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6569 return FALSE; |
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 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
6572 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
|
6573 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6574 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6575 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6576 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6577 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6578 } |
12188 | 6579 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6580 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6581 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6582 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6583 gaim_separator(GTK_WIDGET(menu)); |
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 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6586 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6587 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6588 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6589 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6590 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6591 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6592 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6593 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6594 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6595 G_CALLBACK(close_tab_cb), menu); |
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 gaim_separator(menu); |
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 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6600 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6601 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6602 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6603 G_CALLBACK(close_others_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6604 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6605 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6606 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6607 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6608 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6609 G_CALLBACK(close_window), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6610 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6611 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6612 } |
11581 | 6613 |
6614 static void | |
6615 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6616 gpointer user_data) | |
6617 { | |
6618 GaimGtkWindow *win; | |
6619 GaimConversation *conv; | |
6620 GaimGtkConversation *gtkconv; | |
6621 | |
6622 win = user_data; | |
6623 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6624 conv = gtkconv->active_conv; | |
6625 | |
6626 g_return_if_fail(conv != NULL); | |
6627 | |
6628 /* | |
6629 * Only set "unseen" to "none" if the window has focus | |
6630 */ | |
6631 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6632 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6633 |
6634 /* Update the menubar */ | |
6635 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6636 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
|
6637 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6638 |
11594 | 6639 generate_send_to_items(win); |
6640 | |
11604 | 6641 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6642 |
6643 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6644 gtkconv->make_sound); | |
6645 | |
6646 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6647 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6648 | |
6649 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 6650 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 6651 |
6652 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6653 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6654 gtkconv->u.im->show_icon); | |
11604 | 6655 |
11581 | 6656 /* |
6657 * We pause icons when they are not visible. If this icon should | |
6658 * be animated then start it back up again. | |
6659 */ | |
6660 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6661 (gtkconv->u.im->animate)) | |
6662 start_anim(NULL, gtkconv); | |
6663 } | |
6664 | |
6665 /************************************************************************** | |
6666 * GTK+ window ops | |
6667 **************************************************************************/ | |
6668 | |
6669 GList * | |
6670 gaim_gtk_conv_windows_get_list() | |
6671 { | |
6672 return window_list; | |
6673 } | |
6674 | |
6675 GaimGtkWindow * | |
6676 gaim_gtk_conv_window_new() | |
6677 { | |
6678 GaimGtkWindow *win; | |
6679 GtkPositionType pos; | |
6680 GtkWidget *testidea; | |
6681 GtkWidget *menubar; | |
6682 | |
6683 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6684 | |
6685 window_list = g_list_append(window_list, win); | |
6686 | |
6687 /* Create the window. */ | |
6688 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6689 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6690 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6691 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6692 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6693 | |
6694 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6695 G_CALLBACK(close_win_cb), win); | |
6696 | |
6697 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6698 G_CALLBACK(focus_win_cb), win); | |
6699 | |
6700 /* Create the notebook. */ | |
6701 win->notebook = gtk_notebook_new(); | |
6702 | |
6703 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6704 | |
6705 #if 0 | |
6706 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6707 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6708 #endif | |
6709 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6710 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6711 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6712 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6713 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6714 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6715 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6716 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6717 |
11581 | 6718 gtk_widget_show(win->notebook); |
6719 | |
6720 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6721 G_CALLBACK(before_switch_conv_cb), win); | |
6722 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6723 G_CALLBACK(switch_conv_cb), win); | |
6724 | |
6725 /* Setup the tab drag and drop signals. */ | |
6726 gtk_widget_add_events(win->notebook, | |
6727 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6728 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6729 G_CALLBACK(notebook_press_cb), win); | |
6730 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6731 G_CALLBACK(notebook_release_cb), win); | |
6732 | |
6733 testidea = gtk_vbox_new(FALSE, 0); | |
6734 | |
6735 /* Setup the menubar. */ | |
6736 menubar = setup_menubar(win); | |
6737 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6738 | |
6739 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6740 | |
6741 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6742 | |
6743 gtk_widget_show(testidea); | |
6744 | |
6745 return win; | |
6746 } | |
6747 | |
6748 void | |
6749 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6750 { | |
6751 window_list = g_list_remove(window_list, win); | |
6752 | |
11611 | 6753 if (win->gtkconvs) { |
6754 while (win->gtkconvs) { | |
6755 GList *nextgtk = win->gtkconvs->next; | |
6756 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6757 GList *nextcore = gtkconv->convs->next; | |
6758 GaimConversation *conv = gtkconv->convs->data; | |
6759 gaim_conversation_destroy(conv); | |
6760 if (!nextgtk && !nextcore) | |
6761 /* we'll end up invoking ourselves when we destroy our last child */ | |
6762 /* so don't destroy ourselves right now */ | |
6763 return; | |
6764 } | |
6765 return; | |
6766 } | |
11581 | 6767 gtk_widget_destroy(win->window); |
6768 | |
6769 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6770 | |
6771 g_free(win); | |
6772 } | |
6773 | |
6774 void | |
6775 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6776 { | |
6777 gtk_widget_show(win->window); | |
6778 } | |
6779 | |
6780 void | |
6781 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6782 { | |
6783 gtk_widget_hide(win->window); | |
6784 } | |
6785 | |
6786 void | |
6787 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6788 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6789 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6790 } |
6791 | |
6792 void | |
6793 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6794 { | |
6795 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6796 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6797 gtkconv->tab_cont)); | |
6798 } | |
6799 | |
6800 void | |
6801 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6802 { | |
6803 GaimConversation *conv = gtkconv->active_conv; | |
6804 GaimGtkConversation *focus_gtkconv; | |
6805 GtkWidget *tabby, *menu_tabby; | |
6806 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6807 GtkWidget *close_image; | |
6808 GaimConversationType conv_type; | |
6809 const char *name; | |
6810 const gchar *tmp_lab; | |
6811 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6812 gboolean tabs_side = FALSE; |
6813 gint angle = 0; | |
11581 | 6814 |
6815 name = gaim_conversation_get_name(conv); | |
6816 conv_type = gaim_conversation_get_type(conv); | |
6817 | |
6818 | |
6819 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6820 gtkconv->win = win; | |
6821 | |
11619 | 6822 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6823 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6824 tabs_side = TRUE; | |
6825 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6826 angle = 90; | |
6827 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6828 angle = 270; | |
6829 | |
6830 if (angle) | |
6831 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6832 else | |
6833 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6834 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6835 | |
6836 /* Close button. */ | |
6837 gtkconv->close = gtk_button_new(); | |
6838 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6839 if (gtk_check_version(2, 4, 2) == NULL) { | |
6840 /* Need to account for extra padding around the gtkbutton */ | |
6841 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6842 "focus-line-width", &focus_width, | |
6843 "focus-padding", &focus_pad, | |
6844 NULL); | |
6845 close_button_width += (focus_width + focus_pad) * 2; | |
6846 close_button_height += (focus_width + focus_pad) * 2; | |
6847 } | |
6848 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6849 close_button_width, close_button_height); | |
6850 | |
6851 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6852 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6853 gtk_widget_show(close_image); | |
6854 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6855 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6856 _("Close conversation"), NULL); | |
6857 | |
6858 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6859 G_CALLBACK(close_conv_cb), gtkconv); | |
6860 | |
11851 | 6861 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6862 /* |
6863 * I love Galeon. They have a fix for that stupid annoying visible | |
6864 * border bug. I love you guys! -- ChipX86 | |
6865 */ | |
11851 | 6866 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6867 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6868 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6869 #endif |
11581 | 6870 |
6871 /* Status icon. */ | |
6872 gtkconv->icon = gtk_image_new(); | |
6873 gtkconv->menu_icon = gtk_image_new(); | |
6874 update_tab_icon(conv); | |
6875 | |
6876 /* Tab label. */ | |
6877 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6878 |
11581 | 6879 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6880 if (!angle) |
6881 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6882 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6883 if (tabs_side) { |
6884 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6885 } | |
6886 if (angle) | |
6887 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6888 #endif |
6889 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6890 #if 0 | |
6891 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6892 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6893 #endif | |
6894 | |
6895 /* Pack it all together. */ | |
11619 | 6896 if (angle == 90) |
6897 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6898 else | |
6899 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6900 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6901 FALSE, FALSE, 0); | |
6902 | |
6903 gtk_widget_show_all(gtkconv->icon); | |
6904 gtk_widget_show_all(gtkconv->menu_icon); | |
6905 | |
6906 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6907 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6908 gtk_widget_show(gtkconv->tab_label); | |
6909 gtk_widget_show(gtkconv->menu_label); | |
6910 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6911 | |
11619 | 6912 if (angle == 90) |
6913 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6914 else | |
6915 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6916 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6917 gtk_widget_show(gtkconv->close); | |
6918 | |
6919 gtk_widget_show(tabby); | |
6920 gtk_widget_show(menu_tabby); | |
6921 | |
6922 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6923 gaim_gtkconv_update_buddy_icon(conv); | |
6924 | |
6925 /* Add this pane to the conversation's notebook. */ | |
6926 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6927 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6928 |
6929 | |
6930 gtk_widget_show(tab_cont); | |
6931 | |
6932 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6933 /* Er, bug in notebooks? Switch to the page manually. */ | |
6934 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6935 | |
6936 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6937 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6938 } else | |
6939 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6940 | |
6941 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6942 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6943 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6944 | |
6945 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6946 update_send_to_selection(win); |
11581 | 6947 } |
6948 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6949 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6950 private_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv, gboolean destroy_empty) |
11581 | 6951 { |
6952 unsigned int index; | |
6953 GaimConversationType conv_type; | |
6954 | |
6955 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6956 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6957 | |
6958 g_object_ref(gtkconv->tab_cont); | |
6959 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6960 | |
6961 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6962 | |
6963 /* go back to tabless if need be */ | |
6964 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6965 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6966 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6967 } | |
6968 | |
6969 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6970 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6971 if (destroy_empty && !win->gtkconvs) |
11582 | 6972 gaim_gtk_conv_window_destroy(win); |
11581 | 6973 } |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6974 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6975 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6976 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6977 private_remove_gtkconv(win, gtkconv, TRUE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6978 } |
11581 | 6979 |
6980 GaimGtkConversation * | |
6981 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
6982 { | |
6983 GtkWidget *tab_cont; | |
6984 | |
6985 if (index == -1) | |
6986 index = 0; | |
6987 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 6988 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 6989 } |
6990 | |
6991 GaimGtkConversation * | |
6992 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
6993 { | |
6994 int index; | |
6995 GtkWidget *tab_cont; | |
6996 | |
6997 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
6998 if (index == -1) | |
6999 index = 0; | |
7000 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7001 if (!tab_cont) | |
7002 return NULL; | |
7003 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7004 } | |
7005 | |
7006 | |
7007 GaimConversation * | |
7008 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7009 { | |
7010 GaimGtkConversation *gtkconv; | |
7011 | |
7012 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7013 return gtkconv ? gtkconv->active_conv : NULL; | |
7014 } | |
7015 | |
7016 gboolean | |
7017 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7018 { | |
7019 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7020 } | |
7021 | |
7022 gboolean | |
7023 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7024 { | |
7025 gboolean has_focus = FALSE; | |
7026 | |
7027 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7028 | |
7029 return has_focus; | |
7030 } | |
7031 | |
7032 GaimGtkWindow * | |
7033 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7034 { | |
7035 GaimGtkWindow *win; | |
7036 GdkWindow *gdkwin; | |
7037 GList *l; | |
7038 | |
7039 gdkwin = gdk_window_at_pointer(&x, &y); | |
7040 | |
7041 if (gdkwin) | |
7042 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7043 | |
7044 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7045 win = l->data; | |
7046 | |
7047 if (gdkwin == win->window->window) | |
7048 return win; | |
7049 } | |
7050 | |
7051 return NULL; | |
7052 } | |
7053 | |
7054 GList * | |
7055 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7056 { | |
7057 return win->gtkconvs; | |
7058 } | |
7059 | |
7060 guint | |
7061 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7062 { | |
7063 return g_list_length(win->gtkconvs); | |
7064 } | |
7065 | |
7066 GaimGtkWindow * | |
7067 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7068 { | |
7069 GList *wins, *convs; | |
7070 GaimGtkWindow *win; | |
7071 GaimGtkConversation *conv; | |
7072 | |
7073 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7074 return NULL; | |
7075 | |
7076 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7077 win = wins->data; | |
7078 | |
7079 for (convs = win->gtkconvs; | |
7080 convs != NULL; | |
7081 convs = convs->next) { | |
7082 | |
7083 conv = convs->data; | |
7084 | |
7085 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7086 return win; | |
7087 } | |
7088 } | |
7089 | |
7090 return NULL; | |
7091 } | |
7092 | |
7093 GaimGtkWindow * | |
7094 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7095 { | |
7096 GList *wins, *convs; | |
7097 GaimGtkWindow *win; | |
7098 GaimGtkConversation *conv; | |
7099 | |
7100 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7101 return NULL; | |
7102 | |
7103 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7104 wins != NULL; | |
7105 wins = wins->prev) { | |
7106 | |
7107 win = wins->data; | |
7108 | |
7109 for (convs = win->gtkconvs; | |
7110 convs != NULL; | |
7111 convs = convs->next) { | |
7112 | |
7113 conv = convs->data; | |
7114 | |
7115 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7116 return win; | |
7117 } | |
7118 } | |
7119 | |
7120 return NULL; | |
7121 } | |
7122 | |
7123 | |
7124 /************************************************************************** | |
7125 * Conversation placement functions | |
7126 **************************************************************************/ | |
7127 typedef struct | |
7128 { | |
7129 char *id; | |
7130 char *name; | |
7131 GaimConvPlacementFunc fnc; | |
7132 | |
7133 } ConvPlacementData; | |
7134 | |
7135 static GList *conv_placement_fncs = NULL; | |
7136 static GaimConvPlacementFunc place_conv = NULL; | |
7137 | |
7138 /* This one places conversations in the last made window. */ | |
7139 static void | |
7140 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7141 { | |
7142 GaimGtkWindow *win; | |
7143 | |
7144 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7145 win = l ? l->data : NULL;; | |
7146 | |
7147 if (win == NULL) { | |
7148 win = gaim_gtk_conv_window_new(); | |
7149 | |
7150 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7151 gaim_gtk_conv_window_show(win); | |
7152 } else { | |
7153 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7154 } | |
7155 } | |
7156 | |
7157 /* This one places conversations in the last made window of the same type. */ | |
7158 static void | |
7159 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7160 { | |
7161 GaimGtkWindow *win; | |
7162 | |
7163 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7164 | |
7165 if (win == NULL) { | |
7166 win = gaim_gtk_conv_window_new(); | |
7167 | |
7168 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7169 gaim_gtk_conv_window_show(win); | |
7170 } else | |
7171 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7172 } | |
7173 | |
7174 /* This one places each conversation in its own window. */ | |
7175 static void | |
7176 conv_placement_new_window(GaimGtkConversation *conv) | |
7177 { | |
7178 GaimGtkWindow *win; | |
7179 | |
7180 win = gaim_gtk_conv_window_new(); | |
7181 | |
7182 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7183 | |
7184 gaim_gtk_conv_window_show(win); | |
7185 } | |
7186 | |
7187 static GaimGroup * | |
7188 conv_get_group(GaimGtkConversation *conv) | |
7189 { | |
7190 GaimGroup *group = NULL; | |
7191 | |
7192 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7193 GaimBuddy *buddy; | |
7194 | |
7195 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7196 gaim_conversation_get_name(conv->active_conv)); | |
7197 | |
7198 if (buddy != NULL) | |
12088 | 7199 group = gaim_buddy_get_group(buddy); |
11581 | 7200 |
7201 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7202 GaimChat *chat; | |
7203 | |
7204 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7205 gaim_conversation_get_name(conv->active_conv)); | |
7206 | |
7207 if (chat != NULL) | |
7208 group = gaim_chat_get_group(chat); | |
7209 } | |
7210 | |
7211 return group; | |
7212 } | |
7213 | |
7214 /* | |
7215 * This groups things by, well, group. Buddies from groups will always be | |
7216 * grouped together, and a buddy from a group not belonging to any currently | |
7217 * open windows will get a new window. | |
7218 */ | |
7219 static void | |
7220 conv_placement_by_group(GaimGtkConversation *conv) | |
7221 { | |
7222 GaimConversationType type; | |
7223 GaimGroup *group = NULL; | |
7224 GList *wl, *cl; | |
7225 | |
7226 type = gaim_conversation_get_type(conv->active_conv); | |
7227 | |
7228 group = conv_get_group(conv); | |
7229 | |
7230 /* Go through the list of IMs and find one with this group. */ | |
7231 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7232 GaimGtkWindow *win2; | |
7233 GaimGtkConversation *conv2; | |
7234 GaimGroup *group2 = NULL; | |
7235 | |
7236 win2 = wl->data; | |
7237 | |
7238 for (cl = win2->gtkconvs; | |
7239 cl != NULL; | |
7240 cl = cl->next) { | |
7241 conv2 = cl->data; | |
7242 | |
7243 group2 = conv_get_group(conv2); | |
7244 | |
7245 if (group == group2) { | |
7246 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7247 | |
7248 return; | |
7249 } | |
7250 } | |
7251 } | |
7252 | |
7253 /* Make a new window. */ | |
7254 conv_placement_new_window(conv); | |
7255 } | |
7256 | |
7257 /* This groups things by account. Otherwise, the same semantics as above */ | |
7258 static void | |
7259 conv_placement_by_account(GaimGtkConversation *conv) | |
7260 { | |
7261 GaimConversationType type; | |
7262 GList *wins, *convs; | |
7263 GaimAccount *account; | |
7264 | |
7265 account = gaim_conversation_get_account(conv->active_conv); | |
7266 type = gaim_conversation_get_type(conv->active_conv); | |
7267 | |
7268 /* Go through the list of IMs and find one with this group. */ | |
7269 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7270 GaimGtkWindow *win2; | |
7271 GaimGtkConversation *conv2; | |
7272 | |
7273 win2 = wins->data; | |
7274 | |
7275 for (convs = win2->gtkconvs; | |
7276 convs != NULL; | |
7277 convs = convs->next) { | |
7278 conv2 = convs->data; | |
7279 | |
7280 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7281 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7282 return; | |
7283 } | |
7284 } | |
7285 } | |
7286 | |
7287 /* Make a new window. */ | |
7288 conv_placement_new_window(conv); | |
7289 } | |
7290 | |
7291 static ConvPlacementData * | |
7292 get_conv_placement_data(const char *id) | |
7293 { | |
7294 ConvPlacementData *data = NULL; | |
7295 GList *n; | |
7296 | |
7297 for (n = conv_placement_fncs; n; n = n->next) { | |
7298 data = n->data; | |
7299 if (!strcmp(data->id, id)) | |
7300 return data; | |
7301 } | |
7302 | |
7303 return NULL; | |
7304 } | |
7305 | |
7306 static void | |
7307 add_conv_placement_fnc(const char *id, const char *name, | |
7308 GaimConvPlacementFunc fnc) | |
7309 { | |
7310 ConvPlacementData *data; | |
7311 | |
7312 data = g_new(ConvPlacementData, 1); | |
7313 | |
7314 data->id = g_strdup(id); | |
7315 data->name = g_strdup(name); | |
7316 data->fnc = fnc; | |
7317 | |
7318 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7319 } | |
7320 | |
7321 static void | |
7322 ensure_default_funcs(void) | |
7323 { | |
7324 if (conv_placement_fncs == NULL) { | |
7325 add_conv_placement_fnc("last", _("Last created window"), | |
7326 conv_placement_last_created_win); | |
7327 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7328 conv_placement_last_created_win_type); | |
7329 add_conv_placement_fnc("new", _("New window"), | |
7330 conv_placement_new_window); | |
7331 add_conv_placement_fnc("group", _("By group"), | |
7332 conv_placement_by_group); | |
7333 add_conv_placement_fnc("account", _("By account"), | |
7334 conv_placement_by_account); | |
7335 } | |
7336 } | |
7337 | |
7338 GList * | |
7339 gaim_gtkconv_placement_get_options(void) | |
7340 { | |
7341 GList *n, *list = NULL; | |
7342 ConvPlacementData *data; | |
7343 | |
7344 ensure_default_funcs(); | |
7345 | |
7346 for (n = conv_placement_fncs; n; n = n->next) { | |
7347 data = n->data; | |
7348 list = g_list_append(list, data->name); | |
7349 list = g_list_append(list, data->id); | |
7350 } | |
7351 | |
7352 return list; | |
7353 } | |
7354 | |
7355 | |
7356 void | |
7357 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7358 GaimConvPlacementFunc fnc) | |
7359 { | |
7360 g_return_if_fail(id != NULL); | |
7361 g_return_if_fail(name != NULL); | |
7362 g_return_if_fail(fnc != NULL); | |
7363 | |
7364 ensure_default_funcs(); | |
7365 | |
7366 add_conv_placement_fnc(id, name, fnc); | |
7367 } | |
7368 | |
7369 void | |
7370 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7371 { | |
7372 ConvPlacementData *data = get_conv_placement_data(id); | |
7373 | |
7374 if (data == NULL) | |
7375 return; | |
7376 | |
7377 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7378 | |
7379 g_free(data->id); | |
7380 g_free(data->name); | |
7381 g_free(data); | |
7382 } | |
7383 | |
7384 const char * | |
7385 gaim_gtkconv_placement_get_name(const char *id) | |
7386 { | |
7387 ConvPlacementData *data; | |
7388 | |
7389 ensure_default_funcs(); | |
7390 | |
7391 data = get_conv_placement_data(id); | |
7392 | |
7393 if (data == NULL) | |
7394 return NULL; | |
7395 | |
7396 return data->name; | |
7397 } | |
7398 | |
7399 GaimConvPlacementFunc | |
7400 gaim_gtkconv_placement_get_fnc(const char *id) | |
7401 { | |
7402 ConvPlacementData *data; | |
7403 | |
7404 ensure_default_funcs(); | |
7405 | |
7406 data = get_conv_placement_data(id); | |
7407 | |
7408 if (data == NULL) | |
7409 return NULL; | |
7410 | |
7411 return data->fnc; | |
7412 } | |
7413 | |
7414 void | |
7415 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7416 { | |
7417 g_return_if_fail(func != NULL); | |
7418 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7419 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7420 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7421 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7422 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7423 place_conv = NULL; |
11581 | 7424 } |
7425 | |
7426 GaimConvPlacementFunc | |
7427 gaim_gtkconv_placement_get_current_func(void) | |
7428 { | |
7429 return place_conv; | |
7430 } | |
7431 | |
7432 void | |
7433 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7434 { | |
7435 if (place_conv) | |
7436 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7437 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7438 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7439 } |
12239 | 7440 |
7441 gboolean | |
7442 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
7443 { | |
7444 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
7445 | |
7446 return (gtkconv->win == hidden_convwin); | |
7447 } |