Mercurial > pidgin
annotate src/gtkconv.c @ 12047:0b7ec6a106d5
[gaim-migrate @ 14342]
Possible crash fix from Fernando Herrera.
I'm not sure when this would crash, exactly. Maybe if you pass
something invalid to gtk_image_new
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 12 Nov 2005 14:07:42 +0000 |
parents | e67993da8a22 |
children | d676eec43d13 |
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 |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
4168 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4169 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4170 |
7956 | 4171 /* this is gonna crash one day, I can feel it. */ |
4172 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4173 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4174 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4175 } |
4359 | 4176 |
10737 | 4177 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4178 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4179 g_snprintf(buf2, sizeof(buf2), |
8690 | 4180 "<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
|
4181 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4182 |
8962 | 4183 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4184 |
8722 | 4185 } else if (flags & GAIM_MESSAGE_ERROR) { |
4186 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4187 "<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
|
4188 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4189 |
8962 | 4190 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4191 | |
7431 | 4192 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4193 g_snprintf(buf2, BUF_LONG, |
8690 | 4194 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4195 sml_attrib ? sml_attrib : "", message); |
7440 | 4196 |
10884 | 4197 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4198 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4199 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4200 } else { |
4895 | 4201 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4202 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
|
4203 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4204 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4205 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
|
4206 int tag_end_offset = 0; |
7440 | 4207 |
6621 | 4208 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4209 str = g_malloc(1024); |
7440 | 4210 |
4359 | 4211 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4212 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4213 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4214 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4215 tag_start_offset += 3; |
4359 | 4216 } |
4217 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4218 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4219 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4220 tag_end_offset = 2; |
4359 | 4221 strcpy(color, "#00FF00"); |
4222 } | |
7440 | 4223 } |
4359 | 4224 else { |
10504 | 4225 if (gaim_message_meify(new_message, -1)) { |
4359 | 4226 str = g_malloc(1024); |
7440 | 4227 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4228 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4229 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
|
4230 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4231 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4232 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4233 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4234 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4235 } |
7440 | 4236 |
6621 | 4237 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4238 strcpy(color, "#AF7F00"); |
4239 else | |
4240 strcpy(color, "#062585"); | |
4241 } | |
4242 else { | |
4243 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4244 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4245 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
|
4246 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4247 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4248 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4249 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4250 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4251 } |
6621 | 4252 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4253 strcpy(color, "#AF7F00"); |
6621 | 4254 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4255 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4256 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4257 |
10108 | 4258 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4259 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4260 } else |
7854 | 4261 strcpy(color, RECV_COLOR); |
4359 | 4262 } |
6621 | 4263 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4264 strcpy(color, SEND_COLOR); |
10892 | 4265 else { |
4266 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4267 strcpy(color, "#000000"); | |
4268 } | |
4359 | 4269 } |
4270 } | |
10892 | 4271 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4272 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4273 g_free(alias_escaped); |
11508 | 4274 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4275 /* 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
|
4276 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4277 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4278 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4279 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4280 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4281 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4282 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4283 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4284 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4285 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4286 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4287 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4288 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4289 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4290 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4291 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4292 |
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 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4295 /* 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
|
4296 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4297 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4298 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4299 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4300 } |
7440 | 4301 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4302 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4303 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4304 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4305 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4306 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4307 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4308 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4309 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4310 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4311 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4312 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4313 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4314 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4315 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4316 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4317 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4318 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4319 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4320 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4321 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4322 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4323 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4324 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4325 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4326 |
4359 | 4327 g_free(str); |
4328 | |
4895 | 4329 if(gc){ |
4896 | 4330 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4331 char *post = "</font>"; |
4332 int pre_len = strlen(pre); | |
4333 int post_len = strlen(post); | |
7440 | 4334 |
4895 | 4335 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4336 |
4895 | 4337 strcpy(with_font_tag, pre); |
4338 memcpy(with_font_tag + pre_len, new_message, length); | |
4339 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4340 |
4895 | 4341 length += pre_len + post_len; |
4342 g_free(pre); | |
4343 } | |
4608 | 4344 else |
4895 | 4345 with_font_tag = g_memdup(new_message, length); |
7440 | 4346 |
8962 | 4347 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4348 with_font_tag, gtk_font_options); | |
7440 | 4349 |
4350 g_free(with_font_tag); | |
7447 | 4351 g_free(new_message); |
7440 | 4352 } |
4353 | |
5012 | 4354 if(sml_attrib) |
4355 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4356 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4357 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4358 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4359 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4360 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4361 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4362 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4363 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4364 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4365 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4366 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4367 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
|
4368 unseen = GAIM_UNSEEN_NOLOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4369 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4370 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4371 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4372 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4373 } |
4359 | 4374 } |
4375 | |
4376 static void | |
11869 | 4377 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
|
4378 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4379 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4380 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4381 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4382 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4383 GList *ll; |
11869 | 4384 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4385 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4386 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4387 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4388 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4389 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4390 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4391 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4392 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
|
4393 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4394 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4395 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4396 num_users), |
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 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4399 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4400 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4401 l = users; |
11869 | 4402 ll = flags; |
4403 lll = aliases; | |
4404 while (l != NULL && ll != NULL && lll != NULL) { | |
4405 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
|
4406 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4407 ll = ll->next; |
11869 | 4408 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4409 } |
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 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4413 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
|
4414 const char *new_name, const char *new_alias) |
4359 | 4415 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4416 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4417 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4418 GaimGtkChatPane *gtkchat; |
11869 | 4419 GaimConvChatBuddyFlags flags; |
4359 | 4420 GtkTreeIter iter; |
4421 GtkTreeModel *model; | |
4422 int f = 1; | |
4423 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4424 chat = GAIM_CONV_CHAT(conv); |
4359 | 4425 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4426 gtkchat = gtkconv->u.chat; | |
4427 | |
9554 | 4428 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4429 | |
4430 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4431 return; | |
4432 | |
4433 while (f != 0) { | |
4434 char *val; | |
4435 | |
11869 | 4436 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4437 |
4438 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4439 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4440 g_free(val); | |
4359 | 4441 break; |
4442 } | |
9554 | 4443 |
4444 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4445 | |
4446 g_free(val); | |
4359 | 4447 } |
4448 | |
9554 | 4449 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4450 return; |
4451 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4452 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4453 |
11869 | 4454 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4455 } |
4456 | |
4457 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4458 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4459 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4460 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4461 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4462 GaimGtkChatPane *gtkchat; |
4359 | 4463 GtkTreeIter iter; |
4464 GtkTreeModel *model; | |
4465 char tmp[BUF_LONG]; | |
4466 int num_users; | |
4467 int f = 1; | |
4468 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4469 chat = GAIM_CONV_CHAT(conv); |
4359 | 4470 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4471 gtkchat = gtkconv->u.chat; | |
4472 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4473 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
|
4474 |
9554 | 4475 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4476 | |
4477 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4478 return; | |
4479 | |
4480 while (f != 0) { | |
4481 char *val; | |
4482 | |
4483 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4484 | |
4485 if (!gaim_utf8_strcasecmp(user, val)) { | |
4486 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4487 g_free(val); | |
4359 | 4488 break; |
4489 } | |
9554 | 4490 |
4491 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4492 | |
4493 g_free(val); | |
4359 | 4494 } |
4495 | |
9554 | 4496 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4497 return; |
4498 | |
4499 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4500 ngettext("%d person in room", "%d people in room", |
4501 num_users), num_users); | |
4359 | 4502 |
4503 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4504 | |
4505 } | |
4506 | |
4507 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4508 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4509 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4510 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4511 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4512 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4513 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4514 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4515 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4516 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4517 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4518 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4519 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4520 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4521 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4522 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4523 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4524 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
|
4525 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4526 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4527 for (l = users; l != NULL; l = l->next) { |
9554 | 4528 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4529 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4530 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4531 continue; |
4532 | |
4533 do { | |
4534 char *val; | |
4535 | |
4536 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4537 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4538 | |
9696 | 4539 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4540 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4541 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4542 #else |
4543 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4544 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4545 #endif | |
4546 } | |
9554 | 4547 else |
4548 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4549 | |
4550 g_free(val); | |
4551 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4552 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4553 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4554 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4555 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4556 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4557 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4558 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4559 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4560 |
9554 | 4561 static void |
4562 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4563 { | |
4564 GaimConvChat *chat; | |
11869 | 4565 GaimConvChatBuddyFlags flags; |
9554 | 4566 GaimGtkConversation *gtkconv; |
4567 GaimGtkChatPane *gtkchat; | |
4568 GtkTreeIter iter; | |
4569 GtkTreeModel *model; | |
4570 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4571 char *alias = NULL; |
9554 | 4572 |
4573 chat = GAIM_CONV_CHAT(conv); | |
4574 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4575 gtkchat = gtkconv->u.chat; | |
4576 | |
4577 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4578 | |
4579 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4580 return; | |
4581 | |
4582 while (f != 0) { | |
4583 char *val; | |
4584 | |
4585 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4586 | |
4587 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4588 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4589 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4590 g_free(val); | |
4591 break; | |
4592 } | |
4593 | |
4594 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4595 | |
4596 g_free(val); | |
4597 } | |
4598 | |
4599 if (!gaim_conv_chat_find_user(chat, user)) | |
4600 return; | |
4601 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4602 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4603 |
11869 | 4604 flags = gaim_conv_chat_user_get_flags(chat, user); |
4605 | |
4606 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4607 g_free(alias); |
9554 | 4608 } |
4609 | |
11581 | 4610 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4611 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4612 { |
11581 | 4613 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4614 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4615 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4616 |
11581 | 4617 win = gtkconv->win; |
4618 | |
4619 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
|
4620 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4621 if (has_focus) |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4622 { |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4623 GaimConversation *c = gaim_gtk_conv_window_get_active_conversation(win); |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4624 if (GAIM_GTK_CONVERSATION(c) == gtkconv) |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4625 return TRUE; |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4626 } |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4627 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4628 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4629 |
10526 | 4630 static gboolean |
4631 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4632 { | |
4633 GaimGtkConversation *gtkconv; | |
4634 GtkIMHtmlSmiley *smiley; | |
4635 GdkPixbufLoader *loader; | |
11525 | 4636 struct smiley_list *list; |
4637 const char *sml = NULL, *conv_sml; | |
4638 | |
4639 if (!conv || !smile || !*smile) { | |
10526 | 4640 return FALSE; |
4641 } | |
4642 | |
11525 | 4643 /* If smileys are off, return false */ |
4644 if (gaim_gtkthemes_smileys_disabled()) | |
4645 return FALSE; | |
4646 | |
4647 /* If possible add this smiley to the current theme. | |
4648 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4649 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4650 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4651 |
4652 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4653 if (!strcmp(list->sml, conv_sml)) { | |
4654 sml = list->sml; | |
4655 break; | |
4656 } | |
4657 } | |
4658 | |
10526 | 4659 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4660 | |
4661 if (smiley) { | |
11525 | 4662 |
4663 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4664 return FALSE; | |
4665 } | |
4666 | |
4667 /* Close the old GdkPixbufAnimation, then create a new one for | |
4668 * the smiley we are about to receive */ | |
4669 g_object_unref(G_OBJECT(smiley->icon)); | |
4670 | |
4671 smiley->loader = gdk_pixbuf_loader_new(); | |
4672 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4673 if (smiley->icon) | |
4674 g_object_ref(G_OBJECT(smiley->icon)); | |
4675 | |
4676 /* A custom smiley is already associated */ | |
4677 return TRUE; | |
10526 | 4678 } |
4679 | |
4680 loader = gdk_pixbuf_loader_new(); | |
4681 | |
4682 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4683 /* 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
|
4684 GtkIMHtmlSmiley by opaque */ |
10526 | 4685 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4686 smiley->file = NULL; | |
4687 smiley->smile = g_strdup(smile); | |
4688 smiley->loader = loader; | |
11525 | 4689 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4690 |
4691 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4692 if (smiley->icon) | |
4693 g_object_ref(G_OBJECT(smiley->icon)); | |
4694 | |
11525 | 4695 |
10526 | 4696 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4697 |
10526 | 4698 return TRUE; |
4699 } | |
4700 | |
10537 | 4701 static void |
10526 | 4702 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4703 const guchar *data, gsize size) |
10526 | 4704 { |
4705 GaimGtkConversation *gtkconv; | |
4706 GtkIMHtmlSmiley *smiley; | |
10537 | 4707 GdkPixbufLoader *loader; |
10526 | 4708 const char *sml; |
4709 | |
4710 sml = gaim_account_get_protocol_name(conv->account); | |
4711 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4712 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4713 | |
10537 | 4714 if (!smiley) |
10526 | 4715 return; |
10537 | 4716 |
10526 | 4717 loader = smiley->loader; |
10537 | 4718 if (!loader) |
10526 | 4719 return; |
4720 | |
4721 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4722 } | |
4723 | |
4724 static void | |
4725 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4726 { | |
4727 GaimGtkConversation *gtkconv; | |
4728 GtkIMHtmlSmiley *smiley; | |
4729 GdkPixbufLoader *loader; | |
4730 const char *sml; | |
11525 | 4731 GtkWidget *icon = NULL; |
4732 GtkTextChildAnchor *anchor = NULL; | |
4733 GtkTextIter end; | |
4734 GtkIMHtml *imhtml; | |
4735 GSList *current = NULL; | |
10526 | 4736 |
4737 g_return_if_fail(conv != NULL); | |
4738 g_return_if_fail(smile != NULL); | |
4739 | |
4740 sml = gaim_account_get_protocol_name(conv->account); | |
4741 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4742 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4743 | |
10537 | 4744 if (!smiley) |
10526 | 4745 return; |
4746 | |
4747 loader = smiley->loader; | |
4748 | |
10537 | 4749 if (!loader) |
10526 | 4750 return; |
10537 | 4751 |
11525 | 4752 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4753 if (smiley->icon) | |
4754 g_object_ref(G_OBJECT(smiley->icon)); | |
4755 | |
4756 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4757 | |
4758 icon = gtk_image_new_from_animation(smiley->icon); | |
4759 | |
4760 if (icon) { | |
12047 | 4761 gtk_widget_show(icon); |
4762 | |
11525 | 4763 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
4764 | |
4765 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4766 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4767 | |
4768 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4769 } | |
4770 | |
4771 } | |
4772 | |
4773 g_slist_free(smiley->anchors); | |
4774 smiley->anchors = NULL; | |
4775 | |
4776 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4777 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4778 * makes me question it */ | |
4779 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4780 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4781 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4782 | |
10526 | 4783 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4784 | |
4785 gdk_pixbuf_loader_close(loader, NULL); | |
4786 g_object_unref(G_OBJECT(loader)); | |
4787 smiley->loader = NULL; | |
4788 } | |
4789 | |
11581 | 4790 /* |
4791 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4792 * sensitive/insensitive. This is called after changing tabs and when an | |
4793 * account signs on or off. | |
4794 */ | |
4795 static void | |
4796 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4797 { | |
4798 GaimGtkWindow *win; | |
4799 GaimConversation *conv = gtkconv->active_conv; | |
4800 GaimConnection *gc; | |
4801 GaimPluginProtocolInfo *prpl_info = NULL; | |
4802 GdkPixbuf *window_icon = NULL; | |
4803 GtkIMHtmlButtons buttons; | |
4804 GaimAccount *account; | |
4805 | |
4806 win = gaim_gtkconv_get_window(gtkconv); | |
4807 gc = gaim_conversation_get_gc(conv); | |
4808 account = gaim_conversation_get_account(conv); | |
4809 | |
4810 if (gc != NULL) | |
4811 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4812 | |
11594 | 4813 if (win->menu.send_to != NULL) |
11734 | 4814 update_send_to_selection(win); |
11581 | 4815 |
4816 /* | |
4817 * Handle hiding and showing stuff based on what type of conv this is. | |
4818 * Stuff that Gaim IMs support in general should be shown for IM | |
4819 * conversations. Stuff that Gaim chats support in general should be | |
4820 * shown for chat conversations. It doesn't matter whether the PRPL | |
4821 * supports it or not--that only affects if the button or menu item | |
4822 * is sensitive or not. | |
4823 */ | |
4824 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4825 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4826 | |
4827 /* Deal with menu items */ | |
4828 gtk_widget_show(win->menu.view_log); | |
4829 gtk_widget_show(win->menu.send_file); | |
4830 gtk_widget_show(win->menu.add_pounce); | |
4831 gtk_widget_show(win->menu.get_info); | |
4832 gtk_widget_hide(win->menu.invite); | |
4833 gtk_widget_show(win->menu.alias); | |
4834 gtk_widget_show(win->menu.block); | |
4835 | |
4836 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4837 gtk_widget_show(win->menu.add); | |
4838 gtk_widget_hide(win->menu.remove); | |
4839 } else { | |
4840 gtk_widget_show(win->menu.remove); | |
4841 gtk_widget_hide(win->menu.add); | |
4842 } | |
4843 | |
4844 gtk_widget_show(win->menu.insert_link); | |
4845 gtk_widget_show(win->menu.insert_image); | |
4846 gtk_widget_show(win->menu.show_icon); | |
4847 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4848 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4849 | |
4850 /* Deal with menu items */ | |
4851 gtk_widget_show(win->menu.view_log); | |
4852 gtk_widget_hide(win->menu.send_file); | |
4853 gtk_widget_hide(win->menu.add_pounce); | |
4854 gtk_widget_hide(win->menu.get_info); | |
4855 gtk_widget_show(win->menu.invite); | |
4856 gtk_widget_show(win->menu.alias); | |
4857 gtk_widget_hide(win->menu.block); | |
4858 gtk_widget_hide(win->menu.show_icon); | |
4859 | |
4860 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4861 /* If the chat is NOT in the buddy list */ | |
4862 gtk_widget_show(win->menu.add); | |
4863 gtk_widget_hide(win->menu.remove); | |
4864 } else { | |
4865 /* If the chat IS in the buddy list */ | |
4866 gtk_widget_hide(win->menu.add); | |
4867 gtk_widget_show(win->menu.remove); | |
4868 } | |
4869 | |
4870 gtk_widget_show(win->menu.insert_link); | |
4871 gtk_widget_hide(win->menu.insert_image); | |
4872 } | |
4873 | |
4874 /* | |
4875 * Handle graying stuff out based on whether an account is connected | |
4876 * and what features that account supports. | |
4877 */ | |
4878 if ((gc != NULL) && | |
12012 | 4879 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
4880 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
4881 { | |
11581 | 4882 /* Account is online */ |
4883 /* Deal with the toolbar */ | |
12012 | 4884 if (conv->features & GAIM_CONNECTION_HTML) |
4885 { | |
4886 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
4887 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
4888 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
4889 buttons &= ~GTK_IMHTML_IMAGE; | |
4890 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
4891 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
4892 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
4893 { | |
4894 buttons &= ~GTK_IMHTML_GROW; | |
4895 buttons &= ~GTK_IMHTML_SHRINK; | |
4896 } | |
4897 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
4898 buttons &= ~GTK_IMHTML_LINKDESC; | |
4899 } else { | |
4900 buttons = GTK_IMHTML_SMILEY; | |
4901 } | |
4902 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
4903 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 4904 |
4905 /* Deal with menu items */ | |
12012 | 4906 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4907 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4908 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
4909 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
4910 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
4911 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
4912 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE)); | |
4913 | |
4914 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
4915 { | |
4916 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
4917 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
4918 gtk_widget_set_sensitive(win->menu.send_file, | |
4919 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
4920 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
4921 gtk_widget_set_sensitive(win->menu.alias, | |
4922 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
4923 } | |
4924 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
4925 { | |
4926 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
4927 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
4928 gtk_widget_set_sensitive(win->menu.alias, | |
4929 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
4930 } | |
11581 | 4931 |
4932 /* Deal with chat userlist buttons */ | |
12012 | 4933 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4934 { | |
4935 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
4936 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
4937 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
4938 } | |
4939 } else { | |
11581 | 4940 /* Account is offline */ |
4941 /* Or it's a chat that we've left. */ | |
4942 | |
4943 /* Then deal with menu items */ | |
12012 | 4944 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4945 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
4946 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4947 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
4948 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
4949 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
4950 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
4951 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
4952 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
4953 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
4954 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 4955 |
4956 /* Deal with chat userlist buttons */ | |
12012 | 4957 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4958 { | |
4959 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
4960 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
4961 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
4962 } | |
4963 } | |
11581 | 4964 |
4965 /* | |
4966 * Update the window's icon | |
4967 */ | |
4968 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
12012 | 4969 (gtkconv->u.im->anim)) |
11581 | 4970 { |
4971 window_icon = | |
4972 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
4973 g_object_ref(window_icon); | |
4974 } else { | |
4975 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
4976 } | |
4977 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
4978 if (window_icon != NULL) | |
4979 g_object_unref(G_OBJECT(window_icon)); | |
4980 } | |
4981 | |
10526 | 4982 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4983 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4984 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 4985 { |
11581 | 4986 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4987 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4988 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4989 GaimConvChat *chat; |
4359 | 4990 |
10116 | 4991 g_return_if_fail(conv != NULL); |
4992 | |
4359 | 4993 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4994 win = gtkconv->win; |
10810 | 4995 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 4996 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
4997 * instead of the gross hack? | |
4998 */ | |
4359 | 4999 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5000 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5001 { |
4359 | 5002 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5003 |
11338 | 5004 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5005 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5006 |
4359 | 5007 gaim_gtkconv_update_buttons_by_protocol(conv); |
5008 | |
11734 | 5009 update_send_to_selection(win); |
4359 | 5010 |
11525 | 5011 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5012 |
6395 | 5013 update_tab_icon(conv); |
4359 | 5014 } |
5015 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5016 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5017 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5018 { |
9472 | 5019 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5020 GaimConvIm *im = NULL; |
9472 | 5021 GaimConnection *gc = gaim_conversation_get_gc(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5022 /* 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
|
5023 char style[51]; |
4736 | 5024 |
11338 | 5025 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5026 im = GAIM_CONV_IM(conv); |
4359 | 5027 |
11338 | 5028 if (!gc || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5029 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5030 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5031 else | |
5032 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5033 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5034 *style = '\0'; |
4359 | 5035 |
5036 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5037 gtk_widget_realize(gtkconv->tab_label); | |
5038 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5039 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5040 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5041 { |
11759 | 5042 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5043 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5044 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5045 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5046 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5047 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5048 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5049 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5050 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5051 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5052 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5053 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5054 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5055 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5056 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5057 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5058 { |
11758 | 5059 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5060 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5061 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5062 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5063 { |
8536 | 5064 char *html_title,*label; |
5065 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5066 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5067 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5068 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5069 style, html_title); |
8536 | 5070 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5071 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5072 g_free(label); |
4359 | 5073 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5074 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5075 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5076 |
11581 | 5077 if (conv == gaim_gtk_conv_window_get_active_conversation(win)) |
10810 | 5078 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5079 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5080 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5081 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
11581 | 5082 if (conv == gaim_gtk_conv_window_get_active_conversation(win)) |
5083 gtk_window_set_title(GTK_WINDOW(win->window), title); | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5084 } |
9472 | 5085 |
5086 g_free(title); | |
4359 | 5087 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5088 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5089 { |
7154 | 5090 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5091 chat = GAIM_CONV_CHAT(conv); |
4359 | 5092 gtkchat = gtkconv->u.chat; |
5093 | |
7154 | 5094 topic = gaim_conv_chat_get_topic(chat); |
5095 | |
9554 | 5096 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5097 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5098 topic ? topic : "", NULL); |
4359 | 5099 } |
5100 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5101 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5102 { |
11581 | 5103 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5104 generate_send_to_items(win); |
8946 | 5105 update_tab_icon(conv); |
9472 | 5106 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5107 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5108 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5109 { |
8946 | 5110 update_tab_icon(conv); |
4359 | 5111 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5112 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
|
5113 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5114 { |
9472 | 5115 gaim_conversation_autoset_title(conv); |
10810 | 5116 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5117 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5118 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5119 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5120 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5121 } |
10665 | 5122 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5123 { | |
10810 | 5124 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5125 } |
4359 | 5126 } |
5127 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5128 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5129 { |
11581 | 5130 gaim_gtkconv_new, |
4359 | 5131 gaim_gtkconv_destroy, /* destroy_conversation */ |
5132 gaim_gtkconv_write_chat, /* write_chat */ | |
5133 gaim_gtkconv_write_im, /* write_im */ | |
5134 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5135 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5136 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5137 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5138 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5139 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5140 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5141 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5142 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5143 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5144 gaim_gtkconv_updated /* updated */ |
5145 }; | |
5146 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5147 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5148 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5149 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5150 return &conversation_ui_ops; |
4359 | 5151 } |
5152 | |
5153 /************************************************************************** | |
5154 * Public conversation utility functions | |
5155 **************************************************************************/ | |
5156 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5157 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5158 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5159 GaimGtkConversation *gtkconv; |
11581 | 5160 GaimGtkWindow *win; |
4359 | 5161 |
10381 | 5162 GdkPixbufLoader *loader; |
5163 GdkPixbufAnimation *anim; | |
4359 | 5164 GError *err = NULL; |
5165 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5166 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5167 size_t len; |
4359 | 5168 |
5169 GdkPixbuf *buf; | |
5170 | |
5171 GtkWidget *event; | |
5172 GtkWidget *frame; | |
5173 GdkPixbuf *scale; | |
5174 GdkPixmap *pm; | |
5175 GdkBitmap *bm; | |
9318 | 5176 int scale_width, scale_height; |
5177 | |
5178 GaimAccount *account; | |
5179 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5180 |
9324 | 5181 GaimBuddyIcon *icon; |
5182 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5183 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5184 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5185 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5186 |
5187 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5188 win = gtkconv->win; |
10175 | 5189 |
9687 | 5190 if (!gtkconv->u.im->show_icon) |
5191 return; | |
5192 | |
9318 | 5193 account = gaim_conversation_get_account(conv); |
5194 if(account && account->gc) | |
5195 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5196 |
9845 | 5197 /* Remove the current icon stuff */ |
9885 | 5198 if (gtkconv->u.im->icon_container != NULL) |
5199 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5200 gtkconv->u.im->icon_container = NULL; | |
9845 | 5201 |
5202 if (gtkconv->u.im->anim != NULL) | |
5203 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5204 | |
9887 | 5205 gtkconv->u.im->anim = NULL; |
5206 | |
9845 | 5207 if (gtkconv->u.im->icon_timer != 0) |
5208 g_source_remove(gtkconv->u.im->icon_timer); | |
5209 | |
5210 gtkconv->u.im->icon_timer = 0; | |
5211 | |
5212 if (gtkconv->u.im->iter != NULL) | |
5213 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5214 |
10116 | 5215 gtkconv->u.im->iter = NULL; |
5216 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5217 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5218 return; |
5219 | |
5220 if (gaim_conversation_get_gc(conv) == NULL) | |
5221 return; | |
5222 | |
9324 | 5223 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5224 | |
5225 if (icon == NULL) | |
5226 return; | |
5227 | |
5228 data = gaim_buddy_icon_get_data(icon, &len); | |
5229 | |
10381 | 5230 loader = gdk_pixbuf_loader_new(); |
5231 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5232 anim = gdk_pixbuf_loader_get_animation(loader); | |
5233 if (anim) | |
5234 g_object_ref(G_OBJECT(anim)); | |
5235 gdk_pixbuf_loader_close(loader, &err); | |
5236 g_object_unref(loader); | |
5237 | |
5238 if (!anim) | |
9324 | 5239 return; |
10381 | 5240 gtkconv->u.im->anim = anim; |
9324 | 5241 |
4359 | 5242 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5243 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5244 "Buddy icon error: %s\n", err->message); |
4359 | 5245 g_error_free(err); |
5246 } | |
5247 | |
5248 if (!gtkconv->u.im->anim) | |
5249 return; | |
5250 | |
5251 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5252 gtkconv->u.im->iter = NULL; | |
5253 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5254 } else { | |
5255 gtkconv->u.im->iter = | |
8496 | 5256 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5257 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5258 if (gtkconv->u.im->animate) |
10810 | 5259 start_anim(NULL, gtkconv); |
4359 | 5260 } |
5261 | |
10483 | 5262 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5263 NULL, &scale_width, &scale_height); |
4359 | 5264 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5265 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5266 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5267 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5268 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5269 GDK_INTERP_BILINEAR); |
4359 | 5270 |
5271 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5272 g_object_unref(G_OBJECT(scale)); |
4359 | 5273 |
8821 | 5274 |
9885 | 5275 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5276 |
4359 | 5277 frame = gtk_frame_new(NULL); |
5278 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5279 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5280 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5281 FALSE, FALSE, 0); | |
8821 | 5282 |
4359 | 5283 event = gtk_event_box_new(); |
5284 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5285 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5286 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5287 gtk_widget_show(event); |
5288 | |
4635 | 5289 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5290 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5291 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5292 gtk_widget_show(gtkconv->u.im->icon); | |
5293 | |
4793 | 5294 g_object_unref(G_OBJECT(pm)); |
4359 | 5295 |
5296 if (bm) | |
4793 | 5297 g_object_unref(G_OBJECT(bm)); |
7143 | 5298 |
10356 | 5299 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5300 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5301 |
9885 | 5302 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5303 gtk_widget_show(frame); |
5304 | |
7143 | 5305 /* The buddy icon code needs badly to be fixed. */ |
5306 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
11581 | 5307 if(conv == gaim_gtk_conv_window_get_active_conversation(gtkconv->win)) |
5308 gtk_window_set_icon(GTK_WINDOW(win->window), buf); | |
4359 | 5309 } |
5310 | |
5311 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5312 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5313 { |
11581 | 5314 GaimGtkWindow *win; |
4359 | 5315 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5316 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5317 return; |
5318 | |
11581 | 5319 win = GAIM_GTK_CONVERSATION(conv)->win; |
5320 | |
5321 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5322 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5323 } |
5324 | |
5325 int | |
11614 | 5326 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5327 { |
4359 | 5328 gint nb_x, nb_y, x_rel, y_rel; |
5329 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5330 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5331 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5332 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5333 gboolean horiz; |
4359 | 5334 |
11614 | 5335 if (to_right) |
5336 *to_right = FALSE; | |
5337 | |
11581 | 5338 notebook = GTK_NOTEBOOK(win->notebook); |
5339 | |
5340 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5341 x_rel = x - nb_x; |
5342 y_rel = y - nb_y; | |
5343 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5344 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5345 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5346 |
11780 | 5347 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5348 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5349 #else |
5350 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5351 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5352 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5353 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5354 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5355 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5356 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5357 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5358 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5359 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5360 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5361 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
|
5362 page_num = i; |
11614 | 5363 |
5364 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5365 *to_right = TRUE; | |
5366 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5367 break; |
4359 | 5368 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5369 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5370 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5371 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
|
5372 page_num = i; |
11614 | 5373 |
5374 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5375 *to_right = TRUE; | |
5376 | |
4359 | 5377 break; |
5378 } | |
5379 } | |
5380 } | |
5381 | |
5382 return page_num; | |
5383 } | |
5384 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5385 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5386 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
|
5387 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5388 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5389 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5390 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5391 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5392 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5393 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5394 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5395 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5396 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5397 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5398 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5399 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5400 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5401 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5402 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5403 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5404 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5405 } |
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 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5408 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5409 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5410 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5411 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5412 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5413 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5414 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5415 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5416 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5417 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5418 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5419 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5420 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5421 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5422 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5423 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5424 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5425 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5426 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5427 if (value) |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
5428 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5429 else { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5430 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5431 gtkspell_detach(spell); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5432 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5433 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5434 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5435 } |
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 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5438 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5439 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5440 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5441 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5442 GtkPositionType pos; |
11581 | 5443 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5444 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5445 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5446 |
11581 | 5447 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5448 win = l->data; | |
5449 | |
11619 | 5450 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
|
5451 } |
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 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5455 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5456 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5457 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5458 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5459 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5460 GaimGtkConversation *gtkconv; |
11581 | 5461 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5462 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5463 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5464 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5465 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5466 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5467 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5468 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5469 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5470 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5471 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5472 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5473 gtk_check_menu_item_set_active( |
11581 | 5474 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5475 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5476 |
5477 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5478 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5479 else |
8317 | 5480 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5481 } |
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 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5485 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5486 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5487 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5488 GList *l; |
8189 | 5489 GaimConversation *conv; |
5490 GaimGtkConversation *gtkconv; | |
11581 | 5491 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5492 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5493 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
|
5494 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5495 |
8189 | 5496 /* Set the "animate" flag for each icon based on the new preference */ |
5497 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5498 conv = (GaimConversation *)l->data; | |
5499 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5500 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5501 } |
8189 | 5502 |
5503 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5504 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5505 win = l->data; | |
5506 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5507 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5508 } |
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 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5511 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5512 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
|
5513 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5514 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5515 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5516 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5517 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5518 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5519 |
11338 | 5520 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5521 gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5522 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5523 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5524 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5525 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5526 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5527 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5528 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5529 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5530 } |
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 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5533 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5534 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5535 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5536 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5537 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5538 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5539 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5540 |
11581 | 5541 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5542 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5543 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5544 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5545 |
11581 | 5546 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5547 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5548 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5549 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5550 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5551 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5552 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5553 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5554 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5555 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5556 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5557 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5558 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5559 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5560 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5561 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5562 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5563 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5564 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5565 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5566 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5567 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5568 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5569 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5570 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5571 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5572 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5573 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5574 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5575 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5576 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5577 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5578 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5579 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5580 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5581 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5582 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
|
5583 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5584 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5585 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5586 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5587 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5588 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5589 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5590 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5591 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5592 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5593 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5594 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5595 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5596 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5597 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5598 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5599 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
|
5600 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5601 /* Connect callbacks. */ |
10087 | 5602 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
|
5603 close_on_tabs_pref_cb, NULL); |
10087 | 5604 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
|
5605 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5606 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5607 spellcheck_pref_cb, NULL); |
10087 | 5608 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5609 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5610 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5611 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5612 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5613 |
10087 | 5614 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5615 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5616 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5617 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5618 /* IM callbacks */ |
10087 | 5619 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
|
5620 animate_buddy_icons_pref_cb, NULL); |
10087 | 5621 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
|
5622 show_buddy_icons_pref_cb, NULL); |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5623 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5624 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5625 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5626 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5627 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5628 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5629 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5630 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5631 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5632 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5633 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5634 |
5635 /********************************************************************** | |
5636 * Register commands | |
5637 **********************************************************************/ | |
9829 | 5638 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5639 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5640 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5641 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5642 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5643 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5644 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5645 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5646 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
|
5647 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5648 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5649 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5650 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5651 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5652 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5653 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5654 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5655 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5656 **********************************************************************/ |
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 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5659 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5660 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5661 G_CALLBACK(buddy_update_cb), NULL); |
5662 | |
11581 | 5663 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5664 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5665 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5666 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5667 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5668 { |
10443 | 5669 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5670 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5671 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5672 } |
11581 | 5673 |
5674 | |
5675 | |
5676 | |
5677 | |
5678 | |
5679 | |
5680 | |
5681 | |
5682 | |
5683 | |
5684 | |
5685 | |
5686 | |
5687 | |
5688 | |
5689 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5690 * and touch each others' private members all day long */ | |
5691 | |
5692 /** | |
5693 * @file gtkconvwin.c GTK+ Conversation Window API | |
5694 * @ingroup gtkui | |
5695 * | |
5696 * gaim | |
5697 * | |
5698 * Gaim is the legal property of its developers, whose names are too numerous | |
5699 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5700 * source distribution. | |
5701 * | |
5702 * This program is free software; you can redistribute it and/or modify | |
5703 * it under the terms of the GNU General Public License as published by | |
5704 * the Free Software Foundation; either version 2 of the License, or | |
5705 * (at your option) any later version. | |
5706 * | |
5707 * This program is distributed in the hope that it will be useful, | |
5708 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
5709 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
5710 * GNU General Public License for more details. | |
5711 * | |
5712 * You should have received a copy of the GNU General Public License | |
5713 * along with this program; if not, write to the Free Software | |
5714 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5715 * | |
5716 */ | |
5717 #include "internal.h" | |
5718 #include "gtkgaim.h" | |
5719 | |
5720 | |
5721 #include <gdk/gdkkeysyms.h> | |
5722 | |
5723 #include "account.h" | |
5724 #include "cmds.h" | |
5725 #include "debug.h" | |
5726 #include "imgstore.h" | |
5727 #include "log.h" | |
5728 #include "notify.h" | |
5729 #include "prpl.h" | |
5730 #include "request.h" | |
5731 #include "util.h" | |
5732 | |
5733 #include "gtkdnd-hints.h" | |
5734 #include "gtkblist.h" | |
5735 #include "gtkconv.h" | |
5736 #include "gtkdialogs.h" | |
5737 #include "gtkmenutray.h" | |
5738 #include "gtkpounce.h" | |
5739 #include "gtkprefs.h" | |
5740 #include "gtkprivacy.h" | |
5741 #include "gtkutils.h" | |
5742 #include "gtkstock.h" | |
5743 #include "gtkimhtml.h" | |
5744 #include "gtkimhtmltoolbar.h" | |
5745 | |
5746 static void | |
5747 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
5748 { | |
5749 gtk_widget_destroy(warn_close_dialog); | |
5750 warn_close_dialog = NULL; | |
5751 | |
5752 if (resp == GTK_RESPONSE_OK) | |
5753 gaim_gtk_conv_window_destroy(win); | |
5754 } | |
5755 | |
5756 static void | |
5757 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
5758 { | |
5759 GtkWidget *label; | |
5760 GtkWidget *vbox, *hbox; | |
5761 GtkWidget *img; | |
5762 | |
5763 g_return_if_fail(warn_close_dialog == NULL); | |
5764 | |
5765 | |
5766 warn_close_dialog = gtk_dialog_new_with_buttons( | |
5767 _("Confirm close"), | |
5768 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
5769 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
5770 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
5771 | |
5772 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
5773 GTK_RESPONSE_OK); | |
5774 | |
5775 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
5776 6); | |
5777 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
5778 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
5779 FALSE); | |
5780 | |
5781 /* Setup the outside spacing. */ | |
5782 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
5783 | |
5784 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
5785 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
5786 | |
5787 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
5788 GTK_ICON_SIZE_DIALOG); | |
5789 /* Setup the inner hbox and put the dialog's icon in it. */ | |
5790 hbox = gtk_hbox_new(FALSE, 12); | |
5791 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
5792 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
5793 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
5794 | |
5795 /* Setup the right vbox. */ | |
5796 vbox = gtk_vbox_new(FALSE, 12); | |
5797 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
5798 | |
5799 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
5800 gtk_widget_set_size_request(label, 350, -1); | |
5801 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
5802 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
5803 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
5804 | |
5805 /* Connect the signals. */ | |
5806 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
5807 G_CALLBACK(do_close), gtkwin); | |
5808 | |
5809 } | |
5810 | |
5811 /************************************************************************** | |
5812 * Callbacks | |
5813 **************************************************************************/ | |
5814 | |
5815 static gboolean | |
5816 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
5817 { | |
5818 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5819 GList *l; |
11581 | 5820 |
5821 /* If there are unread messages then show a warning dialog */ | |
5822 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
5823 l != NULL; l = l->next) | |
5824 { | |
5825 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5826 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
|
5827 gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5828 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5829 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5830 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5831 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5832 return TRUE; |
11581 | 5833 } |
5834 } | |
5835 | |
5836 gaim_gtk_conv_window_destroy(win); | |
5837 | |
5838 return TRUE; | |
5839 } | |
5840 | |
11604 | 5841 static void |
5842 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
5843 { | |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5844 /* only allow NONE or higher priority unseen state */ |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5845 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
|
5846 || state > gtkconv->unseen_state) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5847 gtkconv->unseen_state = state; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5848 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5849 } |
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 |
11581 | 5852 /* |
5853 * When a conversation window is focused, we know the user | |
5854 * has looked at it so we know there are no longer unseen | |
5855 * messages. | |
5856 */ | |
5857 static gint | |
5858 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
5859 { | |
5860 GaimGtkWindow *win = d; | |
11604 | 5861 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
5862 | |
5863 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 5864 |
5865 return FALSE; | |
5866 } | |
5867 | |
11851 | 5868 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 5869 /* Courtesy of Galeon! */ |
5870 static void | |
5871 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
5872 { | |
5873 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
5874 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
5875 } | |
11851 | 5876 #endif |
11581 | 5877 |
5878 static void | |
5879 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
5880 { | |
5881 static GdkCursor *cursor = NULL; | |
5882 | |
5883 gtkwin->in_drag = TRUE; | |
5884 | |
5885 if (gtkwin->drag_leave_signal) { | |
5886 g_signal_handler_disconnect(G_OBJECT(widget), | |
5887 gtkwin->drag_leave_signal); | |
5888 gtkwin->drag_leave_signal = 0; | |
5889 } | |
5890 | |
5891 if (cursor == NULL) | |
5892 cursor = gdk_cursor_new(GDK_FLEUR); | |
5893 | |
5894 /* Grab the pointer */ | |
5895 gtk_grab_add(gtkwin->notebook); | |
5896 #ifndef _WIN32 | |
5897 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
5898 always be true after a button press. */ | |
5899 if (!gdk_pointer_is_grabbed()) | |
5900 #endif | |
5901 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
5902 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
5903 NULL, cursor, GDK_CURRENT_TIME); | |
5904 } | |
5905 | |
5906 static gboolean | |
5907 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
5908 { | |
5909 | |
5910 /* | |
5911 * Make sure the user moved the mouse far enough for the | |
5912 * drag to be initiated. | |
5913 */ | |
5914 if (win->in_predrag) { | |
5915 if (e->x_root < win->drag_min_x || | |
5916 e->x_root >= win->drag_max_x || | |
5917 e->y_root < win->drag_min_y || | |
5918 e->y_root >= win->drag_max_y) { | |
5919 | |
5920 win->in_predrag = FALSE; | |
5921 notebook_init_grab(win, widget); | |
5922 } | |
5923 } | |
5924 else { /* Otherwise, draw the arrows. */ | |
5925 GaimGtkWindow *dest_win; | |
5926 GtkNotebook *dest_notebook; | |
5927 GtkWidget *tab; | |
5928 gint nb_x, nb_y, page_num; | |
5929 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
5930 gboolean horiz_tabs = FALSE; | |
11614 | 5931 GaimGtkConversation *gtkconv; |
5932 gboolean to_right = FALSE; | |
11581 | 5933 |
5934 /* Get the window that the cursor is over. */ | |
5935 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
5936 | |
5937 if (dest_win == NULL) { | |
5938 dnd_hints_hide_all(); | |
5939 | |
5940 return TRUE; | |
5941 } | |
5942 | |
5943 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
5944 | |
5945 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
5946 | |
5947 arrow1_x = arrow2_x = nb_x; | |
5948 arrow1_y = arrow2_y = nb_y; | |
5949 | |
5950 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 5951 e->x_root, e->y_root, &to_right); |
5952 to_right = to_right && (win != dest_win); | |
11581 | 5953 |
5954 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
5955 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
5956 | |
5957 horiz_tabs = TRUE; | |
5958 } | |
5959 | |
11614 | 5960 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
5961 tab = gtkconv->tabby; | |
11581 | 5962 |
5963 if (horiz_tabs) { | |
5964 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
5965 | |
11614 | 5966 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 5967 arrow1_x += tab->allocation.width; |
5968 arrow2_x += tab->allocation.width; | |
5969 } | |
5970 | |
5971 arrow1_y = nb_y + tab->allocation.y; | |
5972 arrow2_y = nb_y + tab->allocation.y + | |
5973 tab->allocation.height; | |
5974 } else { | |
5975 arrow1_x = nb_x + tab->allocation.x; | |
5976 arrow2_x = nb_x + tab->allocation.x + | |
5977 tab->allocation.width; | |
5978 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
5979 | |
5980 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
5981 arrow1_y += tab->allocation.height; | |
5982 arrow2_y += tab->allocation.height; | |
5983 } | |
5984 } | |
5985 | |
5986 if (horiz_tabs) { | |
5987 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
5988 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
5989 } else { | |
5990 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
5991 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
5992 } | |
5993 } | |
5994 | |
5995 return TRUE; | |
5996 } | |
5997 | |
5998 static gboolean | |
5999 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6000 { | |
6001 if (win->in_drag) | |
6002 return FALSE; | |
6003 | |
6004 if (e->x_root < win->drag_min_x || | |
6005 e->x_root >= win->drag_max_x || | |
6006 e->y_root < win->drag_min_y || | |
6007 e->y_root >= win->drag_max_y) { | |
6008 | |
6009 win->in_predrag = FALSE; | |
6010 notebook_init_grab(win, widget); | |
6011 } | |
6012 | |
6013 return TRUE; | |
6014 } | |
6015 | |
6016 /* | |
6017 * THANK YOU GALEON! | |
6018 */ | |
6019 static gboolean | |
6020 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6021 { | |
6022 gint nb_x, nb_y, x_rel, y_rel; | |
6023 int tab_clicked; | |
6024 GtkWidget *page; | |
6025 GtkWidget *tab; | |
6026 | |
6027 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6028 return FALSE; | |
6029 | |
6030 | |
6031 if (win->in_drag) { | |
6032 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6033 "Already in the middle of a window drag at tab_press_cb\n"); | |
6034 return TRUE; | |
6035 } | |
6036 | |
6037 /* | |
6038 * Make sure a tab was actually clicked. The arrow buttons | |
6039 * mess things up. | |
6040 */ | |
11614 | 6041 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6042 |
6043 if (tab_clicked == -1) | |
6044 return FALSE; | |
6045 | |
6046 /* | |
6047 * Get the relative position of the press event, with regards to | |
6048 * the position of the notebook. | |
6049 */ | |
6050 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6051 | |
6052 x_rel = e->x_root - nb_x; | |
6053 y_rel = e->y_root - nb_y; | |
6054 | |
6055 /* Reset the min/max x/y */ | |
6056 win->drag_min_x = 0; | |
6057 win->drag_min_y = 0; | |
6058 win->drag_max_x = 0; | |
6059 win->drag_max_y = 0; | |
6060 | |
6061 /* Find out which tab was dragged. */ | |
6062 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6063 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6064 | |
6065 win->drag_min_x = tab->allocation.x + nb_x; | |
6066 win->drag_min_y = tab->allocation.y + nb_y; | |
6067 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6068 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6069 | |
6070 /* Make sure the click occurred in the tab. */ | |
6071 if (e->x_root < win->drag_min_x || | |
6072 e->x_root >= win->drag_max_x || | |
6073 e->y_root < win->drag_min_y || | |
6074 e->y_root >= win->drag_max_y) { | |
6075 | |
6076 return FALSE; | |
6077 } | |
6078 | |
6079 win->in_predrag = TRUE; | |
6080 win->drag_tab = tab_clicked; | |
6081 | |
6082 /* Connect the new motion signals. */ | |
6083 win->drag_motion_signal = | |
6084 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6085 G_CALLBACK(notebook_motion_cb), win); | |
6086 | |
6087 win->drag_leave_signal = | |
6088 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6089 G_CALLBACK(notebook_leave_cb), win); | |
6090 | |
6091 return FALSE; | |
6092 } | |
6093 | |
6094 static gboolean | |
6095 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6096 { | |
6097 GaimGtkWindow *dest_win; | |
6098 GaimConversation *conv; | |
6099 GaimGtkConversation *gtkconv; | |
6100 gint dest_page_num = 0; | |
6101 gboolean new_window = FALSE; | |
11614 | 6102 gboolean to_right = FALSE; |
11581 | 6103 |
6104 /* | |
6105 * Don't check to make sure that the event's window matches the | |
6106 * widget's, because we may be getting an event passed on from the | |
6107 * close button. | |
6108 */ | |
6109 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6110 return FALSE; | |
6111 | |
6112 if (gdk_pointer_is_grabbed()) { | |
6113 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6114 gtk_grab_remove(widget); | |
6115 } | |
6116 | |
6117 if (!win->in_predrag && !win->in_drag) | |
6118 return FALSE; | |
6119 | |
6120 /* Disconnect the motion signal. */ | |
6121 if (win->drag_motion_signal) { | |
6122 g_signal_handler_disconnect(G_OBJECT(widget), | |
6123 win->drag_motion_signal); | |
6124 | |
6125 win->drag_motion_signal = 0; | |
6126 } | |
6127 | |
6128 /* | |
6129 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6130 * signal. | |
6131 */ | |
6132 if (win->in_predrag) { | |
6133 win->in_predrag = FALSE; | |
6134 | |
6135 if (win->drag_leave_signal) { | |
6136 g_signal_handler_disconnect(G_OBJECT(widget), | |
6137 win->drag_leave_signal); | |
6138 | |
6139 win->drag_leave_signal = 0; | |
6140 } | |
6141 } | |
6142 | |
6143 /* If we're not in drag... */ | |
6144 /* We're perfectly normal people! */ | |
6145 if (!win->in_drag) | |
6146 return FALSE; | |
6147 | |
6148 win->in_drag = FALSE; | |
6149 | |
6150 dnd_hints_hide_all(); | |
6151 | |
6152 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6153 | |
6154 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6155 | |
6156 if (dest_win == NULL) { | |
6157 /* If the current window doesn't have any other conversations, | |
6158 * there isn't much point transferring the conv to a new window. */ | |
6159 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6160 /* Make a new window to stick this to. */ | |
6161 dest_win = gaim_gtk_conv_window_new(); | |
6162 new_window = TRUE; | |
6163 } | |
6164 } | |
6165 | |
6166 if (dest_win == NULL) | |
6167 return FALSE; | |
6168 | |
6169 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6170 "conversation-dragging", win, dest_win); | |
6171 | |
6172 /* Get the destination page number. */ | |
6173 if (!new_window) | |
6174 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6175 e->x_root, e->y_root, &to_right); |
11581 | 6176 |
6177 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6178 | |
6179 if (win == dest_win) { | |
6180 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6181 } else { | |
6182 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6183 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6184 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6185 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6186 if (new_window) { | |
6187 gint win_width, win_height; | |
6188 | |
6189 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6190 &win_width, &win_height); | |
6191 | |
6192 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6193 e->x_root - (win_width / 2), | |
6194 e->y_root - (win_height / 2)); | |
6195 | |
6196 gaim_gtk_conv_window_show(dest_win); | |
6197 } | |
6198 } | |
6199 | |
6200 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6201 | |
6202 return TRUE; | |
6203 } | |
6204 | |
6205 | |
6206 static void | |
6207 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6208 gpointer user_data) | |
6209 { | |
6210 GaimGtkWindow *win; | |
6211 GaimConversation *conv; | |
6212 GaimGtkConversation *gtkconv; | |
6213 | |
6214 win = user_data; | |
6215 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6216 | |
6217 g_return_if_fail(conv != NULL); | |
6218 | |
6219 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6220 return; | |
6221 | |
6222 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6223 | |
6224 stop_anim(NULL, gtkconv); | |
6225 } | |
6226 | |
6227 static void | |
6228 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6229 gpointer user_data) | |
6230 { | |
6231 GaimGtkWindow *win; | |
6232 GaimConversation *conv; | |
6233 GaimGtkConversation *gtkconv; | |
6234 | |
6235 win = user_data; | |
6236 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6237 conv = gtkconv->active_conv; | |
6238 | |
6239 g_return_if_fail(conv != NULL); | |
6240 | |
6241 /* | |
6242 * Only set "unseen" to "none" if the window has focus | |
6243 */ | |
6244 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6245 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6246 |
6247 /* Update the menubar */ | |
6248 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6249 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
|
6250 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6251 |
11594 | 6252 generate_send_to_items(win); |
6253 | |
11604 | 6254 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6255 |
6256 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6257 gtkconv->make_sound); | |
6258 | |
6259 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6260 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6261 | |
6262 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6263 gtkconv->show_timestamps); | |
6264 | |
6265 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6266 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6267 gtkconv->u.im->show_icon); | |
11604 | 6268 |
11581 | 6269 /* |
6270 * We pause icons when they are not visible. If this icon should | |
6271 * be animated then start it back up again. | |
6272 */ | |
6273 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6274 (gtkconv->u.im->animate)) | |
6275 start_anim(NULL, gtkconv); | |
6276 } | |
6277 | |
6278 /************************************************************************** | |
6279 * GTK+ window ops | |
6280 **************************************************************************/ | |
6281 | |
6282 static GList *window_list = NULL; | |
6283 | |
6284 GList * | |
6285 gaim_gtk_conv_windows_get_list() | |
6286 { | |
6287 return window_list; | |
6288 } | |
6289 | |
6290 GaimGtkWindow * | |
6291 gaim_gtk_conv_window_new() | |
6292 { | |
6293 GaimGtkWindow *win; | |
6294 GtkPositionType pos; | |
6295 GtkWidget *testidea; | |
6296 GtkWidget *menubar; | |
6297 | |
6298 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6299 | |
6300 window_list = g_list_append(window_list, win); | |
6301 | |
6302 /* Create the window. */ | |
6303 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6304 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6305 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6306 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6307 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6308 | |
6309 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6310 G_CALLBACK(close_win_cb), win); | |
6311 | |
6312 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6313 G_CALLBACK(focus_win_cb), win); | |
6314 | |
6315 /* Create the notebook. */ | |
6316 win->notebook = gtk_notebook_new(); | |
6317 | |
6318 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6319 | |
6320 #if 0 | |
6321 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6322 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6323 #endif | |
6324 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6325 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6326 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6327 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6328 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6329 | |
6330 gtk_widget_show(win->notebook); | |
6331 | |
6332 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6333 G_CALLBACK(before_switch_conv_cb), win); | |
6334 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6335 G_CALLBACK(switch_conv_cb), win); | |
6336 | |
6337 /* Setup the tab drag and drop signals. */ | |
6338 gtk_widget_add_events(win->notebook, | |
6339 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6340 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6341 G_CALLBACK(notebook_press_cb), win); | |
6342 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6343 G_CALLBACK(notebook_release_cb), win); | |
6344 | |
6345 testidea = gtk_vbox_new(FALSE, 0); | |
6346 | |
6347 /* Setup the menubar. */ | |
6348 menubar = setup_menubar(win); | |
6349 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6350 | |
6351 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6352 | |
6353 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6354 | |
6355 gtk_widget_show(testidea); | |
6356 | |
6357 return win; | |
6358 } | |
6359 | |
6360 void | |
6361 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6362 { | |
6363 window_list = g_list_remove(window_list, win); | |
6364 | |
11611 | 6365 if (win->gtkconvs) { |
6366 while (win->gtkconvs) { | |
6367 GList *nextgtk = win->gtkconvs->next; | |
6368 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6369 GList *nextcore = gtkconv->convs->next; | |
6370 GaimConversation *conv = gtkconv->convs->data; | |
6371 gaim_conversation_destroy(conv); | |
6372 if (!nextgtk && !nextcore) | |
6373 /* we'll end up invoking ourselves when we destroy our last child */ | |
6374 /* so don't destroy ourselves right now */ | |
6375 return; | |
6376 } | |
6377 return; | |
6378 } | |
11581 | 6379 gtk_widget_destroy(win->window); |
6380 | |
6381 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6382 | |
6383 g_free(win); | |
6384 } | |
6385 | |
6386 void | |
6387 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6388 { | |
6389 gtk_widget_show(win->window); | |
6390 } | |
6391 | |
6392 void | |
6393 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6394 { | |
6395 gtk_widget_hide(win->window); | |
6396 } | |
6397 | |
6398 void | |
6399 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6400 { | |
6401 gtk_widget_show(win->window); | |
6402 gtk_window_deiconify(GTK_WINDOW(win->window)); | |
6403 gdk_window_raise(win->window->window); | |
6404 } | |
6405 | |
6406 void | |
6407 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6408 { | |
6409 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6410 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6411 gtkconv->tab_cont)); | |
6412 } | |
6413 | |
6414 void | |
6415 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6416 { | |
6417 GaimConversation *conv = gtkconv->active_conv; | |
6418 GaimGtkConversation *focus_gtkconv; | |
6419 GtkWidget *tabby, *menu_tabby; | |
6420 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6421 GtkWidget *close_image; | |
6422 GaimConversationType conv_type; | |
6423 const char *name; | |
6424 const gchar *tmp_lab; | |
6425 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6426 gboolean tabs_side = FALSE; |
6427 gint angle = 0; | |
11581 | 6428 |
6429 name = gaim_conversation_get_name(conv); | |
6430 conv_type = gaim_conversation_get_type(conv); | |
6431 | |
6432 | |
6433 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6434 gtkconv->win = win; | |
6435 | |
11619 | 6436 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6437 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6438 tabs_side = TRUE; | |
6439 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6440 angle = 90; | |
6441 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6442 angle = 270; | |
6443 | |
6444 if (angle) | |
6445 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6446 else | |
6447 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6448 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6449 | |
6450 /* Close button. */ | |
6451 gtkconv->close = gtk_button_new(); | |
6452 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6453 if (gtk_check_version(2, 4, 2) == NULL) { | |
6454 /* Need to account for extra padding around the gtkbutton */ | |
6455 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6456 "focus-line-width", &focus_width, | |
6457 "focus-padding", &focus_pad, | |
6458 NULL); | |
6459 close_button_width += (focus_width + focus_pad) * 2; | |
6460 close_button_height += (focus_width + focus_pad) * 2; | |
6461 } | |
6462 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6463 close_button_width, close_button_height); | |
6464 | |
6465 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6466 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6467 gtk_widget_show(close_image); | |
6468 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6469 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6470 _("Close conversation"), NULL); | |
6471 | |
6472 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6473 G_CALLBACK(close_conv_cb), gtkconv); | |
6474 | |
11851 | 6475 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6476 /* |
6477 * I love Galeon. They have a fix for that stupid annoying visible | |
6478 * border bug. I love you guys! -- ChipX86 | |
6479 */ | |
11851 | 6480 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6481 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6482 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6483 #endif |
11581 | 6484 |
6485 /* Status icon. */ | |
6486 gtkconv->icon = gtk_image_new(); | |
6487 gtkconv->menu_icon = gtk_image_new(); | |
6488 update_tab_icon(conv); | |
6489 | |
6490 /* Tab label. */ | |
6491 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6492 |
11581 | 6493 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6494 if (!angle) |
6495 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6496 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6497 if (tabs_side) { |
6498 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6499 } | |
6500 if (angle) | |
6501 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6502 #endif |
6503 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6504 #if 0 | |
6505 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6506 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6507 #endif | |
6508 | |
6509 /* Pack it all together. */ | |
11619 | 6510 if (angle == 90) |
6511 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6512 else | |
6513 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6514 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6515 FALSE, FALSE, 0); | |
6516 | |
6517 gtk_widget_show_all(gtkconv->icon); | |
6518 gtk_widget_show_all(gtkconv->menu_icon); | |
6519 | |
6520 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6521 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6522 gtk_widget_show(gtkconv->tab_label); | |
6523 gtk_widget_show(gtkconv->menu_label); | |
6524 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6525 | |
11619 | 6526 if (angle == 90) |
6527 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6528 else | |
6529 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6530 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6531 gtk_widget_show(gtkconv->close); | |
6532 | |
6533 gtk_widget_show(tabby); | |
6534 gtk_widget_show(menu_tabby); | |
6535 | |
6536 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6537 gaim_gtkconv_update_buddy_icon(conv); | |
6538 | |
6539 /* Add this pane to the conversation's notebook. */ | |
6540 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6541 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6542 |
6543 | |
6544 gtk_widget_show(tab_cont); | |
6545 | |
6546 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6547 /* Er, bug in notebooks? Switch to the page manually. */ | |
6548 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6549 | |
6550 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6551 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6552 } else | |
6553 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6554 | |
6555 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6556 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6557 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6558 | |
6559 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6560 update_send_to_selection(win); |
11581 | 6561 } |
6562 | |
6563 void | |
6564 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6565 { | |
6566 unsigned int index; | |
6567 GaimConversationType conv_type; | |
6568 | |
6569 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6570 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6571 | |
6572 g_object_ref(gtkconv->tab_cont); | |
6573 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6574 | |
6575 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6576 | |
6577 /* go back to tabless if need be */ | |
6578 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6579 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6580 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6581 } | |
6582 | |
6583 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6584 |
6585 if (!win->gtkconvs) | |
6586 gaim_gtk_conv_window_destroy(win); | |
11581 | 6587 } |
6588 | |
6589 GaimGtkConversation * | |
6590 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
6591 { | |
6592 GtkWidget *tab_cont; | |
6593 | |
6594 if (index == -1) | |
6595 index = 0; | |
6596 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 6597 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 6598 } |
6599 | |
6600 GaimGtkConversation * | |
6601 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
6602 { | |
6603 int index; | |
6604 GtkWidget *tab_cont; | |
6605 | |
6606 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
6607 if (index == -1) | |
6608 index = 0; | |
6609 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
6610 if (!tab_cont) | |
6611 return NULL; | |
6612 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
6613 } | |
6614 | |
6615 | |
6616 GaimConversation * | |
6617 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
6618 { | |
6619 GaimGtkConversation *gtkconv; | |
6620 | |
6621 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
6622 return gtkconv ? gtkconv->active_conv : NULL; | |
6623 } | |
6624 | |
6625 gboolean | |
6626 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
6627 { | |
6628 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
6629 } | |
6630 | |
6631 gboolean | |
6632 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
6633 { | |
6634 gboolean has_focus = FALSE; | |
6635 | |
6636 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
6637 | |
6638 return has_focus; | |
6639 } | |
6640 | |
6641 GaimGtkWindow * | |
6642 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
6643 { | |
6644 GaimGtkWindow *win; | |
6645 GdkWindow *gdkwin; | |
6646 GList *l; | |
6647 | |
6648 gdkwin = gdk_window_at_pointer(&x, &y); | |
6649 | |
6650 if (gdkwin) | |
6651 gdkwin = gdk_window_get_toplevel(gdkwin); | |
6652 | |
6653 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
6654 win = l->data; | |
6655 | |
6656 if (gdkwin == win->window->window) | |
6657 return win; | |
6658 } | |
6659 | |
6660 return NULL; | |
6661 } | |
6662 | |
6663 GList * | |
6664 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
6665 { | |
6666 return win->gtkconvs; | |
6667 } | |
6668 | |
6669 guint | |
6670 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
6671 { | |
6672 return g_list_length(win->gtkconvs); | |
6673 } | |
6674 | |
6675 GaimGtkWindow * | |
6676 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
6677 { | |
6678 GList *wins, *convs; | |
6679 GaimGtkWindow *win; | |
6680 GaimGtkConversation *conv; | |
6681 | |
6682 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6683 return NULL; | |
6684 | |
6685 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
6686 win = wins->data; | |
6687 | |
6688 for (convs = win->gtkconvs; | |
6689 convs != NULL; | |
6690 convs = convs->next) { | |
6691 | |
6692 conv = convs->data; | |
6693 | |
6694 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6695 return win; | |
6696 } | |
6697 } | |
6698 | |
6699 return NULL; | |
6700 } | |
6701 | |
6702 GaimGtkWindow * | |
6703 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
6704 { | |
6705 GList *wins, *convs; | |
6706 GaimGtkWindow *win; | |
6707 GaimGtkConversation *conv; | |
6708 | |
6709 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6710 return NULL; | |
6711 | |
6712 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6713 wins != NULL; | |
6714 wins = wins->prev) { | |
6715 | |
6716 win = wins->data; | |
6717 | |
6718 for (convs = win->gtkconvs; | |
6719 convs != NULL; | |
6720 convs = convs->next) { | |
6721 | |
6722 conv = convs->data; | |
6723 | |
6724 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6725 return win; | |
6726 } | |
6727 } | |
6728 | |
6729 return NULL; | |
6730 } | |
6731 | |
6732 | |
6733 /************************************************************************** | |
6734 * Conversation placement functions | |
6735 **************************************************************************/ | |
6736 typedef struct | |
6737 { | |
6738 char *id; | |
6739 char *name; | |
6740 GaimConvPlacementFunc fnc; | |
6741 | |
6742 } ConvPlacementData; | |
6743 | |
6744 static GList *conv_placement_fncs = NULL; | |
6745 static GaimConvPlacementFunc place_conv = NULL; | |
6746 | |
6747 /* This one places conversations in the last made window. */ | |
6748 static void | |
6749 conv_placement_last_created_win(GaimGtkConversation *conv) | |
6750 { | |
6751 GaimGtkWindow *win; | |
6752 | |
6753 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6754 win = l ? l->data : NULL;; | |
6755 | |
6756 if (win == NULL) { | |
6757 win = gaim_gtk_conv_window_new(); | |
6758 | |
6759 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6760 gaim_gtk_conv_window_show(win); | |
6761 } else { | |
6762 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6763 } | |
6764 } | |
6765 | |
6766 /* This one places conversations in the last made window of the same type. */ | |
6767 static void | |
6768 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
6769 { | |
6770 GaimGtkWindow *win; | |
6771 | |
6772 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
6773 | |
6774 if (win == NULL) { | |
6775 win = gaim_gtk_conv_window_new(); | |
6776 | |
6777 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6778 gaim_gtk_conv_window_show(win); | |
6779 } else | |
6780 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6781 } | |
6782 | |
6783 /* This one places each conversation in its own window. */ | |
6784 static void | |
6785 conv_placement_new_window(GaimGtkConversation *conv) | |
6786 { | |
6787 GaimGtkWindow *win; | |
6788 | |
6789 win = gaim_gtk_conv_window_new(); | |
6790 | |
6791 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6792 | |
6793 gaim_gtk_conv_window_show(win); | |
6794 } | |
6795 | |
6796 static GaimGroup * | |
6797 conv_get_group(GaimGtkConversation *conv) | |
6798 { | |
6799 GaimGroup *group = NULL; | |
6800 | |
6801 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
6802 GaimBuddy *buddy; | |
6803 | |
6804 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
6805 gaim_conversation_get_name(conv->active_conv)); | |
6806 | |
6807 if (buddy != NULL) | |
6808 group = gaim_find_buddys_group(buddy); | |
6809 | |
6810 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
6811 GaimChat *chat; | |
6812 | |
6813 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
6814 gaim_conversation_get_name(conv->active_conv)); | |
6815 | |
6816 if (chat != NULL) | |
6817 group = gaim_chat_get_group(chat); | |
6818 } | |
6819 | |
6820 return group; | |
6821 } | |
6822 | |
6823 /* | |
6824 * This groups things by, well, group. Buddies from groups will always be | |
6825 * grouped together, and a buddy from a group not belonging to any currently | |
6826 * open windows will get a new window. | |
6827 */ | |
6828 static void | |
6829 conv_placement_by_group(GaimGtkConversation *conv) | |
6830 { | |
6831 GaimConversationType type; | |
6832 GaimGroup *group = NULL; | |
6833 GList *wl, *cl; | |
6834 | |
6835 type = gaim_conversation_get_type(conv->active_conv); | |
6836 | |
6837 group = conv_get_group(conv); | |
6838 | |
6839 /* Go through the list of IMs and find one with this group. */ | |
6840 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
6841 GaimGtkWindow *win2; | |
6842 GaimGtkConversation *conv2; | |
6843 GaimGroup *group2 = NULL; | |
6844 | |
6845 win2 = wl->data; | |
6846 | |
6847 for (cl = win2->gtkconvs; | |
6848 cl != NULL; | |
6849 cl = cl->next) { | |
6850 conv2 = cl->data; | |
6851 | |
6852 group2 = conv_get_group(conv2); | |
6853 | |
6854 if (group == group2) { | |
6855 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
6856 | |
6857 return; | |
6858 } | |
6859 } | |
6860 } | |
6861 | |
6862 /* Make a new window. */ | |
6863 conv_placement_new_window(conv); | |
6864 } | |
6865 | |
6866 /* This groups things by account. Otherwise, the same semantics as above */ | |
6867 static void | |
6868 conv_placement_by_account(GaimGtkConversation *conv) | |
6869 { | |
6870 GaimConversationType type; | |
6871 GList *wins, *convs; | |
6872 GaimAccount *account; | |
6873 | |
6874 account = gaim_conversation_get_account(conv->active_conv); | |
6875 type = gaim_conversation_get_type(conv->active_conv); | |
6876 | |
6877 /* Go through the list of IMs and find one with this group. */ | |
6878 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
6879 GaimGtkWindow *win2; | |
6880 GaimGtkConversation *conv2; | |
6881 | |
6882 win2 = wins->data; | |
6883 | |
6884 for (convs = win2->gtkconvs; | |
6885 convs != NULL; | |
6886 convs = convs->next) { | |
6887 conv2 = convs->data; | |
6888 | |
6889 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
6890 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
6891 return; | |
6892 } | |
6893 } | |
6894 } | |
6895 | |
6896 /* Make a new window. */ | |
6897 conv_placement_new_window(conv); | |
6898 } | |
6899 | |
6900 static ConvPlacementData * | |
6901 get_conv_placement_data(const char *id) | |
6902 { | |
6903 ConvPlacementData *data = NULL; | |
6904 GList *n; | |
6905 | |
6906 for (n = conv_placement_fncs; n; n = n->next) { | |
6907 data = n->data; | |
6908 if (!strcmp(data->id, id)) | |
6909 return data; | |
6910 } | |
6911 | |
6912 return NULL; | |
6913 } | |
6914 | |
6915 static void | |
6916 add_conv_placement_fnc(const char *id, const char *name, | |
6917 GaimConvPlacementFunc fnc) | |
6918 { | |
6919 ConvPlacementData *data; | |
6920 | |
6921 data = g_new(ConvPlacementData, 1); | |
6922 | |
6923 data->id = g_strdup(id); | |
6924 data->name = g_strdup(name); | |
6925 data->fnc = fnc; | |
6926 | |
6927 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
6928 } | |
6929 | |
6930 static void | |
6931 ensure_default_funcs(void) | |
6932 { | |
6933 if (conv_placement_fncs == NULL) { | |
6934 add_conv_placement_fnc("last", _("Last created window"), | |
6935 conv_placement_last_created_win); | |
6936 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
6937 conv_placement_last_created_win_type); | |
6938 add_conv_placement_fnc("new", _("New window"), | |
6939 conv_placement_new_window); | |
6940 add_conv_placement_fnc("group", _("By group"), | |
6941 conv_placement_by_group); | |
6942 add_conv_placement_fnc("account", _("By account"), | |
6943 conv_placement_by_account); | |
6944 } | |
6945 } | |
6946 | |
6947 GList * | |
6948 gaim_gtkconv_placement_get_options(void) | |
6949 { | |
6950 GList *n, *list = NULL; | |
6951 ConvPlacementData *data; | |
6952 | |
6953 ensure_default_funcs(); | |
6954 | |
6955 for (n = conv_placement_fncs; n; n = n->next) { | |
6956 data = n->data; | |
6957 list = g_list_append(list, data->name); | |
6958 list = g_list_append(list, data->id); | |
6959 } | |
6960 | |
6961 return list; | |
6962 } | |
6963 | |
6964 | |
6965 void | |
6966 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
6967 GaimConvPlacementFunc fnc) | |
6968 { | |
6969 g_return_if_fail(id != NULL); | |
6970 g_return_if_fail(name != NULL); | |
6971 g_return_if_fail(fnc != NULL); | |
6972 | |
6973 ensure_default_funcs(); | |
6974 | |
6975 add_conv_placement_fnc(id, name, fnc); | |
6976 } | |
6977 | |
6978 void | |
6979 gaim_gtkconv_placement_remove_fnc(const char *id) | |
6980 { | |
6981 ConvPlacementData *data = get_conv_placement_data(id); | |
6982 | |
6983 if (data == NULL) | |
6984 return; | |
6985 | |
6986 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
6987 | |
6988 g_free(data->id); | |
6989 g_free(data->name); | |
6990 g_free(data); | |
6991 } | |
6992 | |
6993 const char * | |
6994 gaim_gtkconv_placement_get_name(const char *id) | |
6995 { | |
6996 ConvPlacementData *data; | |
6997 | |
6998 ensure_default_funcs(); | |
6999 | |
7000 data = get_conv_placement_data(id); | |
7001 | |
7002 if (data == NULL) | |
7003 return NULL; | |
7004 | |
7005 return data->name; | |
7006 } | |
7007 | |
7008 GaimConvPlacementFunc | |
7009 gaim_gtkconv_placement_get_fnc(const char *id) | |
7010 { | |
7011 ConvPlacementData *data; | |
7012 | |
7013 ensure_default_funcs(); | |
7014 | |
7015 data = get_conv_placement_data(id); | |
7016 | |
7017 if (data == NULL) | |
7018 return NULL; | |
7019 | |
7020 return data->fnc; | |
7021 } | |
7022 | |
7023 void | |
7024 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7025 { | |
7026 g_return_if_fail(func != NULL); | |
7027 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7028 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7029 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7030 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7031 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7032 place_conv = NULL; |
11581 | 7033 } |
7034 | |
7035 GaimConvPlacementFunc | |
7036 gaim_gtkconv_placement_get_current_func(void) | |
7037 { | |
7038 return place_conv; | |
7039 } | |
7040 | |
7041 void | |
7042 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7043 { | |
7044 if (place_conv) | |
7045 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7046 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7047 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7048 } |