Mercurial > pidgin
annotate src/gtkconv.c @ 12075:f62022e07351
[gaim-migrate @ 14372]
another docklet patch from sadrul - this one fixes the scrollwheel behavior in the status message box so that it doesn't change your status.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 14 Nov 2005 01:23:36 +0000 |
parents | e859c1663a27 |
children | 3b52d94437f3 |
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 |
11594 | 116 static gboolean update_send_to_selection(GaimGtkWindow *win); |
117 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 118 |
4359 | 119 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 120 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 121 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
122 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
123 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 124 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 125 static gboolean tab_complete(GaimConversation *conv); |
11604 | 126 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 127 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 128 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
129 static char *item_factory_translate_func (const char *path, gpointer func_data); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
130 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
4359 | 131 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
132 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
133 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
134 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
135 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
136 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
137 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
138 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
139 (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
|
140 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
141 /* 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
|
142 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
143 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
144 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
145 col.blue *= scale; |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
148 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
149 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
150 |
4359 | 151 /************************************************************************** |
152 * Callbacks | |
153 **************************************************************************/ | |
10971 | 154 |
4359 | 155 static gint |
10810 | 156 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 157 { |
10810 | 158 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 159 |
10810 | 160 l = list; |
161 while (l) { | |
162 GaimConversation *conv = l->data; | |
163 gaim_conversation_destroy(conv); | |
164 l = l->next; | |
165 } | |
11508 | 166 |
10810 | 167 g_list_free(list); |
11508 | 168 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
169 return TRUE; |
4359 | 170 } |
171 | |
8914 | 172 static gboolean |
10810 | 173 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 174 { |
10810 | 175 GaimConversation *conv = gtkconv->active_conv; |
11508 | 176 |
8914 | 177 if (!GTK_WIDGET_VISIBLE(w)) |
178 return FALSE; | |
179 | |
180 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
181 return FALSE; | |
182 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
183 /* 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
|
184 * 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
|
185 * 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
|
186 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
187 /* 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
|
188 * negate it anyway. --luke */ |
11338 | 189 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 190 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
191 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
192 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
|
193 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
|
194 } |
8914 | 195 if (w == gtkconv->entry) |
196 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
197 } | |
11338 | 198 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 199 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
200 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
201 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
|
202 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
|
203 } |
8914 | 204 if (w == gtkconv->entry) |
205 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
206 } | |
207 | |
208 return FALSE; | |
209 } | |
210 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
211 static void |
10810 | 212 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
213 { |
10810 | 214 GaimConversation *conv = c->active_conv; |
11508 | 215 |
10665 | 216 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
217 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
218 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
219 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
220 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
221 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
222 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
223 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
224 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
225 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
226 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
227 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
|
228 gtk_imhtml_toggle_underline(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 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
231 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
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 (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
234 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
235 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
236 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
237 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
238 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
242 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
243 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
244 fg_color.blue / 256); |
8061 | 245 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
251 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
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 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 g_free(color); |
8677 | 267 |
9025 | 268 |
10665 | 269 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 270 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
271 else | |
272 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 273 } |
274 } | |
9130 | 275 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
276 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
277 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
278 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
279 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
280 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
281 |
9130 | 282 static const char * |
283 gaim_gtk_get_cmd_prefix(void) | |
284 { | |
285 return "/"; | |
286 } | |
287 | |
9167 | 288 static GaimCmdRet |
9829 | 289 say_command_cb(GaimConversation *conv, |
290 const char *cmd, char **args, char **error, void *data) | |
291 { | |
11338 | 292 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 293 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 294 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 295 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
296 | |
297 return GAIM_CMD_RET_OK; | |
298 } | |
299 | |
300 static GaimCmdRet | |
9167 | 301 me_command_cb(GaimConversation *conv, |
9597 | 302 const char *cmd, char **args, char **error, void *data) |
9167 | 303 { |
304 char *tmp; | |
305 | |
306 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 307 |
11338 | 308 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 309 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 310 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 311 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
312 | |
313 g_free(tmp); | |
314 return GAIM_CMD_RET_OK; | |
315 } | |
316 | |
9212 | 317 static GaimCmdRet |
318 debug_command_cb(GaimConversation *conv, | |
9597 | 319 const char *cmd, char **args, char **error, void *data) |
9212 | 320 { |
321 char *tmp, *markup; | |
322 GaimCmdStatus status; | |
323 | |
324 if (!g_ascii_strcasecmp(args[0], "version")) { | |
325 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
|
326 markup = g_markup_escape_text(tmp, -1); |
9212 | 327 |
328 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
329 | |
330 g_free(tmp); | |
331 g_free(markup); | |
332 return status; | |
333 } else { | |
334 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
335 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
336 return GAIM_CMD_STATUS_OK; | |
337 } | |
338 } | |
339 | |
9213 | 340 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
341 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
342 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
343 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
344 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
345 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
346 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
347 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
348 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
349 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
350 } |
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 static GaimCmdRet |
9213 | 353 help_command_cb(GaimConversation *conv, |
9597 | 354 const char *cmd, char **args, char **error, void *data) |
9213 | 355 { |
9597 | 356 GList *l, *text; |
9213 | 357 GString *s; |
9597 | 358 |
359 if (args[0] != NULL) { | |
360 s = g_string_new(""); | |
361 text = gaim_cmd_help(conv, args[0]); | |
362 | |
363 if (text) { | |
364 for (l = text; l; l = l->next) | |
365 if (l->next) | |
9816 | 366 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 367 else |
9816 | 368 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 369 } else { |
370 g_string_append(s, _("No such command (in this context).")); | |
371 } | |
372 } else { | |
373 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
374 "The following commands are available in this context:\n")); | |
375 | |
376 text = gaim_cmd_list(conv); | |
377 for (l = text; l; l = l->next) | |
9213 | 378 if (l->next) |
9597 | 379 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 380 else |
9597 | 381 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 382 } |
383 | |
384 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
385 g_string_free(s, TRUE); | |
386 | |
387 return GAIM_CMD_STATUS_OK; | |
388 } | |
389 | |
4359 | 390 static void |
9374 | 391 send_history_add(GaimConversation *conv, const char *message) |
392 { | |
393 GList *first; | |
394 | |
395 first = g_list_first(conv->send_history); | |
396 | |
397 if (first->data) | |
398 g_free(first->data); | |
399 | |
400 first->data = g_strdup(message); | |
401 | |
402 conv->send_history = g_list_prepend(first, NULL); | |
403 } | |
404 | |
9832 | 405 static gboolean |
406 check_for_and_do_command(GaimConversation *conv) | |
407 { | |
408 GaimGtkConversation *gtkconv; | |
409 char *cmd; | |
410 const char *prefix; | |
411 GaimAccount *account; | |
412 GtkTextIter start; | |
413 | |
414 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
415 account = gaim_conversation_get_account(conv); | |
416 prefix = gaim_gtk_get_cmd_prefix(); | |
417 | |
418 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
419 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
420 | |
421 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
422 && !gtk_text_iter_get_child_anchor(&start)) { | |
423 GaimCmdStatus status; | |
424 char *error, *cmdline, *markup, *send_history; | |
425 GtkTextIter end; | |
426 | |
427 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
428 send_history_add(conv, send_history); | |
429 g_free(send_history); | |
430 | |
431 cmdline = cmd + strlen(prefix); | |
432 | |
433 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
434 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
435 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
436 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
437 g_free(cmd); | |
438 g_free(markup); | |
439 | |
440 switch (status) { | |
441 case GAIM_CMD_STATUS_OK: | |
442 return TRUE; | |
443 case GAIM_CMD_STATUS_NOT_FOUND: | |
444 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
445 gaim_conversation_write(conv, "", _("No such command."), | |
446 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
447 | |
448 return TRUE; | |
449 } | |
450 return FALSE; | |
451 case GAIM_CMD_STATUS_WRONG_ARGS: | |
452 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
453 "to that command."), | |
454 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
455 return TRUE; | |
456 case GAIM_CMD_STATUS_FAILED: | |
457 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
458 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
459 if(error) | |
460 g_free(error); | |
461 return TRUE; | |
462 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 463 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 464 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 465 GAIM_MESSAGE_NO_LOG, time(NULL)); |
466 else | |
10843 | 467 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 468 GAIM_MESSAGE_NO_LOG, time(NULL)); |
469 return TRUE; | |
470 case GAIM_CMD_STATUS_WRONG_PRPL: | |
471 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
472 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
473 return TRUE; | |
474 } | |
475 } | |
476 | |
477 g_free(cmd); | |
478 return FALSE; | |
479 } | |
480 | |
9374 | 481 static void |
10810 | 482 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 483 { |
10810 | 484 GaimConversation *conv = gtkconv->active_conv; |
8655 | 485 GaimAccount *account; |
8677 | 486 GaimConnection *gc; |
8448 | 487 char *buf, *clean; |
4359 | 488 |
8655 | 489 account = gaim_conversation_get_account(conv); |
9130 | 490 |
9471 | 491 if (!gaim_account_is_connected(account)) |
492 return; | |
493 | |
11338 | 494 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 495 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 496 return; |
497 | |
9832 | 498 if (check_for_and_do_command(conv)) { |
499 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
500 return; | |
9130 | 501 } |
502 | |
8442 | 503 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 504 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 505 |
4359 | 506 gtk_widget_grab_focus(gtkconv->entry); |
507 | |
8448 | 508 if (strlen(clean) == 0) { |
509 g_free(clean); | |
4359 | 510 return; |
511 } | |
512 | |
8677 | 513 gc = gaim_account_get_connection(account); |
10665 | 514 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 515 char **bufs; |
516 int i; | |
517 | |
518 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
519 for (i = 0; bufs[i]; i++) { | |
9374 | 520 send_history_add(conv, bufs[i]); |
11338 | 521 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 522 gaim_conv_im_send(GAIM_CONV_IM(conv), bufs[i]); |
11338 | 523 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 524 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), bufs[i]); |
525 } | |
526 | |
527 g_strfreev(bufs); | |
528 | |
529 } else { | |
9374 | 530 send_history_add(conv, buf); |
11338 | 531 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 532 gaim_conv_im_send(GAIM_CONV_IM(conv), buf); |
11338 | 533 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 534 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), buf); |
535 } | |
4359 | 536 |
8677 | 537 g_free(clean); |
4359 | 538 g_free(buf); |
539 | |
8061 | 540 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 541 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 542 } |
543 | |
544 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
545 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 546 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
547 GaimAccount *account; |
4359 | 548 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
549 GaimConversation *conv = gtkconv->active_conv; |
4359 | 550 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
551 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
552 name = gaim_conversation_get_name(conv); |
7879 | 553 |
11338 | 554 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 555 GaimBuddy *b; |
556 | |
557 b = gaim_find_buddy(account, name); | |
558 if (b != NULL) | |
9730 | 559 gaim_gtkdialogs_remove_buddy(b); |
7859 | 560 else if (account != NULL && gaim_account_is_connected(account)) |
561 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 562 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 563 GaimChat *c; |
564 | |
565 c = gaim_blist_find_chat(account, name); | |
566 if (c != NULL) | |
9730 | 567 gaim_gtkdialogs_remove_chat(c); |
7859 | 568 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 569 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 570 } |
4359 | 571 |
572 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
573 } | |
574 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
575 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 576 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
577 GaimConversation *conv = gtkconv->active_conv; |
7975 | 578 GaimPluginProtocolInfo *prpl_info = NULL; |
579 GaimConnection *gc; | |
580 | |
581 if ((gc = gaim_conversation_get_gc(conv))) { | |
582 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
583 | |
584 /* | |
585 * If there are special needs for getting info on users in | |
586 * buddy chat "rooms"... | |
587 */ | |
588 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
589 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
590 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
591 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
592 } |
7975 | 593 else |
594 prpl_info->get_info(gc, who); | |
595 } | |
596 } | |
597 | |
598 | |
4359 | 599 static void |
10810 | 600 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 601 { |
10810 | 602 GaimConversation *conv = gtkconv->active_conv; |
4359 | 603 |
11338 | 604 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 605 serv_get_info(gaim_conversation_get_gc(conv), |
606 gaim_conversation_get_name(conv)); | |
607 | |
608 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 609 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 610 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
611 GaimGtkChatPane *gtkchat; |
4359 | 612 GtkTreeIter iter; |
613 GtkTreeModel *model; | |
614 GtkTreeSelection *sel; | |
9554 | 615 char *name; |
4359 | 616 |
617 gtkchat = gtkconv->u.chat; | |
618 | |
619 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
620 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
621 | |
622 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 623 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 624 else |
625 return; | |
626 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
627 chat_do_info(gtkconv, name); |
9554 | 628 g_free(name); |
4359 | 629 } |
630 } | |
631 | |
632 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
633 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 634 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
635 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
636 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
637 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
638 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
639 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
640 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
641 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 642 |
643 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
644 } | |
645 | |
646 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
647 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 648 { |
649 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
650 GaimGtkConversation *gtkconv; |
4359 | 651 |
652 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
653 | |
654 if (resp == GTK_RESPONSE_OK) { | |
655 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
656 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
657 | |
10113 | 658 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 659 return; |
660 | |
661 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
662 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 663 message, buddy); |
664 } | |
665 | |
666 gtk_widget_destroy(invite_dialog); | |
667 invite_dialog = NULL; | |
668 | |
669 g_free(info); | |
670 } | |
671 | |
672 static void | |
9909 | 673 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
674 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
675 { | |
676 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
677 const char *convprotocol; | |
678 | |
679 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
680 | |
681 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
682 { | |
683 GaimBlistNode *node = NULL; | |
684 GaimBuddy *buddy; | |
685 | |
686 memcpy(&node, sd->data, sizeof(node)); | |
687 | |
688 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
689 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
690 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
691 buddy = (GaimBuddy *)node; | |
692 else | |
693 return; | |
694 | |
695 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
696 { | |
697 gaim_notify_error(NULL, NULL, | |
698 _("That buddy is not on the same protocol as this " | |
10843 | 699 "chat."), NULL); |
9909 | 700 } |
701 else | |
702 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
703 | |
704 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
705 } | |
706 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
707 { | |
708 char *protocol = NULL; | |
709 char *username = NULL; | |
710 GaimAccount *account; | |
711 | |
11137 | 712 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 713 &protocol, &username, NULL)) |
714 { | |
715 if (account == NULL) | |
716 { | |
717 gaim_notify_error(NULL, NULL, | |
718 _("You are not currently signed on with an account that " | |
719 "can invite that buddy."), NULL); | |
720 } | |
721 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
722 { | |
723 gaim_notify_error(NULL, NULL, | |
724 _("That buddy is not on the same protocol as this " | |
10843 | 725 "chat."), NULL); |
9909 | 726 } |
727 else | |
728 { | |
729 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
730 } | |
731 } | |
732 | |
733 if (username != NULL) g_free(username); | |
734 if (protocol != NULL) g_free(protocol); | |
735 | |
736 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
737 } | |
738 } | |
739 | |
740 static const GtkTargetEntry dnd_targets[] = | |
741 { | |
742 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
743 {"application/x-im-contact", 0, 1} | |
744 }; | |
745 | |
746 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
747 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 748 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
749 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
750 InviteBuddyInfo *info = NULL; |
4359 | 751 |
752 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
753 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
754 GaimGtkWindow *gtkwin; |
4359 | 755 GtkWidget *label; |
756 GtkWidget *vbox, *hbox; | |
757 GtkWidget *table; | |
758 GtkWidget *img; | |
759 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
760 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 761 GTK_ICON_SIZE_DIALOG); |
4359 | 762 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
763 info = g_new0(InviteBuddyInfo, 1); |
4359 | 764 info->conv = conv; |
765 | |
11581 | 766 gc = gaim_conversation_get_gc(conv); |
767 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 768 |
769 /* Create the new dialog. */ | |
770 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 771 _("Invite Buddy Into Chat Room"), |
7879 | 772 GTK_WINDOW(gtkwin->window), 0, |
773 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
774 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 775 |
776 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 777 GTK_RESPONSE_OK); |
11243 | 778 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 779 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
780 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
781 | |
9909 | 782 info->window = GTK_WIDGET(invite_dialog); |
783 | |
4359 | 784 /* Setup the outside spacing. */ |
785 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
786 | |
11243 | 787 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
788 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 789 |
790 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 791 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 792 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
793 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
794 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
795 | |
796 /* Setup the right vbox. */ | |
797 vbox = gtk_vbox_new(FALSE, 0); | |
798 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
799 | |
800 /* Put our happy label in it. */ | |
801 label = gtk_label_new(_("Please enter the name of the user you wish " | |
802 "to invite, along with an optional invite " | |
803 "message.")); | |
804 gtk_widget_set_size_request(label, 350, -1); | |
805 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
806 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
807 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
808 | |
809 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 810 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 811 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
812 | |
813 /* Setup the table we're going to use to lay stuff out. */ | |
814 table = gtk_table_new(2, 2, FALSE); | |
11243 | 815 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
816 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
817 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 818 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
819 | |
820 /* Now the Buddy label */ | |
821 label = gtk_label_new(NULL); | |
822 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
823 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
824 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
825 | |
826 /* Now the Buddy drop-down entry field. */ | |
827 info->entry = gtk_combo_new(); | |
828 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
829 gtk_entry_set_activates_default( | |
830 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
831 | |
832 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
833 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
834 | |
835 /* Fill in the names. */ | |
836 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
837 generate_invite_user_names(gc)); | |
838 | |
839 | |
840 /* Now the label for "Message" */ | |
841 label = gtk_label_new(NULL); | |
842 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
843 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
844 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
845 | |
846 | |
847 /* And finally, the Message entry field. */ | |
848 info->message = gtk_entry_new(); | |
849 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
850 | |
851 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
852 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
853 | |
854 /* Connect the signals. */ | |
855 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
856 G_CALLBACK(do_invite), info); | |
9909 | 857 /* Setup drag-and-drop */ |
858 gtk_drag_dest_set(info->window, | |
859 GTK_DEST_DEFAULT_MOTION | | |
860 GTK_DEST_DEFAULT_DROP, | |
861 dnd_targets, | |
862 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
863 GDK_ACTION_COPY); | |
864 gtk_drag_dest_set(info->entry, | |
865 GTK_DEST_DEFAULT_MOTION | | |
866 GTK_DEST_DEFAULT_DROP, | |
867 dnd_targets, | |
868 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
869 GDK_ACTION_COPY); | |
870 | |
871 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
872 G_CALLBACK(invite_dnd_recv), info); | |
873 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
874 G_CALLBACK(invite_dnd_recv), info); | |
875 | |
4359 | 876 } |
877 | |
878 gtk_widget_show_all(invite_dialog); | |
879 | |
880 if (info != NULL) | |
881 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
882 } | |
883 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
884 static void |
7748 | 885 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
886 { | |
9714 | 887 gaim_gtkdialogs_im(); |
7748 | 888 } |
889 | |
890 static void | |
9504 | 891 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 892 { |
9504 | 893 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 894 FILE *fp; |
895 const char *name; | |
10849 | 896 gchar *text; |
9489 | 897 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
898 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 899 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 900 return; |
901 } | |
902 | |
903 name = gaim_conversation_get_name(conv); | |
10849 | 904 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 905 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 906 |
907 text = gtk_imhtml_get_markup( | |
908 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
909 fprintf(fp, "%s", text); | |
910 g_free(text); | |
911 | |
912 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 913 fclose(fp); |
914 } | |
915 | |
10849 | 916 /* |
917 * It would be kinda cool if this gave the option of saving a | |
918 * plaintext v. HTML file. | |
919 */ | |
9489 | 920 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
921 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
922 { |
11581 | 923 GaimGtkWindow *win = data; |
924 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 925 gchar *buf; |
926 | |
927 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 928 |
10849 | 929 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
930 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 931 |
932 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
933 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
934 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
935 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
936 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
937 { |
11581 | 938 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
939 GaimConversation *conv; |
9917 | 940 GaimLogType type; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
941 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
942 GaimAccount *account; |
10845 | 943 GSList *buddies, *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
944 |
11581 | 945 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
946 |
11338 | 947 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 948 type = GAIM_LOG_IM; |
11338 | 949 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 950 type = GAIM_LOG_CHAT; |
951 else | |
952 return; | |
953 | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
954 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
955 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
956 |
10845 | 957 buddies = gaim_find_buddies(account, name); |
958 for (cur = buddies; cur != NULL; cur = cur->next) | |
959 { | |
960 GaimBlistNode *node = cur->data; | |
10846 | 961 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 962 { |
963 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
964 g_slist_free(buddies); | |
965 return; | |
966 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
967 } |
10845 | 968 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
969 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
970 gaim_gtk_log_show(type, name, account); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
971 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
972 |
8974 | 973 static void |
974 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
975 { | |
11581 | 976 GaimGtkWindow *win = data; |
8974 | 977 GaimConversation *conv; |
978 GaimGtkConversation *gtkconv; | |
979 | |
11581 | 980 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 981 gtkconv = GAIM_GTK_CONVERSATION(conv); |
982 | |
983 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
984 } | |
985 | |
7295 | 986 struct _search { |
987 GaimGtkConversation *gtkconv; | |
988 GtkWidget *entry; | |
989 }; | |
990 | |
7929 | 991 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 992 { |
7929 | 993 switch (resp) { |
994 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
995 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
996 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 997 break; |
998 | |
999 case GTK_RESPONSE_DELETE_EVENT: | |
1000 case GTK_RESPONSE_CLOSE: | |
1001 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1002 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1003 s->gtkconv->dialogs.search = NULL; | |
1004 g_free(s); | |
1005 break; | |
1006 } | |
7295 | 1007 } |
1008 | |
1009 static void | |
7751 | 1010 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1011 { |
11581 | 1012 GaimGtkWindow *gtkwin = data; |
1013 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1014 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1015 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1016 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1017 GTK_ICON_SIZE_DIALOG); |
7929 | 1018 GtkWidget *label; |
7295 | 1019 struct _search *s; |
1020 | |
7798 | 1021 if (gtkconv->dialogs.search) { |
1022 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1023 return; |
7798 | 1024 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1025 |
7295 | 1026 s = g_malloc(sizeof(struct _search)); |
1027 s->gtkconv = gtkconv; | |
7929 | 1028 |
1029 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1030 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1031 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1032 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1033 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1034 GTK_RESPONSE_OK); |
7929 | 1035 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1036 G_CALLBACK(do_search_cb), s); | |
1037 | |
11243 | 1038 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1039 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1040 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1041 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
|
1042 gtk_container_set_border_width( |
11243 | 1043 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1044 | |
1045 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1046 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1047 hbox); |
7929 | 1048 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1049 | |
1050 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1051 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1052 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1053 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1054 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1055 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1056 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1057 | |
1058 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1059 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1060 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1061 g_signal_connect(G_OBJECT(s->entry), "changed", |
1062 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1063 gtkconv->dialogs.search); | |
1064 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
|
1065 |
7295 | 1066 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1067 gtk_widget_grab_focus(s->entry); |
7295 | 1068 } |
1069 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1070 static void |
9468 | 1071 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1072 { | |
11581 | 1073 GaimGtkWindow *win = data; |
1074 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1075 |
11338 | 1076 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1077 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1078 } | |
1079 | |
1080 } | |
1081 | |
1082 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1083 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1084 { |
11581 | 1085 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1086 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1087 |
11581 | 1088 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
|
1089 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1090 gaim_gtkpounce_dialog_show(gaim_conversation_get_account(conv), |
11581 | 1091 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1092 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1093 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1094 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1095 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1096 { |
11581 | 1097 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1098 GaimGtkConversation *gtkconv; |
8756 | 1099 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1100 |
11581 | 1101 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1102 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1103 | |
1104 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1105 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1106 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1107 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1108 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1109 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1110 { |
11581 | 1111 GaimGtkWindow *win = data; |
8756 | 1112 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1113 GaimGtkConversation *gtkconv; |
8756 | 1114 GtkIMHtmlToolbar *toolbar; |
1115 | |
11581 | 1116 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1117 conv = gtkconv->active_conv; | |
8756 | 1118 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1119 | |
1120 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1121 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1122 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1123 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1124 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1125 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1126 { |
11581 | 1127 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 GaimConversation *conv; |
7879 | 1129 GaimAccount *account; |
1130 const char *name; | |
1131 | |
11581 | 1132 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1133 account = gaim_conversation_get_account(conv); |
1134 name = gaim_conversation_get_name(conv); | |
1135 | |
11338 | 1136 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1137 GaimBuddy *b; |
1138 | |
1139 b = gaim_find_buddy(account, name); | |
1140 if (b != NULL) | |
9730 | 1141 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1142 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1143 GaimChat *c; |
1144 | |
1145 c = gaim_blist_find_chat(account, name); | |
1146 if (c != NULL) | |
9730 | 1147 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1148 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1149 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1150 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1151 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1152 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 { |
11581 | 1154 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 |
11581 | 1157 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 |
10810 | 1159 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1160 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1163 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 { |
11581 | 1165 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1166 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1167 |
11581 | 1168 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1170 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1171 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1174 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1175 { |
11581 | 1176 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1178 |
11581 | 1179 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1180 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1181 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1182 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1185 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 { |
11581 | 1187 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 |
11581 | 1190 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1192 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1193 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1196 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 { |
11581 | 1198 GaimGtkWindow *win = data; |
1199 | |
1200 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
|
1201 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1202 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1204 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1205 { |
11581 | 1206 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1207 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1208 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 |
11581 | 1210 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1215 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
|
1216 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1217 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1218 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1219 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1220 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1221 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1222 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1223 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1224 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1225 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1226 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1227 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1228 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1229 time(NULL)); |
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 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1232 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1233 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1234 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1235 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1236 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1237 time(NULL)); |
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 /* 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
|
1240 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1241 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1244 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1245 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1246 { |
11581 | 1247 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1248 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1249 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1250 |
11581 | 1251 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1252 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1253 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1254 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1255 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1256 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1257 |
10377 | 1258 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1259 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
|
1260 } |
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 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1263 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1264 { |
11581 | 1265 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1266 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1267 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1268 |
11581 | 1269 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1270 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1271 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1272 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1274 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1275 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1278 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1279 |
7961 | 1280 static void |
9188 | 1281 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1282 { | |
11581 | 1283 GaimGtkWindow *win = data; |
9188 | 1284 GaimConversation *conv; |
1285 GaimGtkConversation *gtkconv; | |
1286 | |
11581 | 1287 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1288 |
1289 if (!conv) | |
1290 return; | |
1291 | |
1292 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1293 | |
1294 gtkconv->show_timestamps = | |
1295 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
1296 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
1297 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); | |
1298 } | |
1299 | |
1300 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1301 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1302 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1303 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1304 GaimAccount *account; |
1305 GaimConnection *gc; | |
7961 | 1306 GaimPluginProtocolInfo *prpl_info = NULL; |
1307 char *real_who; | |
1308 | |
1309 account = gaim_conversation_get_account(conv); | |
10431 | 1310 g_return_if_fail(account != NULL); |
1311 | |
1312 gc = gaim_account_get_connection(account); | |
1313 g_return_if_fail(gc != NULL); | |
1314 | |
1315 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1316 | |
1317 if (prpl_info && prpl_info->get_cb_real_name) | |
1318 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1319 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1320 else | |
1321 real_who = g_strdup(who); | |
1322 | |
1323 if(!real_who) | |
1324 return; | |
1325 | |
10431 | 1326 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1327 |
1328 g_free(real_who); | |
1329 } | |
1330 | |
1331 static void | |
10810 | 1332 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1333 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1334 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1335 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1336 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1337 GtkTreeSelection *sel; |
9554 | 1338 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1339 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1343 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1344 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1345 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1346 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
|
1347 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1348 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1349 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1350 chat_do_im(gtkconv, name); |
9554 | 1351 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1352 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1353 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1354 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1355 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1356 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1357 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1358 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1359 GaimConvChat *chat; |
11869 | 1360 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1361 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1363 GtkTreeSelection *sel; |
10504 | 1364 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1365 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1366 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1367 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1373 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1374 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1375 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1376 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1377 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1378 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1381 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1382 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1384 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1385 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1387 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 |
11869 | 1389 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1390 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1391 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1395 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1396 { |
1397 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1398 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1399 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1401 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1403 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1404 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1405 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1406 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1407 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1408 | |
1409 serv_send_file(gc, who, NULL); | |
1410 } | |
1411 | |
1412 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1413 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1416 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1417 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1418 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1419 chat_do_info(gtkconv, who); |
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1423 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
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 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1429 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1430 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1431 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1433 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1434 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1437 * 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
|
1438 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1439 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1441 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1442 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1443 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1444 } |
5908
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 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1447 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1448 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1449 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1450 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1451 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1452 GaimAccount *account; |
6695 | 1453 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1455 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1456 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1457 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1458 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1459 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 if (b != NULL) |
9730 | 1461 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1462 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1463 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1464 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1467 |
8143 | 1468 static GtkWidget * |
10504 | 1469 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1470 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1471 { | |
1472 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1473 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1474 gboolean is_me = FALSE; |
8143 | 1475 GtkWidget *button; |
1476 | |
1477 /* | |
1478 * If a menu already exists, destroy it before creating a new one, | |
1479 * thus freeing-up the memory it occupied. | |
1480 */ | |
1481 if (menu) | |
1482 gtk_widget_destroy(menu); | |
1483 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1484 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1485 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1486 |
8143 | 1487 menu = gtk_menu_new(); |
1488 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1489 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1490 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1491 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
|
1492 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
|
1493 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1494 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1495 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1496 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1497 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1498 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1499 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
|
1500 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1501 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1502 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
|
1503 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
|
1504 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1505 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1506 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1507 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1508 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1509 } |
9498 | 1510 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1511 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1512 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
|
1513 G_CALLBACK(menu_chat_info_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); |
8143 | 1515 } |
1516 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1517 if (prpl_info->get_cb_away) { |
10221 | 1518 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
|
1519 G_CALLBACK(menu_chat_get_away_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 (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1524 if (gaim_find_buddy(gc->account, who)) |
10221 | 1525 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
|
1526 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1527 else |
10221 | 1528 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
|
1529 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1530 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1531 } |
1532 | |
1533 return menu; | |
1534 } | |
1535 | |
1536 | |
1537 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1538 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1539 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1540 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1541 GaimPluginProtocolInfo *prpl_info = NULL; |
1542 GaimGtkChatPane *gtkchat; | |
1543 GaimConnection *gc; | |
1544 GaimAccount *account; | |
1545 GtkTreeSelection *sel; | |
1546 GtkTreeIter iter; | |
1547 GtkTreeModel *model; | |
1548 GtkWidget *menu; | |
1549 gchar *who; | |
1550 | |
1551 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1552 gtkchat = gtkconv->u.chat; | |
1553 account = gaim_conversation_get_account(conv); | |
1554 gc = account->gc; | |
1555 | |
1556 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1557 | |
1558 if (gc != NULL) | |
1559 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1560 | |
1561 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1562 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1563 return FALSE; | |
1564 | |
9498 | 1565 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1566 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1567 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1568 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1569 0, GDK_CURRENT_TIME); |
10504 | 1570 g_free(who); |
8143 | 1571 |
1572 return TRUE; | |
1573 } | |
1574 | |
1575 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1576 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1577 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1578 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1579 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1580 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1581 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1582 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1583 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1584 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1585 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1586 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1587 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1588 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1589 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1590 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1591 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1592 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1593 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1594 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1595 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1596 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
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 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
|
1599 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1600 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1601 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1602 return FALSE; |
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 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1605 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1608 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
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 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1611 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
|
1612 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1613 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1614 chat_do_im(gtkconv, who); |
7398 | 1615 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1616 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1617 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1618 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1620 |
10504 | 1621 g_free(who); |
1622 gtk_tree_path_free(path); | |
1623 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1624 return TRUE; |
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 |
8133 | 1627 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1628 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1629 { |
10827 | 1630 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1631 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1632 int index, i, total, found = 0; |
8133 | 1633 |
11581 | 1634 win = gtkconv->win; |
1635 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1636 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1637 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1638 /* 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
|
1639 for (i = forward ? index + 1 : index - 1; |
11581 | 1640 !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
|
1641 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1642 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1643 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1644 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1645 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1646 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1647 found = 1; |
8133 | 1648 } |
11252 | 1649 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1650 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1651 /* 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
|
1652 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1653 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1654 (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
|
1655 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1656 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1657 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1658 found = 1; |
8133 | 1659 } |
10827 | 1660 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1661 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1662 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1663 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1664 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1665 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1666 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1667 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1668 } |
11581 | 1669 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1670 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1671 } |
8133 | 1672 } |
1673 | |
10827 | 1674 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1675 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1676 } |
1677 | |
4359 | 1678 static gboolean |
8105 | 1679 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1680 { |
11581 | 1681 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1682 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1683 GaimGtkConversation *gtkconv; |
8105 | 1684 int curconv; |
1685 | |
10810 | 1686 gtkconv = (GaimGtkConversation *)data; |
10849 | 1687 conv = gtkconv->active_conv; |
11581 | 1688 win = gtkconv->win; |
1689 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1690 |
8105 | 1691 /* If CTRL was held down... */ |
1692 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1693 switch (event->keyval) { |
1694 case GDK_Up: | |
1695 if (!conv->send_history) | |
1696 break; | |
1697 | |
1698 if (!conv->send_history->prev) { | |
1699 GtkTextIter start, end; | |
1700 | |
1701 if (conv->send_history->data) | |
1702 g_free(conv->send_history->data); | |
1703 | |
1704 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1705 &start); | |
1706 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1707 | |
1708 conv->send_history->data = | |
8506 | 1709 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1710 } |
8677 | 1711 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1712 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1713 GObject *object; |
8677 | 1714 GtkTextIter iter; |
1715 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1716 |
1717 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1718 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1719 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1720 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1721 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
|
1722 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1723 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1724 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1725 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1726 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
|
1727 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1728 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1729 |
8061 | 1730 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1731 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1732 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1733 0, NULL); |
8677 | 1734 /* this is mainly just a hack so the formatting at the |
1735 * cursor gets picked up. */ | |
1736 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1737 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1738 } |
1739 | |
8105 | 1740 return TRUE; |
4359 | 1741 break; |
1742 | |
1743 case GDK_Down: | |
1744 if (!conv->send_history) | |
1745 break; | |
1746 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1747 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1748 GObject *object; |
8677 | 1749 GtkTextIter iter; |
1750 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1751 |
4359 | 1752 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1753 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1754 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1755 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1756 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
|
1757 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1758 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1759 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1760 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1761 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
|
1762 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1763 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1764 |
8105 | 1765 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1766 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1767 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1768 0, NULL); |
8677 | 1769 /* this is mainly just a hack so the formatting at the |
1770 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1771 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1772 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1773 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1774 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1775 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1776 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1777 } |
4359 | 1778 } |
1779 | |
8105 | 1780 return TRUE; |
4359 | 1781 break; |
8105 | 1782 |
8108 | 1783 case GDK_Page_Down: |
8143 | 1784 case ']': |
11581 | 1785 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1786 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1787 else |
11581 | 1788 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1789 return TRUE; |
1790 break; | |
1791 | |
8108 | 1792 case GDK_Page_Up: |
8143 | 1793 case '[': |
11581 | 1794 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1795 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1796 else |
11581 | 1797 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1798 return TRUE; |
1799 break; | |
1800 | |
8108 | 1801 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1802 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1803 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1804 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1805 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1806 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1807 } |
8108 | 1808 |
1809 return TRUE; | |
1810 break; | |
1811 | |
11252 | 1812 case GDK_comma: |
11581 | 1813 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1814 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1815 curconv - 1); |
1816 break; | |
1817 | |
1818 case GDK_period: | |
11581 | 1819 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1820 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1821 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1822 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1823 #else |
1824 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1825 #endif | |
11252 | 1826 break; |
1827 | |
8105 | 1828 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1829 } |
8758 | 1830 |
8105 | 1831 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1832 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1833 { |
10864 | 1834 if (event->keyval > '0' && event->keyval <= '9') |
1835 { | |
8105 | 1836 int switchto = event->keyval - '1'; |
11581 | 1837 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1838 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1839 |
1840 return TRUE; | |
1841 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1842 } |
8758 | 1843 |
8105 | 1844 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1845 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1846 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1847 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1848 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1849 case GDK_Tab: |
9605 | 1850 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1851 break; |
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 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1854 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1855 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1856 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1857 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1858 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1859 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1860 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1861 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1862 |
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 } |
4359 | 1865 return FALSE; |
1866 } | |
1867 | |
1868 /* | |
1869 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1870 * 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
|
1871 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1872 * 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
|
1873 * going all the way down to the notebook. I suspect a bug in |
4359 | 1874 * GtkTextView, but I'm not ready to point any fingers yet. |
1875 */ | |
1876 static gboolean | |
1877 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1878 { | |
1879 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1880 /* Right single click */ | |
1881 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1882 | |
1883 return TRUE; | |
1884 } | |
1885 | |
1886 return FALSE; | |
1887 } | |
1888 | |
8173 | 1889 /* |
1890 * If someone tries to type into the conversation backlog of a | |
1891 * conversation window then we yank focus from the conversation backlog | |
1892 * and give it to the text entry box so that people can type | |
1893 * all the live long day and it will get entered into the entry box. | |
1894 */ | |
6057 | 1895 static gboolean |
8105 | 1896 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1897 { |
1898 GaimGtkConversation *gtkconv = data; | |
1899 | |
8237 | 1900 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1901 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1902 (event->keyval == GDK_F10) || |
1903 (event->keyval == GDK_Shift_L) || | |
1904 (event->keyval == GDK_Shift_R) || | |
1905 (event->keyval == GDK_Escape) || | |
8177 | 1906 (event->keyval == GDK_Up) || |
1907 (event->keyval == GDK_Down) || | |
1908 (event->keyval == GDK_Left) || | |
8191 | 1909 (event->keyval == GDK_Right) || |
1910 (event->keyval == GDK_Home) || | |
9297 | 1911 (event->keyval == GDK_End) || |
1912 (event->keyval == GDK_Tab) || | |
1913 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1914 return FALSE; |
1915 | |
1916 if (event->type == GDK_KEY_RELEASE) | |
1917 gtk_widget_grab_focus(gtkconv->entry); | |
1918 | |
1919 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1920 | |
1921 return TRUE; | |
6057 | 1922 } |
1923 | |
4359 | 1924 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1925 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1926 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1927 GaimGtkConversation *gtkconv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1928 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1929 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1930 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1931 gtkconv = GAIM_GTK_CONVERSATION(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 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1934 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1935 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1936 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1937 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1938 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1939 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1940 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1941 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
|
1942 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1943 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1944 void |
11604 | 1945 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1946 { | |
1947 GaimGtkConversation *gtkconv; | |
1948 | |
1949 g_return_if_fail(conv != NULL); | |
1950 | |
1951 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1952 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1953 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1954 |
1955 gray_stuff_out(gtkconv); | |
1956 update_typing_icon(gtkconv); | |
1957 | |
1958 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
1959 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
1960 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
1961 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 1962 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
1963 gaim_account_get_protocol_name(conv->account)); | |
1964 } | |
1965 | |
1966 static void | |
4673 | 1967 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1968 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1969 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 1970 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1971 GaimConversation *conv; |
4359 | 1972 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1973 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1974 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1975 |
11594 | 1976 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 1977 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 1978 } |
1979 | |
1980 static void | |
1981 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1982 gchar *new_text, gint new_text_length, gpointer user_data) | |
1983 { | |
10810 | 1984 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
1985 GaimConversation *conv; | |
1986 | |
1987 g_return_if_fail(gtkconv != NULL); | |
11508 | 1988 |
10810 | 1989 conv = gtkconv->active_conv; |
4359 | 1990 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1991 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1992 return; |
1993 | |
10810 | 1994 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
1995 gtk_text_iter_is_end(position))); | |
4359 | 1996 } |
1997 | |
1998 static void | |
1999 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2000 GtkTextIter *end_pos, gpointer user_data) | |
2001 { | |
10810 | 2002 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2003 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2004 GaimConvIm *im; |
4359 | 2005 |
10810 | 2006 g_return_if_fail(gtkconv != NULL); |
11508 | 2007 |
10810 | 2008 conv = gtkconv->active_conv; |
4359 | 2009 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2010 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2011 return; |
2012 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2013 im = GAIM_CONV_IM(conv); |
4359 | 2014 |
2015 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2016 | |
2017 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2018 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2019 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2020 |
2021 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2022 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2023 GAIM_NOT_TYPING); |
4359 | 2024 } |
2025 else { | |
2026 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2027 got_typing_keypress(gtkconv, FALSE); |
4359 | 2028 } |
2029 } | |
2030 | |
8189 | 2031 /************************************************************************** |
2032 * A bunch of buddy icon functions | |
2033 **************************************************************************/ | |
11581 | 2034 GdkPixbuf * |
2035 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2036 { |
10116 | 2037 GaimAccount *account = NULL; |
2038 const char *name = NULL; | |
7143 | 2039 GdkPixbuf *status = NULL; |
2040 | |
10116 | 2041 g_return_val_if_fail(conv != NULL, NULL); |
2042 | |
2043 account = gaim_conversation_get_account(conv); | |
2044 name = gaim_conversation_get_name(conv); | |
2045 | |
2046 g_return_val_if_fail(account != NULL, NULL); | |
2047 g_return_val_if_fail(name != NULL, NULL); | |
2048 | |
11338 | 2049 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2050 GaimBuddy *b = gaim_find_buddy(account, name); |
2051 if (b != NULL) { | |
2052 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2053 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2054 } |
2055 } | |
2056 | |
2057 if (!status) { | |
2058 GdkPixbuf *pixbuf; | |
10884 | 2059 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2060 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2061 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2062 { |
7143 | 2063 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2064 GDK_INTERP_BILINEAR); | |
2065 g_object_unref(pixbuf); | |
2066 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2067 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2068 status = pixbuf; |
7143 | 2069 } |
2070 return status; | |
2071 } | |
2072 | |
8189 | 2073 static void |
2074 update_tab_icon(GaimConversation *conv) | |
2075 { | |
2076 GaimGtkConversation *gtkconv; | |
11581 | 2077 GaimGtkWindow *win; |
8189 | 2078 GaimAccount *account; |
2079 const char *name; | |
2080 GdkPixbuf *status = NULL; | |
2081 | |
10116 | 2082 g_return_if_fail(conv != NULL); |
2083 | |
8189 | 2084 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2085 win = gtkconv->win; |
8189 | 2086 name = gaim_conversation_get_name(conv); |
2087 account = gaim_conversation_get_account(conv); | |
2088 | |
11581 | 2089 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2090 |
10116 | 2091 g_return_if_fail(status != NULL); |
2092 | |
8189 | 2093 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2094 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2095 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2096 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2097 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2098 |
11581 | 2099 if (gaim_gtk_conv_window_get_active_conversation(win) == conv && |
11338 | 2100 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2101 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2102 { |
11581 | 2103 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2104 | |
2105 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2106 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2107 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2108 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2109 } |
8189 | 2110 } |
2111 | |
2112 static gboolean | |
2113 redraw_icon(gpointer data) | |
2114 { | |
10810 | 2115 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2116 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2117 GaimAccount *account; |
2118 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2119 |
2120 GdkPixbuf *buf; | |
2121 GdkPixbuf *scale; | |
2122 GdkPixmap *pm; | |
2123 GdkBitmap *bm; | |
2124 gint delay; | |
9318 | 2125 int scale_width, scale_height; |
8189 | 2126 |
2127 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2128 account = gaim_conversation_get_account(conv); |
2129 if(account && account->gc) | |
2130 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2131 |
2132 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2133 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2134 | |
10483 | 2135 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2136 NULL, &scale_width, &scale_height); |
2137 | |
2138 /* this code is ugly, and scares me */ | |
8189 | 2139 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2140 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2141 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2142 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2143 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2144 GDK_INTERP_BILINEAR); |
8189 | 2145 |
2146 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2147 g_object_unref(G_OBJECT(scale)); | |
2148 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2149 g_object_unref(G_OBJECT(pm)); | |
2150 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2151 | |
2152 if (bm) | |
2153 g_object_unref(G_OBJECT(bm)); | |
2154 | |
9131 | 2155 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2156 |
2157 if (delay < 100) | |
9131 | 2158 delay = 100; |
2159 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2160 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2161 |
2162 return FALSE; | |
2163 } | |
2164 | |
2165 static void | |
10810 | 2166 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2167 { |
2168 int delay; | |
2169 | |
8228 | 2170 if (gtkconv->u.im->anim == NULL) |
2171 return; | |
2172 | |
8202 | 2173 if (gtkconv->u.im->icon_timer != 0) |
2174 return; | |
2175 | |
8189 | 2176 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2177 return; | |
2178 | |
10639 | 2179 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2180 | |
2181 if (delay < 100) | |
2182 delay = 100; | |
2183 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2184 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2185 } |
2186 | |
2187 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2188 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2189 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2190 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2191 GaimGtkWindow *gtkwin; |
2192 | |
2193 g_return_if_fail(conv != NULL); | |
2194 | |
9887 | 2195 if (gtkconv->u.im->icon_container != NULL) |
2196 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2197 |
2198 if (gtkconv->u.im->anim != NULL) | |
2199 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2200 | |
2201 if (gtkconv->u.im->icon_timer != 0) | |
2202 g_source_remove(gtkconv->u.im->icon_timer); | |
2203 | |
2204 if (gtkconv->u.im->iter != NULL) | |
2205 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2206 | |
2207 gtkconv->u.im->icon_timer = 0; | |
2208 gtkconv->u.im->icon = NULL; | |
2209 gtkconv->u.im->anim = NULL; | |
2210 gtkconv->u.im->iter = NULL; | |
10456 | 2211 gtkconv->u.im->icon_container = NULL; |
9687 | 2212 gtkconv->u.im->show_icon = FALSE; |
10456 | 2213 |
11581 | 2214 gtkwin = gtkconv->win; |
10456 | 2215 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2216 } |
2217 | |
9497 | 2218 static void |
9504 | 2219 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2220 { |
10810 | 2221 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2222 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2223 FILE *fp; |
2224 GaimBuddyIcon *icon; | |
2225 const void *data; | |
2226 size_t len; | |
2227 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2228 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2229 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2230 return; |
2231 } | |
2232 | |
2233 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2234 data = gaim_buddy_icon_get_data(icon, &len); | |
2235 | |
2236 if ((len <= 0) || (data == NULL)) { | |
9504 | 2237 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2238 return; |
2239 } | |
2240 | |
2241 fwrite(data, 1, len, fp); | |
2242 fclose(fp); | |
2243 } | |
2244 | |
2245 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2246 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2247 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2248 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2249 const gchar *ext; |
9497 | 2250 gchar *buf; |
2251 | |
2252 g_return_if_fail(conv != NULL); | |
9504 | 2253 |
10953 | 2254 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2255 if (ext == NULL) | |
2256 ext = "icon"; | |
2257 | |
2258 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2259 |
2260 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2261 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2262 |
2263 g_free(buf); | |
2264 } | |
2265 | |
11581 | 2266 static void |
2267 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2268 { | |
2269 if (gtkconv->u.im->icon_timer != 0) | |
2270 g_source_remove(gtkconv->u.im->icon_timer); | |
2271 | |
2272 gtkconv->u.im->icon_timer = 0; | |
2273 } | |
2274 | |
2275 | |
2276 static void | |
2277 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2278 { | |
2279 gtkconv->u.im->animate = | |
2280 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2281 | |
2282 if (gtkconv->u.im->animate) | |
2283 start_anim(NULL, gtkconv); | |
2284 else | |
2285 stop_anim(NULL, gtkconv); | |
2286 } | |
2287 | |
8189 | 2288 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2289 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2290 { |
2291 static GtkWidget *menu = NULL; | |
2292 GtkWidget *button; | |
2293 | |
2294 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2295 return FALSE; | |
2296 | |
2297 /* | |
2298 * If a menu already exists, destroy it before creating a new one, | |
2299 * thus freeing-up the memory it occupied. | |
2300 */ | |
2301 if (menu != NULL) | |
2302 gtk_widget_destroy(menu); | |
2303 | |
2304 menu = gtk_menu_new(); | |
2305 | |
2306 if (gtkconv->u.im->anim && | |
2307 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2308 { | |
2309 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2310 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2311 gtkconv->u.im->icon_timer); |
2312 } | |
2313 | |
2314 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2315 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2316 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2317 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2318 gtk_widget_show(button); | |
2319 | |
2320 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
|
2321 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2322 0, 0, NULL); |
2323 | |
2324 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2325 | |
2326 return TRUE; | |
2327 } | |
10456 | 2328 |
2329 static void | |
2330 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2331 { | |
11581 | 2332 GaimGtkWindow *win = data; |
10456 | 2333 GaimConversation *conv; |
2334 GaimGtkConversation *gtkconv; | |
2335 gboolean active; | |
2336 | |
11581 | 2337 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2338 |
2339 if (!conv) | |
2340 return; | |
2341 | |
11338 | 2342 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2343 |
2344 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2345 | |
2346 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2347 gtkconv->u.im->show_icon = active; | |
2348 if (active) | |
2349 gaim_gtkconv_update_buddy_icon(conv); | |
2350 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2351 remove_icon(gtkconv); |
10456 | 2352 } |
2353 | |
8189 | 2354 /************************************************************************** |
2355 * End of the bunch of buddy icon functions | |
2356 **************************************************************************/ | |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2357 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2358 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2359 GaimUnseenState min_state) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2360 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2361 GList *l; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2362 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2363 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2364 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2365 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2366 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2367 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2368 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2369 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2370 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2371 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2372 GaimConversation *conv = (GaimConversation*)l->data; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2373 if(GAIM_IS_GTK_CONVERSATION(conv)) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2374 if(GAIM_GTK_CONVERSATION(conv)->unseen_state>=min_state) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2375 return conv; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2376 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2377 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2378 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2379 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2380 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2381 } |
8189 | 2382 |
11581 | 2383 GaimGtkWindow * |
2384 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2385 { | |
2386 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2387 return gtkconv->win; | |
2388 } | |
2389 | |
2390 static GtkItemFactoryEntry menu_items[] = | |
2391 { | |
2392 /* Conversation menu */ | |
2393 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2394 | |
2395 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2396 0, "<StockItem>", GAIM_STOCK_IM }, | |
2397 | |
2398 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2399 | |
2400 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2401 "<StockItem>", GTK_STOCK_FIND }, | |
2402 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, | |
2403 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | |
2404 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
2405 { N_("/Conversation/Clear"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, | |
2406 | |
2407 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2408 | |
2409 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2410 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
2411 0, NULL }, | |
2412 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, | |
2413 "<StockItem>", GAIM_STOCK_INFO }, | |
2414 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2415 "<StockItem>", GAIM_STOCK_INVITE }, | |
2416 | |
2417 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2418 | |
2419 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2420 "<StockItem>", GAIM_STOCK_EDIT }, | |
2421 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2422 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2423 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2424 "<StockItem>", GTK_STOCK_ADD }, | |
2425 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2426 "<StockItem>", GTK_STOCK_REMOVE }, | |
2427 | |
2428 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2429 | |
2430 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2431 "<StockItem>", GAIM_STOCK_LINK }, | |
2432 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2433 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2434 | |
2435 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2436 | |
2437 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2438 "<StockItem>", GTK_STOCK_CLOSE }, | |
2439 | |
2440 /* Options */ | |
2441 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2442 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2443 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2444 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2445 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2446 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2447 }; | |
2448 | |
2449 static const int menu_item_count = | |
2450 sizeof(menu_items) / sizeof(*menu_items); | |
2451 | |
2452 static char * | |
2453 item_factory_translate_func (const char *path, gpointer func_data) | |
2454 { | |
2455 return _((char *)path); | |
2456 } | |
2457 | |
2458 static GtkWidget * | |
2459 setup_menubar(GaimGtkWindow *win) | |
2460 { | |
2461 GtkAccelGroup *accel_group; | |
2462 | |
2463 accel_group = gtk_accel_group_new (); | |
2464 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2465 g_object_unref(accel_group); | |
2466 | |
2467 win->menu.item_factory = | |
2468 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2469 | |
2470 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2471 item_factory_translate_func, | |
2472 NULL, NULL); | |
2473 | |
2474 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2475 menu_items, win); | |
2476 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2477 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2478 | |
2479 | |
2480 win->menu.menubar = | |
2481 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2482 | |
2483 | |
2484 win->menu.view_log = | |
2485 gtk_item_factory_get_widget(win->menu.item_factory, | |
2486 N_("/Conversation/View Log")); | |
2487 | |
2488 /* --- */ | |
2489 | |
2490 win->menu.send_file = | |
2491 gtk_item_factory_get_widget(win->menu.item_factory, | |
2492 N_("/Conversation/Send File...")); | |
2493 | |
2494 win->menu.add_pounce = | |
2495 gtk_item_factory_get_widget(win->menu.item_factory, | |
2496 N_("/Conversation/Add Buddy Pounce...")); | |
2497 | |
2498 /* --- */ | |
2499 | |
2500 win->menu.get_info = | |
2501 gtk_item_factory_get_widget(win->menu.item_factory, | |
2502 N_("/Conversation/Get Info")); | |
2503 | |
2504 win->menu.invite = | |
2505 gtk_item_factory_get_widget(win->menu.item_factory, | |
2506 N_("/Conversation/Invite...")); | |
2507 | |
2508 /* --- */ | |
2509 | |
2510 win->menu.alias = | |
2511 gtk_item_factory_get_widget(win->menu.item_factory, | |
2512 N_("/Conversation/Alias...")); | |
2513 | |
2514 win->menu.block = | |
2515 gtk_item_factory_get_widget(win->menu.item_factory, | |
2516 N_("/Conversation/Block...")); | |
2517 | |
2518 win->menu.add = | |
2519 gtk_item_factory_get_widget(win->menu.item_factory, | |
2520 N_("/Conversation/Add...")); | |
2521 | |
2522 win->menu.remove = | |
2523 gtk_item_factory_get_widget(win->menu.item_factory, | |
2524 N_("/Conversation/Remove...")); | |
2525 | |
2526 /* --- */ | |
2527 | |
2528 win->menu.insert_link = | |
2529 gtk_item_factory_get_widget(win->menu.item_factory, | |
2530 N_("/Conversation/Insert Link...")); | |
2531 | |
2532 win->menu.insert_image = | |
2533 gtk_item_factory_get_widget(win->menu.item_factory, | |
2534 N_("/Conversation/Insert Image...")); | |
2535 | |
2536 /* --- */ | |
2537 | |
2538 win->menu.logging = | |
2539 gtk_item_factory_get_widget(win->menu.item_factory, | |
2540 N_("/Options/Enable Logging")); | |
2541 win->menu.sounds = | |
2542 gtk_item_factory_get_widget(win->menu.item_factory, | |
2543 N_("/Options/Enable Sounds")); | |
2544 win->menu.show_formatting_toolbar = | |
2545 gtk_item_factory_get_widget(win->menu.item_factory, | |
2546 N_("/Options/Show Formatting Toolbars")); | |
2547 win->menu.show_timestamps = | |
2548 gtk_item_factory_get_widget(win->menu.item_factory, | |
2549 N_("/Options/Show Timestamps")); | |
2550 win->menu.show_icon = | |
2551 gtk_item_factory_get_widget(win->menu.item_factory, | |
2552 N_("/Options/Show Buddy Icon")); | |
2553 | |
2554 | |
2555 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2556 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2557 win->menu.tray); | |
2558 gtk_widget_show(win->menu.tray); | |
2559 | |
2560 gtk_widget_show(win->menu.menubar); | |
2561 | |
2562 return win->menu.menubar; | |
2563 } | |
2564 | |
4359 | 2565 |
2566 /************************************************************************** | |
2567 * Utility functions | |
2568 **************************************************************************/ | |
2569 | |
2570 static void | |
10810 | 2571 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2572 { |
10810 | 2573 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2574 GaimConvIm *im; |
4685 | 2575 |
4359 | 2576 /* |
2577 * 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
|
2578 * send GAIM_TYPED any time soon. |
4359 | 2579 */ |
2580 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2581 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2582 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2583 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2584 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2585 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2586 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2587 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2588 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2589 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2590 |
2591 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2592 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2593 GAIM_TYPING); |
4359 | 2594 |
2595 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2596 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2597 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2598 gaim_conv_im_set_type_again(im, 0); |
4359 | 2599 } |
2600 } | |
2601 | |
4736 | 2602 static void |
10810 | 2603 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2604 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2605 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2606 GaimConvIm *im = NULL; |
10810 | 2607 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2608 char *stock_id, *tooltip; |
11508 | 2609 |
11581 | 2610 gtkwin = gtkconv->win; |
4736 | 2611 |
12008 | 2612 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2613 im = GAIM_CONV_IM(conv); |
4736 | 2614 |
12008 | 2615 if (gtkwin->menu.typing_icon) { |
2616 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2617 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2618 |
12008 | 2619 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2620 return; | |
2621 | |
2622 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2623 stock_id = GAIM_STOCK_TYPING; | |
2624 tooltip = _("User is typing..."); | |
2625 } else { | |
2626 stock_id = GAIM_STOCK_TYPED; | |
2627 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2628 } |
12008 | 2629 |
2630 if (gtkwin->menu.typing_icon == NULL) | |
2631 { | |
2632 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
|
2633 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
|
2634 gtkwin->menu.typing_icon, |
12008 | 2635 tooltip); |
4736 | 2636 } |
12008 | 2637 else |
2638 { | |
2639 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2640 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2641 gtkwin->menu.typing_icon, | |
2642 tooltip); | |
2643 } | |
2644 | |
2645 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2646 } |
2647 | |
4685 | 2648 static gboolean |
11594 | 2649 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2650 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2651 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2652 GaimConversation *conv; |
4359 | 2653 GtkWidget *menu; |
2654 GList *child; | |
11594 | 2655 GaimBuddy *b; |
11581 | 2656 |
2657 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2658 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2659 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2660 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2661 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2662 account = gaim_conversation_get_account(conv); |
11581 | 2663 |
11594 | 2664 if (win->menu.send_to == NULL) |
4685 | 2665 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2666 |
11594 | 2667 if (!(b = gaim_find_buddy(account, conv->name))) |
2668 return FALSE; | |
2669 | |
2670 | |
2671 gtk_widget_show(win->menu.send_to); | |
4359 | 2672 |
2673 menu = gtk_menu_item_get_submenu( | |
11594 | 2674 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2675 |
2676 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2677 child != NULL; | |
2678 child = child->next) { | |
2679 | |
2680 GtkWidget *item = child->data; | |
11594 | 2681 GaimBuddy *item_buddy; |
2682 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2683 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2684 "gaim_buddy_name"); | |
2685 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2686 | |
2687 if (b == item_buddy) { | |
4359 | 2688 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2689 break; | |
2690 } | |
2691 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2692 |
4685 | 2693 return FALSE; |
4359 | 2694 } |
2695 | |
2696 static void | |
11594 | 2697 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2698 { | |
2699 GaimAccount *account; | |
2700 GtkWidget *box; | |
2701 GtkWidget *label; | |
2702 GtkWidget *image; | |
2703 GtkWidget *menuitem; | |
11625 | 2704 GdkPixbuf *pixbuf; |
11616 | 2705 gchar *text; |
11594 | 2706 |
2707 account = bud->account; | |
2708 | |
2709 /* Create a pixmap for the protocol icon. */ | |
11625 | 2710 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2711 /* Now convert it to GtkImage */ |
2712 if (pixbuf == NULL) | |
2713 image = gtk_image_new(); | |
2714 else | |
11625 | 2715 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2716 |
2717 gtk_size_group_add_widget(sg, image); | |
2718 | |
2719 g_object_unref(G_OBJECT(pixbuf)); | |
2720 | |
2721 /* Make our menu item */ | |
11616 | 2722 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2723 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2724 g_free(text); | |
11594 | 2725 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2726 | |
2727 /* Do some evil, see some evil, speak some evil. */ | |
2728 box = gtk_hbox_new(FALSE, 0); | |
2729 | |
2730 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2731 g_object_ref(label); | |
2732 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2733 | |
2734 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2735 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2736 | |
2737 g_object_unref(label); | |
2738 | |
2739 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2740 | |
2741 gtk_widget_show(label); | |
2742 gtk_widget_show(image); | |
2743 gtk_widget_show(box); | |
2744 | |
2745 /* Set our data and callbacks. */ | |
2746 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2747 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2748 | |
2749 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2750 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2751 | |
2752 gtk_widget_show(menuitem); | |
2753 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2754 } | |
2755 | |
2756 static void | |
2757 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2758 { |
4359 | 2759 GtkWidget *menu; |
2760 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2761 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2762 GaimGtkConversation *gtkconv; |
2763 GSList *l, *buds; | |
2764 | |
2765 g_return_if_fail(win != NULL); | |
2766 | |
2767 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2768 | |
11604 | 2769 g_return_if_fail(gtkconv != NULL); |
2770 | |
11594 | 2771 if (win->menu.send_to != NULL) |
2772 gtk_widget_destroy(win->menu.send_to); | |
2773 | |
4359 | 2774 |
2775 /* Build the Send As menu */ | |
11594 | 2776 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2777 gtk_widget_show(win->menu.send_to); | |
4359 | 2778 |
2779 menu = gtk_menu_new(); | |
11581 | 2780 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2781 win->menu.send_to, 2); |
2782 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2783 |
2784 gtk_widget_show(menu); | |
2785 | |
11604 | 2786 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2787 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2788 for (l = buds; l != NULL; l = l->next) { | |
2789 GaimBuddy *b; | |
2790 GaimBlistNode *node; | |
2791 | |
2792 b = l->data; | |
2793 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2794 | |
2795 for (node = node->child; node != NULL; node = node->next) | |
2796 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2797 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2798 } | |
2799 | |
2800 g_slist_free(buds); | |
4359 | 2801 } |
2802 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2803 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2804 |
11594 | 2805 gtk_widget_show(win->menu.send_to); |
2806 if (!group) | |
2807 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2808 update_send_to_selection(win); | |
4359 | 2809 } |
2810 | |
2811 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2812 generate_invite_user_names(GaimConnection *gc) |
4359 | 2813 { |
6695 | 2814 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2815 static GList *tmp = NULL; |
2816 | |
2817 if (tmp) | |
2818 g_list_free(tmp); | |
2819 | |
2820 tmp = g_list_append(NULL, ""); | |
2821 | |
2822 if (gc != NULL) { | |
4785 | 2823 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2824 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2825 continue; | |
6695 | 2826 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2827 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2828 continue; |
6695 | 2829 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2830 GaimBuddy *buddy; | |
2831 | |
2832 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2833 continue; | |
2834 | |
2835 buddy = (GaimBuddy *)bnode; | |
2836 | |
2837 if (buddy->account == gc->account && | |
2838 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2839 tmp = g_list_insert_sorted(tmp, buddy->name, |
2840 (GCompareFunc)g_utf8_collate); | |
6695 | 2841 } |
4359 | 2842 } |
2843 } | |
2844 } | |
2845 | |
2846 return tmp; | |
2847 } | |
2848 | |
9498 | 2849 static GdkPixbuf * |
9554 | 2850 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2851 { |
9554 | 2852 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2853 char *filename; |
10274 | 2854 const char *image = NULL; |
9554 | 2855 |
2856 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2857 image = "founder.png"; |
9554 | 2858 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2859 image = "op.png"; |
9554 | 2860 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2861 image = "halfop.png"; |
9554 | 2862 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2863 image = "voice.png"; |
9554 | 2864 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2865 image = "ignored.png"; |
2866 } else { | |
2867 return NULL; | |
9554 | 2868 } |
10274 | 2869 |
2870 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2871 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2872 g_free(filename); | |
2873 | |
2874 if (!pixbuf) | |
2875 return NULL; | |
2876 | |
2877 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2878 g_object_unref(pixbuf); | |
2879 | |
2880 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2881 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2882 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2883 g_free(filename); | |
10274 | 2884 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2885 g_object_unref(pixbuf); |
10274 | 2886 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2887 g_object_unref(scale2); | |
9498 | 2888 } |
2889 | |
10274 | 2890 return scale; |
9498 | 2891 } |
2892 | |
4359 | 2893 static void |
11869 | 2894 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 2895 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2896 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2897 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2898 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2899 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2900 GaimPluginProtocolInfo *prpl_info; |
4359 | 2901 GtkListStore *ls; |
9498 | 2902 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2903 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2904 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2905 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2906 GdkColor send_color; |
11508 | 2907 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2908 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 2909 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2910 chat = GAIM_CONV_CHAT(conv); |
4359 | 2911 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2912 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2913 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2914 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2915 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2916 return; |
4359 | 2917 |
2918 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
2919 | |
9554 | 2920 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 2921 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
2922 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
|
2923 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2924 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2925 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2926 |
4359 | 2927 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2928 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2929 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2930 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2931 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2932 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2933 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
|
2934 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2935 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2936 |
9554 | 2937 if (pixbuf) |
2938 g_object_unref(pixbuf); | |
4359 | 2939 } |
2940 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2941 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2942 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
|
2943 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2944 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2945 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2946 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2947 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2948 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2949 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2950 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2951 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2952 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2953 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2954 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2955 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2956 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2957 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2958 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2959 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2960 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2961 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2962 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2963 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2964 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2965 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2966 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2967 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2968 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2969 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2970 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2971 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2972 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2973 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2974 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2975 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2976 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2977 |
9605 | 2978 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2979 tab_complete(GaimConversation *conv) |
4359 | 2980 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2981 GaimGtkConversation *gtkconv; |
4359 | 2982 GtkTextIter cursor, word_start, start_buffer; |
2983 int start; | |
2984 int most_matched = -1; | |
2985 char *entered, *partial = NULL; | |
2986 char *text; | |
8021 | 2987 char *nick_partial; |
9605 | 2988 const char *prefix; |
4359 | 2989 GList *matches = NULL; |
9605 | 2990 gboolean command = FALSE; |
4359 | 2991 |
2992 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2993 | |
2994 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
2995 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2996 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2997 | |
2998 word_start = cursor; | |
2999 | |
3000 /* if there's nothing there just return */ | |
3001 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3002 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
|
3003 |
4359 | 3004 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3005 &cursor, FALSE); | |
3006 | |
3007 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3008 start = strlen(text) - 1; | |
3009 | |
8021 | 3010 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3011 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3012 start-=2; |
3013 } | |
4359 | 3014 |
3015 /* find the start of the word that we're tabbing */ | |
3016 while (start >= 0 && text[start] != ' ') { | |
3017 gtk_text_iter_backward_char(&word_start); | |
3018 start--; | |
3019 } | |
3020 | |
9605 | 3021 prefix = gaim_gtk_get_cmd_prefix(); |
3022 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3023 command = TRUE; | |
3024 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3025 } | |
3026 | |
4359 | 3027 g_free(text); |
3028 | |
3029 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3030 &cursor, FALSE); | |
3031 | |
8021 | 3032 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3033 g_free(entered); |
11338 | 3034 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3035 } |
3036 | |
8021 | 3037 nick_partial = g_malloc(strlen(entered)+1); |
3038 | |
9605 | 3039 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3040 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3041 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3042 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3043 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3044 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3045 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3046 &matches, TRUE, l->data); |
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 g_list_free(list); |
11338 | 3049 } 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
|
3050 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3051 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3052 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
|
3053 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3054 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3055 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3056 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3057 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3058 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3059 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3060 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3061 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3062 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3064 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
|
3065 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3066 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3067 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3068 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3069 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3070 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3071 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3072 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3073 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3074 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3075 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3076 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3077 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3078 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3079 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3080 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3081 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3082 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3083 } |
9605 | 3084 } else { |
3085 g_free(nick_partial); | |
3086 g_free(entered); | |
3087 return FALSE; | |
3088 } | |
3089 | |
8021 | 3090 g_free(nick_partial); |
3091 | |
4359 | 3092 /* we're only here if we're doing new style */ |
3093 | |
3094 /* if there weren't any matches, return */ | |
3095 if (!matches) { | |
3096 /* if matches isn't set partials won't be either */ | |
3097 g_free(entered); | |
11338 | 3098 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3099 } |
3100 | |
3101 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3102 | |
3103 if (!matches->next) { | |
3104 /* there was only one match. fill it in. */ | |
3105 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3106 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3107 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3108 | |
3109 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3110 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3111 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3112 g_free(tmp); | |
3113 } | |
3114 else | |
3115 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3116 matches->data, -1); | |
3117 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3118 g_free(matches->data); |
4359 | 3119 matches = g_list_remove(matches, matches->data); |
3120 } | |
3121 else { | |
3122 /* | |
3123 * there were lots of matches, fill in as much as possible | |
3124 * and display all of them | |
3125 */ | |
3126 char *addthis = g_malloc0(1); | |
3127 | |
3128 while (matches) { | |
3129 char *tmp = addthis; | |
3130 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3131 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3132 g_free(matches->data); |
4359 | 3133 matches = g_list_remove(matches, matches->data); |
3134 } | |
3135 | |
6982 | 3136 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3137 time(NULL)); |
3138 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3139 g_free(addthis); | |
3140 } | |
3141 | |
3142 g_free(entered); | |
3143 g_free(partial); | |
9605 | 3144 |
3145 return TRUE; | |
4359 | 3146 } |
3147 | |
10810 | 3148 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3149 { |
3150 GaimPluginProtocolInfo *prpl_info = NULL; | |
3151 GaimConnection *gc; | |
10810 | 3152 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3153 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3154 char *new_topic; |
8858 | 3155 const char *current_topic; |
7971 | 3156 |
3157 gc = gaim_conversation_get_gc(conv); | |
3158 | |
3159 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3160 return; | |
3161 | |
3162 if(prpl_info->set_chat_topic == NULL) | |
3163 return; | |
3164 | |
3165 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3166 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3167 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3168 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3169 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3170 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3171 g_free(new_topic); |
7971 | 3172 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3173 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3174 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3175 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3176 |
8858 | 3177 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3178 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3179 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3180 g_free(new_topic); |
7971 | 3181 } |
3182 | |
9554 | 3183 static gint |
3184 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3185 { | |
3186 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3187 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3188 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3189 gint ret = 0; |
3190 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3191 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3192 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3193 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3194 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3195 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3196 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3197 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3198 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3199 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3200 -1); |
9554 | 3201 |
3202 if (user1 == NULL || user2 == NULL) { | |
3203 if (!(user1 == NULL && user2 == NULL)) | |
3204 ret = (user1 == NULL) ? -1: 1; | |
3205 } else if (f1 != f2) { | |
3206 /* sort more important users first */ | |
3207 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3208 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3209 ret = buddy1 ? -1 : 1; |
9554 | 3210 } else { |
10904 | 3211 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3212 } |
3213 | |
3214 g_free(user1); | |
3215 g_free(user2); | |
3216 | |
3217 return ret; | |
3218 } | |
3219 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3220 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3221 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
|
3222 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3223 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3224 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3225 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3226 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3227 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3228 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3229 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3230 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3231 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3232 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3233 /* 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
|
3234 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
|
3235 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3236 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
|
3237 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3238 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3239 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3240 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3241 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3242 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3243 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3244 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
|
3245 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3246 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3247 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3248 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3249 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3250 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3251 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3252 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3253 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3254 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3255 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3256 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3257 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3258 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3259 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3260 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3261 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3262 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3263 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3264 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3265 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3266 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3267 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3268 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3269 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3270 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3271 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3272 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3273 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3274 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
|
3275 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3276 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3277 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3278 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3280 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3281 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3282 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3283 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3284 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3285 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3286 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3287 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3291 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3292 GaimBlistNode *bnode; |
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 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3295 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3296 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3297 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3298 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
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 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3305 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3306 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3308 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3309 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3310 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3313 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3314 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3317 /* 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
|
3318 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3319 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3320 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 /* 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
|
3322 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
|
3323 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3324 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
|
3325 return; |
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 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3331 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 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
|
3333 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 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
|
3336 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3341 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3344 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 g_free(normalized_name); |
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 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
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 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3355 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3358 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 /* 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
|
3360 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3361 return; |
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 buddy_cb_common(buddy, conv, FALSE); |
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 |
4359 | 3366 static GtkWidget * |
10810 | 3367 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3368 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3369 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3370 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3371 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3372 GaimConnection *gc; |
4359 | 3373 GtkWidget *vpaned, *hpaned; |
10175 | 3374 GtkWidget *vbox, *hbox, *frame; |
4359 | 3375 GtkWidget *lbox, *bbox; |
3376 GtkWidget *label; | |
3377 GtkWidget *list; | |
3378 GtkWidget *button; | |
7949 | 3379 GtkWidget *sw; |
4359 | 3380 GtkListStore *ls; |
3381 GtkCellRenderer *rend; | |
3382 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3383 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3384 GList *focus_chain = NULL; |
4359 | 3385 |
3386 gtkchat = gtkconv->u.chat; | |
3387 gc = gaim_conversation_get_gc(conv); | |
3388 | |
3389 /* Setup the outer pane. */ | |
3390 vpaned = gtk_vpaned_new(); | |
3391 gtk_widget_show(vpaned); | |
3392 | |
3393 /* Setup the top part of the pane. */ | |
11243 | 3394 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3395 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3396 gtk_widget_show(vbox); |
3397 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3398 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3399 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3400 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3401 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3402 { |
11243 | 3403 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3404 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3405 gtk_widget_show(hbox); |
3406 | |
3407 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3408 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3409 gtk_widget_show(label); |
3410 | |
3411 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3412 |
7971 | 3413 if(prpl_info->set_chat_topic == NULL) { |
3414 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3415 } else { | |
3416 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3417 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3418 } |
3419 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3420 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3421 gtk_widget_show(gtkchat->topic_text); |
3422 } | |
3423 | |
3424 /* Setup the horizontal pane. */ | |
3425 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3426 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3427 gtk_widget_show(hpaned); |
3428 | |
10175 | 3429 /* Setup gtkihmtml. */ |
3430 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3431 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3432 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3433 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3434 gtk_widget_show(frame); | |
3435 | |
3436 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3437 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3438 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3439 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3440 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3441 |
4359 | 3442 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3443 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3444 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3445 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3446 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3447 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3448 |
3449 /* Build the right pane. */ | |
11243 | 3450 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3451 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3452 gtk_widget_show(lbox); |
3453 | |
3454 /* Setup the label telling how many people are in the room. */ | |
3455 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3456 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3457 gtk_widget_show(gtkchat->count); | |
3458 | |
3459 /* Setup the list of users. */ | |
7949 | 3460 sw = gtk_scrolled_window_new(NULL, NULL); |
3461 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3462 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3463 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3464 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3465 gtk_widget_show(sw); | |
4359 | 3466 |
9554 | 3467 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
|
3468 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
|
3469 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3470 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3471 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3472 GTK_SORT_ASCENDING); |
3473 | |
3474 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3475 | |
9498 | 3476 rend = gtk_cell_renderer_pixbuf_new(); |
3477 | |
4359 | 3478 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3479 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3480 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3481 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3482 |
3483 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3484 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3485 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3486 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3487 |
9498 | 3488 rend = gtk_cell_renderer_text_new(); |
3489 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3490 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3491 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3492 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3493 NULL); |
4359 | 3494 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3495 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3496 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3497 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3498 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3499 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3500 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3501 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3502 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3503 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3504 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3505 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3506 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3507 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3508 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3509 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3510 #endif |
4359 | 3511 |
3512 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3513 | |
3514 gtk_widget_set_size_request(list, 150, -1); | |
3515 | |
3516 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3517 gtk_widget_show(list); | |
3518 | |
3519 gtkchat->list = list; | |
3520 | |
7949 | 3521 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3522 |
3523 /* Setup the user list toolbar. */ | |
11243 | 3524 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3525 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3526 gtk_widget_show(bbox); | |
3527 | |
3528 /* IM */ | |
10221 | 3529 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3530 GAIM_BUTTON_VERTICAL); |
10500 | 3531 gtkchat->userlist_im = button; |
4359 | 3532 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3533 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
|
3534 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3535 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3536 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3537 |
3538 gtk_widget_show(button); | |
3539 | |
3540 /* Ignore */ | |
3541 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3542 GAIM_BUTTON_VERTICAL); | |
10500 | 3543 gtkchat->userlist_ignore = button; |
4359 | 3544 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3545 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
|
3546 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3547 _("Ignore the user"), NULL); |
4359 | 3548 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3549 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3550 gtk_widget_show(button); |
3551 | |
3552 /* Info */ | |
3553 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3554 GAIM_BUTTON_VERTICAL); | |
10500 | 3555 gtkchat->userlist_info = button; |
4359 | 3556 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3557 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3558 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3559 _("Get the user's information"), NULL); |
4359 | 3560 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3561 G_CALLBACK(info_cb), gtkconv); |
4359 | 3562 |
3563 gtk_widget_show(button); | |
3564 | |
10175 | 3565 /* Setup the bottom half of the conversation window */ |
11243 | 3566 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3567 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3568 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3569 |
11243 | 3570 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3571 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3572 gtk_widget_show(gtkconv->lower_hbox); | |
3573 | |
11243 | 3574 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3575 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3576 gtk_widget_show(vbox); | |
3577 | |
10175 | 3578 /* Setup the toolbar, entry widget and all signals */ |
3579 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3580 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3581 gtk_widget_show(frame); |
3582 | |
9005 | 3583 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3584 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3585 gaim_account_get_protocol_name(conv->account)); |
10175 | 3586 gtk_widget_set_size_request(gtkconv->entry, -1, |
3587 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3588 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3589 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3590 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3591 |
3592 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3593 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3594 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3595 G_CALLBACK(send_cb), gtkconv); |
4359 | 3596 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3597 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3598 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3599 G_CALLBACK(size_allocate_cb), gtkconv); |
3600 | |
3601 default_formatize(gtkconv); | |
4359 | 3602 |
9080 | 3603 /* |
3604 * Focus for chat windows should be as follows: | |
3605 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3606 * user list buttons -> entry -> buttons at bottom | |
3607 */ | |
9332 | 3608 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3609 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3610 | |
4359 | 3611 return vpaned; |
3612 } | |
3613 | |
3614 static GtkWidget * | |
10810 | 3615 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3616 { |
10810 | 3617 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3618 GtkWidget *frame; |
4359 | 3619 GtkWidget *paned; |
10175 | 3620 GtkWidget *vbox; |
3621 GtkWidget *vbox2; | |
9080 | 3622 GList *focus_chain = NULL; |
4359 | 3623 |
10175 | 3624 /* Setup the outer pane */ |
4359 | 3625 paned = gtk_vpaned_new(); |
3626 gtk_widget_show(paned); | |
3627 | |
10175 | 3628 /* Setup the top part of the pane */ |
11243 | 3629 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3630 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3631 gtk_widget_show(vbox); |
3632 | |
10175 | 3633 /* Setup the gtkimhtml widget */ |
3634 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3635 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3636 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3637 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3638 gtk_widget_show(frame); | |
3639 | |
3640 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3641 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3642 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3643 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3644 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3645 |
3646 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3647 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3648 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3649 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3650 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3651 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3652 |
10175 | 3653 /* Setup the bottom half of the conversation window */ |
11243 | 3654 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3655 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3656 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3657 |
11243 | 3658 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3659 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3660 gtk_widget_show(gtkconv->lower_hbox); | |
3661 | |
11243 | 3662 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3663 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3664 gtk_widget_show(vbox2); | |
8821 | 3665 |
10175 | 3666 /* Setup the toolbar, entry widget and all signals */ |
3667 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3668 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3669 gtk_widget_show(frame); |
3670 | |
9005 | 3671 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3672 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3673 gaim_account_get_protocol_name(conv->account)); |
10175 | 3674 gtk_widget_set_size_request(gtkconv->entry, -1, |
3675 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3676 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3677 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3678 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
|
3679 |
4359 | 3680 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3681 G_CALLBACK(entry_key_press_cb), gtkconv); |
3682 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3683 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3684 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3685 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3686 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3687 |
3688 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3689 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3690 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3691 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3692 |
8481 | 3693 /* had to move this after the imtoolbar is attached so that the |
3694 * signals get fired to toggle the buttons on the toolbar as well. | |
3695 */ | |
10810 | 3696 default_formatize(gtkconv); |
4359 | 3697 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3698 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3699 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3700 |
8758 | 3701 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3702 gtkconv->u.im->show_icon = TRUE; |
4359 | 3703 |
9080 | 3704 /* |
3705 * Focus for IM windows should be as follows: | |
10356 | 3706 * Tab title -> conversation scrollback -> entry |
9080 | 3707 */ |
9332 | 3708 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3709 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3710 |
4359 | 3711 return paned; |
3712 } | |
3713 | |
3714 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3715 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3716 GtkSelectionData *sd, guint info, guint t, |
3717 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3718 { |
10810 | 3719 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3720 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3721 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3722 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3723 { |
4781 | 3724 GaimBlistNode *n = NULL; |
6695 | 3725 GaimBuddy *b; |
11581 | 3726 GaimGtkConversation *gtkconv = NULL; |
9622 | 3727 |
11812 | 3728 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3729 |
6695 | 3730 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3731 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3732 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3733 b = (GaimBuddy*)n; | |
3734 else | |
4781 | 3735 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3736 |
9622 | 3737 /* |
3738 * If we already have an open conversation with this buddy, then | |
3739 * just move the conv to this window. Otherwise, create a new | |
3740 * conv and add it to this window. | |
3741 */ | |
11338 | 3742 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3743 if (c != NULL) { |
11581 | 3744 GaimGtkWindow *oldwin; |
3745 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3746 oldwin = gtkconv->win; | |
9622 | 3747 if (oldwin != win) { |
11581 | 3748 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3749 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3750 } |
3751 } else { | |
11338 | 3752 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3753 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3754 if (gtkconv->win != win) |
3755 { | |
3756 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3757 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3758 } | |
9622 | 3759 } |
3760 | |
3761 /* Make this conversation the active conversation */ | |
11581 | 3762 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3763 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3764 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3765 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3766 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
|
3767 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3768 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3769 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3770 GaimAccount *account; |
11581 | 3771 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3772 |
11137 | 3773 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3774 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3775 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3776 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3777 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3778 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3779 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3780 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3781 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3782 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3783 { |
11338 | 3784 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3785 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3786 if (gtkconv->win != win) |
3787 { | |
3788 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3789 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3790 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3791 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3792 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3793 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3794 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3795 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3796 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3797 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3798 } |
9525 | 3799 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3800 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3801 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3802 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3803 } |
10145 | 3804 else |
3805 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3806 } |
4359 | 3807 |
3808 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3809 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3810 { |
10145 | 3811 GTK_IMHTML_DND_TARGETS, |
3812 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3813 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3814 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3815 |
10810 | 3816 static GaimGtkConversation * |
3817 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3818 { | |
3819 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3820 GaimContact *c; | |
3821 GaimBlistNode *cn; | |
10935 | 3822 |
10810 | 3823 if (!bud) |
3824 return NULL; | |
10935 | 3825 |
10810 | 3826 if (!(c = gaim_buddy_get_contact(bud))) |
3827 return NULL; | |
10935 | 3828 |
10810 | 3829 cn = (GaimBlistNode *)c; |
3830 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3831 GaimConversation *conv; | |
11338 | 3832 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3833 if (conv->ui_data) |
3834 return conv->ui_data; | |
3835 } | |
3836 } | |
10935 | 3837 |
10810 | 3838 return NULL; |
3839 } | |
3840 | |
11855 | 3841 static void |
3842 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3843 { | |
3844 GList *list; | |
3845 | |
3846 g_return_if_fail(bnode); | |
3847 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3848 | |
3849 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3850 { | |
3851 GaimGtkWindow *win = list->data; | |
3852 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3853 | |
3854 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3855 continue; | |
3856 | |
3857 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3858 } | |
3859 } | |
3860 | |
11581 | 3861 /************************************************************************** |
3862 * Conversation UI operations | |
3863 **************************************************************************/ | |
3864 void | |
3865 gaim_gtkconv_new(GaimConversation *conv) | |
3866 { | |
3867 GaimGtkConversation *gtkconv; | |
3868 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3869 GtkWidget *pane = NULL; |
3870 GtkWidget *tab_cont; | |
11581 | 3871 |
3872 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3873 conv->ui_data = gtkconv; |
3874 if (!g_list_find(gtkconv->convs, conv)) | |
3875 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3876 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3877 return; |
4359 | 3878 } |
3879 | |
11581 | 3880 gtkconv = g_new0(GaimGtkConversation, 1); |
3881 conv->ui_data = gtkconv; | |
3882 gtkconv->active_conv = conv; | |
3883 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3884 | |
3885 /* Setup some initial variables. */ | |
3886 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3887 gtkconv->tooltips = gtk_tooltips_new(); | |
3888 | |
3889 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3890 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3891 | |
3892 pane = setup_im_pane(gtkconv); | |
3893 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3894 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3895 pane = setup_chat_pane(gtkconv); | |
3896 } | |
3897 | |
3898 if (pane == NULL) { | |
3899 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
3900 g_free(gtkconv->u.chat); | |
3901 else if (conv_type == GAIM_CONV_TYPE_IM) | |
3902 g_free(gtkconv->u.im); | |
3903 | |
3904 g_free(gtkconv); | |
3905 conv->ui_data = NULL; | |
3906 return; | |
10449 | 3907 } |
11581 | 3908 |
3909 /* Setup drag-and-drop */ | |
3910 gtk_drag_dest_set(pane, | |
3911 GTK_DEST_DEFAULT_MOTION | | |
3912 GTK_DEST_DEFAULT_DROP, | |
3913 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3914 GDK_ACTION_COPY); | |
3915 gtk_drag_dest_set(pane, | |
3916 GTK_DEST_DEFAULT_MOTION | | |
3917 GTK_DEST_DEFAULT_DROP, | |
3918 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3919 GDK_ACTION_COPY); | |
3920 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
3921 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3922 GDK_ACTION_COPY); | |
3923 | |
3924 gtk_drag_dest_set(gtkconv->entry, 0, | |
3925 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3926 GDK_ACTION_COPY); | |
3927 | |
3928 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
3929 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3930 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
3931 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3932 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
3933 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3934 | |
3935 /* Setup the container for the tab. */ | |
3936 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
3937 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
3938 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
3939 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
3940 gtk_widget_show(pane); | |
3941 | |
3942 gtkconv->make_sound = TRUE; | |
3943 | |
3944 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
3945 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
3946 else |
11581 | 3947 gtk_widget_hide(gtkconv->toolbar); |
3948 | |
3949 gtkconv->show_timestamps = TRUE; | |
3950 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
3951 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
3952 gaim_account_get_protocol_name(conv->account)); |
11581 | 3953 |
3954 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
3955 G_CALLBACK(gtk_widget_grab_focus), | |
3956 gtkconv->entry); | |
3957 | |
3958 gaim_gtkconv_placement_place(gtkconv); | |
3959 } | |
3960 | |
4359 | 3961 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3962 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 3963 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3964 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 3965 |
10810 | 3966 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
3967 /* Don't destroy ourselves until all our convos are gone */ | |
3968 if (gtkconv->convs) | |
3969 return; | |
11508 | 3970 |
11581 | 3971 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
3972 | |
9504 | 3973 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
3974 gaim_request_close_with_handle(conv); | |
4359 | 3975 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3976 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 3977 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3978 |
11338 | 3979 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 3980 if (gtkconv->u.im->icon_timer != 0) |
3981 g_source_remove(gtkconv->u.im->icon_timer); | |
3982 | |
4359 | 3983 if (gtkconv->u.im->anim != NULL) |
4793 | 3984 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 3985 |
3986 g_free(gtkconv->u.im); | |
11581 | 3987 } 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
|
3988 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 3989 g_free(gtkconv->u.chat); |
3990 } | |
3991 | |
4633 | 3992 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
3993 | |
4359 | 3994 g_free(gtkconv); |
3995 } | |
3996 | |
3997 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3998 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 3999 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4000 time_t mtime) |
4359 | 4001 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4002 GaimGtkConversation *gtkconv; |
4359 | 4003 |
4004 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4005 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4006 |
6982 | 4007 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4008 } |
4009 | |
4010 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4011 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4012 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4013 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4014 GaimGtkConversation *gtkconv; |
4359 | 4015 |
4016 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4017 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4018 |
10398 | 4019 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4020 |
6982 | 4021 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4022 } |
4023 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4024 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4025 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4026 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4027 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4028 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4029 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4030 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4031 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4032 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4033 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4034 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4035 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4036 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4037 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4038 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4039 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4040 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4041 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4042 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4043 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4044 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4045 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4046 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4047 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4048 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4049 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4050 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4051 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4052 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4053 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4054 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4055 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4056 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4057 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4058 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4059 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4060 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4061 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4062 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4063 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4064 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4065 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4066 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4067 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4068 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4069 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4070 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4071 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4072 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4073 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4074 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4075 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4076 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4077 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4078 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4079 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4080 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4081 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4082 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4083 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4084 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4085 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4086 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4087 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4088 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4089 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4090 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4091 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4092 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4093 buddytag = gtk_text_buffer_create_tag( |
11096 | 4094 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4095 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4096 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4097 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4098 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4099 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4100 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4101 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4102 |
4359 | 4103 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4104 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4105 const char *message, GaimMessageFlags flags, |
4359 | 4106 time_t mtime) |
4107 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4108 GaimGtkConversation *gtkconv; |
11581 | 4109 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4110 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4111 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4112 GaimPluginProtocolInfo *prpl_info; |
4359 | 4113 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4114 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4115 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4116 int line_count; |
4359 | 4117 char buf2[BUF_LONG]; |
4118 char mdate[64]; | |
4119 char color[10]; | |
4120 char *str; | |
4121 char *with_font_tag; | |
4896 | 4122 char *sml_attrib = NULL; |
6982 | 4123 size_t length = strlen(message) + 1; |
4895 | 4124 |
4359 | 4125 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4126 |
4127 /* Set the active conversation to the one that just messaged us. */ | |
4128 /* 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
|
4129 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4130 |
4359 | 4131 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4132 account = gaim_conversation_get_account(conv); |
11581 | 4133 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4134 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4135 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4136 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4137 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4138 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4139 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4140 /* 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
|
4141 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4142 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4143 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4144 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4145 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4146 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4147 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4148 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4149 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4150 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4151 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4152 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4153 |
8677 | 4154 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4155 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4156 | |
5133 | 4157 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4158 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4159 else | |
4160 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4161 |
4896 | 4162 if(gc) |
9699 | 4163 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4164 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4165 |
10503 | 4166 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4167 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4168 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4169 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4170 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4171 |
7956 | 4172 /* this is gonna crash one day, I can feel it. */ |
4173 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4174 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4175 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4176 } |
4359 | 4177 |
10737 | 4178 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4179 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4180 g_snprintf(buf2, sizeof(buf2), |
8690 | 4181 "<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
|
4182 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4183 |
8962 | 4184 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4185 |
8722 | 4186 } else if (flags & GAIM_MESSAGE_ERROR) { |
4187 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4188 "<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
|
4189 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4190 |
8962 | 4191 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4192 | |
7431 | 4193 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4194 g_snprintf(buf2, BUF_LONG, |
8690 | 4195 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4196 sml_attrib ? sml_attrib : "", message); |
7440 | 4197 |
10884 | 4198 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4199 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4200 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4201 } else { |
4895 | 4202 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4203 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
|
4204 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4205 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4206 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
|
4207 int tag_end_offset = 0; |
7440 | 4208 |
6621 | 4209 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4210 str = g_malloc(1024); |
7440 | 4211 |
4359 | 4212 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4213 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4214 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4215 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4216 tag_start_offset += 3; |
4359 | 4217 } |
4218 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4219 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4220 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4221 tag_end_offset = 2; |
4359 | 4222 strcpy(color, "#00FF00"); |
4223 } | |
7440 | 4224 } |
4359 | 4225 else { |
10504 | 4226 if (gaim_message_meify(new_message, -1)) { |
4359 | 4227 str = g_malloc(1024); |
7440 | 4228 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4229 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4230 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
|
4231 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4232 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4233 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4234 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4235 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4236 } |
7440 | 4237 |
6621 | 4238 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4239 strcpy(color, "#AF7F00"); |
4240 else | |
4241 strcpy(color, "#062585"); | |
4242 } | |
4243 else { | |
4244 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4245 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4246 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
|
4247 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4248 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4249 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4250 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4251 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4252 } |
6621 | 4253 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4254 strcpy(color, "#AF7F00"); |
6621 | 4255 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4256 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4257 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4258 |
10108 | 4259 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4260 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4261 } else |
7854 | 4262 strcpy(color, RECV_COLOR); |
4359 | 4263 } |
6621 | 4264 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4265 strcpy(color, SEND_COLOR); |
10892 | 4266 else { |
4267 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4268 strcpy(color, "#000000"); | |
4269 } | |
4359 | 4270 } |
4271 } | |
10892 | 4272 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4273 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4274 g_free(alias_escaped); |
11508 | 4275 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4276 /* 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
|
4277 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4278 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4279 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4280 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4281 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4282 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4283 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4284 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4285 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4286 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4287 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4288 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4289 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4290 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4291 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4292 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4293 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4294 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4295 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4296 /* 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
|
4297 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4298 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4299 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4300 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4301 } |
7440 | 4302 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4303 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4304 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4305 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4306 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4307 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4308 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4309 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4310 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4311 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4312 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4313 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4314 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4315 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4316 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4317 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4318 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4319 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4320 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4321 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4322 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4323 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4324 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4325 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4326 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4327 |
4359 | 4328 g_free(str); |
4329 | |
4895 | 4330 if(gc){ |
4896 | 4331 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4332 char *post = "</font>"; |
4333 int pre_len = strlen(pre); | |
4334 int post_len = strlen(post); | |
7440 | 4335 |
4895 | 4336 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4337 |
4895 | 4338 strcpy(with_font_tag, pre); |
4339 memcpy(with_font_tag + pre_len, new_message, length); | |
4340 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4341 |
4895 | 4342 length += pre_len + post_len; |
4343 g_free(pre); | |
4344 } | |
4608 | 4345 else |
4895 | 4346 with_font_tag = g_memdup(new_message, length); |
7440 | 4347 |
8962 | 4348 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4349 with_font_tag, gtk_font_options); | |
7440 | 4350 |
4351 g_free(with_font_tag); | |
7447 | 4352 g_free(new_message); |
7440 | 4353 } |
4354 | |
5012 | 4355 if(sml_attrib) |
4356 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4357 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4358 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4359 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4360 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4361 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4362 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4363 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4364 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4365 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4366 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4367 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4368 else if ((flags & GAIM_MESSAGE_NO_LOG) == GAIM_MESSAGE_NO_LOG) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4369 unseen = GAIM_UNSEEN_NOLOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4370 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4371 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4372 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4373 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4374 } |
4359 | 4375 } |
4376 | |
4377 static void | |
11869 | 4378 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
|
4379 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4380 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4381 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4382 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4383 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4384 GList *ll; |
11869 | 4385 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4386 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4387 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4388 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4389 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4390 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4391 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4392 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4393 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
|
4394 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4395 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4396 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4397 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4398 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4399 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4400 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4401 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4402 l = users; |
11869 | 4403 ll = flags; |
4404 lll = aliases; | |
4405 while (l != NULL && ll != NULL && lll != NULL) { | |
4406 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
|
4407 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4408 ll = ll->next; |
11869 | 4409 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4410 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4411 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4412 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4413 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4414 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
|
4415 const char *new_name, const char *new_alias) |
4359 | 4416 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4417 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4418 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4419 GaimGtkChatPane *gtkchat; |
11869 | 4420 GaimConvChatBuddyFlags flags; |
4359 | 4421 GtkTreeIter iter; |
4422 GtkTreeModel *model; | |
4423 int f = 1; | |
4424 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4425 chat = GAIM_CONV_CHAT(conv); |
4359 | 4426 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4427 gtkchat = gtkconv->u.chat; | |
4428 | |
9554 | 4429 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4430 | |
4431 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4432 return; | |
4433 | |
4434 while (f != 0) { | |
4435 char *val; | |
4436 | |
11869 | 4437 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4438 |
4439 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4440 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4441 g_free(val); | |
4359 | 4442 break; |
4443 } | |
9554 | 4444 |
4445 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4446 | |
4447 g_free(val); | |
4359 | 4448 } |
4449 | |
9554 | 4450 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4451 return; |
4452 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4453 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4454 |
11869 | 4455 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4456 } |
4457 | |
4458 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4459 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4460 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4461 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4462 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4463 GaimGtkChatPane *gtkchat; |
4359 | 4464 GtkTreeIter iter; |
4465 GtkTreeModel *model; | |
4466 char tmp[BUF_LONG]; | |
4467 int num_users; | |
4468 int f = 1; | |
4469 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4470 chat = GAIM_CONV_CHAT(conv); |
4359 | 4471 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4472 gtkchat = gtkconv->u.chat; | |
4473 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4474 num_users = g_list_length(gaim_conv_chat_get_users(chat)) - 1; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4475 |
9554 | 4476 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4477 | |
4478 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4479 return; | |
4480 | |
4481 while (f != 0) { | |
4482 char *val; | |
4483 | |
4484 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4485 | |
4486 if (!gaim_utf8_strcasecmp(user, val)) { | |
4487 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4488 g_free(val); | |
4359 | 4489 break; |
4490 } | |
9554 | 4491 |
4492 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4493 | |
4494 g_free(val); | |
4359 | 4495 } |
4496 | |
9554 | 4497 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4498 return; |
4499 | |
4500 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4501 ngettext("%d person in room", "%d people in room", |
4502 num_users), num_users); | |
4359 | 4503 |
4504 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4505 | |
4506 } | |
4507 | |
4508 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4509 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4510 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4511 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4512 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4513 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4514 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4515 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4516 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4517 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4518 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4519 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4520 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4521 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4522 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4523 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4524 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4525 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
|
4526 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4527 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4528 for (l = users; l != NULL; l = l->next) { |
9554 | 4529 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4530 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4531 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4532 continue; |
4533 | |
4534 do { | |
4535 char *val; | |
4536 | |
4537 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4538 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4539 | |
9696 | 4540 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4541 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4542 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4543 #else |
4544 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4545 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4546 #endif | |
4547 } | |
9554 | 4548 else |
4549 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4550 | |
4551 g_free(val); | |
4552 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4553 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4554 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4555 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4556 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4557 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4558 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4559 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4560 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4561 |
9554 | 4562 static void |
4563 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4564 { | |
4565 GaimConvChat *chat; | |
11869 | 4566 GaimConvChatBuddyFlags flags; |
9554 | 4567 GaimGtkConversation *gtkconv; |
4568 GaimGtkChatPane *gtkchat; | |
4569 GtkTreeIter iter; | |
4570 GtkTreeModel *model; | |
4571 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4572 char *alias = NULL; |
9554 | 4573 |
4574 chat = GAIM_CONV_CHAT(conv); | |
4575 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4576 gtkchat = gtkconv->u.chat; | |
4577 | |
4578 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4579 | |
4580 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4581 return; | |
4582 | |
4583 while (f != 0) { | |
4584 char *val; | |
4585 | |
4586 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4587 | |
4588 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4589 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4590 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4591 g_free(val); | |
4592 break; | |
4593 } | |
4594 | |
4595 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4596 | |
4597 g_free(val); | |
4598 } | |
4599 | |
4600 if (!gaim_conv_chat_find_user(chat, user)) | |
4601 return; | |
4602 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4603 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4604 |
11869 | 4605 flags = gaim_conv_chat_user_get_flags(chat, user); |
4606 | |
4607 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4608 g_free(alias); |
9554 | 4609 } |
4610 | |
11581 | 4611 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4612 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4613 { |
11581 | 4614 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4615 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4616 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4617 |
11581 | 4618 win = gtkconv->win; |
4619 | |
4620 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
|
4621 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4622 if (has_focus) |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4623 { |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4624 GaimConversation *c = gaim_gtk_conv_window_get_active_conversation(win); |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4625 if (GAIM_GTK_CONVERSATION(c) == gtkconv) |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4626 return TRUE; |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4627 } |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4628 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4629 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4630 |
10526 | 4631 static gboolean |
4632 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4633 { | |
4634 GaimGtkConversation *gtkconv; | |
4635 GtkIMHtmlSmiley *smiley; | |
4636 GdkPixbufLoader *loader; | |
11525 | 4637 struct smiley_list *list; |
4638 const char *sml = NULL, *conv_sml; | |
4639 | |
4640 if (!conv || !smile || !*smile) { | |
10526 | 4641 return FALSE; |
4642 } | |
4643 | |
11525 | 4644 /* If smileys are off, return false */ |
4645 if (gaim_gtkthemes_smileys_disabled()) | |
4646 return FALSE; | |
4647 | |
4648 /* If possible add this smiley to the current theme. | |
4649 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4650 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4651 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4652 |
4653 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4654 if (!strcmp(list->sml, conv_sml)) { | |
4655 sml = list->sml; | |
4656 break; | |
4657 } | |
4658 } | |
4659 | |
10526 | 4660 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4661 | |
4662 if (smiley) { | |
11525 | 4663 |
4664 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4665 return FALSE; | |
4666 } | |
4667 | |
4668 /* Close the old GdkPixbufAnimation, then create a new one for | |
4669 * the smiley we are about to receive */ | |
4670 g_object_unref(G_OBJECT(smiley->icon)); | |
4671 | |
4672 smiley->loader = gdk_pixbuf_loader_new(); | |
4673 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4674 if (smiley->icon) | |
4675 g_object_ref(G_OBJECT(smiley->icon)); | |
4676 | |
4677 /* A custom smiley is already associated */ | |
4678 return TRUE; | |
10526 | 4679 } |
4680 | |
4681 loader = gdk_pixbuf_loader_new(); | |
4682 | |
4683 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4684 /* 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
|
4685 GtkIMHtmlSmiley by opaque */ |
10526 | 4686 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4687 smiley->file = NULL; | |
4688 smiley->smile = g_strdup(smile); | |
4689 smiley->loader = loader; | |
11525 | 4690 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4691 |
4692 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4693 if (smiley->icon) | |
4694 g_object_ref(G_OBJECT(smiley->icon)); | |
4695 | |
11525 | 4696 |
10526 | 4697 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4698 |
10526 | 4699 return TRUE; |
4700 } | |
4701 | |
10537 | 4702 static void |
10526 | 4703 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4704 const guchar *data, gsize size) |
10526 | 4705 { |
4706 GaimGtkConversation *gtkconv; | |
4707 GtkIMHtmlSmiley *smiley; | |
10537 | 4708 GdkPixbufLoader *loader; |
10526 | 4709 const char *sml; |
4710 | |
4711 sml = gaim_account_get_protocol_name(conv->account); | |
4712 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4713 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4714 | |
10537 | 4715 if (!smiley) |
10526 | 4716 return; |
10537 | 4717 |
10526 | 4718 loader = smiley->loader; |
10537 | 4719 if (!loader) |
10526 | 4720 return; |
4721 | |
4722 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4723 } | |
4724 | |
4725 static void | |
4726 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4727 { | |
4728 GaimGtkConversation *gtkconv; | |
4729 GtkIMHtmlSmiley *smiley; | |
4730 GdkPixbufLoader *loader; | |
4731 const char *sml; | |
11525 | 4732 GtkWidget *icon = NULL; |
4733 GtkTextChildAnchor *anchor = NULL; | |
4734 GtkTextIter end; | |
4735 GtkIMHtml *imhtml; | |
4736 GSList *current = NULL; | |
10526 | 4737 |
4738 g_return_if_fail(conv != NULL); | |
4739 g_return_if_fail(smile != NULL); | |
4740 | |
4741 sml = gaim_account_get_protocol_name(conv->account); | |
4742 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4743 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4744 | |
10537 | 4745 if (!smiley) |
10526 | 4746 return; |
4747 | |
4748 loader = smiley->loader; | |
4749 | |
10537 | 4750 if (!loader) |
10526 | 4751 return; |
10537 | 4752 |
11525 | 4753 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4754 if (smiley->icon) | |
4755 g_object_ref(G_OBJECT(smiley->icon)); | |
4756 | |
4757 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4758 | |
4759 icon = gtk_image_new_from_animation(smiley->icon); | |
4760 | |
4761 if (icon) { | |
12047 | 4762 gtk_widget_show(icon); |
4763 | |
11525 | 4764 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
4765 | |
4766 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4767 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4768 | |
4769 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4770 } | |
4771 | |
4772 } | |
4773 | |
4774 g_slist_free(smiley->anchors); | |
4775 smiley->anchors = NULL; | |
4776 | |
4777 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4778 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4779 * makes me question it */ | |
4780 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4781 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4782 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4783 | |
10526 | 4784 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4785 | |
4786 gdk_pixbuf_loader_close(loader, NULL); | |
4787 g_object_unref(G_OBJECT(loader)); | |
4788 smiley->loader = NULL; | |
4789 } | |
4790 | |
11581 | 4791 /* |
4792 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4793 * sensitive/insensitive. This is called after changing tabs and when an | |
4794 * account signs on or off. | |
4795 */ | |
4796 static void | |
4797 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4798 { | |
4799 GaimGtkWindow *win; | |
4800 GaimConversation *conv = gtkconv->active_conv; | |
4801 GaimConnection *gc; | |
4802 GaimPluginProtocolInfo *prpl_info = NULL; | |
4803 GdkPixbuf *window_icon = NULL; | |
4804 GtkIMHtmlButtons buttons; | |
4805 GaimAccount *account; | |
4806 | |
4807 win = gaim_gtkconv_get_window(gtkconv); | |
4808 gc = gaim_conversation_get_gc(conv); | |
4809 account = gaim_conversation_get_account(conv); | |
4810 | |
4811 if (gc != NULL) | |
4812 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4813 | |
11594 | 4814 if (win->menu.send_to != NULL) |
11734 | 4815 update_send_to_selection(win); |
11581 | 4816 |
4817 /* | |
4818 * Handle hiding and showing stuff based on what type of conv this is. | |
4819 * Stuff that Gaim IMs support in general should be shown for IM | |
4820 * conversations. Stuff that Gaim chats support in general should be | |
4821 * shown for chat conversations. It doesn't matter whether the PRPL | |
4822 * supports it or not--that only affects if the button or menu item | |
4823 * is sensitive or not. | |
4824 */ | |
4825 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4826 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4827 | |
4828 /* Deal with menu items */ | |
4829 gtk_widget_show(win->menu.view_log); | |
4830 gtk_widget_show(win->menu.send_file); | |
4831 gtk_widget_show(win->menu.add_pounce); | |
4832 gtk_widget_show(win->menu.get_info); | |
4833 gtk_widget_hide(win->menu.invite); | |
4834 gtk_widget_show(win->menu.alias); | |
4835 gtk_widget_show(win->menu.block); | |
4836 | |
4837 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4838 gtk_widget_show(win->menu.add); | |
4839 gtk_widget_hide(win->menu.remove); | |
4840 } else { | |
4841 gtk_widget_show(win->menu.remove); | |
4842 gtk_widget_hide(win->menu.add); | |
4843 } | |
4844 | |
4845 gtk_widget_show(win->menu.insert_link); | |
4846 gtk_widget_show(win->menu.insert_image); | |
4847 gtk_widget_show(win->menu.show_icon); | |
4848 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4849 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4850 | |
4851 /* Deal with menu items */ | |
4852 gtk_widget_show(win->menu.view_log); | |
4853 gtk_widget_hide(win->menu.send_file); | |
4854 gtk_widget_hide(win->menu.add_pounce); | |
4855 gtk_widget_hide(win->menu.get_info); | |
4856 gtk_widget_show(win->menu.invite); | |
4857 gtk_widget_show(win->menu.alias); | |
4858 gtk_widget_hide(win->menu.block); | |
4859 gtk_widget_hide(win->menu.show_icon); | |
4860 | |
4861 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4862 /* If the chat is NOT in the buddy list */ | |
4863 gtk_widget_show(win->menu.add); | |
4864 gtk_widget_hide(win->menu.remove); | |
4865 } else { | |
4866 /* If the chat IS in the buddy list */ | |
4867 gtk_widget_hide(win->menu.add); | |
4868 gtk_widget_show(win->menu.remove); | |
4869 } | |
4870 | |
4871 gtk_widget_show(win->menu.insert_link); | |
4872 gtk_widget_hide(win->menu.insert_image); | |
4873 } | |
4874 | |
4875 /* | |
4876 * Handle graying stuff out based on whether an account is connected | |
4877 * and what features that account supports. | |
4878 */ | |
4879 if ((gc != NULL) && | |
12012 | 4880 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
4881 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
4882 { | |
11581 | 4883 /* Account is online */ |
4884 /* Deal with the toolbar */ | |
12012 | 4885 if (conv->features & GAIM_CONNECTION_HTML) |
4886 { | |
4887 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
4888 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
4889 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
4890 buttons &= ~GTK_IMHTML_IMAGE; | |
4891 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
4892 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
4893 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
4894 { | |
4895 buttons &= ~GTK_IMHTML_GROW; | |
4896 buttons &= ~GTK_IMHTML_SHRINK; | |
4897 } | |
4898 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
4899 buttons &= ~GTK_IMHTML_LINKDESC; | |
4900 } else { | |
4901 buttons = GTK_IMHTML_SMILEY; | |
4902 } | |
4903 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
4904 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 4905 |
4906 /* Deal with menu items */ | |
12012 | 4907 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4908 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4909 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
4910 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
4911 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
4912 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
4913 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE)); | |
4914 | |
4915 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
4916 { | |
4917 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
4918 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
4919 gtk_widget_set_sensitive(win->menu.send_file, | |
4920 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
4921 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
4922 gtk_widget_set_sensitive(win->menu.alias, | |
4923 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
4924 } | |
4925 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
4926 { | |
4927 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
4928 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
4929 gtk_widget_set_sensitive(win->menu.alias, | |
4930 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
4931 } | |
11581 | 4932 |
4933 /* Deal with chat userlist buttons */ | |
12012 | 4934 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4935 { | |
4936 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
4937 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
4938 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
4939 } | |
4940 } else { | |
11581 | 4941 /* Account is offline */ |
4942 /* Or it's a chat that we've left. */ | |
4943 | |
4944 /* Then deal with menu items */ | |
12012 | 4945 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4946 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
4947 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4948 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
4949 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
4950 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
4951 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
4952 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
4953 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
4954 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
4955 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 4956 |
4957 /* Deal with chat userlist buttons */ | |
12012 | 4958 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4959 { | |
4960 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
4961 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
4962 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
4963 } | |
4964 } | |
11581 | 4965 |
4966 /* | |
4967 * Update the window's icon | |
4968 */ | |
4969 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
12012 | 4970 (gtkconv->u.im->anim)) |
11581 | 4971 { |
4972 window_icon = | |
4973 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
4974 g_object_ref(window_icon); | |
4975 } else { | |
4976 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
4977 } | |
4978 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
4979 if (window_icon != NULL) | |
4980 g_object_unref(G_OBJECT(window_icon)); | |
4981 } | |
4982 | |
10526 | 4983 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4984 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4985 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 4986 { |
11581 | 4987 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4988 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4989 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4990 GaimConvChat *chat; |
4359 | 4991 |
10116 | 4992 g_return_if_fail(conv != NULL); |
4993 | |
4359 | 4994 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4995 win = gtkconv->win; |
10810 | 4996 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 4997 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
4998 * instead of the gross hack? | |
4999 */ | |
4359 | 5000 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5001 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5002 { |
4359 | 5003 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5004 |
11338 | 5005 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5006 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5007 |
4359 | 5008 gaim_gtkconv_update_buttons_by_protocol(conv); |
5009 | |
11734 | 5010 update_send_to_selection(win); |
4359 | 5011 |
11525 | 5012 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5013 |
6395 | 5014 update_tab_icon(conv); |
4359 | 5015 } |
5016 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5017 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5018 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5019 { |
9472 | 5020 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5021 GaimConvIm *im = NULL; |
9472 | 5022 GaimConnection *gc = gaim_conversation_get_gc(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5023 /* 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
|
5024 char style[51]; |
4736 | 5025 |
11338 | 5026 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5027 im = GAIM_CONV_IM(conv); |
4359 | 5028 |
11338 | 5029 if (!gc || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5030 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5031 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5032 else | |
5033 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5034 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5035 *style = '\0'; |
4359 | 5036 |
5037 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5038 gtk_widget_realize(gtkconv->tab_label); | |
5039 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5040 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5041 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5042 { |
11759 | 5043 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5044 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5045 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5046 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5047 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5048 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5049 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5050 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5051 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5052 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5053 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5054 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5055 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5056 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5057 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5058 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5059 { |
11758 | 5060 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5061 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5062 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5063 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5064 { |
8536 | 5065 char *html_title,*label; |
5066 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5067 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5068 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5069 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5070 style, html_title); |
8536 | 5071 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5072 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5073 g_free(label); |
4359 | 5074 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5075 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5076 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5077 |
11581 | 5078 if (conv == gaim_gtk_conv_window_get_active_conversation(win)) |
10810 | 5079 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5080 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5081 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5082 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
11581 | 5083 if (conv == gaim_gtk_conv_window_get_active_conversation(win)) |
5084 gtk_window_set_title(GTK_WINDOW(win->window), title); | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5085 } |
9472 | 5086 |
5087 g_free(title); | |
4359 | 5088 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5089 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5090 { |
7154 | 5091 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5092 chat = GAIM_CONV_CHAT(conv); |
4359 | 5093 gtkchat = gtkconv->u.chat; |
5094 | |
7154 | 5095 topic = gaim_conv_chat_get_topic(chat); |
5096 | |
9554 | 5097 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5098 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5099 topic ? topic : "", NULL); |
4359 | 5100 } |
5101 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5102 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5103 { |
11581 | 5104 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5105 generate_send_to_items(win); |
8946 | 5106 update_tab_icon(conv); |
9472 | 5107 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5108 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5109 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5110 { |
8946 | 5111 update_tab_icon(conv); |
4359 | 5112 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5113 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
|
5114 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5115 { |
9472 | 5116 gaim_conversation_autoset_title(conv); |
10810 | 5117 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5118 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5119 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5120 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5121 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5122 } |
10665 | 5123 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5124 { | |
10810 | 5125 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5126 } |
4359 | 5127 } |
5128 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5129 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5130 { |
11581 | 5131 gaim_gtkconv_new, |
4359 | 5132 gaim_gtkconv_destroy, /* destroy_conversation */ |
5133 gaim_gtkconv_write_chat, /* write_chat */ | |
5134 gaim_gtkconv_write_im, /* write_im */ | |
5135 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5136 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5137 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5138 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5139 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5140 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5141 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5142 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5143 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5144 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5145 gaim_gtkconv_updated /* updated */ |
5146 }; | |
5147 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5148 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5149 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5150 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5151 return &conversation_ui_ops; |
4359 | 5152 } |
5153 | |
5154 /************************************************************************** | |
5155 * Public conversation utility functions | |
5156 **************************************************************************/ | |
5157 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5158 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5159 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5160 GaimGtkConversation *gtkconv; |
11581 | 5161 GaimGtkWindow *win; |
4359 | 5162 |
10381 | 5163 GdkPixbufLoader *loader; |
5164 GdkPixbufAnimation *anim; | |
4359 | 5165 GError *err = NULL; |
5166 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5167 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5168 size_t len; |
4359 | 5169 |
5170 GdkPixbuf *buf; | |
5171 | |
5172 GtkWidget *event; | |
5173 GtkWidget *frame; | |
5174 GdkPixbuf *scale; | |
5175 GdkPixmap *pm; | |
5176 GdkBitmap *bm; | |
9318 | 5177 int scale_width, scale_height; |
5178 | |
5179 GaimAccount *account; | |
5180 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5181 |
9324 | 5182 GaimBuddyIcon *icon; |
5183 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5184 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5185 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5186 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5187 |
5188 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5189 win = gtkconv->win; |
10175 | 5190 |
9687 | 5191 if (!gtkconv->u.im->show_icon) |
5192 return; | |
5193 | |
9318 | 5194 account = gaim_conversation_get_account(conv); |
5195 if(account && account->gc) | |
5196 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5197 |
9845 | 5198 /* Remove the current icon stuff */ |
9885 | 5199 if (gtkconv->u.im->icon_container != NULL) |
5200 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5201 gtkconv->u.im->icon_container = NULL; | |
9845 | 5202 |
5203 if (gtkconv->u.im->anim != NULL) | |
5204 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5205 | |
9887 | 5206 gtkconv->u.im->anim = NULL; |
5207 | |
9845 | 5208 if (gtkconv->u.im->icon_timer != 0) |
5209 g_source_remove(gtkconv->u.im->icon_timer); | |
5210 | |
5211 gtkconv->u.im->icon_timer = 0; | |
5212 | |
5213 if (gtkconv->u.im->iter != NULL) | |
5214 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5215 |
10116 | 5216 gtkconv->u.im->iter = NULL; |
5217 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5218 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5219 return; |
5220 | |
5221 if (gaim_conversation_get_gc(conv) == NULL) | |
5222 return; | |
5223 | |
9324 | 5224 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5225 | |
5226 if (icon == NULL) | |
5227 return; | |
5228 | |
5229 data = gaim_buddy_icon_get_data(icon, &len); | |
5230 | |
10381 | 5231 loader = gdk_pixbuf_loader_new(); |
5232 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5233 anim = gdk_pixbuf_loader_get_animation(loader); | |
5234 if (anim) | |
5235 g_object_ref(G_OBJECT(anim)); | |
5236 gdk_pixbuf_loader_close(loader, &err); | |
5237 g_object_unref(loader); | |
5238 | |
5239 if (!anim) | |
9324 | 5240 return; |
10381 | 5241 gtkconv->u.im->anim = anim; |
9324 | 5242 |
4359 | 5243 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5244 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5245 "Buddy icon error: %s\n", err->message); |
4359 | 5246 g_error_free(err); |
5247 } | |
5248 | |
5249 if (!gtkconv->u.im->anim) | |
5250 return; | |
5251 | |
5252 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5253 gtkconv->u.im->iter = NULL; | |
5254 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5255 } else { | |
5256 gtkconv->u.im->iter = | |
8496 | 5257 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5258 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5259 if (gtkconv->u.im->animate) |
10810 | 5260 start_anim(NULL, gtkconv); |
4359 | 5261 } |
5262 | |
10483 | 5263 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5264 NULL, &scale_width, &scale_height); |
4359 | 5265 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5266 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5267 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5268 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5269 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5270 GDK_INTERP_BILINEAR); |
4359 | 5271 |
5272 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5273 g_object_unref(G_OBJECT(scale)); |
4359 | 5274 |
8821 | 5275 |
9885 | 5276 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5277 |
4359 | 5278 frame = gtk_frame_new(NULL); |
5279 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5280 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5281 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5282 FALSE, FALSE, 0); | |
8821 | 5283 |
4359 | 5284 event = gtk_event_box_new(); |
5285 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5286 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5287 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5288 gtk_widget_show(event); |
5289 | |
4635 | 5290 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5291 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5292 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5293 gtk_widget_show(gtkconv->u.im->icon); | |
5294 | |
4793 | 5295 g_object_unref(G_OBJECT(pm)); |
4359 | 5296 |
5297 if (bm) | |
4793 | 5298 g_object_unref(G_OBJECT(bm)); |
7143 | 5299 |
10356 | 5300 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5301 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5302 |
9885 | 5303 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5304 gtk_widget_show(frame); |
5305 | |
7143 | 5306 /* The buddy icon code needs badly to be fixed. */ |
5307 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
11581 | 5308 if(conv == gaim_gtk_conv_window_get_active_conversation(gtkconv->win)) |
5309 gtk_window_set_icon(GTK_WINDOW(win->window), buf); | |
4359 | 5310 } |
5311 | |
5312 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5313 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5314 { |
11581 | 5315 GaimGtkWindow *win; |
4359 | 5316 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5317 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5318 return; |
5319 | |
11581 | 5320 win = GAIM_GTK_CONVERSATION(conv)->win; |
5321 | |
5322 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5323 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5324 } |
5325 | |
5326 int | |
11614 | 5327 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5328 { |
4359 | 5329 gint nb_x, nb_y, x_rel, y_rel; |
5330 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5331 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5332 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5333 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5334 gboolean horiz; |
4359 | 5335 |
11614 | 5336 if (to_right) |
5337 *to_right = FALSE; | |
5338 | |
11581 | 5339 notebook = GTK_NOTEBOOK(win->notebook); |
5340 | |
5341 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5342 x_rel = x - nb_x; |
5343 y_rel = y - nb_y; | |
5344 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5345 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5346 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5347 |
11780 | 5348 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5349 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5350 #else |
5351 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5352 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5353 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5354 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5355 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5356 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5357 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5358 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5359 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5360 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5361 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5362 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
|
5363 page_num = i; |
11614 | 5364 |
5365 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5366 *to_right = TRUE; | |
5367 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5368 break; |
4359 | 5369 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5370 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5371 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5372 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
|
5373 page_num = i; |
11614 | 5374 |
5375 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5376 *to_right = TRUE; | |
5377 | |
4359 | 5378 break; |
5379 } | |
5380 } | |
5381 } | |
5382 | |
5383 return page_num; | |
5384 } | |
5385 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5386 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5387 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
|
5388 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5389 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5390 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5391 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5392 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5393 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5394 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5395 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5396 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5397 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5398 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5399 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5400 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5401 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5402 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5403 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5404 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5405 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5406 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5407 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5408 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5409 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5410 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5411 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5412 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5413 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5414 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5415 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5416 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5417 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5418 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5419 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5420 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5421 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5422 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5423 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5424 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5425 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5426 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5427 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5428 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5429 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5430 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5431 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5432 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5433 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5434 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5435 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5436 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5437 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5438 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5439 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5440 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5441 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5442 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5443 GtkPositionType pos; |
11581 | 5444 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5445 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5446 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5447 |
11581 | 5448 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5449 win = l->data; | |
5450 | |
11619 | 5451 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
|
5452 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5453 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5454 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5455 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5456 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5457 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5458 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5459 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5460 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5461 GaimGtkConversation *gtkconv; |
11581 | 5462 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5463 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5464 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5465 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5466 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5467 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5468 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5469 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5470 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5471 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5472 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5473 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5474 gtk_check_menu_item_set_active( |
11581 | 5475 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5476 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5477 |
5478 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5479 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5480 else |
8317 | 5481 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5482 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5483 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5484 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5485 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5486 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5487 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5488 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5489 GList *l; |
8189 | 5490 GaimConversation *conv; |
5491 GaimGtkConversation *gtkconv; | |
11581 | 5492 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5493 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5494 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
|
5495 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5496 |
8189 | 5497 /* Set the "animate" flag for each icon based on the new preference */ |
5498 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5499 conv = (GaimConversation *)l->data; | |
5500 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5501 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5502 } |
8189 | 5503 |
5504 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5505 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5506 win = l->data; | |
5507 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5508 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5509 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5510 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5511 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5512 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5513 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
|
5514 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5515 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5516 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5517 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5518 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5519 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5520 |
11338 | 5521 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5522 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5523 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5524 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5525 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5526 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5527 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5528 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5529 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5530 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5531 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5532 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5533 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5534 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5535 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5536 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5537 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5538 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5539 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5540 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5541 |
11581 | 5542 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5543 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5544 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5545 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5546 |
11581 | 5547 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5548 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5549 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5550 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5551 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5552 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5553 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5554 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5555 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5556 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5557 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5558 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5559 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5560 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5561 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5562 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5563 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5564 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5565 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5566 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5567 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5568 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5569 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5570 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5571 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5572 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5573 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5574 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5575 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5576 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5577 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5578 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5579 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5580 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5581 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5582 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5583 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
|
5584 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5585 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5586 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5587 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5588 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5589 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5590 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5591 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5592 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5593 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5594 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5595 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5596 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5597 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5598 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5599 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5600 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
|
5601 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5602 /* Connect callbacks. */ |
10087 | 5603 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
|
5604 close_on_tabs_pref_cb, NULL); |
10087 | 5605 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
|
5606 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5607 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5608 spellcheck_pref_cb, NULL); |
10087 | 5609 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5610 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5611 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5612 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5613 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5614 |
10087 | 5615 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5616 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5617 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5618 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5619 /* IM callbacks */ |
10087 | 5620 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
|
5621 animate_buddy_icons_pref_cb, NULL); |
10087 | 5622 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
|
5623 show_buddy_icons_pref_cb, NULL); |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5624 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5625 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5626 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5627 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5628 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5629 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5630 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5631 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5632 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5633 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5634 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5635 |
5636 /********************************************************************** | |
5637 * Register commands | |
5638 **********************************************************************/ | |
9829 | 5639 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5640 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5641 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5642 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5643 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5644 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5645 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5646 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5647 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
|
5648 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5649 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5650 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5651 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5652 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5653 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5654 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5655 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5656 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5657 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5658 |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5659 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5660 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5661 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5662 G_CALLBACK(buddy_update_cb), NULL); |
5663 | |
11581 | 5664 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5665 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5666 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5667 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5668 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5669 { |
10443 | 5670 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5671 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5672 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5673 } |
11581 | 5674 |
5675 | |
5676 | |
5677 | |
5678 | |
5679 | |
5680 | |
5681 | |
5682 | |
5683 | |
5684 | |
5685 | |
5686 | |
5687 | |
5688 | |
5689 | |
5690 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5691 * and touch each others' private members all day long */ | |
5692 | |
5693 /** | |
5694 * @file gtkconvwin.c GTK+ Conversation Window API | |
5695 * @ingroup gtkui | |
5696 * | |
5697 * gaim | |
5698 * | |
5699 * Gaim is the legal property of its developers, whose names are too numerous | |
5700 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5701 * source distribution. | |
5702 * | |
5703 * This program is free software; you can redistribute it and/or modify | |
5704 * it under the terms of the GNU General Public License as published by | |
5705 * the Free Software Foundation; either version 2 of the License, or | |
5706 * (at your option) any later version. | |
5707 * | |
5708 * This program is distributed in the hope that it will be useful, | |
5709 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
5710 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
5711 * GNU General Public License for more details. | |
5712 * | |
5713 * You should have received a copy of the GNU General Public License | |
5714 * along with this program; if not, write to the Free Software | |
5715 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5716 * | |
5717 */ | |
5718 #include "internal.h" | |
5719 #include "gtkgaim.h" | |
5720 | |
5721 | |
5722 #include <gdk/gdkkeysyms.h> | |
5723 | |
5724 #include "account.h" | |
5725 #include "cmds.h" | |
5726 #include "debug.h" | |
5727 #include "imgstore.h" | |
5728 #include "log.h" | |
5729 #include "notify.h" | |
5730 #include "prpl.h" | |
5731 #include "request.h" | |
5732 #include "util.h" | |
5733 | |
5734 #include "gtkdnd-hints.h" | |
5735 #include "gtkblist.h" | |
5736 #include "gtkconv.h" | |
5737 #include "gtkdialogs.h" | |
5738 #include "gtkmenutray.h" | |
5739 #include "gtkpounce.h" | |
5740 #include "gtkprefs.h" | |
5741 #include "gtkprivacy.h" | |
5742 #include "gtkutils.h" | |
5743 #include "gtkstock.h" | |
5744 #include "gtkimhtml.h" | |
5745 #include "gtkimhtmltoolbar.h" | |
5746 | |
5747 static void | |
5748 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
5749 { | |
5750 gtk_widget_destroy(warn_close_dialog); | |
5751 warn_close_dialog = NULL; | |
5752 | |
5753 if (resp == GTK_RESPONSE_OK) | |
5754 gaim_gtk_conv_window_destroy(win); | |
5755 } | |
5756 | |
5757 static void | |
5758 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
5759 { | |
5760 GtkWidget *label; | |
5761 GtkWidget *vbox, *hbox; | |
5762 GtkWidget *img; | |
5763 | |
5764 g_return_if_fail(warn_close_dialog == NULL); | |
5765 | |
5766 | |
5767 warn_close_dialog = gtk_dialog_new_with_buttons( | |
5768 _("Confirm close"), | |
5769 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
5770 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
5771 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
5772 | |
5773 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
5774 GTK_RESPONSE_OK); | |
5775 | |
5776 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
5777 6); | |
5778 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
5779 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
5780 FALSE); | |
5781 | |
5782 /* Setup the outside spacing. */ | |
5783 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
5784 | |
5785 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
5786 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
5787 | |
5788 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
5789 GTK_ICON_SIZE_DIALOG); | |
5790 /* Setup the inner hbox and put the dialog's icon in it. */ | |
5791 hbox = gtk_hbox_new(FALSE, 12); | |
5792 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
5793 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
5794 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
5795 | |
5796 /* Setup the right vbox. */ | |
5797 vbox = gtk_vbox_new(FALSE, 12); | |
5798 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
5799 | |
5800 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
5801 gtk_widget_set_size_request(label, 350, -1); | |
5802 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
5803 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
5804 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
5805 | |
5806 /* Connect the signals. */ | |
5807 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
5808 G_CALLBACK(do_close), gtkwin); | |
5809 | |
5810 } | |
5811 | |
5812 /************************************************************************** | |
5813 * Callbacks | |
5814 **************************************************************************/ | |
5815 | |
5816 static gboolean | |
5817 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
5818 { | |
5819 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5820 GList *l; |
11581 | 5821 |
5822 /* If there are unread messages then show a warning dialog */ | |
5823 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
5824 l != NULL; l = l->next) | |
5825 { | |
5826 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5827 if (gaim_conversation_get_type(gtkconv->active_conv) == GAIM_CONV_TYPE_IM && |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5828 gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5829 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5830 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5831 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5832 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5833 return TRUE; |
11581 | 5834 } |
5835 } | |
5836 | |
5837 gaim_gtk_conv_window_destroy(win); | |
5838 | |
5839 return TRUE; | |
5840 } | |
5841 | |
11604 | 5842 static void |
5843 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
5844 { | |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5845 /* only allow NONE or higher priority unseen state */ |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5846 if((state==GAIM_UNSEEN_NONE && gtkconv->unseen_state!=GAIM_UNSEEN_NONE) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5847 || state > gtkconv->unseen_state) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5848 gtkconv->unseen_state = state; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5849 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5850 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5851 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5852 |
11581 | 5853 /* |
5854 * When a conversation window is focused, we know the user | |
5855 * has looked at it so we know there are no longer unseen | |
5856 * messages. | |
5857 */ | |
5858 static gint | |
5859 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
5860 { | |
5861 GaimGtkWindow *win = d; | |
11604 | 5862 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
5863 | |
5864 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 5865 |
5866 return FALSE; | |
5867 } | |
5868 | |
11851 | 5869 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 5870 /* Courtesy of Galeon! */ |
5871 static void | |
5872 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
5873 { | |
5874 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
5875 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
5876 } | |
11851 | 5877 #endif |
11581 | 5878 |
5879 static void | |
5880 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
5881 { | |
5882 static GdkCursor *cursor = NULL; | |
5883 | |
5884 gtkwin->in_drag = TRUE; | |
5885 | |
5886 if (gtkwin->drag_leave_signal) { | |
5887 g_signal_handler_disconnect(G_OBJECT(widget), | |
5888 gtkwin->drag_leave_signal); | |
5889 gtkwin->drag_leave_signal = 0; | |
5890 } | |
5891 | |
5892 if (cursor == NULL) | |
5893 cursor = gdk_cursor_new(GDK_FLEUR); | |
5894 | |
5895 /* Grab the pointer */ | |
5896 gtk_grab_add(gtkwin->notebook); | |
5897 #ifndef _WIN32 | |
5898 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
5899 always be true after a button press. */ | |
5900 if (!gdk_pointer_is_grabbed()) | |
5901 #endif | |
5902 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
5903 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
5904 NULL, cursor, GDK_CURRENT_TIME); | |
5905 } | |
5906 | |
5907 static gboolean | |
5908 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
5909 { | |
5910 | |
5911 /* | |
5912 * Make sure the user moved the mouse far enough for the | |
5913 * drag to be initiated. | |
5914 */ | |
5915 if (win->in_predrag) { | |
5916 if (e->x_root < win->drag_min_x || | |
5917 e->x_root >= win->drag_max_x || | |
5918 e->y_root < win->drag_min_y || | |
5919 e->y_root >= win->drag_max_y) { | |
5920 | |
5921 win->in_predrag = FALSE; | |
5922 notebook_init_grab(win, widget); | |
5923 } | |
5924 } | |
5925 else { /* Otherwise, draw the arrows. */ | |
5926 GaimGtkWindow *dest_win; | |
5927 GtkNotebook *dest_notebook; | |
5928 GtkWidget *tab; | |
5929 gint nb_x, nb_y, page_num; | |
5930 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
5931 gboolean horiz_tabs = FALSE; | |
11614 | 5932 GaimGtkConversation *gtkconv; |
5933 gboolean to_right = FALSE; | |
11581 | 5934 |
5935 /* Get the window that the cursor is over. */ | |
5936 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
5937 | |
5938 if (dest_win == NULL) { | |
5939 dnd_hints_hide_all(); | |
5940 | |
5941 return TRUE; | |
5942 } | |
5943 | |
5944 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
5945 | |
5946 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
5947 | |
5948 arrow1_x = arrow2_x = nb_x; | |
5949 arrow1_y = arrow2_y = nb_y; | |
5950 | |
5951 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 5952 e->x_root, e->y_root, &to_right); |
5953 to_right = to_right && (win != dest_win); | |
11581 | 5954 |
5955 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
5956 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
5957 | |
5958 horiz_tabs = TRUE; | |
5959 } | |
5960 | |
11614 | 5961 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
5962 tab = gtkconv->tabby; | |
11581 | 5963 |
5964 if (horiz_tabs) { | |
5965 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
5966 | |
11614 | 5967 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 5968 arrow1_x += tab->allocation.width; |
5969 arrow2_x += tab->allocation.width; | |
5970 } | |
5971 | |
5972 arrow1_y = nb_y + tab->allocation.y; | |
5973 arrow2_y = nb_y + tab->allocation.y + | |
5974 tab->allocation.height; | |
5975 } else { | |
5976 arrow1_x = nb_x + tab->allocation.x; | |
5977 arrow2_x = nb_x + tab->allocation.x + | |
5978 tab->allocation.width; | |
5979 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
5980 | |
5981 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
5982 arrow1_y += tab->allocation.height; | |
5983 arrow2_y += tab->allocation.height; | |
5984 } | |
5985 } | |
5986 | |
5987 if (horiz_tabs) { | |
5988 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
5989 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
5990 } else { | |
5991 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
5992 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
5993 } | |
5994 } | |
5995 | |
5996 return TRUE; | |
5997 } | |
5998 | |
5999 static gboolean | |
6000 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6001 { | |
6002 if (win->in_drag) | |
6003 return FALSE; | |
6004 | |
6005 if (e->x_root < win->drag_min_x || | |
6006 e->x_root >= win->drag_max_x || | |
6007 e->y_root < win->drag_min_y || | |
6008 e->y_root >= win->drag_max_y) { | |
6009 | |
6010 win->in_predrag = FALSE; | |
6011 notebook_init_grab(win, widget); | |
6012 } | |
6013 | |
6014 return TRUE; | |
6015 } | |
6016 | |
6017 /* | |
6018 * THANK YOU GALEON! | |
6019 */ | |
6020 static gboolean | |
6021 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6022 { | |
6023 gint nb_x, nb_y, x_rel, y_rel; | |
6024 int tab_clicked; | |
6025 GtkWidget *page; | |
6026 GtkWidget *tab; | |
6027 | |
6028 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6029 return FALSE; | |
6030 | |
6031 | |
6032 if (win->in_drag) { | |
6033 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6034 "Already in the middle of a window drag at tab_press_cb\n"); | |
6035 return TRUE; | |
6036 } | |
6037 | |
6038 /* | |
6039 * Make sure a tab was actually clicked. The arrow buttons | |
6040 * mess things up. | |
6041 */ | |
11614 | 6042 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6043 |
6044 if (tab_clicked == -1) | |
6045 return FALSE; | |
6046 | |
6047 /* | |
6048 * Get the relative position of the press event, with regards to | |
6049 * the position of the notebook. | |
6050 */ | |
6051 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6052 | |
6053 x_rel = e->x_root - nb_x; | |
6054 y_rel = e->y_root - nb_y; | |
6055 | |
6056 /* Reset the min/max x/y */ | |
6057 win->drag_min_x = 0; | |
6058 win->drag_min_y = 0; | |
6059 win->drag_max_x = 0; | |
6060 win->drag_max_y = 0; | |
6061 | |
6062 /* Find out which tab was dragged. */ | |
6063 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6064 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6065 | |
6066 win->drag_min_x = tab->allocation.x + nb_x; | |
6067 win->drag_min_y = tab->allocation.y + nb_y; | |
6068 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6069 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6070 | |
6071 /* Make sure the click occurred in the tab. */ | |
6072 if (e->x_root < win->drag_min_x || | |
6073 e->x_root >= win->drag_max_x || | |
6074 e->y_root < win->drag_min_y || | |
6075 e->y_root >= win->drag_max_y) { | |
6076 | |
6077 return FALSE; | |
6078 } | |
6079 | |
6080 win->in_predrag = TRUE; | |
6081 win->drag_tab = tab_clicked; | |
6082 | |
6083 /* Connect the new motion signals. */ | |
6084 win->drag_motion_signal = | |
6085 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6086 G_CALLBACK(notebook_motion_cb), win); | |
6087 | |
6088 win->drag_leave_signal = | |
6089 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6090 G_CALLBACK(notebook_leave_cb), win); | |
6091 | |
6092 return FALSE; | |
6093 } | |
6094 | |
6095 static gboolean | |
6096 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6097 { | |
6098 GaimGtkWindow *dest_win; | |
6099 GaimConversation *conv; | |
6100 GaimGtkConversation *gtkconv; | |
6101 gint dest_page_num = 0; | |
6102 gboolean new_window = FALSE; | |
11614 | 6103 gboolean to_right = FALSE; |
11581 | 6104 |
6105 /* | |
6106 * Don't check to make sure that the event's window matches the | |
6107 * widget's, because we may be getting an event passed on from the | |
6108 * close button. | |
6109 */ | |
6110 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6111 return FALSE; | |
6112 | |
6113 if (gdk_pointer_is_grabbed()) { | |
6114 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6115 gtk_grab_remove(widget); | |
6116 } | |
6117 | |
6118 if (!win->in_predrag && !win->in_drag) | |
6119 return FALSE; | |
6120 | |
6121 /* Disconnect the motion signal. */ | |
6122 if (win->drag_motion_signal) { | |
6123 g_signal_handler_disconnect(G_OBJECT(widget), | |
6124 win->drag_motion_signal); | |
6125 | |
6126 win->drag_motion_signal = 0; | |
6127 } | |
6128 | |
6129 /* | |
6130 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6131 * signal. | |
6132 */ | |
6133 if (win->in_predrag) { | |
6134 win->in_predrag = FALSE; | |
6135 | |
6136 if (win->drag_leave_signal) { | |
6137 g_signal_handler_disconnect(G_OBJECT(widget), | |
6138 win->drag_leave_signal); | |
6139 | |
6140 win->drag_leave_signal = 0; | |
6141 } | |
6142 } | |
6143 | |
6144 /* If we're not in drag... */ | |
6145 /* We're perfectly normal people! */ | |
6146 if (!win->in_drag) | |
6147 return FALSE; | |
6148 | |
6149 win->in_drag = FALSE; | |
6150 | |
6151 dnd_hints_hide_all(); | |
6152 | |
6153 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6154 | |
6155 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6156 | |
6157 if (dest_win == NULL) { | |
6158 /* If the current window doesn't have any other conversations, | |
6159 * there isn't much point transferring the conv to a new window. */ | |
6160 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6161 /* Make a new window to stick this to. */ | |
6162 dest_win = gaim_gtk_conv_window_new(); | |
6163 new_window = TRUE; | |
6164 } | |
6165 } | |
6166 | |
6167 if (dest_win == NULL) | |
6168 return FALSE; | |
6169 | |
6170 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6171 "conversation-dragging", win, dest_win); | |
6172 | |
6173 /* Get the destination page number. */ | |
6174 if (!new_window) | |
6175 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6176 e->x_root, e->y_root, &to_right); |
11581 | 6177 |
6178 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6179 | |
6180 if (win == dest_win) { | |
6181 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6182 } else { | |
6183 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6184 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6185 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6186 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6187 if (new_window) { | |
6188 gint win_width, win_height; | |
6189 | |
6190 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6191 &win_width, &win_height); | |
6192 | |
6193 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6194 e->x_root - (win_width / 2), | |
6195 e->y_root - (win_height / 2)); | |
6196 | |
6197 gaim_gtk_conv_window_show(dest_win); | |
6198 } | |
6199 } | |
6200 | |
6201 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6202 | |
6203 return TRUE; | |
6204 } | |
6205 | |
6206 | |
6207 static void | |
6208 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6209 gpointer user_data) | |
6210 { | |
6211 GaimGtkWindow *win; | |
6212 GaimConversation *conv; | |
6213 GaimGtkConversation *gtkconv; | |
6214 | |
6215 win = user_data; | |
6216 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6217 | |
6218 g_return_if_fail(conv != NULL); | |
6219 | |
6220 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6221 return; | |
6222 | |
6223 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6224 | |
6225 stop_anim(NULL, gtkconv); | |
6226 } | |
6227 | |
6228 static void | |
6229 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6230 gpointer user_data) | |
6231 { | |
6232 GaimGtkWindow *win; | |
6233 GaimConversation *conv; | |
6234 GaimGtkConversation *gtkconv; | |
6235 | |
6236 win = user_data; | |
6237 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6238 conv = gtkconv->active_conv; | |
6239 | |
6240 g_return_if_fail(conv != NULL); | |
6241 | |
6242 /* | |
6243 * Only set "unseen" to "none" if the window has focus | |
6244 */ | |
6245 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6246 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6247 |
6248 /* Update the menubar */ | |
6249 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6250 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
|
6251 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6252 |
11594 | 6253 generate_send_to_items(win); |
6254 | |
11604 | 6255 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6256 |
6257 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6258 gtkconv->make_sound); | |
6259 | |
6260 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6261 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6262 | |
6263 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6264 gtkconv->show_timestamps); | |
6265 | |
6266 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6267 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6268 gtkconv->u.im->show_icon); | |
11604 | 6269 |
11581 | 6270 /* |
6271 * We pause icons when they are not visible. If this icon should | |
6272 * be animated then start it back up again. | |
6273 */ | |
6274 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6275 (gtkconv->u.im->animate)) | |
6276 start_anim(NULL, gtkconv); | |
6277 } | |
6278 | |
6279 /************************************************************************** | |
6280 * GTK+ window ops | |
6281 **************************************************************************/ | |
6282 | |
6283 static GList *window_list = NULL; | |
6284 | |
6285 GList * | |
6286 gaim_gtk_conv_windows_get_list() | |
6287 { | |
6288 return window_list; | |
6289 } | |
6290 | |
6291 GaimGtkWindow * | |
6292 gaim_gtk_conv_window_new() | |
6293 { | |
6294 GaimGtkWindow *win; | |
6295 GtkPositionType pos; | |
6296 GtkWidget *testidea; | |
6297 GtkWidget *menubar; | |
6298 | |
6299 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6300 | |
6301 window_list = g_list_append(window_list, win); | |
6302 | |
6303 /* Create the window. */ | |
6304 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6305 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6306 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6307 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6308 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6309 | |
6310 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6311 G_CALLBACK(close_win_cb), win); | |
6312 | |
6313 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6314 G_CALLBACK(focus_win_cb), win); | |
6315 | |
6316 /* Create the notebook. */ | |
6317 win->notebook = gtk_notebook_new(); | |
6318 | |
6319 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6320 | |
6321 #if 0 | |
6322 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6323 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6324 #endif | |
6325 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6326 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6327 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6328 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6329 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6330 | |
6331 gtk_widget_show(win->notebook); | |
6332 | |
6333 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6334 G_CALLBACK(before_switch_conv_cb), win); | |
6335 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6336 G_CALLBACK(switch_conv_cb), win); | |
6337 | |
6338 /* Setup the tab drag and drop signals. */ | |
6339 gtk_widget_add_events(win->notebook, | |
6340 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6341 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6342 G_CALLBACK(notebook_press_cb), win); | |
6343 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6344 G_CALLBACK(notebook_release_cb), win); | |
6345 | |
6346 testidea = gtk_vbox_new(FALSE, 0); | |
6347 | |
6348 /* Setup the menubar. */ | |
6349 menubar = setup_menubar(win); | |
6350 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6351 | |
6352 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6353 | |
6354 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6355 | |
6356 gtk_widget_show(testidea); | |
6357 | |
6358 return win; | |
6359 } | |
6360 | |
6361 void | |
6362 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6363 { | |
6364 window_list = g_list_remove(window_list, win); | |
6365 | |
11611 | 6366 if (win->gtkconvs) { |
6367 while (win->gtkconvs) { | |
6368 GList *nextgtk = win->gtkconvs->next; | |
6369 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6370 GList *nextcore = gtkconv->convs->next; | |
6371 GaimConversation *conv = gtkconv->convs->data; | |
6372 gaim_conversation_destroy(conv); | |
6373 if (!nextgtk && !nextcore) | |
6374 /* we'll end up invoking ourselves when we destroy our last child */ | |
6375 /* so don't destroy ourselves right now */ | |
6376 return; | |
6377 } | |
6378 return; | |
6379 } | |
11581 | 6380 gtk_widget_destroy(win->window); |
6381 | |
6382 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6383 | |
6384 g_free(win); | |
6385 } | |
6386 | |
6387 void | |
6388 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6389 { | |
6390 gtk_widget_show(win->window); | |
6391 } | |
6392 | |
6393 void | |
6394 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6395 { | |
6396 gtk_widget_hide(win->window); | |
6397 } | |
6398 | |
6399 void | |
6400 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6401 { | |
6402 gtk_widget_show(win->window); | |
6403 gtk_window_deiconify(GTK_WINDOW(win->window)); | |
6404 gdk_window_raise(win->window->window); | |
6405 } | |
6406 | |
6407 void | |
6408 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6409 { | |
6410 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6411 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6412 gtkconv->tab_cont)); | |
6413 } | |
6414 | |
6415 void | |
6416 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6417 { | |
6418 GaimConversation *conv = gtkconv->active_conv; | |
6419 GaimGtkConversation *focus_gtkconv; | |
6420 GtkWidget *tabby, *menu_tabby; | |
6421 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6422 GtkWidget *close_image; | |
6423 GaimConversationType conv_type; | |
6424 const char *name; | |
6425 const gchar *tmp_lab; | |
6426 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6427 gboolean tabs_side = FALSE; |
6428 gint angle = 0; | |
11581 | 6429 |
6430 name = gaim_conversation_get_name(conv); | |
6431 conv_type = gaim_conversation_get_type(conv); | |
6432 | |
6433 | |
6434 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6435 gtkconv->win = win; | |
6436 | |
11619 | 6437 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6438 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6439 tabs_side = TRUE; | |
6440 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6441 angle = 90; | |
6442 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6443 angle = 270; | |
6444 | |
6445 if (angle) | |
6446 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6447 else | |
6448 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6449 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6450 | |
6451 /* Close button. */ | |
6452 gtkconv->close = gtk_button_new(); | |
6453 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6454 if (gtk_check_version(2, 4, 2) == NULL) { | |
6455 /* Need to account for extra padding around the gtkbutton */ | |
6456 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6457 "focus-line-width", &focus_width, | |
6458 "focus-padding", &focus_pad, | |
6459 NULL); | |
6460 close_button_width += (focus_width + focus_pad) * 2; | |
6461 close_button_height += (focus_width + focus_pad) * 2; | |
6462 } | |
6463 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6464 close_button_width, close_button_height); | |
6465 | |
6466 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6467 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6468 gtk_widget_show(close_image); | |
6469 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6470 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6471 _("Close conversation"), NULL); | |
6472 | |
6473 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6474 G_CALLBACK(close_conv_cb), gtkconv); | |
6475 | |
11851 | 6476 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6477 /* |
6478 * I love Galeon. They have a fix for that stupid annoying visible | |
6479 * border bug. I love you guys! -- ChipX86 | |
6480 */ | |
11851 | 6481 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6482 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6483 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6484 #endif |
11581 | 6485 |
6486 /* Status icon. */ | |
6487 gtkconv->icon = gtk_image_new(); | |
6488 gtkconv->menu_icon = gtk_image_new(); | |
6489 update_tab_icon(conv); | |
6490 | |
6491 /* Tab label. */ | |
6492 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6493 |
11581 | 6494 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6495 if (!angle) |
6496 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6497 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6498 if (tabs_side) { |
6499 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6500 } | |
6501 if (angle) | |
6502 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6503 #endif |
6504 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6505 #if 0 | |
6506 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6507 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6508 #endif | |
6509 | |
6510 /* Pack it all together. */ | |
11619 | 6511 if (angle == 90) |
6512 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6513 else | |
6514 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6515 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6516 FALSE, FALSE, 0); | |
6517 | |
6518 gtk_widget_show_all(gtkconv->icon); | |
6519 gtk_widget_show_all(gtkconv->menu_icon); | |
6520 | |
6521 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6522 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6523 gtk_widget_show(gtkconv->tab_label); | |
6524 gtk_widget_show(gtkconv->menu_label); | |
6525 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6526 | |
11619 | 6527 if (angle == 90) |
6528 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6529 else | |
6530 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6531 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6532 gtk_widget_show(gtkconv->close); | |
6533 | |
6534 gtk_widget_show(tabby); | |
6535 gtk_widget_show(menu_tabby); | |
6536 | |
6537 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6538 gaim_gtkconv_update_buddy_icon(conv); | |
6539 | |
6540 /* Add this pane to the conversation's notebook. */ | |
6541 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6542 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6543 |
6544 | |
6545 gtk_widget_show(tab_cont); | |
6546 | |
6547 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6548 /* Er, bug in notebooks? Switch to the page manually. */ | |
6549 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6550 | |
6551 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6552 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6553 } else | |
6554 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6555 | |
6556 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6557 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6558 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6559 | |
6560 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6561 update_send_to_selection(win); |
11581 | 6562 } |
6563 | |
6564 void | |
6565 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6566 { | |
6567 unsigned int index; | |
6568 GaimConversationType conv_type; | |
6569 | |
6570 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6571 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6572 | |
6573 g_object_ref(gtkconv->tab_cont); | |
6574 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6575 | |
6576 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6577 | |
6578 /* go back to tabless if need be */ | |
6579 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6580 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6581 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6582 } | |
6583 | |
6584 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6585 |
6586 if (!win->gtkconvs) | |
6587 gaim_gtk_conv_window_destroy(win); | |
11581 | 6588 } |
6589 | |
6590 GaimGtkConversation * | |
6591 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
6592 { | |
6593 GtkWidget *tab_cont; | |
6594 | |
6595 if (index == -1) | |
6596 index = 0; | |
6597 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 6598 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 6599 } |
6600 | |
6601 GaimGtkConversation * | |
6602 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
6603 { | |
6604 int index; | |
6605 GtkWidget *tab_cont; | |
6606 | |
6607 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
6608 if (index == -1) | |
6609 index = 0; | |
6610 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
6611 if (!tab_cont) | |
6612 return NULL; | |
6613 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
6614 } | |
6615 | |
6616 | |
6617 GaimConversation * | |
6618 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
6619 { | |
6620 GaimGtkConversation *gtkconv; | |
6621 | |
6622 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
6623 return gtkconv ? gtkconv->active_conv : NULL; | |
6624 } | |
6625 | |
6626 gboolean | |
6627 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
6628 { | |
6629 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
6630 } | |
6631 | |
6632 gboolean | |
6633 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
6634 { | |
6635 gboolean has_focus = FALSE; | |
6636 | |
6637 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
6638 | |
6639 return has_focus; | |
6640 } | |
6641 | |
6642 GaimGtkWindow * | |
6643 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
6644 { | |
6645 GaimGtkWindow *win; | |
6646 GdkWindow *gdkwin; | |
6647 GList *l; | |
6648 | |
6649 gdkwin = gdk_window_at_pointer(&x, &y); | |
6650 | |
6651 if (gdkwin) | |
6652 gdkwin = gdk_window_get_toplevel(gdkwin); | |
6653 | |
6654 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
6655 win = l->data; | |
6656 | |
6657 if (gdkwin == win->window->window) | |
6658 return win; | |
6659 } | |
6660 | |
6661 return NULL; | |
6662 } | |
6663 | |
6664 GList * | |
6665 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
6666 { | |
6667 return win->gtkconvs; | |
6668 } | |
6669 | |
6670 guint | |
6671 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
6672 { | |
6673 return g_list_length(win->gtkconvs); | |
6674 } | |
6675 | |
6676 GaimGtkWindow * | |
6677 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
6678 { | |
6679 GList *wins, *convs; | |
6680 GaimGtkWindow *win; | |
6681 GaimGtkConversation *conv; | |
6682 | |
6683 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6684 return NULL; | |
6685 | |
6686 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
6687 win = wins->data; | |
6688 | |
6689 for (convs = win->gtkconvs; | |
6690 convs != NULL; | |
6691 convs = convs->next) { | |
6692 | |
6693 conv = convs->data; | |
6694 | |
6695 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6696 return win; | |
6697 } | |
6698 } | |
6699 | |
6700 return NULL; | |
6701 } | |
6702 | |
6703 GaimGtkWindow * | |
6704 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
6705 { | |
6706 GList *wins, *convs; | |
6707 GaimGtkWindow *win; | |
6708 GaimGtkConversation *conv; | |
6709 | |
6710 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6711 return NULL; | |
6712 | |
6713 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6714 wins != NULL; | |
6715 wins = wins->prev) { | |
6716 | |
6717 win = wins->data; | |
6718 | |
6719 for (convs = win->gtkconvs; | |
6720 convs != NULL; | |
6721 convs = convs->next) { | |
6722 | |
6723 conv = convs->data; | |
6724 | |
6725 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6726 return win; | |
6727 } | |
6728 } | |
6729 | |
6730 return NULL; | |
6731 } | |
6732 | |
6733 | |
6734 /************************************************************************** | |
6735 * Conversation placement functions | |
6736 **************************************************************************/ | |
6737 typedef struct | |
6738 { | |
6739 char *id; | |
6740 char *name; | |
6741 GaimConvPlacementFunc fnc; | |
6742 | |
6743 } ConvPlacementData; | |
6744 | |
6745 static GList *conv_placement_fncs = NULL; | |
6746 static GaimConvPlacementFunc place_conv = NULL; | |
6747 | |
6748 /* This one places conversations in the last made window. */ | |
6749 static void | |
6750 conv_placement_last_created_win(GaimGtkConversation *conv) | |
6751 { | |
6752 GaimGtkWindow *win; | |
6753 | |
6754 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6755 win = l ? l->data : NULL;; | |
6756 | |
6757 if (win == NULL) { | |
6758 win = gaim_gtk_conv_window_new(); | |
6759 | |
6760 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6761 gaim_gtk_conv_window_show(win); | |
6762 } else { | |
6763 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6764 } | |
6765 } | |
6766 | |
6767 /* This one places conversations in the last made window of the same type. */ | |
6768 static void | |
6769 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
6770 { | |
6771 GaimGtkWindow *win; | |
6772 | |
6773 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
6774 | |
6775 if (win == NULL) { | |
6776 win = gaim_gtk_conv_window_new(); | |
6777 | |
6778 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6779 gaim_gtk_conv_window_show(win); | |
6780 } else | |
6781 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6782 } | |
6783 | |
6784 /* This one places each conversation in its own window. */ | |
6785 static void | |
6786 conv_placement_new_window(GaimGtkConversation *conv) | |
6787 { | |
6788 GaimGtkWindow *win; | |
6789 | |
6790 win = gaim_gtk_conv_window_new(); | |
6791 | |
6792 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6793 | |
6794 gaim_gtk_conv_window_show(win); | |
6795 } | |
6796 | |
6797 static GaimGroup * | |
6798 conv_get_group(GaimGtkConversation *conv) | |
6799 { | |
6800 GaimGroup *group = NULL; | |
6801 | |
6802 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
6803 GaimBuddy *buddy; | |
6804 | |
6805 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
6806 gaim_conversation_get_name(conv->active_conv)); | |
6807 | |
6808 if (buddy != NULL) | |
6809 group = gaim_find_buddys_group(buddy); | |
6810 | |
6811 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
6812 GaimChat *chat; | |
6813 | |
6814 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
6815 gaim_conversation_get_name(conv->active_conv)); | |
6816 | |
6817 if (chat != NULL) | |
6818 group = gaim_chat_get_group(chat); | |
6819 } | |
6820 | |
6821 return group; | |
6822 } | |
6823 | |
6824 /* | |
6825 * This groups things by, well, group. Buddies from groups will always be | |
6826 * grouped together, and a buddy from a group not belonging to any currently | |
6827 * open windows will get a new window. | |
6828 */ | |
6829 static void | |
6830 conv_placement_by_group(GaimGtkConversation *conv) | |
6831 { | |
6832 GaimConversationType type; | |
6833 GaimGroup *group = NULL; | |
6834 GList *wl, *cl; | |
6835 | |
6836 type = gaim_conversation_get_type(conv->active_conv); | |
6837 | |
6838 group = conv_get_group(conv); | |
6839 | |
6840 /* Go through the list of IMs and find one with this group. */ | |
6841 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
6842 GaimGtkWindow *win2; | |
6843 GaimGtkConversation *conv2; | |
6844 GaimGroup *group2 = NULL; | |
6845 | |
6846 win2 = wl->data; | |
6847 | |
6848 for (cl = win2->gtkconvs; | |
6849 cl != NULL; | |
6850 cl = cl->next) { | |
6851 conv2 = cl->data; | |
6852 | |
6853 group2 = conv_get_group(conv2); | |
6854 | |
6855 if (group == group2) { | |
6856 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
6857 | |
6858 return; | |
6859 } | |
6860 } | |
6861 } | |
6862 | |
6863 /* Make a new window. */ | |
6864 conv_placement_new_window(conv); | |
6865 } | |
6866 | |
6867 /* This groups things by account. Otherwise, the same semantics as above */ | |
6868 static void | |
6869 conv_placement_by_account(GaimGtkConversation *conv) | |
6870 { | |
6871 GaimConversationType type; | |
6872 GList *wins, *convs; | |
6873 GaimAccount *account; | |
6874 | |
6875 account = gaim_conversation_get_account(conv->active_conv); | |
6876 type = gaim_conversation_get_type(conv->active_conv); | |
6877 | |
6878 /* Go through the list of IMs and find one with this group. */ | |
6879 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
6880 GaimGtkWindow *win2; | |
6881 GaimGtkConversation *conv2; | |
6882 | |
6883 win2 = wins->data; | |
6884 | |
6885 for (convs = win2->gtkconvs; | |
6886 convs != NULL; | |
6887 convs = convs->next) { | |
6888 conv2 = convs->data; | |
6889 | |
6890 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
6891 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
6892 return; | |
6893 } | |
6894 } | |
6895 } | |
6896 | |
6897 /* Make a new window. */ | |
6898 conv_placement_new_window(conv); | |
6899 } | |
6900 | |
6901 static ConvPlacementData * | |
6902 get_conv_placement_data(const char *id) | |
6903 { | |
6904 ConvPlacementData *data = NULL; | |
6905 GList *n; | |
6906 | |
6907 for (n = conv_placement_fncs; n; n = n->next) { | |
6908 data = n->data; | |
6909 if (!strcmp(data->id, id)) | |
6910 return data; | |
6911 } | |
6912 | |
6913 return NULL; | |
6914 } | |
6915 | |
6916 static void | |
6917 add_conv_placement_fnc(const char *id, const char *name, | |
6918 GaimConvPlacementFunc fnc) | |
6919 { | |
6920 ConvPlacementData *data; | |
6921 | |
6922 data = g_new(ConvPlacementData, 1); | |
6923 | |
6924 data->id = g_strdup(id); | |
6925 data->name = g_strdup(name); | |
6926 data->fnc = fnc; | |
6927 | |
6928 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
6929 } | |
6930 | |
6931 static void | |
6932 ensure_default_funcs(void) | |
6933 { | |
6934 if (conv_placement_fncs == NULL) { | |
6935 add_conv_placement_fnc("last", _("Last created window"), | |
6936 conv_placement_last_created_win); | |
6937 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
6938 conv_placement_last_created_win_type); | |
6939 add_conv_placement_fnc("new", _("New window"), | |
6940 conv_placement_new_window); | |
6941 add_conv_placement_fnc("group", _("By group"), | |
6942 conv_placement_by_group); | |
6943 add_conv_placement_fnc("account", _("By account"), | |
6944 conv_placement_by_account); | |
6945 } | |
6946 } | |
6947 | |
6948 GList * | |
6949 gaim_gtkconv_placement_get_options(void) | |
6950 { | |
6951 GList *n, *list = NULL; | |
6952 ConvPlacementData *data; | |
6953 | |
6954 ensure_default_funcs(); | |
6955 | |
6956 for (n = conv_placement_fncs; n; n = n->next) { | |
6957 data = n->data; | |
6958 list = g_list_append(list, data->name); | |
6959 list = g_list_append(list, data->id); | |
6960 } | |
6961 | |
6962 return list; | |
6963 } | |
6964 | |
6965 | |
6966 void | |
6967 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
6968 GaimConvPlacementFunc fnc) | |
6969 { | |
6970 g_return_if_fail(id != NULL); | |
6971 g_return_if_fail(name != NULL); | |
6972 g_return_if_fail(fnc != NULL); | |
6973 | |
6974 ensure_default_funcs(); | |
6975 | |
6976 add_conv_placement_fnc(id, name, fnc); | |
6977 } | |
6978 | |
6979 void | |
6980 gaim_gtkconv_placement_remove_fnc(const char *id) | |
6981 { | |
6982 ConvPlacementData *data = get_conv_placement_data(id); | |
6983 | |
6984 if (data == NULL) | |
6985 return; | |
6986 | |
6987 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
6988 | |
6989 g_free(data->id); | |
6990 g_free(data->name); | |
6991 g_free(data); | |
6992 } | |
6993 | |
6994 const char * | |
6995 gaim_gtkconv_placement_get_name(const char *id) | |
6996 { | |
6997 ConvPlacementData *data; | |
6998 | |
6999 ensure_default_funcs(); | |
7000 | |
7001 data = get_conv_placement_data(id); | |
7002 | |
7003 if (data == NULL) | |
7004 return NULL; | |
7005 | |
7006 return data->name; | |
7007 } | |
7008 | |
7009 GaimConvPlacementFunc | |
7010 gaim_gtkconv_placement_get_fnc(const char *id) | |
7011 { | |
7012 ConvPlacementData *data; | |
7013 | |
7014 ensure_default_funcs(); | |
7015 | |
7016 data = get_conv_placement_data(id); | |
7017 | |
7018 if (data == NULL) | |
7019 return NULL; | |
7020 | |
7021 return data->fnc; | |
7022 } | |
7023 | |
7024 void | |
7025 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7026 { | |
7027 g_return_if_fail(func != NULL); | |
7028 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7029 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7030 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7031 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7032 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7033 place_conv = NULL; |
11581 | 7034 } |
7035 | |
7036 GaimConvPlacementFunc | |
7037 gaim_gtkconv_placement_get_current_func(void) | |
7038 { | |
7039 return place_conv; | |
7040 } | |
7041 | |
7042 void | |
7043 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7044 { | |
7045 if (place_conv) | |
7046 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7047 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7048 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7049 } |