Mercurial > pidgin
annotate src/gtkconv.c @ 12175:a655bdeb561d
[gaim-migrate @ 14477]
SF Patch #1360582 from Casey Harkins (charkins)
"This patch adds an unseen_count field to gtkconvs which
obviously counts the number of unseen messages. It is
handled entirely within ...set_unseen() in gtkconv.c.
The code for filling the gtkblist menutray context menu
with unseen conversations is moved into gtkconv.c
because it will also be used by the docklet (avoiding
code duplication). I documented it in ChangeLog.API.
The context menu items and the tooltips faceprint added
now will show the message count as well."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 21 Nov 2005 00:43:20 +0000 |
parents | ffdd2ccf3a53 |
children | 762bb28154bf |
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 |
11731 | 70 #define SEND_COLOR "#001f41" |
71 #define RECV_COLOR "#a63802" | |
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; |
8448 | 493 char *buf, *clean; |
4359 | 494 |
8655 | 495 account = gaim_conversation_get_account(conv); |
9130 | 496 |
9471 | 497 if (!gaim_account_is_connected(account)) |
498 return; | |
499 | |
11338 | 500 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 501 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 502 return; |
503 | |
9832 | 504 if (check_for_and_do_command(conv)) { |
505 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
506 return; | |
9130 | 507 } |
508 | |
8442 | 509 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 510 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 511 |
4359 | 512 gtk_widget_grab_focus(gtkconv->entry); |
513 | |
8448 | 514 if (strlen(clean) == 0) { |
515 g_free(clean); | |
4359 | 516 return; |
517 } | |
518 | |
8677 | 519 gc = gaim_account_get_connection(account); |
10665 | 520 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 521 char **bufs; |
522 int i; | |
523 | |
524 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
525 for (i = 0; bufs[i]; i++) { | |
9374 | 526 send_history_add(conv, bufs[i]); |
11338 | 527 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 528 gaim_conv_im_send(GAIM_CONV_IM(conv), bufs[i]); |
11338 | 529 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 530 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), bufs[i]); |
531 } | |
532 | |
533 g_strfreev(bufs); | |
534 | |
535 } else { | |
9374 | 536 send_history_add(conv, buf); |
11338 | 537 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 538 gaim_conv_im_send(GAIM_CONV_IM(conv), buf); |
11338 | 539 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 540 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), buf); |
541 } | |
4359 | 542 |
8677 | 543 g_free(clean); |
4359 | 544 g_free(buf); |
545 | |
8061 | 546 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 547 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 548 } |
549 | |
550 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
551 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 552 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
553 GaimAccount *account; |
4359 | 554 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
555 GaimConversation *conv = gtkconv->active_conv; |
4359 | 556 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
557 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
558 name = gaim_conversation_get_name(conv); |
7879 | 559 |
11338 | 560 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 561 GaimBuddy *b; |
562 | |
563 b = gaim_find_buddy(account, name); | |
564 if (b != NULL) | |
9730 | 565 gaim_gtkdialogs_remove_buddy(b); |
7859 | 566 else if (account != NULL && gaim_account_is_connected(account)) |
567 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 568 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 569 GaimChat *c; |
570 | |
571 c = gaim_blist_find_chat(account, name); | |
572 if (c != NULL) | |
9730 | 573 gaim_gtkdialogs_remove_chat(c); |
7859 | 574 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 575 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 576 } |
4359 | 577 |
578 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
579 } | |
580 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
581 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 582 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
583 GaimConversation *conv = gtkconv->active_conv; |
7975 | 584 GaimPluginProtocolInfo *prpl_info = NULL; |
585 GaimConnection *gc; | |
586 | |
587 if ((gc = gaim_conversation_get_gc(conv))) { | |
588 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
589 | |
590 /* | |
591 * If there are special needs for getting info on users in | |
592 * buddy chat "rooms"... | |
593 */ | |
594 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
595 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
596 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
597 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
598 } |
7975 | 599 else |
600 prpl_info->get_info(gc, who); | |
601 } | |
602 } | |
603 | |
604 | |
4359 | 605 static void |
10810 | 606 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 607 { |
10810 | 608 GaimConversation *conv = gtkconv->active_conv; |
4359 | 609 |
11338 | 610 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 611 serv_get_info(gaim_conversation_get_gc(conv), |
612 gaim_conversation_get_name(conv)); | |
613 | |
614 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 615 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 616 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
617 GaimGtkChatPane *gtkchat; |
4359 | 618 GtkTreeIter iter; |
619 GtkTreeModel *model; | |
620 GtkTreeSelection *sel; | |
9554 | 621 char *name; |
4359 | 622 |
623 gtkchat = gtkconv->u.chat; | |
624 | |
625 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
626 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
627 | |
628 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 629 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 630 else |
631 return; | |
632 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
633 chat_do_info(gtkconv, name); |
9554 | 634 g_free(name); |
4359 | 635 } |
636 } | |
637 | |
638 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
639 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 640 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
641 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
642 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
643 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
644 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
645 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
646 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
647 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 648 |
649 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
650 } | |
651 | |
652 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
653 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 654 { |
655 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
656 GaimGtkConversation *gtkconv; |
4359 | 657 |
658 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
659 | |
660 if (resp == GTK_RESPONSE_OK) { | |
661 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
662 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
663 | |
10113 | 664 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 665 return; |
666 | |
667 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
668 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 669 message, buddy); |
670 } | |
671 | |
672 gtk_widget_destroy(invite_dialog); | |
673 invite_dialog = NULL; | |
674 | |
675 g_free(info); | |
676 } | |
677 | |
678 static void | |
9909 | 679 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
680 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
681 { | |
682 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
683 const char *convprotocol; | |
684 | |
685 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
686 | |
687 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
688 { | |
689 GaimBlistNode *node = NULL; | |
690 GaimBuddy *buddy; | |
691 | |
692 memcpy(&node, sd->data, sizeof(node)); | |
693 | |
694 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
695 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
696 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
697 buddy = (GaimBuddy *)node; | |
698 else | |
699 return; | |
700 | |
701 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
702 { | |
703 gaim_notify_error(NULL, NULL, | |
704 _("That buddy is not on the same protocol as this " | |
10843 | 705 "chat."), NULL); |
9909 | 706 } |
707 else | |
708 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
709 | |
710 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
711 } | |
712 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
713 { | |
714 char *protocol = NULL; | |
715 char *username = NULL; | |
716 GaimAccount *account; | |
717 | |
11137 | 718 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 719 &protocol, &username, NULL)) |
720 { | |
721 if (account == NULL) | |
722 { | |
723 gaim_notify_error(NULL, NULL, | |
724 _("You are not currently signed on with an account that " | |
725 "can invite that buddy."), NULL); | |
726 } | |
727 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
728 { | |
729 gaim_notify_error(NULL, NULL, | |
730 _("That buddy is not on the same protocol as this " | |
10843 | 731 "chat."), NULL); |
9909 | 732 } |
733 else | |
734 { | |
735 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
736 } | |
737 } | |
738 | |
739 if (username != NULL) g_free(username); | |
740 if (protocol != NULL) g_free(protocol); | |
741 | |
742 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
743 } | |
744 } | |
745 | |
746 static const GtkTargetEntry dnd_targets[] = | |
747 { | |
748 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
749 {"application/x-im-contact", 0, 1} | |
750 }; | |
751 | |
752 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
753 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 754 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
755 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
756 InviteBuddyInfo *info = NULL; |
4359 | 757 |
758 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
759 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
760 GaimGtkWindow *gtkwin; |
4359 | 761 GtkWidget *label; |
762 GtkWidget *vbox, *hbox; | |
763 GtkWidget *table; | |
764 GtkWidget *img; | |
765 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
766 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 767 GTK_ICON_SIZE_DIALOG); |
4359 | 768 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
769 info = g_new0(InviteBuddyInfo, 1); |
4359 | 770 info->conv = conv; |
771 | |
11581 | 772 gc = gaim_conversation_get_gc(conv); |
773 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 774 |
775 /* Create the new dialog. */ | |
776 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 777 _("Invite Buddy Into Chat Room"), |
7879 | 778 GTK_WINDOW(gtkwin->window), 0, |
779 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
780 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 781 |
782 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 783 GTK_RESPONSE_OK); |
11243 | 784 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 785 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
786 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
787 | |
9909 | 788 info->window = GTK_WIDGET(invite_dialog); |
789 | |
4359 | 790 /* Setup the outside spacing. */ |
791 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
792 | |
11243 | 793 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
794 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 795 |
796 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 797 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 798 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
799 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
800 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
801 | |
802 /* Setup the right vbox. */ | |
803 vbox = gtk_vbox_new(FALSE, 0); | |
804 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
805 | |
806 /* Put our happy label in it. */ | |
807 label = gtk_label_new(_("Please enter the name of the user you wish " | |
808 "to invite, along with an optional invite " | |
809 "message.")); | |
810 gtk_widget_set_size_request(label, 350, -1); | |
811 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
812 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
813 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
814 | |
815 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 816 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 817 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
818 | |
819 /* Setup the table we're going to use to lay stuff out. */ | |
820 table = gtk_table_new(2, 2, FALSE); | |
11243 | 821 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
822 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
823 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 824 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
825 | |
826 /* Now the Buddy label */ | |
827 label = gtk_label_new(NULL); | |
828 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
829 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
830 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
831 | |
832 /* Now the Buddy drop-down entry field. */ | |
833 info->entry = gtk_combo_new(); | |
834 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
835 gtk_entry_set_activates_default( | |
836 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
837 | |
838 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
839 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
840 | |
841 /* Fill in the names. */ | |
842 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
843 generate_invite_user_names(gc)); | |
844 | |
845 | |
846 /* Now the label for "Message" */ | |
847 label = gtk_label_new(NULL); | |
848 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
849 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
850 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
851 | |
852 | |
853 /* And finally, the Message entry field. */ | |
854 info->message = gtk_entry_new(); | |
855 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
856 | |
857 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
858 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
859 | |
860 /* Connect the signals. */ | |
861 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
862 G_CALLBACK(do_invite), info); | |
9909 | 863 /* Setup drag-and-drop */ |
864 gtk_drag_dest_set(info->window, | |
865 GTK_DEST_DEFAULT_MOTION | | |
866 GTK_DEST_DEFAULT_DROP, | |
867 dnd_targets, | |
868 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
869 GDK_ACTION_COPY); | |
870 gtk_drag_dest_set(info->entry, | |
871 GTK_DEST_DEFAULT_MOTION | | |
872 GTK_DEST_DEFAULT_DROP, | |
873 dnd_targets, | |
874 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
875 GDK_ACTION_COPY); | |
876 | |
877 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
878 G_CALLBACK(invite_dnd_recv), info); | |
879 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
880 G_CALLBACK(invite_dnd_recv), info); | |
881 | |
4359 | 882 } |
883 | |
884 gtk_widget_show_all(invite_dialog); | |
885 | |
886 if (info != NULL) | |
887 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
888 } | |
889 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
890 static void |
7748 | 891 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
892 { | |
9714 | 893 gaim_gtkdialogs_im(); |
7748 | 894 } |
895 | |
896 static void | |
9504 | 897 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 898 { |
9504 | 899 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 900 FILE *fp; |
901 const char *name; | |
10849 | 902 gchar *text; |
9489 | 903 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
904 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 905 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 906 return; |
907 } | |
908 | |
909 name = gaim_conversation_get_name(conv); | |
10849 | 910 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 911 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 912 |
913 text = gtk_imhtml_get_markup( | |
914 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
915 fprintf(fp, "%s", text); | |
916 g_free(text); | |
917 | |
918 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 919 fclose(fp); |
920 } | |
921 | |
10849 | 922 /* |
923 * It would be kinda cool if this gave the option of saving a | |
924 * plaintext v. HTML file. | |
925 */ | |
9489 | 926 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
927 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
928 { |
11581 | 929 GaimGtkWindow *win = data; |
930 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 931 gchar *buf; |
932 | |
933 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 934 |
10849 | 935 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
936 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 937 |
938 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
939 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
940 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
941 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
942 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
943 { |
11581 | 944 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
945 GaimConversation *conv; |
9917 | 946 GaimLogType type; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
947 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
948 GaimAccount *account; |
10845 | 949 GSList *buddies, *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
950 |
11581 | 951 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
952 |
11338 | 953 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 954 type = GAIM_LOG_IM; |
11338 | 955 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 956 type = GAIM_LOG_CHAT; |
957 else | |
958 return; | |
959 | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
960 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
961 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
962 |
10845 | 963 buddies = gaim_find_buddies(account, name); |
964 for (cur = buddies; cur != NULL; cur = cur->next) | |
965 { | |
966 GaimBlistNode *node = cur->data; | |
10846 | 967 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 968 { |
969 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
970 g_slist_free(buddies); | |
971 return; | |
972 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
973 } |
10845 | 974 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
975 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
976 gaim_gtk_log_show(type, name, account); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
977 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
978 |
8974 | 979 static void |
980 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
981 { | |
11581 | 982 GaimGtkWindow *win = data; |
8974 | 983 GaimConversation *conv; |
984 GaimGtkConversation *gtkconv; | |
985 | |
11581 | 986 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 987 gtkconv = GAIM_GTK_CONVERSATION(conv); |
988 | |
989 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
990 } | |
991 | |
7295 | 992 struct _search { |
993 GaimGtkConversation *gtkconv; | |
994 GtkWidget *entry; | |
995 }; | |
996 | |
7929 | 997 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 998 { |
7929 | 999 switch (resp) { |
1000 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1001 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1002 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1003 break; |
1004 | |
1005 case GTK_RESPONSE_DELETE_EVENT: | |
1006 case GTK_RESPONSE_CLOSE: | |
1007 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1008 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1009 s->gtkconv->dialogs.search = NULL; | |
1010 g_free(s); | |
1011 break; | |
1012 } | |
7295 | 1013 } |
1014 | |
1015 static void | |
7751 | 1016 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1017 { |
11581 | 1018 GaimGtkWindow *gtkwin = data; |
1019 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1020 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1021 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1022 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1023 GTK_ICON_SIZE_DIALOG); |
7929 | 1024 GtkWidget *label; |
7295 | 1025 struct _search *s; |
1026 | |
7798 | 1027 if (gtkconv->dialogs.search) { |
1028 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1029 return; |
7798 | 1030 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1031 |
7295 | 1032 s = g_malloc(sizeof(struct _search)); |
1033 s->gtkconv = gtkconv; | |
7929 | 1034 |
1035 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1036 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1037 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1038 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1039 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1040 GTK_RESPONSE_OK); |
7929 | 1041 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1042 G_CALLBACK(do_search_cb), s); | |
1043 | |
11243 | 1044 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1045 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1046 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1047 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
|
1048 gtk_container_set_border_width( |
11243 | 1049 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1050 | |
1051 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1052 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1053 hbox); |
7929 | 1054 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1055 | |
1056 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1057 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1058 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1059 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1060 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1061 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1062 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1063 | |
1064 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1065 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1066 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1067 g_signal_connect(G_OBJECT(s->entry), "changed", |
1068 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1069 gtkconv->dialogs.search); | |
1070 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
|
1071 |
7295 | 1072 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1073 gtk_widget_grab_focus(s->entry); |
7295 | 1074 } |
1075 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1076 static void |
9468 | 1077 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1078 { | |
11581 | 1079 GaimGtkWindow *win = data; |
1080 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1081 |
11338 | 1082 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1083 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1084 } | |
1085 | |
1086 } | |
1087 | |
1088 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1089 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1090 { |
11581 | 1091 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1092 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1093 |
11581 | 1094 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
|
1095 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1096 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1097 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1098 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1099 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1100 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1101 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1102 { |
11581 | 1103 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1104 GaimGtkConversation *gtkconv; |
8756 | 1105 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1106 |
11581 | 1107 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1108 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1109 | |
1110 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1111 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1112 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1113 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1114 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1115 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1116 { |
11581 | 1117 GaimGtkWindow *win = data; |
8756 | 1118 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1119 GaimGtkConversation *gtkconv; |
8756 | 1120 GtkIMHtmlToolbar *toolbar; |
1121 | |
11581 | 1122 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1123 conv = gtkconv->active_conv; | |
8756 | 1124 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1125 | |
1126 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1127 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1129 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1130 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1131 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1132 { |
11581 | 1133 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 GaimConversation *conv; |
7879 | 1135 GaimAccount *account; |
1136 const char *name; | |
1137 | |
11581 | 1138 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1139 account = gaim_conversation_get_account(conv); |
1140 name = gaim_conversation_get_name(conv); | |
1141 | |
11338 | 1142 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1143 GaimBuddy *b; |
1144 | |
1145 b = gaim_find_buddy(account, name); | |
1146 if (b != NULL) | |
9730 | 1147 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1148 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1149 GaimChat *c; |
1150 | |
1151 c = gaim_blist_find_chat(account, name); | |
1152 if (c != NULL) | |
9730 | 1153 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1154 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 { |
11581 | 1160 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 |
11581 | 1163 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 |
10810 | 1165 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1166 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1167 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1168 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1170 { |
11581 | 1171 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 |
11581 | 1174 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1175 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1176 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
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_block_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 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1187 block_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_add_remove_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 add_remove_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_close_conv_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; |
1205 | |
1206 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
|
1207 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1210 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 { |
11581 | 1212 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1214 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 |
11581 | 1216 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1221 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
|
1222 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1223 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1224 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1225 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1226 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1227 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1228 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1229 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1230 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1231 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1232 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1233 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1234 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1235 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1236 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1237 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1238 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1239 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1240 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1241 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1242 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1243 time(NULL)); |
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 /* 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
|
1246 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1247 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1248 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1249 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1250 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1251 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1252 { |
11581 | 1253 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1254 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1255 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1256 |
11581 | 1257 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1258 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1259 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1260 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1261 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1262 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1263 |
10377 | 1264 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1265 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
|
1266 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1267 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1268 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1269 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1270 { |
11581 | 1271 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1272 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1274 |
11581 | 1275 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1278 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1279 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1280 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1281 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1282 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1283 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1284 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1285 |
7961 | 1286 static void |
9188 | 1287 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1288 { | |
11581 | 1289 GaimGtkWindow *win = data; |
9188 | 1290 GaimConversation *conv; |
1291 GaimGtkConversation *gtkconv; | |
1292 | |
11581 | 1293 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1294 |
1295 if (!conv) | |
1296 return; | |
1297 | |
1298 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1299 | |
1300 gtkconv->show_timestamps = | |
1301 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
1302 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
1303 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); | |
1304 } | |
1305 | |
1306 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1307 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1309 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1310 GaimAccount *account; |
1311 GaimConnection *gc; | |
7961 | 1312 GaimPluginProtocolInfo *prpl_info = NULL; |
1313 char *real_who; | |
1314 | |
1315 account = gaim_conversation_get_account(conv); | |
10431 | 1316 g_return_if_fail(account != NULL); |
1317 | |
1318 gc = gaim_account_get_connection(account); | |
1319 g_return_if_fail(gc != NULL); | |
1320 | |
1321 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1322 | |
1323 if (prpl_info && prpl_info->get_cb_real_name) | |
1324 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1325 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1326 else | |
1327 real_who = g_strdup(who); | |
1328 | |
1329 if(!real_who) | |
1330 return; | |
1331 | |
10431 | 1332 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1333 |
1334 g_free(real_who); | |
1335 } | |
1336 | |
1337 static void | |
10810 | 1338 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1339 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1343 GtkTreeSelection *sel; |
9554 | 1344 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1345 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1346 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1347 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1348 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1349 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1350 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1351 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1352 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
|
1353 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1354 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1355 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1356 chat_do_im(gtkconv, name); |
9554 | 1357 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1358 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1359 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1360 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1361 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1363 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1364 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1365 GaimConvChat *chat; |
11869 | 1366 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1367 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 GtkTreeSelection *sel; |
10504 | 1370 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1371 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1373 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1374 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1376 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
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 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1380 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1381 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1382 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1383 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1384 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1390 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1391 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1393 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 |
11869 | 1395 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1396 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1397 g_free(alias); |
5908
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1401 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1402 { |
1403 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1404 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1405 chat_do_im(gtkconv, who); |
5908
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1409 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1410 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1411 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1412 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1413 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1414 | |
1415 serv_send_file(gc, who, NULL); | |
1416 } | |
1417 | |
1418 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1419 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1421 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1425 chat_do_info(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_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1430 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1431 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1433 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1434 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1435 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1436 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1437 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1438 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1439 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1441 |
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 * 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
|
1444 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1445 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1446 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1447 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1448 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1449 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1450 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1451 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1452 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1453 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1455 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1457 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1458 GaimAccount *account; |
6695 | 1459 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1462 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1463 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1464 b = gaim_find_buddy(account, name); |
5908
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 (b != NULL) |
9730 | 1467 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1468 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1469 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1470 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1471 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
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 |
8143 | 1474 static GtkWidget * |
10504 | 1475 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1476 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1477 { | |
1478 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1479 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1480 gboolean is_me = FALSE; |
8143 | 1481 GtkWidget *button; |
1482 | |
1483 /* | |
1484 * If a menu already exists, destroy it before creating a new one, | |
1485 * thus freeing-up the memory it occupied. | |
1486 */ | |
1487 if (menu) | |
1488 gtk_widget_destroy(menu); | |
1489 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1490 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1491 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1492 |
8143 | 1493 menu = gtk_menu_new(); |
1494 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1495 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1496 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1497 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
|
1498 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
|
1499 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1500 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1501 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1502 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1503 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1504 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1505 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
|
1506 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1507 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1508 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
|
1509 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
|
1510 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1511 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1512 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1513 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1514 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1515 } |
9498 | 1516 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1517 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1518 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
|
1519 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1520 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1521 } |
1522 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1523 if (prpl_info->get_cb_away) { |
10221 | 1524 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
|
1525 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1526 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1527 } |
1528 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1529 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1530 if (gaim_find_buddy(gc->account, who)) |
10221 | 1531 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
|
1532 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1533 else |
10221 | 1534 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
|
1535 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1536 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1537 } |
1538 | |
1539 return menu; | |
1540 } | |
1541 | |
1542 | |
1543 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1544 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1545 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1546 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1547 GaimPluginProtocolInfo *prpl_info = NULL; |
1548 GaimGtkChatPane *gtkchat; | |
1549 GaimConnection *gc; | |
1550 GaimAccount *account; | |
1551 GtkTreeSelection *sel; | |
1552 GtkTreeIter iter; | |
1553 GtkTreeModel *model; | |
1554 GtkWidget *menu; | |
1555 gchar *who; | |
1556 | |
1557 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1558 gtkchat = gtkconv->u.chat; | |
1559 account = gaim_conversation_get_account(conv); | |
1560 gc = account->gc; | |
1561 | |
1562 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1563 | |
1564 if (gc != NULL) | |
1565 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1566 | |
1567 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1568 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1569 return FALSE; | |
1570 | |
9498 | 1571 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1572 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1573 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1574 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1575 0, GDK_CURRENT_TIME); |
10504 | 1576 g_free(who); |
8143 | 1577 |
1578 return TRUE; | |
1579 } | |
1580 | |
1581 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1582 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1583 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1584 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1585 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1586 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1587 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1588 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1589 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1590 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1591 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1592 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1593 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1594 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1595 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1596 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1597 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1598 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1599 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1600 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1601 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1602 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1603 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1604 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
|
1605 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1606 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1607 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1608 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1609 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1610 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1611 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1612 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1613 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1614 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1615 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1616 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1617 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
|
1618 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1620 chat_do_im(gtkconv, who); |
7398 | 1621 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1622 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1623 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1624 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1625 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1626 |
10504 | 1627 g_free(who); |
1628 gtk_tree_path_free(path); | |
1629 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1630 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1631 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1632 |
8133 | 1633 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1634 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1635 { |
10827 | 1636 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1637 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1638 int index, i, total, found = 0; |
8133 | 1639 |
11581 | 1640 win = gtkconv->win; |
1641 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1642 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1643 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1644 /* 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
|
1645 for (i = forward ? index + 1 : index - 1; |
11581 | 1646 !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
|
1647 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1648 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1649 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1650 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1651 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1652 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1653 found = 1; |
8133 | 1654 } |
11252 | 1655 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1656 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1657 /* 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
|
1658 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1659 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1660 (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
|
1661 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1662 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1663 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1664 found = 1; |
8133 | 1665 } |
10827 | 1666 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1667 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1668 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1669 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1670 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1671 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1672 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1673 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1674 } |
11581 | 1675 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1676 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1677 } |
8133 | 1678 } |
1679 | |
10827 | 1680 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1681 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1682 } |
1683 | |
4359 | 1684 static gboolean |
8105 | 1685 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1686 { |
11581 | 1687 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1688 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1689 GaimGtkConversation *gtkconv; |
8105 | 1690 int curconv; |
1691 | |
10810 | 1692 gtkconv = (GaimGtkConversation *)data; |
10849 | 1693 conv = gtkconv->active_conv; |
11581 | 1694 win = gtkconv->win; |
1695 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1696 |
8105 | 1697 /* If CTRL was held down... */ |
1698 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1699 switch (event->keyval) { |
1700 case GDK_Up: | |
1701 if (!conv->send_history) | |
1702 break; | |
1703 | |
1704 if (!conv->send_history->prev) { | |
1705 GtkTextIter start, end; | |
1706 | |
1707 if (conv->send_history->data) | |
1708 g_free(conv->send_history->data); | |
1709 | |
1710 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1711 &start); | |
1712 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1713 | |
1714 conv->send_history->data = | |
8506 | 1715 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1716 } |
8677 | 1717 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1718 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1719 GObject *object; |
8677 | 1720 GtkTextIter iter; |
1721 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1722 |
1723 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1724 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1725 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1726 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1727 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
|
1728 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1729 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1730 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1731 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1732 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
|
1733 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1734 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1735 |
8061 | 1736 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1737 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1738 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1739 0, NULL); |
8677 | 1740 /* this is mainly just a hack so the formatting at the |
1741 * cursor gets picked up. */ | |
1742 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1743 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1744 } |
1745 | |
8105 | 1746 return TRUE; |
4359 | 1747 break; |
1748 | |
1749 case GDK_Down: | |
1750 if (!conv->send_history) | |
1751 break; | |
1752 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1753 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1754 GObject *object; |
8677 | 1755 GtkTextIter iter; |
1756 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1757 |
4359 | 1758 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1759 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1760 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1761 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1762 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
|
1763 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1764 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1765 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1766 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1767 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
|
1768 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1769 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1770 |
8105 | 1771 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1772 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1773 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1774 0, NULL); |
8677 | 1775 /* this is mainly just a hack so the formatting at the |
1776 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1777 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1778 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1779 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1780 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1781 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1782 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1783 } |
4359 | 1784 } |
1785 | |
8105 | 1786 return TRUE; |
4359 | 1787 break; |
8105 | 1788 |
8108 | 1789 case GDK_Page_Down: |
8143 | 1790 case ']': |
11581 | 1791 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1792 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1793 else |
11581 | 1794 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1795 return TRUE; |
1796 break; | |
1797 | |
8108 | 1798 case GDK_Page_Up: |
8143 | 1799 case '[': |
11581 | 1800 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1801 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1802 else |
11581 | 1803 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1804 return TRUE; |
1805 break; | |
1806 | |
8108 | 1807 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1808 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1809 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1810 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1811 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1812 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1813 } |
8108 | 1814 |
1815 return TRUE; | |
1816 break; | |
1817 | |
11252 | 1818 case GDK_comma: |
11581 | 1819 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1820 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1821 curconv - 1); |
1822 break; | |
1823 | |
1824 case GDK_period: | |
11581 | 1825 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1826 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1827 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1828 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1829 #else |
1830 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1831 #endif | |
11252 | 1832 break; |
1833 | |
8105 | 1834 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1835 } |
8758 | 1836 |
8105 | 1837 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1838 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1839 { |
10864 | 1840 if (event->keyval > '0' && event->keyval <= '9') |
1841 { | |
8105 | 1842 int switchto = event->keyval - '1'; |
11581 | 1843 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1844 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1845 |
1846 return TRUE; | |
1847 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1848 } |
8758 | 1849 |
8105 | 1850 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1851 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1852 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1853 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1854 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1855 case GDK_Tab: |
9605 | 1856 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1857 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1858 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1859 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1860 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1861 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1862 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1863 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1864 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1865 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1866 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1867 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1868 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1869 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1870 } |
4359 | 1871 return FALSE; |
1872 } | |
1873 | |
1874 /* | |
1875 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1876 * 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
|
1877 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1878 * 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
|
1879 * going all the way down to the notebook. I suspect a bug in |
4359 | 1880 * GtkTextView, but I'm not ready to point any fingers yet. |
1881 */ | |
1882 static gboolean | |
1883 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1884 { | |
1885 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1886 /* Right single click */ | |
1887 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1888 | |
1889 return TRUE; | |
1890 } | |
1891 | |
1892 return FALSE; | |
1893 } | |
1894 | |
8173 | 1895 /* |
1896 * If someone tries to type into the conversation backlog of a | |
1897 * conversation window then we yank focus from the conversation backlog | |
1898 * and give it to the text entry box so that people can type | |
1899 * all the live long day and it will get entered into the entry box. | |
1900 */ | |
6057 | 1901 static gboolean |
8105 | 1902 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1903 { |
1904 GaimGtkConversation *gtkconv = data; | |
1905 | |
8237 | 1906 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1907 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1908 (event->keyval == GDK_F10) || |
1909 (event->keyval == GDK_Shift_L) || | |
1910 (event->keyval == GDK_Shift_R) || | |
1911 (event->keyval == GDK_Escape) || | |
8177 | 1912 (event->keyval == GDK_Up) || |
1913 (event->keyval == GDK_Down) || | |
1914 (event->keyval == GDK_Left) || | |
8191 | 1915 (event->keyval == GDK_Right) || |
1916 (event->keyval == GDK_Home) || | |
9297 | 1917 (event->keyval == GDK_End) || |
1918 (event->keyval == GDK_Tab) || | |
1919 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1920 return FALSE; |
1921 | |
1922 if (event->type == GDK_KEY_RELEASE) | |
1923 gtk_widget_grab_focus(gtkconv->entry); | |
1924 | |
1925 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1926 | |
1927 return TRUE; | |
6057 | 1928 } |
1929 | |
4359 | 1930 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1931 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1932 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1933 GaimGtkConversation *gtkconv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1934 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1935 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1936 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1937 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1938 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1939 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1940 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1941 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1942 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1943 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1944 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1945 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1946 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1947 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
|
1948 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1949 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1950 void |
11604 | 1951 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1952 { | |
1953 GaimGtkConversation *gtkconv; | |
1954 | |
1955 g_return_if_fail(conv != NULL); | |
1956 | |
1957 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1958 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1959 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1960 |
1961 gray_stuff_out(gtkconv); | |
1962 update_typing_icon(gtkconv); | |
1963 | |
1964 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
1965 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
1966 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
1967 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 1968 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
1969 gaim_account_get_protocol_name(conv->account)); | |
1970 } | |
1971 | |
1972 static void | |
4673 | 1973 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1974 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1975 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 1976 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1977 GaimConversation *conv; |
4359 | 1978 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1979 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1980 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1981 |
11594 | 1982 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 1983 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 1984 } |
1985 | |
1986 static void | |
1987 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1988 gchar *new_text, gint new_text_length, gpointer user_data) | |
1989 { | |
10810 | 1990 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
1991 GaimConversation *conv; | |
1992 | |
1993 g_return_if_fail(gtkconv != NULL); | |
11508 | 1994 |
10810 | 1995 conv = gtkconv->active_conv; |
4359 | 1996 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1997 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1998 return; |
1999 | |
10810 | 2000 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2001 gtk_text_iter_is_end(position))); | |
4359 | 2002 } |
2003 | |
2004 static void | |
2005 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2006 GtkTextIter *end_pos, gpointer user_data) | |
2007 { | |
10810 | 2008 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2009 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2010 GaimConvIm *im; |
4359 | 2011 |
10810 | 2012 g_return_if_fail(gtkconv != NULL); |
11508 | 2013 |
10810 | 2014 conv = gtkconv->active_conv; |
4359 | 2015 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2016 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2017 return; |
2018 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2019 im = GAIM_CONV_IM(conv); |
4359 | 2020 |
2021 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2022 | |
2023 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2024 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2025 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2026 |
2027 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2028 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2029 GAIM_NOT_TYPING); |
4359 | 2030 } |
2031 else { | |
2032 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2033 got_typing_keypress(gtkconv, FALSE); |
4359 | 2034 } |
2035 } | |
2036 | |
8189 | 2037 /************************************************************************** |
2038 * A bunch of buddy icon functions | |
2039 **************************************************************************/ | |
11581 | 2040 GdkPixbuf * |
2041 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2042 { |
10116 | 2043 GaimAccount *account = NULL; |
2044 const char *name = NULL; | |
7143 | 2045 GdkPixbuf *status = NULL; |
2046 | |
10116 | 2047 g_return_val_if_fail(conv != NULL, NULL); |
2048 | |
2049 account = gaim_conversation_get_account(conv); | |
2050 name = gaim_conversation_get_name(conv); | |
2051 | |
2052 g_return_val_if_fail(account != NULL, NULL); | |
2053 g_return_val_if_fail(name != NULL, NULL); | |
2054 | |
11338 | 2055 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2056 GaimBuddy *b = gaim_find_buddy(account, name); |
2057 if (b != NULL) { | |
2058 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2059 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2060 } |
2061 } | |
2062 | |
2063 if (!status) { | |
2064 GdkPixbuf *pixbuf; | |
10884 | 2065 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2066 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2067 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2068 { |
7143 | 2069 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2070 GDK_INTERP_BILINEAR); | |
2071 g_object_unref(pixbuf); | |
2072 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2073 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2074 status = pixbuf; |
7143 | 2075 } |
2076 return status; | |
2077 } | |
2078 | |
8189 | 2079 static void |
2080 update_tab_icon(GaimConversation *conv) | |
2081 { | |
2082 GaimGtkConversation *gtkconv; | |
11581 | 2083 GaimGtkWindow *win; |
8189 | 2084 GaimAccount *account; |
2085 const char *name; | |
2086 GdkPixbuf *status = NULL; | |
2087 | |
10116 | 2088 g_return_if_fail(conv != NULL); |
2089 | |
8189 | 2090 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2091 win = gtkconv->win; |
8189 | 2092 name = gaim_conversation_get_name(conv); |
2093 account = gaim_conversation_get_account(conv); | |
2094 | |
11581 | 2095 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2096 |
10116 | 2097 g_return_if_fail(status != NULL); |
2098 | |
8189 | 2099 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2100 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2101 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2102 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2103 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2104 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2105 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2106 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2107 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2108 { |
11581 | 2109 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2110 | |
2111 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2112 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2113 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2114 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2115 } |
8189 | 2116 } |
2117 | |
2118 static gboolean | |
2119 redraw_icon(gpointer data) | |
2120 { | |
10810 | 2121 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2122 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2123 GaimAccount *account; |
2124 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2125 |
2126 GdkPixbuf *buf; | |
2127 GdkPixbuf *scale; | |
2128 GdkPixmap *pm; | |
2129 GdkBitmap *bm; | |
2130 gint delay; | |
9318 | 2131 int scale_width, scale_height; |
8189 | 2132 |
2133 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2134 account = gaim_conversation_get_account(conv); |
2135 if(account && account->gc) | |
2136 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2137 |
2138 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2139 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2140 | |
10483 | 2141 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2142 NULL, &scale_width, &scale_height); |
2143 | |
2144 /* this code is ugly, and scares me */ | |
8189 | 2145 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2146 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2147 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2148 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2149 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2150 GDK_INTERP_BILINEAR); |
8189 | 2151 |
2152 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2153 g_object_unref(G_OBJECT(scale)); | |
2154 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2155 g_object_unref(G_OBJECT(pm)); | |
2156 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2157 | |
2158 if (bm) | |
2159 g_object_unref(G_OBJECT(bm)); | |
2160 | |
9131 | 2161 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2162 |
2163 if (delay < 100) | |
9131 | 2164 delay = 100; |
2165 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2166 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2167 |
2168 return FALSE; | |
2169 } | |
2170 | |
2171 static void | |
10810 | 2172 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2173 { |
2174 int delay; | |
2175 | |
8228 | 2176 if (gtkconv->u.im->anim == NULL) |
2177 return; | |
2178 | |
8202 | 2179 if (gtkconv->u.im->icon_timer != 0) |
2180 return; | |
2181 | |
8189 | 2182 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2183 return; | |
2184 | |
10639 | 2185 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2186 | |
2187 if (delay < 100) | |
2188 delay = 100; | |
2189 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2190 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2191 } |
2192 | |
2193 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2194 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2195 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2196 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2197 GaimGtkWindow *gtkwin; |
2198 | |
2199 g_return_if_fail(conv != NULL); | |
2200 | |
9887 | 2201 if (gtkconv->u.im->icon_container != NULL) |
2202 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2203 |
2204 if (gtkconv->u.im->anim != NULL) | |
2205 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2206 | |
2207 if (gtkconv->u.im->icon_timer != 0) | |
2208 g_source_remove(gtkconv->u.im->icon_timer); | |
2209 | |
2210 if (gtkconv->u.im->iter != NULL) | |
2211 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2212 | |
2213 gtkconv->u.im->icon_timer = 0; | |
2214 gtkconv->u.im->icon = NULL; | |
2215 gtkconv->u.im->anim = NULL; | |
2216 gtkconv->u.im->iter = NULL; | |
10456 | 2217 gtkconv->u.im->icon_container = NULL; |
9687 | 2218 gtkconv->u.im->show_icon = FALSE; |
10456 | 2219 |
11581 | 2220 gtkwin = gtkconv->win; |
10456 | 2221 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2222 } |
2223 | |
9497 | 2224 static void |
9504 | 2225 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2226 { |
10810 | 2227 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2228 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2229 FILE *fp; |
2230 GaimBuddyIcon *icon; | |
2231 const void *data; | |
2232 size_t len; | |
2233 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2234 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2235 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2236 return; |
2237 } | |
2238 | |
2239 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2240 data = gaim_buddy_icon_get_data(icon, &len); | |
2241 | |
2242 if ((len <= 0) || (data == NULL)) { | |
9504 | 2243 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2244 return; |
2245 } | |
2246 | |
2247 fwrite(data, 1, len, fp); | |
2248 fclose(fp); | |
2249 } | |
2250 | |
2251 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2252 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2253 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2254 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2255 const gchar *ext; |
9497 | 2256 gchar *buf; |
2257 | |
2258 g_return_if_fail(conv != NULL); | |
9504 | 2259 |
10953 | 2260 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2261 if (ext == NULL) | |
2262 ext = "icon"; | |
2263 | |
2264 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2265 |
2266 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2267 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2268 |
2269 g_free(buf); | |
2270 } | |
2271 | |
11581 | 2272 static void |
2273 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2274 { | |
2275 if (gtkconv->u.im->icon_timer != 0) | |
2276 g_source_remove(gtkconv->u.im->icon_timer); | |
2277 | |
2278 gtkconv->u.im->icon_timer = 0; | |
2279 } | |
2280 | |
2281 | |
2282 static void | |
2283 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2284 { | |
2285 gtkconv->u.im->animate = | |
2286 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2287 | |
2288 if (gtkconv->u.im->animate) | |
2289 start_anim(NULL, gtkconv); | |
2290 else | |
2291 stop_anim(NULL, gtkconv); | |
2292 } | |
2293 | |
8189 | 2294 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2295 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2296 { |
2297 static GtkWidget *menu = NULL; | |
2298 GtkWidget *button; | |
2299 | |
2300 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2301 return FALSE; | |
2302 | |
2303 /* | |
2304 * If a menu already exists, destroy it before creating a new one, | |
2305 * thus freeing-up the memory it occupied. | |
2306 */ | |
2307 if (menu != NULL) | |
2308 gtk_widget_destroy(menu); | |
2309 | |
2310 menu = gtk_menu_new(); | |
2311 | |
2312 if (gtkconv->u.im->anim && | |
2313 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2314 { | |
2315 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2316 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2317 gtkconv->u.im->icon_timer); |
2318 } | |
2319 | |
2320 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2321 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2322 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2323 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2324 gtk_widget_show(button); | |
2325 | |
2326 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
|
2327 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2328 0, 0, NULL); |
2329 | |
2330 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2331 | |
2332 return TRUE; | |
2333 } | |
10456 | 2334 |
2335 static void | |
2336 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2337 { | |
11581 | 2338 GaimGtkWindow *win = data; |
10456 | 2339 GaimConversation *conv; |
2340 GaimGtkConversation *gtkconv; | |
2341 gboolean active; | |
2342 | |
11581 | 2343 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2344 |
2345 if (!conv) | |
2346 return; | |
2347 | |
11338 | 2348 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2349 |
2350 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2351 | |
2352 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2353 gtkconv->u.im->show_icon = active; | |
2354 if (active) | |
2355 gaim_gtkconv_update_buddy_icon(conv); | |
2356 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2357 remove_icon(gtkconv); |
10456 | 2358 } |
2359 | |
8189 | 2360 /************************************************************************** |
2361 * End of the bunch of buddy icon functions | |
2362 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2363 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2364 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2365 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2366 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2367 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2368 if(gtkconv->win==hidden_convwin) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2369 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2370 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2371 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2372 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2373 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2374 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2375 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2376 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2377 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2378 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2379 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2380 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2381 GaimUnseenState min_state) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2382 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2383 GList *l; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2384 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2385 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2386 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2387 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2388 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2389 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2390 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2391 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2392 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2393 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2394 GaimConversation *conv = (GaimConversation*)l->data; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2395 if (GAIM_GTK_CONVERSATION(conv)->unseen_state >= min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2396 return conv; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2397 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2398 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2399 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2400 } |
8189 | 2401 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2402 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2403 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2404 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2405 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2406 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2407 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2408 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2409 guint |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2410 gaim_gtk_conversations_fill_unseen_menu(GtkWidget *menu, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2411 GaimConversationType type, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2412 GaimUnseenState min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2413 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2414 GList *l; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2415 guint ret = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2416 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2417 g_return_val_if_fail(menu != NULL, 0); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2418 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2419 if (type == GAIM_CONV_TYPE_IM) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2420 l = gaim_get_ims(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2421 } else if (type == GAIM_CONV_TYPE_CHAT) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2422 l = gaim_get_chats(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2423 } else { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2424 l = gaim_get_conversations(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2425 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2426 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2427 for (; l != NULL ; l = l->next) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2428 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2429 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2430 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2431 if (gtkconv->unseen_state >= min_state) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2432 GtkWidget *icon = gtk_image_new(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2433 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2434 GtkWidget *item; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2435 gchar *text = g_strdup_printf("%s (%d)", |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2436 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2437 gtkconv->unseen_count); |
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 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2440 g_object_unref(pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2441 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2442 item = gtk_image_menu_item_new_with_label(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2443 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
|
2444 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
|
2445 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2446 g_free(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2447 ret++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2448 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2449 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2450 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2451 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2452 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2453 |
11581 | 2454 GaimGtkWindow * |
2455 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2456 { | |
2457 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2458 return gtkconv->win; | |
2459 } | |
2460 | |
2461 static GtkItemFactoryEntry menu_items[] = | |
2462 { | |
2463 /* Conversation menu */ | |
2464 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2465 | |
2466 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2467 0, "<StockItem>", GAIM_STOCK_IM }, | |
2468 | |
2469 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2470 | |
2471 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2472 "<StockItem>", GTK_STOCK_FIND }, | |
2473 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, | |
2474 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | |
2475 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
2476 { N_("/Conversation/Clear"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, | |
2477 | |
2478 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2479 | |
2480 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2481 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
2482 0, NULL }, | |
2483 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, | |
2484 "<StockItem>", GAIM_STOCK_INFO }, | |
2485 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2486 "<StockItem>", GAIM_STOCK_INVITE }, | |
2487 | |
2488 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2489 | |
2490 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2491 "<StockItem>", GAIM_STOCK_EDIT }, | |
2492 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2493 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2494 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2495 "<StockItem>", GTK_STOCK_ADD }, | |
2496 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2497 "<StockItem>", GTK_STOCK_REMOVE }, | |
2498 | |
2499 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2500 | |
2501 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2502 "<StockItem>", GAIM_STOCK_LINK }, | |
2503 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2504 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2505 | |
2506 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2507 | |
2508 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2509 "<StockItem>", GTK_STOCK_CLOSE }, | |
2510 | |
2511 /* Options */ | |
2512 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2513 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2514 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2515 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2516 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2517 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2518 }; | |
2519 | |
2520 static const int menu_item_count = | |
2521 sizeof(menu_items) / sizeof(*menu_items); | |
2522 | |
2523 static char * | |
2524 item_factory_translate_func (const char *path, gpointer func_data) | |
2525 { | |
2526 return _((char *)path); | |
2527 } | |
2528 | |
2529 static GtkWidget * | |
2530 setup_menubar(GaimGtkWindow *win) | |
2531 { | |
2532 GtkAccelGroup *accel_group; | |
2533 | |
2534 accel_group = gtk_accel_group_new (); | |
2535 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2536 g_object_unref(accel_group); | |
2537 | |
2538 win->menu.item_factory = | |
2539 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2540 | |
2541 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2542 item_factory_translate_func, | |
2543 NULL, NULL); | |
2544 | |
2545 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2546 menu_items, win); | |
2547 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2548 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2549 | |
2550 | |
2551 win->menu.menubar = | |
2552 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2553 | |
2554 | |
2555 win->menu.view_log = | |
2556 gtk_item_factory_get_widget(win->menu.item_factory, | |
2557 N_("/Conversation/View Log")); | |
2558 | |
2559 /* --- */ | |
2560 | |
2561 win->menu.send_file = | |
2562 gtk_item_factory_get_widget(win->menu.item_factory, | |
2563 N_("/Conversation/Send File...")); | |
2564 | |
2565 win->menu.add_pounce = | |
2566 gtk_item_factory_get_widget(win->menu.item_factory, | |
2567 N_("/Conversation/Add Buddy Pounce...")); | |
2568 | |
2569 /* --- */ | |
2570 | |
2571 win->menu.get_info = | |
2572 gtk_item_factory_get_widget(win->menu.item_factory, | |
2573 N_("/Conversation/Get Info")); | |
2574 | |
2575 win->menu.invite = | |
2576 gtk_item_factory_get_widget(win->menu.item_factory, | |
2577 N_("/Conversation/Invite...")); | |
2578 | |
2579 /* --- */ | |
2580 | |
2581 win->menu.alias = | |
2582 gtk_item_factory_get_widget(win->menu.item_factory, | |
2583 N_("/Conversation/Alias...")); | |
2584 | |
2585 win->menu.block = | |
2586 gtk_item_factory_get_widget(win->menu.item_factory, | |
2587 N_("/Conversation/Block...")); | |
2588 | |
2589 win->menu.add = | |
2590 gtk_item_factory_get_widget(win->menu.item_factory, | |
2591 N_("/Conversation/Add...")); | |
2592 | |
2593 win->menu.remove = | |
2594 gtk_item_factory_get_widget(win->menu.item_factory, | |
2595 N_("/Conversation/Remove...")); | |
2596 | |
2597 /* --- */ | |
2598 | |
2599 win->menu.insert_link = | |
2600 gtk_item_factory_get_widget(win->menu.item_factory, | |
2601 N_("/Conversation/Insert Link...")); | |
2602 | |
2603 win->menu.insert_image = | |
2604 gtk_item_factory_get_widget(win->menu.item_factory, | |
2605 N_("/Conversation/Insert Image...")); | |
2606 | |
2607 /* --- */ | |
2608 | |
2609 win->menu.logging = | |
2610 gtk_item_factory_get_widget(win->menu.item_factory, | |
2611 N_("/Options/Enable Logging")); | |
2612 win->menu.sounds = | |
2613 gtk_item_factory_get_widget(win->menu.item_factory, | |
2614 N_("/Options/Enable Sounds")); | |
2615 win->menu.show_formatting_toolbar = | |
2616 gtk_item_factory_get_widget(win->menu.item_factory, | |
2617 N_("/Options/Show Formatting Toolbars")); | |
2618 win->menu.show_timestamps = | |
2619 gtk_item_factory_get_widget(win->menu.item_factory, | |
2620 N_("/Options/Show Timestamps")); | |
2621 win->menu.show_icon = | |
2622 gtk_item_factory_get_widget(win->menu.item_factory, | |
2623 N_("/Options/Show Buddy Icon")); | |
2624 | |
2625 | |
2626 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2627 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2628 win->menu.tray); | |
2629 gtk_widget_show(win->menu.tray); | |
2630 | |
2631 gtk_widget_show(win->menu.menubar); | |
2632 | |
2633 return win->menu.menubar; | |
2634 } | |
2635 | |
4359 | 2636 |
2637 /************************************************************************** | |
2638 * Utility functions | |
2639 **************************************************************************/ | |
2640 | |
2641 static void | |
10810 | 2642 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2643 { |
10810 | 2644 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2645 GaimConvIm *im; |
4685 | 2646 |
4359 | 2647 /* |
2648 * 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
|
2649 * send GAIM_TYPED any time soon. |
4359 | 2650 */ |
2651 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2652 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2653 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2654 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2655 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2656 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2657 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2658 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2659 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2660 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2661 |
2662 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2663 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2664 GAIM_TYPING); |
4359 | 2665 |
2666 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2667 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2668 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2669 gaim_conv_im_set_type_again(im, 0); |
4359 | 2670 } |
2671 } | |
2672 | |
4736 | 2673 static void |
10810 | 2674 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2675 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2676 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2677 GaimConvIm *im = NULL; |
10810 | 2678 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2679 char *stock_id, *tooltip; |
11508 | 2680 |
11581 | 2681 gtkwin = gtkconv->win; |
4736 | 2682 |
12008 | 2683 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2684 im = GAIM_CONV_IM(conv); |
4736 | 2685 |
12008 | 2686 if (gtkwin->menu.typing_icon) { |
2687 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2688 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2689 |
12008 | 2690 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2691 return; | |
2692 | |
2693 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2694 stock_id = GAIM_STOCK_TYPING; | |
2695 tooltip = _("User is typing..."); | |
2696 } else { | |
2697 stock_id = GAIM_STOCK_TYPED; | |
2698 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2699 } |
12008 | 2700 |
2701 if (gtkwin->menu.typing_icon == NULL) | |
2702 { | |
2703 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
|
2704 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
|
2705 gtkwin->menu.typing_icon, |
12008 | 2706 tooltip); |
4736 | 2707 } |
12008 | 2708 else |
2709 { | |
2710 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2711 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2712 gtkwin->menu.typing_icon, | |
2713 tooltip); | |
2714 } | |
2715 | |
2716 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2717 } |
2718 | |
4685 | 2719 static gboolean |
11594 | 2720 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2721 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2722 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2723 GaimConversation *conv; |
4359 | 2724 GtkWidget *menu; |
2725 GList *child; | |
11594 | 2726 GaimBuddy *b; |
11581 | 2727 |
2728 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2729 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2730 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2731 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2732 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2733 account = gaim_conversation_get_account(conv); |
11581 | 2734 |
11594 | 2735 if (win->menu.send_to == NULL) |
4685 | 2736 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2737 |
11594 | 2738 if (!(b = gaim_find_buddy(account, conv->name))) |
2739 return FALSE; | |
2740 | |
2741 | |
2742 gtk_widget_show(win->menu.send_to); | |
4359 | 2743 |
2744 menu = gtk_menu_item_get_submenu( | |
11594 | 2745 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2746 |
2747 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2748 child != NULL; | |
2749 child = child->next) { | |
2750 | |
2751 GtkWidget *item = child->data; | |
11594 | 2752 GaimBuddy *item_buddy; |
2753 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2754 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2755 "gaim_buddy_name"); | |
2756 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2757 | |
2758 if (b == item_buddy) { | |
4359 | 2759 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2760 break; | |
2761 } | |
2762 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2763 |
4685 | 2764 return FALSE; |
4359 | 2765 } |
2766 | |
2767 static void | |
11594 | 2768 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2769 { | |
2770 GaimAccount *account; | |
2771 GtkWidget *box; | |
2772 GtkWidget *label; | |
2773 GtkWidget *image; | |
2774 GtkWidget *menuitem; | |
11625 | 2775 GdkPixbuf *pixbuf; |
11616 | 2776 gchar *text; |
11594 | 2777 |
2778 account = bud->account; | |
2779 | |
2780 /* Create a pixmap for the protocol icon. */ | |
11625 | 2781 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2782 /* Now convert it to GtkImage */ |
2783 if (pixbuf == NULL) | |
2784 image = gtk_image_new(); | |
2785 else | |
11625 | 2786 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2787 |
2788 gtk_size_group_add_widget(sg, image); | |
2789 | |
2790 g_object_unref(G_OBJECT(pixbuf)); | |
2791 | |
2792 /* Make our menu item */ | |
11616 | 2793 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2794 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2795 g_free(text); | |
11594 | 2796 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2797 | |
2798 /* Do some evil, see some evil, speak some evil. */ | |
2799 box = gtk_hbox_new(FALSE, 0); | |
2800 | |
2801 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2802 g_object_ref(label); | |
2803 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2804 | |
2805 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2806 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2807 | |
2808 g_object_unref(label); | |
2809 | |
2810 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2811 | |
2812 gtk_widget_show(label); | |
2813 gtk_widget_show(image); | |
2814 gtk_widget_show(box); | |
2815 | |
2816 /* Set our data and callbacks. */ | |
2817 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2818 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2819 | |
2820 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2821 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2822 | |
2823 gtk_widget_show(menuitem); | |
2824 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2825 } | |
2826 | |
2827 static void | |
2828 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2829 { |
4359 | 2830 GtkWidget *menu; |
2831 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2832 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2833 GaimGtkConversation *gtkconv; |
2834 GSList *l, *buds; | |
2835 | |
2836 g_return_if_fail(win != NULL); | |
2837 | |
2838 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2839 | |
11604 | 2840 g_return_if_fail(gtkconv != NULL); |
2841 | |
11594 | 2842 if (win->menu.send_to != NULL) |
2843 gtk_widget_destroy(win->menu.send_to); | |
2844 | |
4359 | 2845 |
2846 /* Build the Send As menu */ | |
11594 | 2847 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2848 gtk_widget_show(win->menu.send_to); | |
4359 | 2849 |
2850 menu = gtk_menu_new(); | |
11581 | 2851 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2852 win->menu.send_to, 2); |
2853 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2854 |
2855 gtk_widget_show(menu); | |
2856 | |
11604 | 2857 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2858 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2859 for (l = buds; l != NULL; l = l->next) { | |
2860 GaimBuddy *b; | |
2861 GaimBlistNode *node; | |
2862 | |
2863 b = l->data; | |
2864 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2865 | |
2866 for (node = node->child; node != NULL; node = node->next) | |
2867 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2868 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2869 } | |
2870 | |
2871 g_slist_free(buds); | |
4359 | 2872 } |
2873 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2874 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2875 |
11594 | 2876 gtk_widget_show(win->menu.send_to); |
2877 if (!group) | |
2878 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2879 update_send_to_selection(win); | |
4359 | 2880 } |
2881 | |
2882 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2883 generate_invite_user_names(GaimConnection *gc) |
4359 | 2884 { |
6695 | 2885 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2886 static GList *tmp = NULL; |
2887 | |
2888 if (tmp) | |
2889 g_list_free(tmp); | |
2890 | |
2891 tmp = g_list_append(NULL, ""); | |
2892 | |
2893 if (gc != NULL) { | |
4785 | 2894 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2895 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2896 continue; | |
6695 | 2897 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2898 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2899 continue; |
6695 | 2900 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2901 GaimBuddy *buddy; | |
2902 | |
2903 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2904 continue; | |
2905 | |
2906 buddy = (GaimBuddy *)bnode; | |
2907 | |
2908 if (buddy->account == gc->account && | |
2909 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2910 tmp = g_list_insert_sorted(tmp, buddy->name, |
2911 (GCompareFunc)g_utf8_collate); | |
6695 | 2912 } |
4359 | 2913 } |
2914 } | |
2915 } | |
2916 | |
2917 return tmp; | |
2918 } | |
2919 | |
9498 | 2920 static GdkPixbuf * |
9554 | 2921 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2922 { |
9554 | 2923 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2924 char *filename; |
10274 | 2925 const char *image = NULL; |
9554 | 2926 |
2927 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2928 image = "founder.png"; |
9554 | 2929 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2930 image = "op.png"; |
9554 | 2931 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2932 image = "halfop.png"; |
9554 | 2933 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2934 image = "voice.png"; |
9554 | 2935 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2936 image = "ignored.png"; |
2937 } else { | |
2938 return NULL; | |
9554 | 2939 } |
10274 | 2940 |
2941 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2942 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2943 g_free(filename); | |
2944 | |
2945 if (!pixbuf) | |
2946 return NULL; | |
2947 | |
2948 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2949 g_object_unref(pixbuf); | |
2950 | |
2951 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2952 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2953 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2954 g_free(filename); | |
10274 | 2955 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2956 g_object_unref(pixbuf); |
10274 | 2957 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2958 g_object_unref(scale2); | |
9498 | 2959 } |
2960 | |
10274 | 2961 return scale; |
9498 | 2962 } |
2963 | |
4359 | 2964 static void |
11869 | 2965 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 2966 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2967 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2968 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2969 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2970 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2971 GaimPluginProtocolInfo *prpl_info; |
4359 | 2972 GtkListStore *ls; |
9498 | 2973 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2974 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2975 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2976 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2977 GdkColor send_color; |
11508 | 2978 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2979 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 2980 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2981 chat = GAIM_CONV_CHAT(conv); |
4359 | 2982 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2983 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2984 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2985 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2986 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2987 return; |
4359 | 2988 |
2989 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
2990 | |
9554 | 2991 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 2992 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
2993 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
|
2994 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2995 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2996 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2997 |
4359 | 2998 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2999 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3000 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3001 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3002 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3003 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3004 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
|
3005 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3006 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3007 |
9554 | 3008 if (pixbuf) |
3009 g_object_unref(pixbuf); | |
4359 | 3010 } |
3011 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3012 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3013 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
|
3014 GList **matches, gboolean command, char *name) |
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 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3017 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3018 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3019 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3020 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3021 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3022 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3023 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3024 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3025 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3026 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3027 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3028 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3029 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3030 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3031 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3032 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3033 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3034 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3035 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3036 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3037 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3038 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3039 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3040 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3041 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3042 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3043 } |
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 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3046 (GCompareFunc)gaim_utf8_strcasecmp); |
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 |
9605 | 3049 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3050 tab_complete(GaimConversation *conv) |
4359 | 3051 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3052 GaimGtkConversation *gtkconv; |
4359 | 3053 GtkTextIter cursor, word_start, start_buffer; |
3054 int start; | |
3055 int most_matched = -1; | |
3056 char *entered, *partial = NULL; | |
3057 char *text; | |
8021 | 3058 char *nick_partial; |
9605 | 3059 const char *prefix; |
4359 | 3060 GList *matches = NULL; |
9605 | 3061 gboolean command = FALSE; |
4359 | 3062 |
3063 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3064 | |
3065 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3066 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3067 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3068 | |
3069 word_start = cursor; | |
3070 | |
3071 /* if there's nothing there just return */ | |
3072 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3073 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
|
3074 |
4359 | 3075 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3076 &cursor, FALSE); | |
3077 | |
3078 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3079 start = strlen(text) - 1; | |
3080 | |
8021 | 3081 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3082 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3083 start-=2; |
3084 } | |
4359 | 3085 |
3086 /* find the start of the word that we're tabbing */ | |
3087 while (start >= 0 && text[start] != ' ') { | |
3088 gtk_text_iter_backward_char(&word_start); | |
3089 start--; | |
3090 } | |
3091 | |
9605 | 3092 prefix = gaim_gtk_get_cmd_prefix(); |
3093 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3094 command = TRUE; | |
3095 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3096 } | |
3097 | |
4359 | 3098 g_free(text); |
3099 | |
3100 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3101 &cursor, FALSE); | |
3102 | |
8021 | 3103 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3104 g_free(entered); |
11338 | 3105 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3106 } |
3107 | |
8021 | 3108 nick_partial = g_malloc(strlen(entered)+1); |
3109 | |
9605 | 3110 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3111 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3112 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3113 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3114 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3115 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3116 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3117 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3118 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3119 g_list_free(list); |
11338 | 3120 } 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
|
3121 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3122 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3123 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
|
3124 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3125 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3126 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3127 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3128 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3129 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3130 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3131 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3132 |
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 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3135 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
|
3136 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3137 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3138 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3139 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3140 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3141 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3142 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3143 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3144 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3145 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3146 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3147 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3148 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3149 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3150 g_free(alias); |
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 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3153 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3154 } |
9605 | 3155 } else { |
3156 g_free(nick_partial); | |
3157 g_free(entered); | |
3158 return FALSE; | |
3159 } | |
3160 | |
8021 | 3161 g_free(nick_partial); |
3162 | |
4359 | 3163 /* we're only here if we're doing new style */ |
3164 | |
3165 /* if there weren't any matches, return */ | |
3166 if (!matches) { | |
3167 /* if matches isn't set partials won't be either */ | |
3168 g_free(entered); | |
11338 | 3169 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3170 } |
3171 | |
3172 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3173 | |
3174 if (!matches->next) { | |
3175 /* there was only one match. fill it in. */ | |
3176 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3177 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3178 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3179 | |
3180 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3181 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3182 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3183 g_free(tmp); | |
3184 } | |
3185 else | |
3186 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3187 matches->data, -1); | |
3188 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3189 g_free(matches->data); |
4359 | 3190 matches = g_list_remove(matches, matches->data); |
3191 } | |
3192 else { | |
3193 /* | |
3194 * there were lots of matches, fill in as much as possible | |
3195 * and display all of them | |
3196 */ | |
3197 char *addthis = g_malloc0(1); | |
3198 | |
3199 while (matches) { | |
3200 char *tmp = addthis; | |
3201 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3202 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3203 g_free(matches->data); |
4359 | 3204 matches = g_list_remove(matches, matches->data); |
3205 } | |
3206 | |
6982 | 3207 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3208 time(NULL)); |
3209 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3210 g_free(addthis); | |
3211 } | |
3212 | |
3213 g_free(entered); | |
3214 g_free(partial); | |
9605 | 3215 |
3216 return TRUE; | |
4359 | 3217 } |
3218 | |
10810 | 3219 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3220 { |
3221 GaimPluginProtocolInfo *prpl_info = NULL; | |
3222 GaimConnection *gc; | |
10810 | 3223 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3224 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3225 char *new_topic; |
8858 | 3226 const char *current_topic; |
7971 | 3227 |
3228 gc = gaim_conversation_get_gc(conv); | |
3229 | |
3230 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3231 return; | |
3232 | |
3233 if(prpl_info->set_chat_topic == NULL) | |
3234 return; | |
3235 | |
3236 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3237 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3238 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3239 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3240 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3241 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3242 g_free(new_topic); |
7971 | 3243 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3244 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3245 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3246 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3247 |
8858 | 3248 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3249 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3250 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3251 g_free(new_topic); |
7971 | 3252 } |
3253 | |
9554 | 3254 static gint |
3255 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3256 { | |
3257 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3258 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3259 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3260 gint ret = 0; |
3261 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3262 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3263 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3264 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3265 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3266 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3267 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3268 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3269 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3270 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3271 -1); |
9554 | 3272 |
3273 if (user1 == NULL || user2 == NULL) { | |
3274 if (!(user1 == NULL && user2 == NULL)) | |
3275 ret = (user1 == NULL) ? -1: 1; | |
3276 } else if (f1 != f2) { | |
3277 /* sort more important users first */ | |
3278 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3280 ret = buddy1 ? -1 : 1; |
9554 | 3281 } else { |
10904 | 3282 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3283 } |
3284 | |
3285 g_free(user1); | |
3286 g_free(user2); | |
3287 | |
3288 return ret; | |
3289 } | |
3290 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3291 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3292 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
|
3293 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3294 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3295 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3296 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3297 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3298 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3300 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3301 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 /* 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
|
3305 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
|
3306 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 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
|
3308 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3309 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3310 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3313 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3314 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 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
|
3316 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3321 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 /* This user is not me, so look into updating the alias. */ |
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 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3325 alias = gaim_buddy_get_contact_alias(buddy2); |
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 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 -1); |
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 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 break; |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3341 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 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
|
3346 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3347 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3352 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3355 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3358 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 return; |
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 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
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 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 for(bnode = node->child; bnode; bnode = bnode->next) { |
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 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 continue; |
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 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3371 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3372 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3373 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3374 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3375 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3376 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3377 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3378 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3379 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3380 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3381 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3382 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3383 int f; |
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 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3386 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3387 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3388 /* 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
|
3389 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3390 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3391 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3392 /* 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
|
3393 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
|
3394 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3395 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
|
3396 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3397 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3398 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3401 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3402 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3403 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
|
3404 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3406 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
|
3407 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3408 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3409 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3410 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3411 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3412 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3413 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3414 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3415 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3416 g_free(normalized_name); |
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 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3421 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3422 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3423 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3424 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3425 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3426 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3427 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3428 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3429 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3430 /* If 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
|
3431 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3432 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3433 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 buddy_cb_common(buddy, conv, FALSE); |
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 |
4359 | 3437 static GtkWidget * |
10810 | 3438 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3439 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3440 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3441 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3442 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3443 GaimConnection *gc; |
4359 | 3444 GtkWidget *vpaned, *hpaned; |
10175 | 3445 GtkWidget *vbox, *hbox, *frame; |
4359 | 3446 GtkWidget *lbox, *bbox; |
3447 GtkWidget *label; | |
3448 GtkWidget *list; | |
3449 GtkWidget *button; | |
7949 | 3450 GtkWidget *sw; |
4359 | 3451 GtkListStore *ls; |
3452 GtkCellRenderer *rend; | |
3453 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3454 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3455 GList *focus_chain = NULL; |
4359 | 3456 |
3457 gtkchat = gtkconv->u.chat; | |
3458 gc = gaim_conversation_get_gc(conv); | |
3459 | |
3460 /* Setup the outer pane. */ | |
3461 vpaned = gtk_vpaned_new(); | |
3462 gtk_widget_show(vpaned); | |
3463 | |
3464 /* Setup the top part of the pane. */ | |
11243 | 3465 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3466 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3467 gtk_widget_show(vbox); |
3468 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3469 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3470 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3471 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3472 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3473 { |
11243 | 3474 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3475 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3476 gtk_widget_show(hbox); |
3477 | |
3478 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3479 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3480 gtk_widget_show(label); |
3481 | |
3482 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3483 |
7971 | 3484 if(prpl_info->set_chat_topic == NULL) { |
3485 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3486 } else { | |
3487 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3488 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3489 } |
3490 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3491 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3492 gtk_widget_show(gtkchat->topic_text); |
3493 } | |
3494 | |
3495 /* Setup the horizontal pane. */ | |
3496 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3497 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3498 gtk_widget_show(hpaned); |
3499 | |
10175 | 3500 /* Setup gtkihmtml. */ |
3501 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3502 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3503 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3504 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3505 gtk_widget_show(frame); | |
3506 | |
3507 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3508 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3509 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3510 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3511 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3512 |
4359 | 3513 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3514 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3515 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3516 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3517 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3518 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3519 |
3520 /* Build the right pane. */ | |
11243 | 3521 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3522 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3523 gtk_widget_show(lbox); |
3524 | |
3525 /* Setup the label telling how many people are in the room. */ | |
3526 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3527 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3528 gtk_widget_show(gtkchat->count); | |
3529 | |
3530 /* Setup the list of users. */ | |
7949 | 3531 sw = gtk_scrolled_window_new(NULL, NULL); |
3532 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3533 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3534 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3535 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3536 gtk_widget_show(sw); | |
4359 | 3537 |
9554 | 3538 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
|
3539 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
|
3540 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3541 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3542 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3543 GTK_SORT_ASCENDING); |
3544 | |
3545 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3546 | |
9498 | 3547 rend = gtk_cell_renderer_pixbuf_new(); |
3548 | |
4359 | 3549 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3550 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3551 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3552 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3553 |
3554 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3555 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3556 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3557 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3558 |
9498 | 3559 rend = gtk_cell_renderer_text_new(); |
3560 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3561 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3562 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3563 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3564 NULL); |
4359 | 3565 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3566 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3567 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3568 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3569 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3570 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3571 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3572 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3573 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3574 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3575 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3576 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3577 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3578 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3579 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3580 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3581 #endif |
4359 | 3582 |
3583 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3584 | |
3585 gtk_widget_set_size_request(list, 150, -1); | |
3586 | |
3587 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3588 gtk_widget_show(list); | |
3589 | |
3590 gtkchat->list = list; | |
3591 | |
7949 | 3592 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3593 |
3594 /* Setup the user list toolbar. */ | |
11243 | 3595 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3596 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3597 gtk_widget_show(bbox); | |
3598 | |
3599 /* IM */ | |
10221 | 3600 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3601 GAIM_BUTTON_VERTICAL); |
10500 | 3602 gtkchat->userlist_im = button; |
4359 | 3603 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3604 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
|
3605 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3606 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3607 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3608 |
3609 gtk_widget_show(button); | |
3610 | |
3611 /* Ignore */ | |
3612 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3613 GAIM_BUTTON_VERTICAL); | |
10500 | 3614 gtkchat->userlist_ignore = button; |
4359 | 3615 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3616 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
|
3617 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3618 _("Ignore the user"), NULL); |
4359 | 3619 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3620 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3621 gtk_widget_show(button); |
3622 | |
3623 /* Info */ | |
3624 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3625 GAIM_BUTTON_VERTICAL); | |
10500 | 3626 gtkchat->userlist_info = button; |
4359 | 3627 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3628 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3629 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3630 _("Get the user's information"), NULL); |
4359 | 3631 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3632 G_CALLBACK(info_cb), gtkconv); |
4359 | 3633 |
3634 gtk_widget_show(button); | |
3635 | |
10175 | 3636 /* Setup the bottom half of the conversation window */ |
11243 | 3637 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3638 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3639 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3640 |
11243 | 3641 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3642 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3643 gtk_widget_show(gtkconv->lower_hbox); | |
3644 | |
11243 | 3645 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3646 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3647 gtk_widget_show(vbox); | |
3648 | |
10175 | 3649 /* Setup the toolbar, entry widget and all signals */ |
3650 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3651 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3652 gtk_widget_show(frame); |
3653 | |
9005 | 3654 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3655 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3656 gaim_account_get_protocol_name(conv->account)); |
10175 | 3657 gtk_widget_set_size_request(gtkconv->entry, -1, |
3658 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3659 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3660 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3661 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3662 |
3663 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3664 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3665 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3666 G_CALLBACK(send_cb), gtkconv); |
4359 | 3667 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3668 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3669 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3670 G_CALLBACK(size_allocate_cb), gtkconv); |
3671 | |
3672 default_formatize(gtkconv); | |
4359 | 3673 |
9080 | 3674 /* |
3675 * Focus for chat windows should be as follows: | |
3676 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3677 * user list buttons -> entry -> buttons at bottom | |
3678 */ | |
9332 | 3679 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3680 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3681 | |
4359 | 3682 return vpaned; |
3683 } | |
3684 | |
3685 static GtkWidget * | |
10810 | 3686 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3687 { |
10810 | 3688 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3689 GtkWidget *frame; |
4359 | 3690 GtkWidget *paned; |
10175 | 3691 GtkWidget *vbox; |
3692 GtkWidget *vbox2; | |
9080 | 3693 GList *focus_chain = NULL; |
4359 | 3694 |
10175 | 3695 /* Setup the outer pane */ |
4359 | 3696 paned = gtk_vpaned_new(); |
3697 gtk_widget_show(paned); | |
3698 | |
10175 | 3699 /* Setup the top part of the pane */ |
11243 | 3700 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3701 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3702 gtk_widget_show(vbox); |
3703 | |
10175 | 3704 /* Setup the gtkimhtml widget */ |
3705 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3706 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3707 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3708 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3709 gtk_widget_show(frame); | |
3710 | |
3711 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3712 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3713 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3714 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3715 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3716 |
3717 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3718 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3719 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3720 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3721 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3722 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3723 |
10175 | 3724 /* Setup the bottom half of the conversation window */ |
11243 | 3725 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3726 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3727 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3728 |
11243 | 3729 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3730 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3731 gtk_widget_show(gtkconv->lower_hbox); | |
3732 | |
11243 | 3733 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3734 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3735 gtk_widget_show(vbox2); | |
8821 | 3736 |
10175 | 3737 /* Setup the toolbar, entry widget and all signals */ |
3738 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3739 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3740 gtk_widget_show(frame); |
3741 | |
9005 | 3742 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3743 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3744 gaim_account_get_protocol_name(conv->account)); |
10175 | 3745 gtk_widget_set_size_request(gtkconv->entry, -1, |
3746 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3747 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3748 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3749 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
|
3750 |
4359 | 3751 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3752 G_CALLBACK(entry_key_press_cb), gtkconv); |
3753 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3754 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3755 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3756 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3757 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3758 |
3759 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3760 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3761 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3762 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3763 |
8481 | 3764 /* had to move this after the imtoolbar is attached so that the |
3765 * signals get fired to toggle the buttons on the toolbar as well. | |
3766 */ | |
10810 | 3767 default_formatize(gtkconv); |
4359 | 3768 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3769 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3770 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3771 |
8758 | 3772 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3773 gtkconv->u.im->show_icon = TRUE; |
4359 | 3774 |
9080 | 3775 /* |
3776 * Focus for IM windows should be as follows: | |
10356 | 3777 * Tab title -> conversation scrollback -> entry |
9080 | 3778 */ |
9332 | 3779 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3780 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3781 |
4359 | 3782 return paned; |
3783 } | |
3784 | |
3785 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3786 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3787 GtkSelectionData *sd, guint info, guint t, |
3788 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3789 { |
10810 | 3790 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3791 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3792 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3793 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3794 { |
4781 | 3795 GaimBlistNode *n = NULL; |
6695 | 3796 GaimBuddy *b; |
11581 | 3797 GaimGtkConversation *gtkconv = NULL; |
9622 | 3798 |
11812 | 3799 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3800 |
6695 | 3801 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3802 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3803 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3804 b = (GaimBuddy*)n; | |
3805 else | |
4781 | 3806 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3807 |
9622 | 3808 /* |
3809 * If we already have an open conversation with this buddy, then | |
3810 * just move the conv to this window. Otherwise, create a new | |
3811 * conv and add it to this window. | |
3812 */ | |
11338 | 3813 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3814 if (c != NULL) { |
11581 | 3815 GaimGtkWindow *oldwin; |
3816 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3817 oldwin = gtkconv->win; | |
9622 | 3818 if (oldwin != win) { |
11581 | 3819 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3820 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3821 } |
3822 } else { | |
11338 | 3823 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3824 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3825 if (gtkconv->win != win) |
3826 { | |
3827 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3828 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3829 } | |
9622 | 3830 } |
3831 | |
3832 /* Make this conversation the active conversation */ | |
11581 | 3833 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3834 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3835 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3836 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3837 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
|
3838 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3839 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3840 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3841 GaimAccount *account; |
11581 | 3842 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3843 |
11137 | 3844 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3845 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3846 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3847 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3848 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3849 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3850 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3851 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3852 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3853 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3854 { |
11338 | 3855 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3856 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3857 if (gtkconv->win != win) |
3858 { | |
3859 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3860 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3861 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3862 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3863 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3864 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3865 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3866 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3867 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3868 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3869 } |
9525 | 3870 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3871 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3872 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3873 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3874 } |
10145 | 3875 else |
3876 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3877 } |
4359 | 3878 |
3879 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3880 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3881 { |
10145 | 3882 GTK_IMHTML_DND_TARGETS, |
3883 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3884 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3885 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3886 |
10810 | 3887 static GaimGtkConversation * |
3888 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3889 { | |
3890 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3891 GaimContact *c; | |
3892 GaimBlistNode *cn; | |
10935 | 3893 |
10810 | 3894 if (!bud) |
3895 return NULL; | |
10935 | 3896 |
10810 | 3897 if (!(c = gaim_buddy_get_contact(bud))) |
3898 return NULL; | |
10935 | 3899 |
10810 | 3900 cn = (GaimBlistNode *)c; |
3901 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3902 GaimConversation *conv; | |
11338 | 3903 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3904 if (conv->ui_data) |
3905 return conv->ui_data; | |
3906 } | |
3907 } | |
10935 | 3908 |
10810 | 3909 return NULL; |
3910 } | |
3911 | |
11855 | 3912 static void |
3913 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3914 { | |
3915 GList *list; | |
3916 | |
3917 g_return_if_fail(bnode); | |
3918 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3919 | |
3920 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3921 { | |
3922 GaimGtkWindow *win = list->data; | |
3923 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3924 | |
3925 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3926 continue; | |
3927 | |
3928 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3929 } | |
3930 } | |
3931 | |
11581 | 3932 /************************************************************************** |
3933 * Conversation UI operations | |
3934 **************************************************************************/ | |
3935 void | |
3936 gaim_gtkconv_new(GaimConversation *conv) | |
3937 { | |
3938 GaimGtkConversation *gtkconv; | |
3939 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3940 GtkWidget *pane = NULL; |
3941 GtkWidget *tab_cont; | |
11581 | 3942 |
3943 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3944 conv->ui_data = gtkconv; |
3945 if (!g_list_find(gtkconv->convs, conv)) | |
3946 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3947 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3948 return; |
4359 | 3949 } |
3950 | |
11581 | 3951 gtkconv = g_new0(GaimGtkConversation, 1); |
3952 conv->ui_data = gtkconv; | |
3953 gtkconv->active_conv = conv; | |
3954 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3955 | |
3956 /* Setup some initial variables. */ | |
3957 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3958 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3959 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3960 gtkconv->unseen_count = 0; |
11581 | 3961 |
3962 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3963 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3964 | |
3965 pane = setup_im_pane(gtkconv); | |
3966 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3967 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3968 pane = setup_chat_pane(gtkconv); | |
3969 } | |
3970 | |
12101 | 3971 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
3972 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
3973 | |
11581 | 3974 if (pane == NULL) { |
3975 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
3976 g_free(gtkconv->u.chat); | |
3977 else if (conv_type == GAIM_CONV_TYPE_IM) | |
3978 g_free(gtkconv->u.im); | |
3979 | |
3980 g_free(gtkconv); | |
3981 conv->ui_data = NULL; | |
3982 return; | |
10449 | 3983 } |
11581 | 3984 |
3985 /* Setup drag-and-drop */ | |
3986 gtk_drag_dest_set(pane, | |
3987 GTK_DEST_DEFAULT_MOTION | | |
3988 GTK_DEST_DEFAULT_DROP, | |
3989 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3990 GDK_ACTION_COPY); | |
3991 gtk_drag_dest_set(pane, | |
3992 GTK_DEST_DEFAULT_MOTION | | |
3993 GTK_DEST_DEFAULT_DROP, | |
3994 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3995 GDK_ACTION_COPY); | |
3996 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
3997 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3998 GDK_ACTION_COPY); | |
3999 | |
4000 gtk_drag_dest_set(gtkconv->entry, 0, | |
4001 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4002 GDK_ACTION_COPY); | |
4003 | |
4004 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4005 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4006 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4007 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4008 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4009 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4010 | |
4011 /* Setup the container for the tab. */ | |
4012 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4013 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4014 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4015 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4016 gtk_widget_show(pane); | |
4017 | |
4018 gtkconv->make_sound = TRUE; | |
4019 | |
4020 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4021 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4022 else |
11581 | 4023 gtk_widget_hide(gtkconv->toolbar); |
4024 | |
4025 gtkconv->show_timestamps = TRUE; | |
4026 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4027 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4028 gaim_account_get_protocol_name(conv->account)); |
11581 | 4029 |
4030 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4031 G_CALLBACK(gtk_widget_grab_focus), | |
4032 gtkconv->entry); | |
4033 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4034 if (conv_type == GAIM_CONV_TYPE_IM) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4035 /* put conv in hidden_convwin if hide_new pref is always */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4036 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
|
4037 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4038 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4039 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4040 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4041 /* 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
|
4042 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
|
4043 && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4044 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4045 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4046 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4047 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4048 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4049 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4050 |
11581 | 4051 gaim_gtkconv_placement_place(gtkconv); |
4052 } | |
4053 | |
4359 | 4054 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4055 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4056 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4057 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4058 |
10810 | 4059 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4060 /* Don't destroy ourselves until all our convos are gone */ | |
4061 if (gtkconv->convs) | |
4062 return; | |
11508 | 4063 |
11581 | 4064 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4065 | |
9504 | 4066 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4067 gaim_request_close_with_handle(conv); | |
4359 | 4068 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4069 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4070 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4071 |
11338 | 4072 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4073 if (gtkconv->u.im->icon_timer != 0) |
4074 g_source_remove(gtkconv->u.im->icon_timer); | |
4075 | |
4359 | 4076 if (gtkconv->u.im->anim != NULL) |
4793 | 4077 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4078 |
4079 g_free(gtkconv->u.im); | |
11581 | 4080 } 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
|
4081 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4082 g_free(gtkconv->u.chat); |
4083 } | |
4084 | |
4633 | 4085 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4086 | |
4359 | 4087 g_free(gtkconv); |
4088 } | |
4089 | |
4090 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4091 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4092 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4093 time_t mtime) |
4359 | 4094 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4095 GaimGtkConversation *gtkconv; |
4359 | 4096 |
4097 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4098 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4099 |
6982 | 4100 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4101 } |
4102 | |
4103 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4104 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4105 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4106 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4107 GaimGtkConversation *gtkconv; |
4359 | 4108 |
4109 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4110 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4111 |
10398 | 4112 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4113 |
6982 | 4114 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4115 } |
4116 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4117 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4118 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4119 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4120 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4121 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4122 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4123 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4124 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4125 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4126 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4127 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4128 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4129 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4130 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4131 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4132 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4133 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4134 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4135 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4136 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4137 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4138 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4139 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4140 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4141 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4142 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4143 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4144 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4145 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4146 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4147 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4148 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4149 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4150 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4151 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4152 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4153 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4154 gc->prpl); |
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 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4157 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4158 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4159 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4160 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4161 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4162 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4163 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4164 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4165 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4166 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4167 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4168 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4169 return FALSE; |
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 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4173 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4174 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4175 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4176 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4177 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4178 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4179 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4180 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4181 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4182 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4183 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4184 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4185 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4186 buddytag = gtk_text_buffer_create_tag( |
11096 | 4187 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
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 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4190 G_CALLBACK(buddytag_event), conv); |
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 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4193 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4194 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4195 |
4359 | 4196 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4197 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4198 const char *message, GaimMessageFlags flags, |
4359 | 4199 time_t mtime) |
4200 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4201 GaimGtkConversation *gtkconv; |
11581 | 4202 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4203 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4204 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4205 GaimPluginProtocolInfo *prpl_info; |
4359 | 4206 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4207 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4208 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4209 int line_count; |
4359 | 4210 char buf2[BUF_LONG]; |
4211 char mdate[64]; | |
4212 char color[10]; | |
4213 char *str; | |
4214 char *with_font_tag; | |
4896 | 4215 char *sml_attrib = NULL; |
6982 | 4216 size_t length = strlen(message) + 1; |
4895 | 4217 |
4359 | 4218 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4219 |
4220 /* Set the active conversation to the one that just messaged us. */ | |
4221 /* 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
|
4222 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4223 |
4359 | 4224 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4225 account = gaim_conversation_get_account(conv); |
11581 | 4226 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4227 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4228 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4229 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4230 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4231 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4232 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4233 /* 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
|
4234 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4235 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4236 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4237 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4238 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4239 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4240 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4241 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4242 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4243 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4244 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4245 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4246 |
8677 | 4247 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4248 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4249 | |
5133 | 4250 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4251 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4252 else | |
4253 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4254 |
4896 | 4255 if(gc) |
9699 | 4256 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4257 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4258 |
10503 | 4259 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4260 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4261 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4262 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4263 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4264 |
7956 | 4265 /* this is gonna crash one day, I can feel it. */ |
4266 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4267 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4268 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4269 } |
4359 | 4270 |
10737 | 4271 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4272 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4273 g_snprintf(buf2, sizeof(buf2), |
8690 | 4274 "<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
|
4275 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4276 |
8962 | 4277 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4278 |
8722 | 4279 } else if (flags & GAIM_MESSAGE_ERROR) { |
4280 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4281 "<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
|
4282 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4283 |
8962 | 4284 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4285 | |
7431 | 4286 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4287 g_snprintf(buf2, BUF_LONG, |
8690 | 4288 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4289 sml_attrib ? sml_attrib : "", message); |
7440 | 4290 |
10884 | 4291 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4292 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4293 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4294 } else { |
4895 | 4295 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4296 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
|
4297 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4298 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4299 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
|
4300 int tag_end_offset = 0; |
7440 | 4301 |
6621 | 4302 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4303 str = g_malloc(1024); |
7440 | 4304 |
4359 | 4305 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4306 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4307 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4308 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4309 tag_start_offset += 3; |
4359 | 4310 } |
4311 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4312 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4313 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4314 tag_end_offset = 2; |
4359 | 4315 strcpy(color, "#00FF00"); |
4316 } | |
7440 | 4317 } |
4359 | 4318 else { |
10504 | 4319 if (gaim_message_meify(new_message, -1)) { |
4359 | 4320 str = g_malloc(1024); |
7440 | 4321 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4322 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4323 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
|
4324 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4325 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4326 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4327 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4328 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4329 } |
7440 | 4330 |
6621 | 4331 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4332 strcpy(color, "#AF7F00"); |
4333 else | |
4334 strcpy(color, "#062585"); | |
4335 } | |
4336 else { | |
4337 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4338 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4339 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
|
4340 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4341 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4342 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4343 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4344 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4345 } |
6621 | 4346 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4347 strcpy(color, "#AF7F00"); |
6621 | 4348 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4349 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4350 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4351 |
10108 | 4352 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4353 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4354 } else |
7854 | 4355 strcpy(color, RECV_COLOR); |
4359 | 4356 } |
6621 | 4357 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4358 strcpy(color, SEND_COLOR); |
10892 | 4359 else { |
4360 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4361 strcpy(color, "#000000"); | |
4362 } | |
4359 | 4363 } |
4364 } | |
10892 | 4365 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4366 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4367 g_free(alias_escaped); |
11508 | 4368 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4369 /* 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
|
4370 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4371 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4372 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4373 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4374 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4375 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4376 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4377 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4378 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4379 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4380 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4381 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4382 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4383 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4384 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4385 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4386 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4387 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4388 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4389 /* 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
|
4390 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4391 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4392 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4393 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4394 } |
7440 | 4395 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4396 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4397 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4398 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4399 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4400 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4401 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4402 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4403 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4404 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4405 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4406 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4407 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4408 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4409 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4410 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4411 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4412 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4413 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4414 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4415 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4416 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4417 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4418 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4419 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4420 |
4359 | 4421 g_free(str); |
4422 | |
4895 | 4423 if(gc){ |
4896 | 4424 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4425 char *post = "</font>"; |
4426 int pre_len = strlen(pre); | |
4427 int post_len = strlen(post); | |
7440 | 4428 |
4895 | 4429 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4430 |
4895 | 4431 strcpy(with_font_tag, pre); |
4432 memcpy(with_font_tag + pre_len, new_message, length); | |
4433 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4434 |
4895 | 4435 length += pre_len + post_len; |
4436 g_free(pre); | |
4437 } | |
4608 | 4438 else |
4895 | 4439 with_font_tag = g_memdup(new_message, length); |
7440 | 4440 |
8962 | 4441 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4442 with_font_tag, gtk_font_options); | |
7440 | 4443 |
4444 g_free(with_font_tag); | |
7447 | 4445 g_free(new_message); |
7440 | 4446 } |
4447 | |
5012 | 4448 if(sml_attrib) |
4449 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4450 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4451 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4452 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4453 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4454 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4455 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4456 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4457 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4458 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4459 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4460 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4461 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
|
4462 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4463 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4464 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4465 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4466 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4467 } |
4359 | 4468 } |
4469 | |
4470 static void | |
11869 | 4471 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
|
4472 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4473 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4474 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4475 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4476 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4477 GList *ll; |
11869 | 4478 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4479 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4480 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4481 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4482 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4483 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4484 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4485 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4486 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
|
4487 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4488 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4489 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4490 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4491 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4492 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4493 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4494 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4495 l = users; |
11869 | 4496 ll = flags; |
4497 lll = aliases; | |
4498 while (l != NULL && ll != NULL && lll != NULL) { | |
4499 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
|
4500 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4501 ll = ll->next; |
11869 | 4502 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4503 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4504 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4505 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4506 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4507 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
|
4508 const char *new_name, const char *new_alias) |
4359 | 4509 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4510 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4511 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4512 GaimGtkChatPane *gtkchat; |
11869 | 4513 GaimConvChatBuddyFlags flags; |
4359 | 4514 GtkTreeIter iter; |
4515 GtkTreeModel *model; | |
4516 int f = 1; | |
4517 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4518 chat = GAIM_CONV_CHAT(conv); |
4359 | 4519 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4520 gtkchat = gtkconv->u.chat; | |
4521 | |
9554 | 4522 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4523 | |
4524 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4525 return; | |
4526 | |
4527 while (f != 0) { | |
4528 char *val; | |
4529 | |
11869 | 4530 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4531 |
4532 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4533 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4534 g_free(val); | |
4359 | 4535 break; |
4536 } | |
9554 | 4537 |
4538 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4539 | |
4540 g_free(val); | |
4359 | 4541 } |
4542 | |
9554 | 4543 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4544 return; |
4545 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4546 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4547 |
11869 | 4548 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4549 } |
4550 | |
4551 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4552 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4553 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4554 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4555 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4556 GaimGtkChatPane *gtkchat; |
4359 | 4557 GtkTreeIter iter; |
4558 GtkTreeModel *model; | |
4559 char tmp[BUF_LONG]; | |
4560 int num_users; | |
4561 int f = 1; | |
4562 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4563 chat = GAIM_CONV_CHAT(conv); |
4359 | 4564 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4565 gtkchat = gtkconv->u.chat; | |
4566 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4567 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
|
4568 |
9554 | 4569 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4570 | |
4571 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4572 return; | |
4573 | |
4574 while (f != 0) { | |
4575 char *val; | |
4576 | |
4577 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4578 | |
4579 if (!gaim_utf8_strcasecmp(user, val)) { | |
4580 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4581 g_free(val); | |
4359 | 4582 break; |
4583 } | |
9554 | 4584 |
4585 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4586 | |
4587 g_free(val); | |
4359 | 4588 } |
4589 | |
9554 | 4590 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4591 return; |
4592 | |
4593 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4594 ngettext("%d person in room", "%d people in room", |
4595 num_users), num_users); | |
4359 | 4596 |
4597 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4598 | |
4599 } | |
4600 | |
4601 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4602 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4603 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4604 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4605 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4606 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4607 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4608 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4609 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4610 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4611 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4612 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4613 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4614 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4615 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4616 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4617 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4618 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
|
4619 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4620 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4621 for (l = users; l != NULL; l = l->next) { |
9554 | 4622 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4623 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4624 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4625 continue; |
4626 | |
4627 do { | |
4628 char *val; | |
4629 | |
4630 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4631 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4632 | |
9696 | 4633 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4634 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4635 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4636 #else |
4637 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4638 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4639 #endif | |
4640 } | |
9554 | 4641 else |
4642 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4643 | |
4644 g_free(val); | |
4645 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4646 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4647 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4648 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4649 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4650 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4651 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4652 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4653 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4654 |
9554 | 4655 static void |
4656 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4657 { | |
4658 GaimConvChat *chat; | |
11869 | 4659 GaimConvChatBuddyFlags flags; |
9554 | 4660 GaimGtkConversation *gtkconv; |
4661 GaimGtkChatPane *gtkchat; | |
4662 GtkTreeIter iter; | |
4663 GtkTreeModel *model; | |
4664 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4665 char *alias = NULL; |
9554 | 4666 |
4667 chat = GAIM_CONV_CHAT(conv); | |
4668 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4669 gtkchat = gtkconv->u.chat; | |
4670 | |
4671 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4672 | |
4673 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4674 return; | |
4675 | |
4676 while (f != 0) { | |
4677 char *val; | |
4678 | |
4679 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4680 | |
4681 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4682 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4683 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4684 g_free(val); | |
4685 break; | |
4686 } | |
4687 | |
4688 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4689 | |
4690 g_free(val); | |
4691 } | |
4692 | |
4693 if (!gaim_conv_chat_find_user(chat, user)) | |
4694 return; | |
4695 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4696 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4697 |
11869 | 4698 flags = gaim_conv_chat_user_get_flags(chat, user); |
4699 | |
4700 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4701 g_free(alias); |
9554 | 4702 } |
4703 | |
11581 | 4704 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4705 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4706 { |
11581 | 4707 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4708 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4709 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4710 |
11581 | 4711 win = gtkconv->win; |
4712 | |
4713 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
|
4714 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4715 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4716 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4717 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4718 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4719 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4720 |
10526 | 4721 static gboolean |
4722 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4723 { | |
4724 GaimGtkConversation *gtkconv; | |
4725 GtkIMHtmlSmiley *smiley; | |
4726 GdkPixbufLoader *loader; | |
11525 | 4727 struct smiley_list *list; |
4728 const char *sml = NULL, *conv_sml; | |
4729 | |
4730 if (!conv || !smile || !*smile) { | |
10526 | 4731 return FALSE; |
4732 } | |
4733 | |
11525 | 4734 /* If smileys are off, return false */ |
4735 if (gaim_gtkthemes_smileys_disabled()) | |
4736 return FALSE; | |
4737 | |
4738 /* If possible add this smiley to the current theme. | |
4739 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4740 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4741 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4742 |
4743 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4744 if (!strcmp(list->sml, conv_sml)) { | |
4745 sml = list->sml; | |
4746 break; | |
4747 } | |
4748 } | |
4749 | |
10526 | 4750 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4751 | |
4752 if (smiley) { | |
11525 | 4753 |
4754 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4755 return FALSE; | |
4756 } | |
4757 | |
4758 /* Close the old GdkPixbufAnimation, then create a new one for | |
4759 * the smiley we are about to receive */ | |
4760 g_object_unref(G_OBJECT(smiley->icon)); | |
4761 | |
4762 smiley->loader = gdk_pixbuf_loader_new(); | |
4763 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4764 if (smiley->icon) | |
4765 g_object_ref(G_OBJECT(smiley->icon)); | |
4766 | |
4767 /* A custom smiley is already associated */ | |
4768 return TRUE; | |
10526 | 4769 } |
4770 | |
4771 loader = gdk_pixbuf_loader_new(); | |
4772 | |
4773 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4774 /* 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
|
4775 GtkIMHtmlSmiley by opaque */ |
10526 | 4776 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4777 smiley->file = NULL; | |
4778 smiley->smile = g_strdup(smile); | |
4779 smiley->loader = loader; | |
11525 | 4780 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4781 |
4782 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4783 if (smiley->icon) | |
4784 g_object_ref(G_OBJECT(smiley->icon)); | |
4785 | |
11525 | 4786 |
10526 | 4787 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4788 |
10526 | 4789 return TRUE; |
4790 } | |
4791 | |
10537 | 4792 static void |
10526 | 4793 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4794 const guchar *data, gsize size) |
10526 | 4795 { |
4796 GaimGtkConversation *gtkconv; | |
4797 GtkIMHtmlSmiley *smiley; | |
10537 | 4798 GdkPixbufLoader *loader; |
10526 | 4799 const char *sml; |
4800 | |
4801 sml = gaim_account_get_protocol_name(conv->account); | |
4802 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4803 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4804 | |
10537 | 4805 if (!smiley) |
10526 | 4806 return; |
10537 | 4807 |
10526 | 4808 loader = smiley->loader; |
10537 | 4809 if (!loader) |
10526 | 4810 return; |
4811 | |
4812 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4813 } | |
4814 | |
4815 static void | |
4816 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4817 { | |
4818 GaimGtkConversation *gtkconv; | |
4819 GtkIMHtmlSmiley *smiley; | |
4820 GdkPixbufLoader *loader; | |
4821 const char *sml; | |
11525 | 4822 GtkWidget *icon = NULL; |
4823 GtkTextChildAnchor *anchor = NULL; | |
4824 GtkTextIter end; | |
4825 GtkIMHtml *imhtml; | |
4826 GSList *current = NULL; | |
10526 | 4827 |
4828 g_return_if_fail(conv != NULL); | |
4829 g_return_if_fail(smile != NULL); | |
4830 | |
4831 sml = gaim_account_get_protocol_name(conv->account); | |
4832 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4833 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4834 | |
10537 | 4835 if (!smiley) |
10526 | 4836 return; |
4837 | |
4838 loader = smiley->loader; | |
4839 | |
10537 | 4840 if (!loader) |
10526 | 4841 return; |
10537 | 4842 |
11525 | 4843 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4844 if (smiley->icon) | |
4845 g_object_ref(G_OBJECT(smiley->icon)); | |
4846 | |
4847 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4848 | |
4849 icon = gtk_image_new_from_animation(smiley->icon); | |
4850 | |
4851 if (icon) { | |
12047 | 4852 gtk_widget_show(icon); |
4853 | |
11525 | 4854 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
4855 | |
4856 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4857 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4858 | |
4859 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4860 } | |
4861 | |
4862 } | |
4863 | |
4864 g_slist_free(smiley->anchors); | |
4865 smiley->anchors = NULL; | |
4866 | |
4867 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4868 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4869 * makes me question it */ | |
4870 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4871 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4872 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4873 | |
10526 | 4874 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4875 | |
4876 gdk_pixbuf_loader_close(loader, NULL); | |
4877 g_object_unref(G_OBJECT(loader)); | |
4878 smiley->loader = NULL; | |
4879 } | |
4880 | |
11581 | 4881 /* |
4882 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4883 * sensitive/insensitive. This is called after changing tabs and when an | |
4884 * account signs on or off. | |
4885 */ | |
4886 static void | |
4887 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4888 { | |
4889 GaimGtkWindow *win; | |
4890 GaimConversation *conv = gtkconv->active_conv; | |
4891 GaimConnection *gc; | |
4892 GaimPluginProtocolInfo *prpl_info = NULL; | |
4893 GdkPixbuf *window_icon = NULL; | |
4894 GtkIMHtmlButtons buttons; | |
4895 GaimAccount *account; | |
4896 | |
4897 win = gaim_gtkconv_get_window(gtkconv); | |
4898 gc = gaim_conversation_get_gc(conv); | |
4899 account = gaim_conversation_get_account(conv); | |
4900 | |
4901 if (gc != NULL) | |
4902 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4903 | |
11594 | 4904 if (win->menu.send_to != NULL) |
11734 | 4905 update_send_to_selection(win); |
11581 | 4906 |
4907 /* | |
4908 * Handle hiding and showing stuff based on what type of conv this is. | |
4909 * Stuff that Gaim IMs support in general should be shown for IM | |
4910 * conversations. Stuff that Gaim chats support in general should be | |
4911 * shown for chat conversations. It doesn't matter whether the PRPL | |
4912 * supports it or not--that only affects if the button or menu item | |
4913 * is sensitive or not. | |
4914 */ | |
4915 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4916 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4917 | |
4918 /* Deal with menu items */ | |
4919 gtk_widget_show(win->menu.view_log); | |
4920 gtk_widget_show(win->menu.send_file); | |
4921 gtk_widget_show(win->menu.add_pounce); | |
4922 gtk_widget_show(win->menu.get_info); | |
4923 gtk_widget_hide(win->menu.invite); | |
4924 gtk_widget_show(win->menu.alias); | |
4925 gtk_widget_show(win->menu.block); | |
4926 | |
4927 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4928 gtk_widget_show(win->menu.add); | |
4929 gtk_widget_hide(win->menu.remove); | |
4930 } else { | |
4931 gtk_widget_show(win->menu.remove); | |
4932 gtk_widget_hide(win->menu.add); | |
4933 } | |
4934 | |
4935 gtk_widget_show(win->menu.insert_link); | |
4936 gtk_widget_show(win->menu.insert_image); | |
4937 gtk_widget_show(win->menu.show_icon); | |
4938 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4939 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4940 | |
4941 /* Deal with menu items */ | |
4942 gtk_widget_show(win->menu.view_log); | |
4943 gtk_widget_hide(win->menu.send_file); | |
4944 gtk_widget_hide(win->menu.add_pounce); | |
4945 gtk_widget_hide(win->menu.get_info); | |
4946 gtk_widget_show(win->menu.invite); | |
4947 gtk_widget_show(win->menu.alias); | |
4948 gtk_widget_hide(win->menu.block); | |
4949 gtk_widget_hide(win->menu.show_icon); | |
4950 | |
4951 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4952 /* If the chat is NOT in the buddy list */ | |
4953 gtk_widget_show(win->menu.add); | |
4954 gtk_widget_hide(win->menu.remove); | |
4955 } else { | |
4956 /* If the chat IS in the buddy list */ | |
4957 gtk_widget_hide(win->menu.add); | |
4958 gtk_widget_show(win->menu.remove); | |
4959 } | |
4960 | |
4961 gtk_widget_show(win->menu.insert_link); | |
4962 gtk_widget_hide(win->menu.insert_image); | |
4963 } | |
4964 | |
4965 /* | |
4966 * Handle graying stuff out based on whether an account is connected | |
4967 * and what features that account supports. | |
4968 */ | |
4969 if ((gc != NULL) && | |
12012 | 4970 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
4971 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
4972 { | |
11581 | 4973 /* Account is online */ |
4974 /* Deal with the toolbar */ | |
12012 | 4975 if (conv->features & GAIM_CONNECTION_HTML) |
4976 { | |
4977 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
4978 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
4979 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
4980 buttons &= ~GTK_IMHTML_IMAGE; | |
4981 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
4982 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
4983 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
4984 { | |
4985 buttons &= ~GTK_IMHTML_GROW; | |
4986 buttons &= ~GTK_IMHTML_SHRINK; | |
4987 } | |
4988 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
4989 buttons &= ~GTK_IMHTML_LINKDESC; | |
4990 } else { | |
4991 buttons = GTK_IMHTML_SMILEY; | |
4992 } | |
4993 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
4994 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 4995 |
4996 /* Deal with menu items */ | |
12012 | 4997 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4998 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4999 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5000 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5001 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5002 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5003 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5004 |
5005 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5006 { | |
5007 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5008 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5009 gtk_widget_set_sensitive(win->menu.send_file, | |
5010 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5011 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5012 gtk_widget_set_sensitive(win->menu.alias, | |
5013 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
5014 } | |
5015 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5016 { | |
5017 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5018 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5019 gtk_widget_set_sensitive(win->menu.alias, | |
5020 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
5021 } | |
11581 | 5022 |
5023 /* Deal with chat userlist buttons */ | |
12012 | 5024 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5025 { | |
5026 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5027 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5028 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5029 } | |
5030 } else { | |
11581 | 5031 /* Account is offline */ |
5032 /* Or it's a chat that we've left. */ | |
5033 | |
5034 /* Then deal with menu items */ | |
12012 | 5035 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5036 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5037 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5038 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5039 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5040 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5041 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5042 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5043 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5044 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5045 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5046 |
5047 /* Deal with chat userlist buttons */ | |
12012 | 5048 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5049 { | |
5050 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5051 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5052 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5053 } | |
5054 } | |
11581 | 5055 |
5056 /* | |
5057 * Update the window's icon | |
5058 */ | |
12171 | 5059 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5060 { |
12171 | 5061 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5062 (gtkconv->u.im->anim)) | |
5063 { | |
5064 window_icon = | |
5065 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5066 g_object_ref(window_icon); | |
5067 } else { | |
5068 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5069 } | |
5070 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5071 if (window_icon != NULL) | |
5072 g_object_unref(G_OBJECT(window_icon)); | |
5073 } | |
11581 | 5074 } |
5075 | |
10526 | 5076 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5077 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5078 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5079 { |
11581 | 5080 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5081 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5082 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5083 GaimConvChat *chat; |
4359 | 5084 |
10116 | 5085 g_return_if_fail(conv != NULL); |
5086 | |
4359 | 5087 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5088 win = gtkconv->win; |
10810 | 5089 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5090 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5091 * instead of the gross hack? | |
5092 */ | |
4359 | 5093 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5094 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5095 { |
4359 | 5096 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5097 |
11338 | 5098 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5099 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5100 |
4359 | 5101 gaim_gtkconv_update_buttons_by_protocol(conv); |
5102 | |
11734 | 5103 update_send_to_selection(win); |
4359 | 5104 |
11525 | 5105 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5106 |
6395 | 5107 update_tab_icon(conv); |
4359 | 5108 } |
5109 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5110 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5111 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5112 { |
9472 | 5113 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5114 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5115 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5116 /* 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
|
5117 char style[51]; |
4736 | 5118 |
11338 | 5119 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5120 im = GAIM_CONV_IM(conv); |
4359 | 5121 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5122 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5123 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5124 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5125 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5126 else | |
5127 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5128 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5129 *style = '\0'; |
4359 | 5130 |
5131 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5132 gtk_widget_realize(gtkconv->tab_label); | |
5133 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5134 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5135 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5136 { |
11759 | 5137 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5138 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5139 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5140 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5141 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5142 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5143 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5144 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5145 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5146 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5147 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5148 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5149 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5150 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5151 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5152 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5153 { |
11758 | 5154 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5155 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5156 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5157 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5158 { |
8536 | 5159 char *html_title,*label; |
5160 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5161 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5162 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5163 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5164 style, html_title); |
8536 | 5165 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5166 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5167 g_free(label); |
4359 | 5168 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5169 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5170 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5171 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5172 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5173 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5174 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5175 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5176 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5177 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5178 gtk_window_set_title(GTK_WINDOW(win->window), title); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5179 } |
9472 | 5180 |
5181 g_free(title); | |
4359 | 5182 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5183 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5184 { |
7154 | 5185 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5186 chat = GAIM_CONV_CHAT(conv); |
4359 | 5187 gtkchat = gtkconv->u.chat; |
5188 | |
7154 | 5189 topic = gaim_conv_chat_get_topic(chat); |
5190 | |
9554 | 5191 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5192 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5193 topic ? topic : "", NULL); |
4359 | 5194 } |
5195 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5196 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5197 { |
11581 | 5198 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5199 generate_send_to_items(win); |
8946 | 5200 update_tab_icon(conv); |
9472 | 5201 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5202 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5203 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5204 { |
8946 | 5205 update_tab_icon(conv); |
4359 | 5206 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5207 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
|
5208 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5209 { |
9472 | 5210 gaim_conversation_autoset_title(conv); |
10810 | 5211 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5212 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5213 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5214 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5215 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5216 } |
10665 | 5217 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5218 { | |
10810 | 5219 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5220 } |
4359 | 5221 } |
5222 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5223 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5224 { |
11581 | 5225 gaim_gtkconv_new, |
4359 | 5226 gaim_gtkconv_destroy, /* destroy_conversation */ |
5227 gaim_gtkconv_write_chat, /* write_chat */ | |
5228 gaim_gtkconv_write_im, /* write_im */ | |
5229 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5230 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5231 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5232 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5233 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5234 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5235 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5236 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5237 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5238 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5239 gaim_gtkconv_updated /* updated */ |
5240 }; | |
5241 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5242 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5243 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5244 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5245 return &conversation_ui_ops; |
4359 | 5246 } |
5247 | |
5248 /************************************************************************** | |
5249 * Public conversation utility functions | |
5250 **************************************************************************/ | |
5251 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5252 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5253 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5254 GaimGtkConversation *gtkconv; |
11581 | 5255 GaimGtkWindow *win; |
4359 | 5256 |
10381 | 5257 GdkPixbufLoader *loader; |
5258 GdkPixbufAnimation *anim; | |
4359 | 5259 GError *err = NULL; |
5260 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5261 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5262 size_t len; |
4359 | 5263 |
5264 GdkPixbuf *buf; | |
5265 | |
5266 GtkWidget *event; | |
5267 GtkWidget *frame; | |
5268 GdkPixbuf *scale; | |
5269 GdkPixmap *pm; | |
5270 GdkBitmap *bm; | |
9318 | 5271 int scale_width, scale_height; |
5272 | |
5273 GaimAccount *account; | |
5274 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5275 |
9324 | 5276 GaimBuddyIcon *icon; |
5277 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5278 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5279 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5280 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5281 |
5282 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5283 win = gtkconv->win; |
10175 | 5284 |
9687 | 5285 if (!gtkconv->u.im->show_icon) |
5286 return; | |
5287 | |
9318 | 5288 account = gaim_conversation_get_account(conv); |
5289 if(account && account->gc) | |
5290 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5291 |
9845 | 5292 /* Remove the current icon stuff */ |
9885 | 5293 if (gtkconv->u.im->icon_container != NULL) |
5294 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5295 gtkconv->u.im->icon_container = NULL; | |
9845 | 5296 |
5297 if (gtkconv->u.im->anim != NULL) | |
5298 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5299 | |
9887 | 5300 gtkconv->u.im->anim = NULL; |
5301 | |
9845 | 5302 if (gtkconv->u.im->icon_timer != 0) |
5303 g_source_remove(gtkconv->u.im->icon_timer); | |
5304 | |
5305 gtkconv->u.im->icon_timer = 0; | |
5306 | |
5307 if (gtkconv->u.im->iter != NULL) | |
5308 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5309 |
10116 | 5310 gtkconv->u.im->iter = NULL; |
5311 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5312 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5313 return; |
5314 | |
5315 if (gaim_conversation_get_gc(conv) == NULL) | |
5316 return; | |
5317 | |
9324 | 5318 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5319 | |
5320 if (icon == NULL) | |
5321 return; | |
5322 | |
5323 data = gaim_buddy_icon_get_data(icon, &len); | |
5324 | |
10381 | 5325 loader = gdk_pixbuf_loader_new(); |
5326 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5327 anim = gdk_pixbuf_loader_get_animation(loader); | |
5328 if (anim) | |
5329 g_object_ref(G_OBJECT(anim)); | |
5330 gdk_pixbuf_loader_close(loader, &err); | |
5331 g_object_unref(loader); | |
5332 | |
5333 if (!anim) | |
9324 | 5334 return; |
10381 | 5335 gtkconv->u.im->anim = anim; |
9324 | 5336 |
4359 | 5337 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5338 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5339 "Buddy icon error: %s\n", err->message); |
4359 | 5340 g_error_free(err); |
5341 } | |
5342 | |
5343 if (!gtkconv->u.im->anim) | |
5344 return; | |
5345 | |
5346 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5347 gtkconv->u.im->iter = NULL; | |
5348 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5349 } else { | |
5350 gtkconv->u.im->iter = | |
8496 | 5351 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5352 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5353 if (gtkconv->u.im->animate) |
10810 | 5354 start_anim(NULL, gtkconv); |
4359 | 5355 } |
5356 | |
10483 | 5357 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5358 NULL, &scale_width, &scale_height); |
4359 | 5359 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5360 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5361 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5362 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5363 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5364 GDK_INTERP_BILINEAR); |
4359 | 5365 |
5366 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5367 g_object_unref(G_OBJECT(scale)); |
4359 | 5368 |
8821 | 5369 |
9885 | 5370 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5371 |
4359 | 5372 frame = gtk_frame_new(NULL); |
5373 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5374 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5375 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5376 FALSE, FALSE, 0); | |
8821 | 5377 |
4359 | 5378 event = gtk_event_box_new(); |
5379 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5380 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5381 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5382 gtk_widget_show(event); |
5383 | |
4635 | 5384 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5385 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5386 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5387 gtk_widget_show(gtkconv->u.im->icon); | |
5388 | |
4793 | 5389 g_object_unref(G_OBJECT(pm)); |
4359 | 5390 |
5391 if (bm) | |
4793 | 5392 g_object_unref(G_OBJECT(bm)); |
7143 | 5393 |
10356 | 5394 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5395 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5396 |
9885 | 5397 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5398 gtk_widget_show(frame); |
5399 | |
7143 | 5400 /* The buddy icon code needs badly to be fixed. */ |
5401 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
|
5402 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5403 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5404 } |
5405 | |
5406 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5407 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5408 { |
11581 | 5409 GaimGtkWindow *win; |
4359 | 5410 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5411 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5412 return; |
5413 | |
11581 | 5414 win = GAIM_GTK_CONVERSATION(conv)->win; |
5415 | |
5416 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5417 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5418 } |
5419 | |
5420 int | |
11614 | 5421 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5422 { |
4359 | 5423 gint nb_x, nb_y, x_rel, y_rel; |
5424 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5425 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5426 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5427 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5428 gboolean horiz; |
4359 | 5429 |
11614 | 5430 if (to_right) |
5431 *to_right = FALSE; | |
5432 | |
11581 | 5433 notebook = GTK_NOTEBOOK(win->notebook); |
5434 | |
5435 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5436 x_rel = x - nb_x; |
5437 y_rel = y - nb_y; | |
5438 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5439 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5440 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5441 |
11780 | 5442 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5443 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5444 #else |
5445 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5446 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5447 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5448 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5449 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5450 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5451 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5452 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5453 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5454 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5455 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5456 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
|
5457 page_num = i; |
11614 | 5458 |
5459 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5460 *to_right = TRUE; | |
5461 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5462 break; |
4359 | 5463 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5464 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5465 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5466 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
|
5467 page_num = i; |
11614 | 5468 |
5469 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5470 *to_right = TRUE; | |
5471 | |
4359 | 5472 break; |
5473 } | |
5474 } | |
5475 } | |
5476 | |
5477 return page_num; | |
5478 } | |
5479 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5480 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5481 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
|
5482 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5483 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5484 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5485 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5486 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5487 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5488 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5489 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5490 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5491 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5492 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5493 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5494 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5495 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5496 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5497 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5498 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5499 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5500 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5501 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5502 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5503 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5504 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5505 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5506 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5507 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5508 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5509 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5510 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5511 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5512 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5513 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5514 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5515 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5516 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5517 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5518 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5519 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5520 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5521 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5522 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5523 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5524 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5525 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5526 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5527 } |
5674
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 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5530 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5531 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5532 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5533 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5534 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5535 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5536 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5537 GtkPositionType pos; |
11581 | 5538 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5539 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5540 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5541 |
11581 | 5542 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5543 win = l->data; | |
5544 | |
11619 | 5545 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
|
5546 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5547 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5548 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5549 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5550 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5551 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5552 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5553 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5554 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5555 GaimGtkConversation *gtkconv; |
11581 | 5556 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5557 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5558 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5559 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5560 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5561 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5562 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5563 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5564 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5565 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5566 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5567 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5568 gtk_check_menu_item_set_active( |
11581 | 5569 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5570 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5571 |
5572 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5573 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5574 else |
8317 | 5575 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5576 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5577 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5578 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5579 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5580 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5581 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5582 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5583 GList *l; |
8189 | 5584 GaimConversation *conv; |
5585 GaimGtkConversation *gtkconv; | |
11581 | 5586 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5587 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5588 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
|
5589 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5590 |
8189 | 5591 /* Set the "animate" flag for each icon based on the new preference */ |
5592 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5593 conv = (GaimConversation *)l->data; | |
5594 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5595 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5596 } |
8189 | 5597 |
5598 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5599 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5600 win = l->data; | |
5601 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5602 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5603 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5604 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5605 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5606 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5607 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
|
5608 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5609 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5610 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5611 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5612 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5613 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5614 |
11338 | 5615 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5616 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5617 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5618 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5619 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5620 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5621 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5622 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5623 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5624 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5625 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5626 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5627 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5628 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5629 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5630 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5631 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5632 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5633 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5634 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5635 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
|
5636 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5637 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5638 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
|
5639 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5640 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5641 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
|
5642 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5643 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5644 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5645 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5646 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5647 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5648 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5649 if(gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5650 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5651 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5652 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5653 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5654 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5655 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5656 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5657 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5658 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5659 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5660 hide_new_pref_cb(const char *name, GaimPrefType type, gpointer value, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5661 gpointer data) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5662 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5663 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5664 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5665 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5666 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5667 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5668 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5669 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5670 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5671 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
|
5672 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5673 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5674 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
|
5675 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5676 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5677 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5678 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5679 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5680 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5681 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5682 if(when_away && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5683 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5684 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5685 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5686 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5687 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5688 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5689 } |
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 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5692 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5693 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5694 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5695 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5696 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5697 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5698 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5699 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5700 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5701 |
11581 | 5702 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5703 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5704 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5705 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5706 |
11581 | 5707 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5708 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5709 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5710 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5711 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5712 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5713 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5714 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5715 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5716 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5717 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5718 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5719 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5720 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5721 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5722 if (gaim_conversation_get_account(conv) == account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5723 gaim_conversation_update(conv, GPOINTER_TO_INT(event)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5724 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5725 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5726 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5727 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5728 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5729 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5730 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5731 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5732 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5733 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5734 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5735 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5736 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5737 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5738 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5739 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5740 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5741 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5742 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5743 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5744 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5745 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5746 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5747 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5748 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5749 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5750 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5751 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5752 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5753 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5754 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5755 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5756 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5757 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5758 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5759 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5760 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
|
5761 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5762 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5763 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5764 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5765 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5766 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5767 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5768 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5769 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5770 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5771 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5772 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5773 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5774 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5775 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5776 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5777 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
|
5778 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5779 /* convert old queuing prefs to hide_new 3-way pref */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5780 if(gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5781 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5782 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "always"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5783 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5784 else if(gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5785 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5786 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "away"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5787 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5788 else { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5789 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5790 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5791 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5792 /* Connect callbacks. */ |
10087 | 5793 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
|
5794 close_on_tabs_pref_cb, NULL); |
10087 | 5795 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
|
5796 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5797 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5798 spellcheck_pref_cb, NULL); |
10087 | 5799 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5800 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5801 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5802 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5803 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5804 |
10087 | 5805 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5806 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5807 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5808 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5809 /* IM callbacks */ |
10087 | 5810 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
|
5811 animate_buddy_icons_pref_cb, NULL); |
10087 | 5812 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
|
5813 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5814 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5815 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5816 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5817 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5818 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5819 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5820 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5821 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5822 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5823 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5824 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5825 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5826 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5827 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5828 |
5829 /********************************************************************** | |
5830 * Register commands | |
5831 **********************************************************************/ | |
9829 | 5832 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5833 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5834 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5835 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5836 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5837 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5838 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5839 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5840 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
|
5841 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5842 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5843 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5844 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5845 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5846 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5847 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5848 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5849 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5850 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5851 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5852 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5853 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5854 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5855 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5856 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5857 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5858 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5859 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5860 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5861 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5862 G_CALLBACK(buddy_update_cb), NULL); |
5863 | |
11581 | 5864 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5865 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5866 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5867 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5868 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5869 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5870 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
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 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5874 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5875 { |
10443 | 5876 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5877 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5878 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5879 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5880 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5881 } |
11581 | 5882 |
5883 | |
5884 | |
5885 | |
5886 | |
5887 | |
5888 | |
5889 | |
5890 | |
5891 | |
5892 | |
5893 | |
5894 | |
5895 | |
5896 | |
5897 | |
5898 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5899 * and touch each others' private members all day long */ | |
5900 | |
5901 /** | |
5902 * @file gtkconvwin.c GTK+ Conversation Window API | |
5903 * @ingroup gtkui | |
5904 * | |
5905 * gaim | |
5906 * | |
5907 * Gaim is the legal property of its developers, whose names are too numerous | |
5908 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5909 * source distribution. | |
5910 * | |
5911 * This program is free software; you can redistribute it and/or modify | |
5912 * it under the terms of the GNU General Public License as published by | |
5913 * the Free Software Foundation; either version 2 of the License, or | |
5914 * (at your option) any later version. | |
5915 * | |
5916 * This program is distributed in the hope that it will be useful, | |
5917 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
5918 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
5919 * GNU General Public License for more details. | |
5920 * | |
5921 * You should have received a copy of the GNU General Public License | |
5922 * along with this program; if not, write to the Free Software | |
5923 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5924 * | |
5925 */ | |
5926 #include "internal.h" | |
5927 #include "gtkgaim.h" | |
5928 | |
5929 | |
5930 #include <gdk/gdkkeysyms.h> | |
5931 | |
5932 #include "account.h" | |
5933 #include "cmds.h" | |
5934 #include "debug.h" | |
5935 #include "imgstore.h" | |
5936 #include "log.h" | |
5937 #include "notify.h" | |
5938 #include "prpl.h" | |
5939 #include "request.h" | |
5940 #include "util.h" | |
5941 | |
5942 #include "gtkdnd-hints.h" | |
5943 #include "gtkblist.h" | |
5944 #include "gtkconv.h" | |
5945 #include "gtkdialogs.h" | |
5946 #include "gtkmenutray.h" | |
5947 #include "gtkpounce.h" | |
5948 #include "gtkprefs.h" | |
5949 #include "gtkprivacy.h" | |
5950 #include "gtkutils.h" | |
5951 #include "gtkstock.h" | |
5952 #include "gtkimhtml.h" | |
5953 #include "gtkimhtmltoolbar.h" | |
5954 | |
5955 static void | |
5956 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
5957 { | |
5958 gtk_widget_destroy(warn_close_dialog); | |
5959 warn_close_dialog = NULL; | |
5960 | |
5961 if (resp == GTK_RESPONSE_OK) | |
5962 gaim_gtk_conv_window_destroy(win); | |
5963 } | |
5964 | |
5965 static void | |
5966 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
5967 { | |
5968 GtkWidget *label; | |
5969 GtkWidget *vbox, *hbox; | |
5970 GtkWidget *img; | |
5971 | |
5972 g_return_if_fail(warn_close_dialog == NULL); | |
5973 | |
5974 | |
5975 warn_close_dialog = gtk_dialog_new_with_buttons( | |
5976 _("Confirm close"), | |
5977 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
5978 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
5979 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
5980 | |
5981 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
5982 GTK_RESPONSE_OK); | |
5983 | |
5984 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
5985 6); | |
5986 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
5987 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
5988 FALSE); | |
5989 | |
5990 /* Setup the outside spacing. */ | |
5991 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
5992 | |
5993 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
5994 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
5995 | |
5996 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
5997 GTK_ICON_SIZE_DIALOG); | |
5998 /* Setup the inner hbox and put the dialog's icon in it. */ | |
5999 hbox = gtk_hbox_new(FALSE, 12); | |
6000 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6001 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6002 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6003 | |
6004 /* Setup the right vbox. */ | |
6005 vbox = gtk_vbox_new(FALSE, 12); | |
6006 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6007 | |
6008 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6009 gtk_widget_set_size_request(label, 350, -1); | |
6010 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6011 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6012 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6013 | |
6014 /* Connect the signals. */ | |
6015 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6016 G_CALLBACK(do_close), gtkwin); | |
6017 | |
6018 } | |
6019 | |
6020 /************************************************************************** | |
6021 * Callbacks | |
6022 **************************************************************************/ | |
6023 | |
6024 static gboolean | |
6025 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6026 { | |
6027 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6028 GList *l; |
11581 | 6029 |
6030 /* If there are unread messages then show a warning dialog */ | |
6031 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6032 l != NULL; l = l->next) | |
6033 { | |
6034 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6035 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
|
6036 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6037 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6038 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6039 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6040 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6041 return TRUE; |
11581 | 6042 } |
6043 } | |
6044 | |
6045 gaim_gtk_conv_window_destroy(win); | |
6046 | |
6047 return TRUE; | |
6048 } | |
6049 | |
11604 | 6050 static void |
6051 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6052 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6053 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6054 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6055 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6056 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6057 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6058 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6059 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6060 gtkconv->unseen_count++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6061 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6062 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6063 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6064 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6065 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6066 /* 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
|
6067 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
|
6068 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6069 |
11581 | 6070 /* |
6071 * When a conversation window is focused, we know the user | |
6072 * has looked at it so we know there are no longer unseen | |
6073 * messages. | |
6074 */ | |
6075 static gint | |
6076 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6077 { | |
6078 GaimGtkWindow *win = d; | |
11604 | 6079 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6080 | |
6081 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6082 |
6083 return FALSE; | |
6084 } | |
6085 | |
11851 | 6086 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6087 /* Courtesy of Galeon! */ |
6088 static void | |
6089 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6090 { | |
6091 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6092 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6093 } | |
11851 | 6094 #endif |
11581 | 6095 |
6096 static void | |
6097 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6098 { | |
6099 static GdkCursor *cursor = NULL; | |
6100 | |
6101 gtkwin->in_drag = TRUE; | |
6102 | |
6103 if (gtkwin->drag_leave_signal) { | |
6104 g_signal_handler_disconnect(G_OBJECT(widget), | |
6105 gtkwin->drag_leave_signal); | |
6106 gtkwin->drag_leave_signal = 0; | |
6107 } | |
6108 | |
6109 if (cursor == NULL) | |
6110 cursor = gdk_cursor_new(GDK_FLEUR); | |
6111 | |
6112 /* Grab the pointer */ | |
6113 gtk_grab_add(gtkwin->notebook); | |
6114 #ifndef _WIN32 | |
6115 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6116 always be true after a button press. */ | |
6117 if (!gdk_pointer_is_grabbed()) | |
6118 #endif | |
6119 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6120 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6121 NULL, cursor, GDK_CURRENT_TIME); | |
6122 } | |
6123 | |
6124 static gboolean | |
6125 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6126 { | |
6127 | |
6128 /* | |
6129 * Make sure the user moved the mouse far enough for the | |
6130 * drag to be initiated. | |
6131 */ | |
6132 if (win->in_predrag) { | |
6133 if (e->x_root < win->drag_min_x || | |
6134 e->x_root >= win->drag_max_x || | |
6135 e->y_root < win->drag_min_y || | |
6136 e->y_root >= win->drag_max_y) { | |
6137 | |
6138 win->in_predrag = FALSE; | |
6139 notebook_init_grab(win, widget); | |
6140 } | |
6141 } | |
6142 else { /* Otherwise, draw the arrows. */ | |
6143 GaimGtkWindow *dest_win; | |
6144 GtkNotebook *dest_notebook; | |
6145 GtkWidget *tab; | |
6146 gint nb_x, nb_y, page_num; | |
6147 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6148 gboolean horiz_tabs = FALSE; | |
11614 | 6149 GaimGtkConversation *gtkconv; |
6150 gboolean to_right = FALSE; | |
11581 | 6151 |
6152 /* Get the window that the cursor is over. */ | |
6153 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6154 | |
6155 if (dest_win == NULL) { | |
6156 dnd_hints_hide_all(); | |
6157 | |
6158 return TRUE; | |
6159 } | |
6160 | |
6161 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6162 | |
6163 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6164 | |
6165 arrow1_x = arrow2_x = nb_x; | |
6166 arrow1_y = arrow2_y = nb_y; | |
6167 | |
6168 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6169 e->x_root, e->y_root, &to_right); |
6170 to_right = to_right && (win != dest_win); | |
11581 | 6171 |
6172 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6173 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6174 | |
6175 horiz_tabs = TRUE; | |
6176 } | |
6177 | |
11614 | 6178 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6179 tab = gtkconv->tabby; | |
11581 | 6180 |
6181 if (horiz_tabs) { | |
6182 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6183 | |
11614 | 6184 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6185 arrow1_x += tab->allocation.width; |
6186 arrow2_x += tab->allocation.width; | |
6187 } | |
6188 | |
6189 arrow1_y = nb_y + tab->allocation.y; | |
6190 arrow2_y = nb_y + tab->allocation.y + | |
6191 tab->allocation.height; | |
6192 } else { | |
6193 arrow1_x = nb_x + tab->allocation.x; | |
6194 arrow2_x = nb_x + tab->allocation.x + | |
6195 tab->allocation.width; | |
6196 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
6197 | |
6198 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
6199 arrow1_y += tab->allocation.height; | |
6200 arrow2_y += tab->allocation.height; | |
6201 } | |
6202 } | |
6203 | |
6204 if (horiz_tabs) { | |
6205 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6206 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6207 } else { | |
6208 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6209 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6210 } | |
6211 } | |
6212 | |
6213 return TRUE; | |
6214 } | |
6215 | |
6216 static gboolean | |
6217 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6218 { | |
6219 if (win->in_drag) | |
6220 return FALSE; | |
6221 | |
6222 if (e->x_root < win->drag_min_x || | |
6223 e->x_root >= win->drag_max_x || | |
6224 e->y_root < win->drag_min_y || | |
6225 e->y_root >= win->drag_max_y) { | |
6226 | |
6227 win->in_predrag = FALSE; | |
6228 notebook_init_grab(win, widget); | |
6229 } | |
6230 | |
6231 return TRUE; | |
6232 } | |
6233 | |
6234 /* | |
6235 * THANK YOU GALEON! | |
6236 */ | |
6237 static gboolean | |
6238 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6239 { | |
6240 gint nb_x, nb_y, x_rel, y_rel; | |
6241 int tab_clicked; | |
6242 GtkWidget *page; | |
6243 GtkWidget *tab; | |
6244 | |
6245 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6246 return FALSE; | |
6247 | |
6248 | |
6249 if (win->in_drag) { | |
6250 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6251 "Already in the middle of a window drag at tab_press_cb\n"); | |
6252 return TRUE; | |
6253 } | |
6254 | |
6255 /* | |
6256 * Make sure a tab was actually clicked. The arrow buttons | |
6257 * mess things up. | |
6258 */ | |
11614 | 6259 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6260 |
6261 if (tab_clicked == -1) | |
6262 return FALSE; | |
6263 | |
6264 /* | |
6265 * Get the relative position of the press event, with regards to | |
6266 * the position of the notebook. | |
6267 */ | |
6268 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6269 | |
6270 x_rel = e->x_root - nb_x; | |
6271 y_rel = e->y_root - nb_y; | |
6272 | |
6273 /* Reset the min/max x/y */ | |
6274 win->drag_min_x = 0; | |
6275 win->drag_min_y = 0; | |
6276 win->drag_max_x = 0; | |
6277 win->drag_max_y = 0; | |
6278 | |
6279 /* Find out which tab was dragged. */ | |
6280 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6281 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6282 | |
6283 win->drag_min_x = tab->allocation.x + nb_x; | |
6284 win->drag_min_y = tab->allocation.y + nb_y; | |
6285 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6286 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6287 | |
6288 /* Make sure the click occurred in the tab. */ | |
6289 if (e->x_root < win->drag_min_x || | |
6290 e->x_root >= win->drag_max_x || | |
6291 e->y_root < win->drag_min_y || | |
6292 e->y_root >= win->drag_max_y) { | |
6293 | |
6294 return FALSE; | |
6295 } | |
6296 | |
6297 win->in_predrag = TRUE; | |
6298 win->drag_tab = tab_clicked; | |
6299 | |
6300 /* Connect the new motion signals. */ | |
6301 win->drag_motion_signal = | |
6302 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6303 G_CALLBACK(notebook_motion_cb), win); | |
6304 | |
6305 win->drag_leave_signal = | |
6306 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6307 G_CALLBACK(notebook_leave_cb), win); | |
6308 | |
6309 return FALSE; | |
6310 } | |
6311 | |
6312 static gboolean | |
6313 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6314 { | |
6315 GaimGtkWindow *dest_win; | |
6316 GaimConversation *conv; | |
6317 GaimGtkConversation *gtkconv; | |
6318 gint dest_page_num = 0; | |
6319 gboolean new_window = FALSE; | |
11614 | 6320 gboolean to_right = FALSE; |
11581 | 6321 |
6322 /* | |
6323 * Don't check to make sure that the event's window matches the | |
6324 * widget's, because we may be getting an event passed on from the | |
6325 * close button. | |
6326 */ | |
6327 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6328 return FALSE; | |
6329 | |
6330 if (gdk_pointer_is_grabbed()) { | |
6331 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6332 gtk_grab_remove(widget); | |
6333 } | |
6334 | |
6335 if (!win->in_predrag && !win->in_drag) | |
6336 return FALSE; | |
6337 | |
6338 /* Disconnect the motion signal. */ | |
6339 if (win->drag_motion_signal) { | |
6340 g_signal_handler_disconnect(G_OBJECT(widget), | |
6341 win->drag_motion_signal); | |
6342 | |
6343 win->drag_motion_signal = 0; | |
6344 } | |
6345 | |
6346 /* | |
6347 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6348 * signal. | |
6349 */ | |
6350 if (win->in_predrag) { | |
6351 win->in_predrag = FALSE; | |
6352 | |
6353 if (win->drag_leave_signal) { | |
6354 g_signal_handler_disconnect(G_OBJECT(widget), | |
6355 win->drag_leave_signal); | |
6356 | |
6357 win->drag_leave_signal = 0; | |
6358 } | |
6359 } | |
6360 | |
6361 /* If we're not in drag... */ | |
6362 /* We're perfectly normal people! */ | |
6363 if (!win->in_drag) | |
6364 return FALSE; | |
6365 | |
6366 win->in_drag = FALSE; | |
6367 | |
6368 dnd_hints_hide_all(); | |
6369 | |
6370 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6371 | |
6372 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6373 | |
6374 if (dest_win == NULL) { | |
6375 /* If the current window doesn't have any other conversations, | |
6376 * there isn't much point transferring the conv to a new window. */ | |
6377 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6378 /* Make a new window to stick this to. */ | |
6379 dest_win = gaim_gtk_conv_window_new(); | |
6380 new_window = TRUE; | |
6381 } | |
6382 } | |
6383 | |
6384 if (dest_win == NULL) | |
6385 return FALSE; | |
6386 | |
6387 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6388 "conversation-dragging", win, dest_win); | |
6389 | |
6390 /* Get the destination page number. */ | |
6391 if (!new_window) | |
6392 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6393 e->x_root, e->y_root, &to_right); |
11581 | 6394 |
6395 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6396 | |
6397 if (win == dest_win) { | |
6398 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6399 } else { | |
6400 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6401 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6402 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6403 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6404 if (new_window) { | |
6405 gint win_width, win_height; | |
6406 | |
6407 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6408 &win_width, &win_height); | |
6409 | |
6410 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6411 e->x_root - (win_width / 2), | |
6412 e->y_root - (win_height / 2)); | |
6413 | |
6414 gaim_gtk_conv_window_show(dest_win); | |
6415 } | |
6416 } | |
6417 | |
6418 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6419 | |
6420 return TRUE; | |
6421 } | |
6422 | |
6423 | |
6424 static void | |
6425 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6426 gpointer user_data) | |
6427 { | |
6428 GaimGtkWindow *win; | |
6429 GaimConversation *conv; | |
6430 GaimGtkConversation *gtkconv; | |
6431 | |
6432 win = user_data; | |
6433 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6434 | |
6435 g_return_if_fail(conv != NULL); | |
6436 | |
6437 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6438 return; | |
6439 | |
6440 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6441 | |
6442 stop_anim(NULL, gtkconv); | |
6443 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6444 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6445 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6446 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6447 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6448 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6449 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6450 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6451 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6452 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6453 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6454 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6455 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6456 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6457 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6458 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6459 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6460 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6461 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6462 /* 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
|
6463 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6464 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6465 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6466 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6467 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6468 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6469 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6470 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6471 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6472 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6473 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6474 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6475 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6476 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6477 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6478 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6479 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6480 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6481 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6482 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6483 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6484 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6485 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6486 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6487 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6488 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6489 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6490 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6491 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6492 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6493 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6494 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6495 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6496 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6497 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6498 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6499 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6500 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6501 GaimGtkConversation *gtkconv; |
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 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6504 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6505 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6506 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6507 } |
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 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6510 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6511 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6512 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6513 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6514 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6515 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6516 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6517 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6518 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
6519 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
|
6520 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6521 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6522 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6523 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6524 return FALSE; |
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 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6527 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
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 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6530 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6531 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6532 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6533 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6534 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6535 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6536 G_CALLBACK(detach_tab_cb), menu); |
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 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6539 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6540 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6541 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6542 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6543 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6544 gaim_separator(menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6545 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6546 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6547 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6548 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6549 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6550 G_CALLBACK(close_others_cb), menu); |
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 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6553 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6554 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6555 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6556 G_CALLBACK(close_window), win); |
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 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6559 } |
11581 | 6560 |
6561 static void | |
6562 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6563 gpointer user_data) | |
6564 { | |
6565 GaimGtkWindow *win; | |
6566 GaimConversation *conv; | |
6567 GaimGtkConversation *gtkconv; | |
6568 | |
6569 win = user_data; | |
6570 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6571 conv = gtkconv->active_conv; | |
6572 | |
6573 g_return_if_fail(conv != NULL); | |
6574 | |
6575 /* | |
6576 * Only set "unseen" to "none" if the window has focus | |
6577 */ | |
6578 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6579 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6580 |
6581 /* Update the menubar */ | |
6582 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6583 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
|
6584 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6585 |
11594 | 6586 generate_send_to_items(win); |
6587 | |
11604 | 6588 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6589 |
6590 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6591 gtkconv->make_sound); | |
6592 | |
6593 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6594 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6595 | |
6596 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6597 gtkconv->show_timestamps); | |
6598 | |
6599 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6600 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6601 gtkconv->u.im->show_icon); | |
11604 | 6602 |
11581 | 6603 /* |
6604 * We pause icons when they are not visible. If this icon should | |
6605 * be animated then start it back up again. | |
6606 */ | |
6607 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6608 (gtkconv->u.im->animate)) | |
6609 start_anim(NULL, gtkconv); | |
6610 } | |
6611 | |
6612 /************************************************************************** | |
6613 * GTK+ window ops | |
6614 **************************************************************************/ | |
6615 | |
6616 GList * | |
6617 gaim_gtk_conv_windows_get_list() | |
6618 { | |
6619 return window_list; | |
6620 } | |
6621 | |
6622 GaimGtkWindow * | |
6623 gaim_gtk_conv_window_new() | |
6624 { | |
6625 GaimGtkWindow *win; | |
6626 GtkPositionType pos; | |
6627 GtkWidget *testidea; | |
6628 GtkWidget *menubar; | |
6629 | |
6630 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6631 | |
6632 window_list = g_list_append(window_list, win); | |
6633 | |
6634 /* Create the window. */ | |
6635 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6636 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6637 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6638 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6639 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6640 | |
6641 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6642 G_CALLBACK(close_win_cb), win); | |
6643 | |
6644 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6645 G_CALLBACK(focus_win_cb), win); | |
6646 | |
6647 /* Create the notebook. */ | |
6648 win->notebook = gtk_notebook_new(); | |
6649 | |
6650 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6651 | |
6652 #if 0 | |
6653 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6654 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6655 #endif | |
6656 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6657 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6658 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6659 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6660 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6661 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6662 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6663 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6664 |
11581 | 6665 gtk_widget_show(win->notebook); |
6666 | |
6667 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6668 G_CALLBACK(before_switch_conv_cb), win); | |
6669 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6670 G_CALLBACK(switch_conv_cb), win); | |
6671 | |
6672 /* Setup the tab drag and drop signals. */ | |
6673 gtk_widget_add_events(win->notebook, | |
6674 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6675 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6676 G_CALLBACK(notebook_press_cb), win); | |
6677 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6678 G_CALLBACK(notebook_release_cb), win); | |
6679 | |
6680 testidea = gtk_vbox_new(FALSE, 0); | |
6681 | |
6682 /* Setup the menubar. */ | |
6683 menubar = setup_menubar(win); | |
6684 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6685 | |
6686 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6687 | |
6688 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6689 | |
6690 gtk_widget_show(testidea); | |
6691 | |
6692 return win; | |
6693 } | |
6694 | |
6695 void | |
6696 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6697 { | |
6698 window_list = g_list_remove(window_list, win); | |
6699 | |
11611 | 6700 if (win->gtkconvs) { |
6701 while (win->gtkconvs) { | |
6702 GList *nextgtk = win->gtkconvs->next; | |
6703 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6704 GList *nextcore = gtkconv->convs->next; | |
6705 GaimConversation *conv = gtkconv->convs->data; | |
6706 gaim_conversation_destroy(conv); | |
6707 if (!nextgtk && !nextcore) | |
6708 /* we'll end up invoking ourselves when we destroy our last child */ | |
6709 /* so don't destroy ourselves right now */ | |
6710 return; | |
6711 } | |
6712 return; | |
6713 } | |
11581 | 6714 gtk_widget_destroy(win->window); |
6715 | |
6716 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6717 | |
6718 g_free(win); | |
6719 } | |
6720 | |
6721 void | |
6722 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6723 { | |
6724 gtk_widget_show(win->window); | |
6725 } | |
6726 | |
6727 void | |
6728 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6729 { | |
6730 gtk_widget_hide(win->window); | |
6731 } | |
6732 | |
6733 void | |
6734 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6735 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6736 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6737 } |
6738 | |
6739 void | |
6740 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6741 { | |
6742 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6743 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6744 gtkconv->tab_cont)); | |
6745 } | |
6746 | |
6747 void | |
6748 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6749 { | |
6750 GaimConversation *conv = gtkconv->active_conv; | |
6751 GaimGtkConversation *focus_gtkconv; | |
6752 GtkWidget *tabby, *menu_tabby; | |
6753 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6754 GtkWidget *close_image; | |
6755 GaimConversationType conv_type; | |
6756 const char *name; | |
6757 const gchar *tmp_lab; | |
6758 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6759 gboolean tabs_side = FALSE; |
6760 gint angle = 0; | |
11581 | 6761 |
6762 name = gaim_conversation_get_name(conv); | |
6763 conv_type = gaim_conversation_get_type(conv); | |
6764 | |
6765 | |
6766 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6767 gtkconv->win = win; | |
6768 | |
11619 | 6769 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6770 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6771 tabs_side = TRUE; | |
6772 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6773 angle = 90; | |
6774 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6775 angle = 270; | |
6776 | |
6777 if (angle) | |
6778 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6779 else | |
6780 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6781 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6782 | |
6783 /* Close button. */ | |
6784 gtkconv->close = gtk_button_new(); | |
6785 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6786 if (gtk_check_version(2, 4, 2) == NULL) { | |
6787 /* Need to account for extra padding around the gtkbutton */ | |
6788 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6789 "focus-line-width", &focus_width, | |
6790 "focus-padding", &focus_pad, | |
6791 NULL); | |
6792 close_button_width += (focus_width + focus_pad) * 2; | |
6793 close_button_height += (focus_width + focus_pad) * 2; | |
6794 } | |
6795 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6796 close_button_width, close_button_height); | |
6797 | |
6798 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6799 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6800 gtk_widget_show(close_image); | |
6801 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6802 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6803 _("Close conversation"), NULL); | |
6804 | |
6805 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6806 G_CALLBACK(close_conv_cb), gtkconv); | |
6807 | |
11851 | 6808 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6809 /* |
6810 * I love Galeon. They have a fix for that stupid annoying visible | |
6811 * border bug. I love you guys! -- ChipX86 | |
6812 */ | |
11851 | 6813 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6814 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6815 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6816 #endif |
11581 | 6817 |
6818 /* Status icon. */ | |
6819 gtkconv->icon = gtk_image_new(); | |
6820 gtkconv->menu_icon = gtk_image_new(); | |
6821 update_tab_icon(conv); | |
6822 | |
6823 /* Tab label. */ | |
6824 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6825 |
11581 | 6826 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6827 if (!angle) |
6828 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6829 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6830 if (tabs_side) { |
6831 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6832 } | |
6833 if (angle) | |
6834 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6835 #endif |
6836 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6837 #if 0 | |
6838 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6839 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6840 #endif | |
6841 | |
6842 /* Pack it all together. */ | |
11619 | 6843 if (angle == 90) |
6844 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6845 else | |
6846 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6847 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6848 FALSE, FALSE, 0); | |
6849 | |
6850 gtk_widget_show_all(gtkconv->icon); | |
6851 gtk_widget_show_all(gtkconv->menu_icon); | |
6852 | |
6853 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6854 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6855 gtk_widget_show(gtkconv->tab_label); | |
6856 gtk_widget_show(gtkconv->menu_label); | |
6857 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6858 | |
11619 | 6859 if (angle == 90) |
6860 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6861 else | |
6862 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6863 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6864 gtk_widget_show(gtkconv->close); | |
6865 | |
6866 gtk_widget_show(tabby); | |
6867 gtk_widget_show(menu_tabby); | |
6868 | |
6869 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6870 gaim_gtkconv_update_buddy_icon(conv); | |
6871 | |
6872 /* Add this pane to the conversation's notebook. */ | |
6873 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6874 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6875 |
6876 | |
6877 gtk_widget_show(tab_cont); | |
6878 | |
6879 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6880 /* Er, bug in notebooks? Switch to the page manually. */ | |
6881 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6882 | |
6883 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6884 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6885 } else | |
6886 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6887 | |
6888 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6889 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6890 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6891 | |
6892 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6893 update_send_to_selection(win); |
11581 | 6894 } |
6895 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6896 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6897 private_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv, gboolean destroy_empty) |
11581 | 6898 { |
6899 unsigned int index; | |
6900 GaimConversationType conv_type; | |
6901 | |
6902 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6903 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6904 | |
6905 g_object_ref(gtkconv->tab_cont); | |
6906 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6907 | |
6908 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6909 | |
6910 /* go back to tabless if need be */ | |
6911 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6912 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6913 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6914 } | |
6915 | |
6916 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6917 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6918 if (destroy_empty && !win->gtkconvs) |
11582 | 6919 gaim_gtk_conv_window_destroy(win); |
11581 | 6920 } |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6921 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6922 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6923 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6924 private_remove_gtkconv(win, gtkconv, TRUE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6925 } |
11581 | 6926 |
6927 GaimGtkConversation * | |
6928 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
6929 { | |
6930 GtkWidget *tab_cont; | |
6931 | |
6932 if (index == -1) | |
6933 index = 0; | |
6934 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 6935 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 6936 } |
6937 | |
6938 GaimGtkConversation * | |
6939 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
6940 { | |
6941 int index; | |
6942 GtkWidget *tab_cont; | |
6943 | |
6944 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
6945 if (index == -1) | |
6946 index = 0; | |
6947 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
6948 if (!tab_cont) | |
6949 return NULL; | |
6950 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
6951 } | |
6952 | |
6953 | |
6954 GaimConversation * | |
6955 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
6956 { | |
6957 GaimGtkConversation *gtkconv; | |
6958 | |
6959 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
6960 return gtkconv ? gtkconv->active_conv : NULL; | |
6961 } | |
6962 | |
6963 gboolean | |
6964 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
6965 { | |
6966 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
6967 } | |
6968 | |
6969 gboolean | |
6970 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
6971 { | |
6972 gboolean has_focus = FALSE; | |
6973 | |
6974 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
6975 | |
6976 return has_focus; | |
6977 } | |
6978 | |
6979 GaimGtkWindow * | |
6980 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
6981 { | |
6982 GaimGtkWindow *win; | |
6983 GdkWindow *gdkwin; | |
6984 GList *l; | |
6985 | |
6986 gdkwin = gdk_window_at_pointer(&x, &y); | |
6987 | |
6988 if (gdkwin) | |
6989 gdkwin = gdk_window_get_toplevel(gdkwin); | |
6990 | |
6991 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
6992 win = l->data; | |
6993 | |
6994 if (gdkwin == win->window->window) | |
6995 return win; | |
6996 } | |
6997 | |
6998 return NULL; | |
6999 } | |
7000 | |
7001 GList * | |
7002 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7003 { | |
7004 return win->gtkconvs; | |
7005 } | |
7006 | |
7007 guint | |
7008 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7009 { | |
7010 return g_list_length(win->gtkconvs); | |
7011 } | |
7012 | |
7013 GaimGtkWindow * | |
7014 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7015 { | |
7016 GList *wins, *convs; | |
7017 GaimGtkWindow *win; | |
7018 GaimGtkConversation *conv; | |
7019 | |
7020 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7021 return NULL; | |
7022 | |
7023 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7024 win = wins->data; | |
7025 | |
7026 for (convs = win->gtkconvs; | |
7027 convs != NULL; | |
7028 convs = convs->next) { | |
7029 | |
7030 conv = convs->data; | |
7031 | |
7032 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7033 return win; | |
7034 } | |
7035 } | |
7036 | |
7037 return NULL; | |
7038 } | |
7039 | |
7040 GaimGtkWindow * | |
7041 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7042 { | |
7043 GList *wins, *convs; | |
7044 GaimGtkWindow *win; | |
7045 GaimGtkConversation *conv; | |
7046 | |
7047 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7048 return NULL; | |
7049 | |
7050 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7051 wins != NULL; | |
7052 wins = wins->prev) { | |
7053 | |
7054 win = wins->data; | |
7055 | |
7056 for (convs = win->gtkconvs; | |
7057 convs != NULL; | |
7058 convs = convs->next) { | |
7059 | |
7060 conv = convs->data; | |
7061 | |
7062 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7063 return win; | |
7064 } | |
7065 } | |
7066 | |
7067 return NULL; | |
7068 } | |
7069 | |
7070 | |
7071 /************************************************************************** | |
7072 * Conversation placement functions | |
7073 **************************************************************************/ | |
7074 typedef struct | |
7075 { | |
7076 char *id; | |
7077 char *name; | |
7078 GaimConvPlacementFunc fnc; | |
7079 | |
7080 } ConvPlacementData; | |
7081 | |
7082 static GList *conv_placement_fncs = NULL; | |
7083 static GaimConvPlacementFunc place_conv = NULL; | |
7084 | |
7085 /* This one places conversations in the last made window. */ | |
7086 static void | |
7087 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7088 { | |
7089 GaimGtkWindow *win; | |
7090 | |
7091 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7092 win = l ? l->data : NULL;; | |
7093 | |
7094 if (win == NULL) { | |
7095 win = gaim_gtk_conv_window_new(); | |
7096 | |
7097 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7098 gaim_gtk_conv_window_show(win); | |
7099 } else { | |
7100 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7101 } | |
7102 } | |
7103 | |
7104 /* This one places conversations in the last made window of the same type. */ | |
7105 static void | |
7106 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7107 { | |
7108 GaimGtkWindow *win; | |
7109 | |
7110 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7111 | |
7112 if (win == NULL) { | |
7113 win = gaim_gtk_conv_window_new(); | |
7114 | |
7115 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7116 gaim_gtk_conv_window_show(win); | |
7117 } else | |
7118 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7119 } | |
7120 | |
7121 /* This one places each conversation in its own window. */ | |
7122 static void | |
7123 conv_placement_new_window(GaimGtkConversation *conv) | |
7124 { | |
7125 GaimGtkWindow *win; | |
7126 | |
7127 win = gaim_gtk_conv_window_new(); | |
7128 | |
7129 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7130 | |
7131 gaim_gtk_conv_window_show(win); | |
7132 } | |
7133 | |
7134 static GaimGroup * | |
7135 conv_get_group(GaimGtkConversation *conv) | |
7136 { | |
7137 GaimGroup *group = NULL; | |
7138 | |
7139 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7140 GaimBuddy *buddy; | |
7141 | |
7142 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7143 gaim_conversation_get_name(conv->active_conv)); | |
7144 | |
7145 if (buddy != NULL) | |
12088 | 7146 group = gaim_buddy_get_group(buddy); |
11581 | 7147 |
7148 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7149 GaimChat *chat; | |
7150 | |
7151 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7152 gaim_conversation_get_name(conv->active_conv)); | |
7153 | |
7154 if (chat != NULL) | |
7155 group = gaim_chat_get_group(chat); | |
7156 } | |
7157 | |
7158 return group; | |
7159 } | |
7160 | |
7161 /* | |
7162 * This groups things by, well, group. Buddies from groups will always be | |
7163 * grouped together, and a buddy from a group not belonging to any currently | |
7164 * open windows will get a new window. | |
7165 */ | |
7166 static void | |
7167 conv_placement_by_group(GaimGtkConversation *conv) | |
7168 { | |
7169 GaimConversationType type; | |
7170 GaimGroup *group = NULL; | |
7171 GList *wl, *cl; | |
7172 | |
7173 type = gaim_conversation_get_type(conv->active_conv); | |
7174 | |
7175 group = conv_get_group(conv); | |
7176 | |
7177 /* Go through the list of IMs and find one with this group. */ | |
7178 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7179 GaimGtkWindow *win2; | |
7180 GaimGtkConversation *conv2; | |
7181 GaimGroup *group2 = NULL; | |
7182 | |
7183 win2 = wl->data; | |
7184 | |
7185 for (cl = win2->gtkconvs; | |
7186 cl != NULL; | |
7187 cl = cl->next) { | |
7188 conv2 = cl->data; | |
7189 | |
7190 group2 = conv_get_group(conv2); | |
7191 | |
7192 if (group == group2) { | |
7193 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7194 | |
7195 return; | |
7196 } | |
7197 } | |
7198 } | |
7199 | |
7200 /* Make a new window. */ | |
7201 conv_placement_new_window(conv); | |
7202 } | |
7203 | |
7204 /* This groups things by account. Otherwise, the same semantics as above */ | |
7205 static void | |
7206 conv_placement_by_account(GaimGtkConversation *conv) | |
7207 { | |
7208 GaimConversationType type; | |
7209 GList *wins, *convs; | |
7210 GaimAccount *account; | |
7211 | |
7212 account = gaim_conversation_get_account(conv->active_conv); | |
7213 type = gaim_conversation_get_type(conv->active_conv); | |
7214 | |
7215 /* Go through the list of IMs and find one with this group. */ | |
7216 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7217 GaimGtkWindow *win2; | |
7218 GaimGtkConversation *conv2; | |
7219 | |
7220 win2 = wins->data; | |
7221 | |
7222 for (convs = win2->gtkconvs; | |
7223 convs != NULL; | |
7224 convs = convs->next) { | |
7225 conv2 = convs->data; | |
7226 | |
7227 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7228 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7229 return; | |
7230 } | |
7231 } | |
7232 } | |
7233 | |
7234 /* Make a new window. */ | |
7235 conv_placement_new_window(conv); | |
7236 } | |
7237 | |
7238 static ConvPlacementData * | |
7239 get_conv_placement_data(const char *id) | |
7240 { | |
7241 ConvPlacementData *data = NULL; | |
7242 GList *n; | |
7243 | |
7244 for (n = conv_placement_fncs; n; n = n->next) { | |
7245 data = n->data; | |
7246 if (!strcmp(data->id, id)) | |
7247 return data; | |
7248 } | |
7249 | |
7250 return NULL; | |
7251 } | |
7252 | |
7253 static void | |
7254 add_conv_placement_fnc(const char *id, const char *name, | |
7255 GaimConvPlacementFunc fnc) | |
7256 { | |
7257 ConvPlacementData *data; | |
7258 | |
7259 data = g_new(ConvPlacementData, 1); | |
7260 | |
7261 data->id = g_strdup(id); | |
7262 data->name = g_strdup(name); | |
7263 data->fnc = fnc; | |
7264 | |
7265 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7266 } | |
7267 | |
7268 static void | |
7269 ensure_default_funcs(void) | |
7270 { | |
7271 if (conv_placement_fncs == NULL) { | |
7272 add_conv_placement_fnc("last", _("Last created window"), | |
7273 conv_placement_last_created_win); | |
7274 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7275 conv_placement_last_created_win_type); | |
7276 add_conv_placement_fnc("new", _("New window"), | |
7277 conv_placement_new_window); | |
7278 add_conv_placement_fnc("group", _("By group"), | |
7279 conv_placement_by_group); | |
7280 add_conv_placement_fnc("account", _("By account"), | |
7281 conv_placement_by_account); | |
7282 } | |
7283 } | |
7284 | |
7285 GList * | |
7286 gaim_gtkconv_placement_get_options(void) | |
7287 { | |
7288 GList *n, *list = NULL; | |
7289 ConvPlacementData *data; | |
7290 | |
7291 ensure_default_funcs(); | |
7292 | |
7293 for (n = conv_placement_fncs; n; n = n->next) { | |
7294 data = n->data; | |
7295 list = g_list_append(list, data->name); | |
7296 list = g_list_append(list, data->id); | |
7297 } | |
7298 | |
7299 return list; | |
7300 } | |
7301 | |
7302 | |
7303 void | |
7304 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7305 GaimConvPlacementFunc fnc) | |
7306 { | |
7307 g_return_if_fail(id != NULL); | |
7308 g_return_if_fail(name != NULL); | |
7309 g_return_if_fail(fnc != NULL); | |
7310 | |
7311 ensure_default_funcs(); | |
7312 | |
7313 add_conv_placement_fnc(id, name, fnc); | |
7314 } | |
7315 | |
7316 void | |
7317 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7318 { | |
7319 ConvPlacementData *data = get_conv_placement_data(id); | |
7320 | |
7321 if (data == NULL) | |
7322 return; | |
7323 | |
7324 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7325 | |
7326 g_free(data->id); | |
7327 g_free(data->name); | |
7328 g_free(data); | |
7329 } | |
7330 | |
7331 const char * | |
7332 gaim_gtkconv_placement_get_name(const char *id) | |
7333 { | |
7334 ConvPlacementData *data; | |
7335 | |
7336 ensure_default_funcs(); | |
7337 | |
7338 data = get_conv_placement_data(id); | |
7339 | |
7340 if (data == NULL) | |
7341 return NULL; | |
7342 | |
7343 return data->name; | |
7344 } | |
7345 | |
7346 GaimConvPlacementFunc | |
7347 gaim_gtkconv_placement_get_fnc(const char *id) | |
7348 { | |
7349 ConvPlacementData *data; | |
7350 | |
7351 ensure_default_funcs(); | |
7352 | |
7353 data = get_conv_placement_data(id); | |
7354 | |
7355 if (data == NULL) | |
7356 return NULL; | |
7357 | |
7358 return data->fnc; | |
7359 } | |
7360 | |
7361 void | |
7362 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7363 { | |
7364 g_return_if_fail(func != NULL); | |
7365 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7366 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7367 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7368 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7369 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7370 place_conv = NULL; |
11581 | 7371 } |
7372 | |
7373 GaimConvPlacementFunc | |
7374 gaim_gtkconv_placement_get_current_func(void) | |
7375 { | |
7376 return place_conv; | |
7377 } | |
7378 | |
7379 void | |
7380 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7381 { | |
7382 if (place_conv) | |
7383 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7384 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7385 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7386 } |