Mercurial > pidgin
annotate src/gtkconv.c @ 12140:ed6c64e5e0ed
[gaim-migrate @ 14441]
A fix from sadrul... This makes the tab right-click menu options work correctly when the conversation window is NOT in the top-left corner of your display.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 18 Nov 2005 23:14:48 +0000 |
parents | 370f9d7868f9 |
children | ffdd2ccf3a53 |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1 /** |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
2 * @file gtkconv.c GTK+ Conversation API |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3 * @ingroup gtkui |
4359 | 4 * |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
5 * gaim |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
6 * |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
10 * |
4359 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
28 |
4359 | 29 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
30 # include <X11/Xlib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
31 #endif |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
32 |
4359 | 33 #ifdef USE_GTKSPELL |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
34 # include <gtkspell/gtkspell.h> |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
35 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
36 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
37 # endif |
4359 | 38 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
39 |
4359 | 40 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
41 |
9699 | 42 #include "account.h" |
9130 | 43 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
44 #include "debug.h" |
6982 | 45 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
46 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
47 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
48 #include "prpl.h" |
6038 | 49 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
50 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
52 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
53 #include "gtkblist.h" |
5717 | 54 #include "gtkconv.h" |
11583 | 55 #include "gtkconvwin.h" |
9709 | 56 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
57 #include "gtkimhtml.h" |
8317 | 58 #include "gtkimhtmltoolbar.h" |
7431 | 59 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
60 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
61 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
62 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
63 #include "gtkprivacy.h" |
11525 | 64 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
65 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
66 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
67 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
69 |
11731 | 70 #define SEND_COLOR "#001f41" |
71 #define RECV_COLOR "#a63802" | |
7854 | 72 |
10108 | 73 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
74 | |
75 /* These colors come from the default GNOME palette */ | |
76 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
77 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
78 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
79 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
80 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
81 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
84 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
86 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
94 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
95 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
96 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
97 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
98 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 99 }; |
6291 | 100 |
4359 | 101 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
102 | |
11581 | 103 typedef struct { |
4359 | 104 GtkWidget *window; |
105 | |
106 GtkWidget *entry; | |
107 GtkWidget *message; | |
108 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
109 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
110 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
111 } InviteBuddyInfo; |
4359 | 112 |
113 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
114 static GtkWidget *warn_close_dialog = NULL; |
4359 | 115 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
116 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
117 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
118 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
119 |
11594 | 120 static gboolean update_send_to_selection(GaimGtkWindow *win); |
121 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 122 |
4359 | 123 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 124 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 125 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
126 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
127 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 128 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 129 static gboolean tab_complete(GaimConversation *conv); |
11604 | 130 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 131 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 132 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
133 static char *item_factory_translate_func (const char *path, gpointer func_data); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
134 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
135 static void private_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
136 gboolean destroy_empty); |
4359 | 137 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
138 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
139 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
140 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
141 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
142 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
143 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
144 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
145 (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
146 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
147 /* The colors are chosen to look fine on white; we should never have to darken */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
148 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
149 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
150 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
151 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
152 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
153 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
154 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
155 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
156 |
4359 | 157 /************************************************************************** |
158 * Callbacks | |
159 **************************************************************************/ | |
10971 | 160 |
4359 | 161 static gint |
10810 | 162 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 163 { |
10810 | 164 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 165 |
10810 | 166 l = list; |
167 while (l) { | |
168 GaimConversation *conv = l->data; | |
169 gaim_conversation_destroy(conv); | |
170 l = l->next; | |
171 } | |
11508 | 172 |
10810 | 173 g_list_free(list); |
11508 | 174 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
175 return TRUE; |
4359 | 176 } |
177 | |
8914 | 178 static gboolean |
10810 | 179 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 180 { |
10810 | 181 GaimConversation *conv = gtkconv->active_conv; |
11508 | 182 |
8914 | 183 if (!GTK_WIDGET_VISIBLE(w)) |
184 return FALSE; | |
185 | |
186 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
187 return FALSE; | |
188 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
189 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
190 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
191 * if there is only one conversation in the window. This way we'll be setting new windows to the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
192 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
193 /* I think that the above justification is not the majority, and that the new tab resizing should |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
194 * negate it anyway. --luke */ |
11338 | 195 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 196 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
197 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
198 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
199 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
200 } |
8914 | 201 if (w == gtkconv->entry) |
202 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
203 } | |
11338 | 204 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 205 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
206 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
207 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
208 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
209 } |
8914 | 210 if (w == gtkconv->entry) |
211 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
212 } | |
213 | |
214 return FALSE; | |
215 } | |
216 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
217 static void |
10810 | 218 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
219 { |
10810 | 220 GaimConversation *conv = c->active_conv; |
11508 | 221 |
10665 | 222 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
223 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
224 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
225 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
226 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
227 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
228 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
229 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
230 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
231 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
232 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
233 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline") != GTK_IMHTML(c->entry)->edit.underline) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
234 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
235 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
236 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
237 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
238 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
242 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
243 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
244 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
245 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 fg_color.blue / 256); |
8061 | 251 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 g_free(color); |
8677 | 273 |
9025 | 274 |
10665 | 275 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 276 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
277 else | |
278 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 279 } |
280 } | |
9130 | 281 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
282 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
283 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
284 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
285 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
286 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
287 |
9130 | 288 static const char * |
289 gaim_gtk_get_cmd_prefix(void) | |
290 { | |
291 return "/"; | |
292 } | |
293 | |
9167 | 294 static GaimCmdRet |
9829 | 295 say_command_cb(GaimConversation *conv, |
296 const char *cmd, char **args, char **error, void *data) | |
297 { | |
11338 | 298 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 299 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 300 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 301 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
302 | |
303 return GAIM_CMD_RET_OK; | |
304 } | |
305 | |
306 static GaimCmdRet | |
9167 | 307 me_command_cb(GaimConversation *conv, |
9597 | 308 const char *cmd, char **args, char **error, void *data) |
9167 | 309 { |
310 char *tmp; | |
311 | |
312 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 313 |
11338 | 314 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 315 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 316 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 317 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
318 | |
319 g_free(tmp); | |
320 return GAIM_CMD_RET_OK; | |
321 } | |
322 | |
9212 | 323 static GaimCmdRet |
324 debug_command_cb(GaimConversation *conv, | |
9597 | 325 const char *cmd, char **args, char **error, void *data) |
9212 | 326 { |
327 char *tmp, *markup; | |
328 GaimCmdStatus status; | |
329 | |
330 if (!g_ascii_strcasecmp(args[0], "version")) { | |
331 tmp = g_strdup_printf(_("me is using Gaim v%s."), VERSION); | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
332 markup = g_markup_escape_text(tmp, -1); |
9212 | 333 |
334 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
335 | |
336 g_free(tmp); | |
337 g_free(markup); | |
338 return status; | |
339 } else { | |
340 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
341 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
342 return GAIM_CMD_STATUS_OK; | |
343 } | |
344 } | |
345 | |
9213 | 346 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
347 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
348 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
349 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
350 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
351 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
352 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
353 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
354 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
355 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
356 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
357 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
358 static GaimCmdRet |
9213 | 359 help_command_cb(GaimConversation *conv, |
9597 | 360 const char *cmd, char **args, char **error, void *data) |
9213 | 361 { |
9597 | 362 GList *l, *text; |
9213 | 363 GString *s; |
9597 | 364 |
365 if (args[0] != NULL) { | |
366 s = g_string_new(""); | |
367 text = gaim_cmd_help(conv, args[0]); | |
368 | |
369 if (text) { | |
370 for (l = text; l; l = l->next) | |
371 if (l->next) | |
9816 | 372 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 373 else |
9816 | 374 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 375 } else { |
376 g_string_append(s, _("No such command (in this context).")); | |
377 } | |
378 } else { | |
379 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
380 "The following commands are available in this context:\n")); | |
381 | |
382 text = gaim_cmd_list(conv); | |
383 for (l = text; l; l = l->next) | |
9213 | 384 if (l->next) |
9597 | 385 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 386 else |
9597 | 387 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 388 } |
389 | |
390 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
391 g_string_free(s, TRUE); | |
392 | |
393 return GAIM_CMD_STATUS_OK; | |
394 } | |
395 | |
4359 | 396 static void |
9374 | 397 send_history_add(GaimConversation *conv, const char *message) |
398 { | |
399 GList *first; | |
400 | |
401 first = g_list_first(conv->send_history); | |
402 | |
403 if (first->data) | |
404 g_free(first->data); | |
405 | |
406 first->data = g_strdup(message); | |
407 | |
408 conv->send_history = g_list_prepend(first, NULL); | |
409 } | |
410 | |
9832 | 411 static gboolean |
412 check_for_and_do_command(GaimConversation *conv) | |
413 { | |
414 GaimGtkConversation *gtkconv; | |
415 char *cmd; | |
416 const char *prefix; | |
417 GaimAccount *account; | |
418 GtkTextIter start; | |
419 | |
420 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
421 account = gaim_conversation_get_account(conv); | |
422 prefix = gaim_gtk_get_cmd_prefix(); | |
423 | |
424 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
425 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
426 | |
427 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
428 && !gtk_text_iter_get_child_anchor(&start)) { | |
429 GaimCmdStatus status; | |
430 char *error, *cmdline, *markup, *send_history; | |
431 GtkTextIter end; | |
432 | |
433 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
434 send_history_add(conv, send_history); | |
435 g_free(send_history); | |
436 | |
437 cmdline = cmd + strlen(prefix); | |
438 | |
439 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
440 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
441 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
442 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
443 g_free(cmd); | |
444 g_free(markup); | |
445 | |
446 switch (status) { | |
447 case GAIM_CMD_STATUS_OK: | |
448 return TRUE; | |
449 case GAIM_CMD_STATUS_NOT_FOUND: | |
450 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
451 gaim_conversation_write(conv, "", _("No such command."), | |
452 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
453 | |
454 return TRUE; | |
455 } | |
456 return FALSE; | |
457 case GAIM_CMD_STATUS_WRONG_ARGS: | |
458 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
459 "to that command."), | |
460 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
461 return TRUE; | |
462 case GAIM_CMD_STATUS_FAILED: | |
463 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
464 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
465 if(error) | |
466 g_free(error); | |
467 return TRUE; | |
468 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 469 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 470 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 471 GAIM_MESSAGE_NO_LOG, time(NULL)); |
472 else | |
10843 | 473 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 474 GAIM_MESSAGE_NO_LOG, time(NULL)); |
475 return TRUE; | |
476 case GAIM_CMD_STATUS_WRONG_PRPL: | |
477 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
478 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
479 return TRUE; | |
480 } | |
481 } | |
482 | |
483 g_free(cmd); | |
484 return FALSE; | |
485 } | |
486 | |
9374 | 487 static void |
10810 | 488 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 489 { |
10810 | 490 GaimConversation *conv = gtkconv->active_conv; |
8655 | 491 GaimAccount *account; |
8677 | 492 GaimConnection *gc; |
8448 | 493 char *buf, *clean; |
4359 | 494 |
8655 | 495 account = gaim_conversation_get_account(conv); |
9130 | 496 |
9471 | 497 if (!gaim_account_is_connected(account)) |
498 return; | |
499 | |
11338 | 500 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 501 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 502 return; |
503 | |
9832 | 504 if (check_for_and_do_command(conv)) { |
505 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
506 return; | |
9130 | 507 } |
508 | |
8442 | 509 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 510 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 511 |
4359 | 512 gtk_widget_grab_focus(gtkconv->entry); |
513 | |
8448 | 514 if (strlen(clean) == 0) { |
515 g_free(clean); | |
4359 | 516 return; |
517 } | |
518 | |
8677 | 519 gc = gaim_account_get_connection(account); |
10665 | 520 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 521 char **bufs; |
522 int i; | |
523 | |
524 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
525 for (i = 0; bufs[i]; i++) { | |
9374 | 526 send_history_add(conv, bufs[i]); |
11338 | 527 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 528 gaim_conv_im_send(GAIM_CONV_IM(conv), bufs[i]); |
11338 | 529 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 530 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), bufs[i]); |
531 } | |
532 | |
533 g_strfreev(bufs); | |
534 | |
535 } else { | |
9374 | 536 send_history_add(conv, buf); |
11338 | 537 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 538 gaim_conv_im_send(GAIM_CONV_IM(conv), buf); |
11338 | 539 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 540 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), buf); |
541 } | |
4359 | 542 |
8677 | 543 g_free(clean); |
4359 | 544 g_free(buf); |
545 | |
8061 | 546 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 547 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 548 } |
549 | |
550 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
551 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 552 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
553 GaimAccount *account; |
4359 | 554 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
555 GaimConversation *conv = gtkconv->active_conv; |
4359 | 556 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
557 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
558 name = gaim_conversation_get_name(conv); |
7879 | 559 |
11338 | 560 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 561 GaimBuddy *b; |
562 | |
563 b = gaim_find_buddy(account, name); | |
564 if (b != NULL) | |
9730 | 565 gaim_gtkdialogs_remove_buddy(b); |
7859 | 566 else if (account != NULL && gaim_account_is_connected(account)) |
567 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 568 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 569 GaimChat *c; |
570 | |
571 c = gaim_blist_find_chat(account, name); | |
572 if (c != NULL) | |
9730 | 573 gaim_gtkdialogs_remove_chat(c); |
7859 | 574 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 575 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 576 } |
4359 | 577 |
578 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
579 } | |
580 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
581 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 582 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
583 GaimConversation *conv = gtkconv->active_conv; |
7975 | 584 GaimPluginProtocolInfo *prpl_info = NULL; |
585 GaimConnection *gc; | |
586 | |
587 if ((gc = gaim_conversation_get_gc(conv))) { | |
588 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
589 | |
590 /* | |
591 * If there are special needs for getting info on users in | |
592 * buddy chat "rooms"... | |
593 */ | |
594 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
595 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
596 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
597 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
598 } |
7975 | 599 else |
600 prpl_info->get_info(gc, who); | |
601 } | |
602 } | |
603 | |
604 | |
4359 | 605 static void |
10810 | 606 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 607 { |
10810 | 608 GaimConversation *conv = gtkconv->active_conv; |
4359 | 609 |
11338 | 610 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 611 serv_get_info(gaim_conversation_get_gc(conv), |
612 gaim_conversation_get_name(conv)); | |
613 | |
614 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 615 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 616 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
617 GaimGtkChatPane *gtkchat; |
4359 | 618 GtkTreeIter iter; |
619 GtkTreeModel *model; | |
620 GtkTreeSelection *sel; | |
9554 | 621 char *name; |
4359 | 622 |
623 gtkchat = gtkconv->u.chat; | |
624 | |
625 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
626 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
627 | |
628 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 629 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 630 else |
631 return; | |
632 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
633 chat_do_info(gtkconv, name); |
9554 | 634 g_free(name); |
4359 | 635 } |
636 } | |
637 | |
638 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
639 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 640 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
641 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
642 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
643 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
644 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
645 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
646 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
647 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 648 |
649 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
650 } | |
651 | |
652 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
653 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 654 { |
655 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
656 GaimGtkConversation *gtkconv; |
4359 | 657 |
658 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
659 | |
660 if (resp == GTK_RESPONSE_OK) { | |
661 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
662 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
663 | |
10113 | 664 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 665 return; |
666 | |
667 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
668 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 669 message, buddy); |
670 } | |
671 | |
672 gtk_widget_destroy(invite_dialog); | |
673 invite_dialog = NULL; | |
674 | |
675 g_free(info); | |
676 } | |
677 | |
678 static void | |
9909 | 679 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
680 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
681 { | |
682 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
683 const char *convprotocol; | |
684 | |
685 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
686 | |
687 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
688 { | |
689 GaimBlistNode *node = NULL; | |
690 GaimBuddy *buddy; | |
691 | |
692 memcpy(&node, sd->data, sizeof(node)); | |
693 | |
694 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
695 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
696 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
697 buddy = (GaimBuddy *)node; | |
698 else | |
699 return; | |
700 | |
701 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
702 { | |
703 gaim_notify_error(NULL, NULL, | |
704 _("That buddy is not on the same protocol as this " | |
10843 | 705 "chat."), NULL); |
9909 | 706 } |
707 else | |
708 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
709 | |
710 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
711 } | |
712 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
713 { | |
714 char *protocol = NULL; | |
715 char *username = NULL; | |
716 GaimAccount *account; | |
717 | |
11137 | 718 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 719 &protocol, &username, NULL)) |
720 { | |
721 if (account == NULL) | |
722 { | |
723 gaim_notify_error(NULL, NULL, | |
724 _("You are not currently signed on with an account that " | |
725 "can invite that buddy."), NULL); | |
726 } | |
727 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
728 { | |
729 gaim_notify_error(NULL, NULL, | |
730 _("That buddy is not on the same protocol as this " | |
10843 | 731 "chat."), NULL); |
9909 | 732 } |
733 else | |
734 { | |
735 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
736 } | |
737 } | |
738 | |
739 if (username != NULL) g_free(username); | |
740 if (protocol != NULL) g_free(protocol); | |
741 | |
742 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
743 } | |
744 } | |
745 | |
746 static const GtkTargetEntry dnd_targets[] = | |
747 { | |
748 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
749 {"application/x-im-contact", 0, 1} | |
750 }; | |
751 | |
752 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
753 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 754 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
755 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
756 InviteBuddyInfo *info = NULL; |
4359 | 757 |
758 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
759 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
760 GaimGtkWindow *gtkwin; |
4359 | 761 GtkWidget *label; |
762 GtkWidget *vbox, *hbox; | |
763 GtkWidget *table; | |
764 GtkWidget *img; | |
765 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
766 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 767 GTK_ICON_SIZE_DIALOG); |
4359 | 768 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
769 info = g_new0(InviteBuddyInfo, 1); |
4359 | 770 info->conv = conv; |
771 | |
11581 | 772 gc = gaim_conversation_get_gc(conv); |
773 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 774 |
775 /* Create the new dialog. */ | |
776 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 777 _("Invite Buddy Into Chat Room"), |
7879 | 778 GTK_WINDOW(gtkwin->window), 0, |
779 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
780 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 781 |
782 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 783 GTK_RESPONSE_OK); |
11243 | 784 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 785 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
786 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
787 | |
9909 | 788 info->window = GTK_WIDGET(invite_dialog); |
789 | |
4359 | 790 /* Setup the outside spacing. */ |
791 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
792 | |
11243 | 793 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
794 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 795 |
796 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 797 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 798 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
799 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
800 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
801 | |
802 /* Setup the right vbox. */ | |
803 vbox = gtk_vbox_new(FALSE, 0); | |
804 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
805 | |
806 /* Put our happy label in it. */ | |
807 label = gtk_label_new(_("Please enter the name of the user you wish " | |
808 "to invite, along with an optional invite " | |
809 "message.")); | |
810 gtk_widget_set_size_request(label, 350, -1); | |
811 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
812 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
813 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
814 | |
815 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 816 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 817 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
818 | |
819 /* Setup the table we're going to use to lay stuff out. */ | |
820 table = gtk_table_new(2, 2, FALSE); | |
11243 | 821 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
822 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
823 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 824 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
825 | |
826 /* Now the Buddy label */ | |
827 label = gtk_label_new(NULL); | |
828 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
829 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
830 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
831 | |
832 /* Now the Buddy drop-down entry field. */ | |
833 info->entry = gtk_combo_new(); | |
834 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
835 gtk_entry_set_activates_default( | |
836 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
837 | |
838 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
839 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
840 | |
841 /* Fill in the names. */ | |
842 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
843 generate_invite_user_names(gc)); | |
844 | |
845 | |
846 /* Now the label for "Message" */ | |
847 label = gtk_label_new(NULL); | |
848 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
849 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
850 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
851 | |
852 | |
853 /* And finally, the Message entry field. */ | |
854 info->message = gtk_entry_new(); | |
855 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
856 | |
857 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
858 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
859 | |
860 /* Connect the signals. */ | |
861 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
862 G_CALLBACK(do_invite), info); | |
9909 | 863 /* Setup drag-and-drop */ |
864 gtk_drag_dest_set(info->window, | |
865 GTK_DEST_DEFAULT_MOTION | | |
866 GTK_DEST_DEFAULT_DROP, | |
867 dnd_targets, | |
868 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
869 GDK_ACTION_COPY); | |
870 gtk_drag_dest_set(info->entry, | |
871 GTK_DEST_DEFAULT_MOTION | | |
872 GTK_DEST_DEFAULT_DROP, | |
873 dnd_targets, | |
874 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
875 GDK_ACTION_COPY); | |
876 | |
877 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
878 G_CALLBACK(invite_dnd_recv), info); | |
879 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
880 G_CALLBACK(invite_dnd_recv), info); | |
881 | |
4359 | 882 } |
883 | |
884 gtk_widget_show_all(invite_dialog); | |
885 | |
886 if (info != NULL) | |
887 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
888 } | |
889 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
890 static void |
7748 | 891 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
892 { | |
9714 | 893 gaim_gtkdialogs_im(); |
7748 | 894 } |
895 | |
896 static void | |
9504 | 897 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 898 { |
9504 | 899 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 900 FILE *fp; |
901 const char *name; | |
10849 | 902 gchar *text; |
9489 | 903 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
904 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 905 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 906 return; |
907 } | |
908 | |
909 name = gaim_conversation_get_name(conv); | |
10849 | 910 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 911 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 912 |
913 text = gtk_imhtml_get_markup( | |
914 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
915 fprintf(fp, "%s", text); | |
916 g_free(text); | |
917 | |
918 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 919 fclose(fp); |
920 } | |
921 | |
10849 | 922 /* |
923 * It would be kinda cool if this gave the option of saving a | |
924 * plaintext v. HTML file. | |
925 */ | |
9489 | 926 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
927 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
928 { |
11581 | 929 GaimGtkWindow *win = data; |
930 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 931 gchar *buf; |
932 | |
933 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 934 |
10849 | 935 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
936 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 937 |
938 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
939 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
940 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
941 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
942 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
943 { |
11581 | 944 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
945 GaimConversation *conv; |
9917 | 946 GaimLogType type; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
947 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
948 GaimAccount *account; |
10845 | 949 GSList *buddies, *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
950 |
11581 | 951 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
952 |
11338 | 953 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 954 type = GAIM_LOG_IM; |
11338 | 955 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 956 type = GAIM_LOG_CHAT; |
957 else | |
958 return; | |
959 | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
960 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
961 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
962 |
10845 | 963 buddies = gaim_find_buddies(account, name); |
964 for (cur = buddies; cur != NULL; cur = cur->next) | |
965 { | |
966 GaimBlistNode *node = cur->data; | |
10846 | 967 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 968 { |
969 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
970 g_slist_free(buddies); | |
971 return; | |
972 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
973 } |
10845 | 974 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
975 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
976 gaim_gtk_log_show(type, name, account); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
977 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
978 |
8974 | 979 static void |
980 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
981 { | |
11581 | 982 GaimGtkWindow *win = data; |
8974 | 983 GaimConversation *conv; |
984 GaimGtkConversation *gtkconv; | |
985 | |
11581 | 986 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 987 gtkconv = GAIM_GTK_CONVERSATION(conv); |
988 | |
989 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
990 } | |
991 | |
7295 | 992 struct _search { |
993 GaimGtkConversation *gtkconv; | |
994 GtkWidget *entry; | |
995 }; | |
996 | |
7929 | 997 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 998 { |
7929 | 999 switch (resp) { |
1000 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1001 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1002 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1003 break; |
1004 | |
1005 case GTK_RESPONSE_DELETE_EVENT: | |
1006 case GTK_RESPONSE_CLOSE: | |
1007 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1008 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1009 s->gtkconv->dialogs.search = NULL; | |
1010 g_free(s); | |
1011 break; | |
1012 } | |
7295 | 1013 } |
1014 | |
1015 static void | |
7751 | 1016 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1017 { |
11581 | 1018 GaimGtkWindow *gtkwin = data; |
1019 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1020 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1021 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1022 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1023 GTK_ICON_SIZE_DIALOG); |
7929 | 1024 GtkWidget *label; |
7295 | 1025 struct _search *s; |
1026 | |
7798 | 1027 if (gtkconv->dialogs.search) { |
1028 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1029 return; |
7798 | 1030 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1031 |
7295 | 1032 s = g_malloc(sizeof(struct _search)); |
1033 s->gtkconv = gtkconv; | |
7929 | 1034 |
1035 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1036 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1037 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1038 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1039 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1040 GTK_RESPONSE_OK); |
7929 | 1041 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1042 G_CALLBACK(do_search_cb), s); | |
1043 | |
11243 | 1044 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1045 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1046 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1047 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BORDER); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1048 gtk_container_set_border_width( |
11243 | 1049 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1050 | |
1051 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1052 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1053 hbox); |
7929 | 1054 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1055 | |
1056 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1057 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1058 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1059 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1060 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1061 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1062 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1063 | |
1064 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1065 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1066 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1067 g_signal_connect(G_OBJECT(s->entry), "changed", |
1068 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1069 gtkconv->dialogs.search); | |
1070 gtk_box_pack_start(GTK_BOX(hbox), s->entry, FALSE, FALSE, 0); | |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1071 |
7295 | 1072 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1073 gtk_widget_grab_focus(s->entry); |
7295 | 1074 } |
1075 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1076 static void |
9468 | 1077 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1078 { | |
11581 | 1079 GaimGtkWindow *win = data; |
1080 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1081 |
11338 | 1082 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1083 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1084 } | |
1085 | |
1086 } | |
1087 | |
1088 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1089 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1090 { |
11581 | 1091 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1092 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1093 |
11581 | 1094 conv = gaim_gtk_conv_window_get_active_gtkconv(win)->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1095 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1096 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1097 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1098 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1099 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1100 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1101 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1102 { |
11581 | 1103 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1104 GaimGtkConversation *gtkconv; |
8756 | 1105 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1106 |
11581 | 1107 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1108 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1109 | |
1110 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1111 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1112 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1113 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1114 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1115 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1116 { |
11581 | 1117 GaimGtkWindow *win = data; |
8756 | 1118 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1119 GaimGtkConversation *gtkconv; |
8756 | 1120 GtkIMHtmlToolbar *toolbar; |
1121 | |
11581 | 1122 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1123 conv = gtkconv->active_conv; | |
8756 | 1124 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1125 | |
1126 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1127 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1129 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1130 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1131 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1132 { |
11581 | 1133 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 GaimConversation *conv; |
7879 | 1135 GaimAccount *account; |
1136 const char *name; | |
1137 | |
11581 | 1138 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1139 account = gaim_conversation_get_account(conv); |
1140 name = gaim_conversation_get_name(conv); | |
1141 | |
11338 | 1142 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1143 GaimBuddy *b; |
1144 | |
1145 b = gaim_find_buddy(account, name); | |
1146 if (b != NULL) | |
9730 | 1147 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1148 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1149 GaimChat *c; |
1150 | |
1151 c = gaim_blist_find_chat(account, name); | |
1152 if (c != NULL) | |
9730 | 1153 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1154 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 { |
11581 | 1160 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 |
11581 | 1163 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 |
10810 | 1165 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1166 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1167 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1168 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1170 { |
11581 | 1171 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 |
11581 | 1174 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1175 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1176 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1178 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1179 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1180 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1181 { |
11581 | 1182 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 |
11581 | 1185 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1187 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 { |
11581 | 1193 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 |
11581 | 1196 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1198 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1199 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1200 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1202 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 { |
11581 | 1204 GaimGtkWindow *win = data; |
1205 | |
1206 close_conv_cb(NULL, GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1207 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1210 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 { |
11581 | 1212 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1214 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 |
11581 | 1216 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1221 logging = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1222 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1223 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1224 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1225 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1226 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1227 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1228 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1229 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1230 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1231 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1232 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1233 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1234 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1235 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1236 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1237 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1238 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1239 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1240 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1241 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1242 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1243 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1244 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1245 /* Disable the logging second, so that the above message can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1246 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1247 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1248 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1249 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1250 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1251 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1252 { |
11581 | 1253 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1254 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1255 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1256 |
11581 | 1257 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1258 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1259 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1260 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1261 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1262 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1263 |
10377 | 1264 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1265 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1266 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1267 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1268 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1269 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1270 { |
11581 | 1271 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1272 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1274 |
11581 | 1275 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1278 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1279 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1280 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1281 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1282 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1283 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1284 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1285 |
7961 | 1286 static void |
9188 | 1287 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1288 { | |
11581 | 1289 GaimGtkWindow *win = data; |
9188 | 1290 GaimConversation *conv; |
1291 GaimGtkConversation *gtkconv; | |
1292 | |
11581 | 1293 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1294 |
1295 if (!conv) | |
1296 return; | |
1297 | |
1298 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1299 | |
1300 gtkconv->show_timestamps = | |
1301 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
1302 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
1303 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); | |
1304 } | |
1305 | |
1306 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1307 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1309 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1310 GaimAccount *account; |
1311 GaimConnection *gc; | |
7961 | 1312 GaimPluginProtocolInfo *prpl_info = NULL; |
1313 char *real_who; | |
1314 | |
1315 account = gaim_conversation_get_account(conv); | |
10431 | 1316 g_return_if_fail(account != NULL); |
1317 | |
1318 gc = gaim_account_get_connection(account); | |
1319 g_return_if_fail(gc != NULL); | |
1320 | |
1321 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1322 | |
1323 if (prpl_info && prpl_info->get_cb_real_name) | |
1324 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1325 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1326 else | |
1327 real_who = g_strdup(who); | |
1328 | |
1329 if(!real_who) | |
1330 return; | |
1331 | |
10431 | 1332 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1333 |
1334 g_free(real_who); | |
1335 } | |
1336 | |
1337 static void | |
10810 | 1338 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1339 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1343 GtkTreeSelection *sel; |
9554 | 1344 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1345 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1346 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1347 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1348 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1349 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1350 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1351 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1352 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1353 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1354 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1355 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1356 chat_do_im(gtkconv, name); |
9554 | 1357 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1358 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1359 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1360 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1361 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1363 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1364 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1365 GaimConvChat *chat; |
11869 | 1366 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1367 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 GtkTreeSelection *sel; |
10504 | 1370 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1371 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1373 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1374 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1376 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1378 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1380 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1381 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1382 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1383 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1384 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1390 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1391 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1393 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 |
11869 | 1395 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1396 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1397 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1401 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1402 { |
1403 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1404 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1405 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1406 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1407 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1409 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1410 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1411 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1412 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1413 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1414 | |
1415 serv_send_file(gc, who, NULL); | |
1416 } | |
1417 | |
1418 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1419 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1421 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1425 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1429 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1430 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1431 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1433 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1434 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1435 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1436 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1437 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1438 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1439 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1441 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1442 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1443 * May want to expand this to work similarly to menu_info_cb? |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1444 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1445 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1446 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1447 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1448 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1449 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1450 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1451 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1452 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1453 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1455 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1457 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1458 GaimAccount *account; |
6695 | 1459 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1462 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1463 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1464 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 if (b != NULL) |
9730 | 1467 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1468 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1469 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1470 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1471 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1472 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1473 |
8143 | 1474 static GtkWidget * |
10504 | 1475 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1476 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1477 { | |
1478 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1479 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1480 gboolean is_me = FALSE; |
8143 | 1481 GtkWidget *button; |
1482 | |
1483 /* | |
1484 * If a menu already exists, destroy it before creating a new one, | |
1485 * thus freeing-up the memory it occupied. | |
1486 */ | |
1487 if (menu) | |
1488 gtk_widget_destroy(menu); | |
1489 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1490 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1491 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1492 |
8143 | 1493 menu = gtk_menu_new(); |
1494 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1495 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1496 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1497 G_CALLBACK(menu_chat_im_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1498 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1499 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1500 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1501 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1502 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1503 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1504 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1505 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1506 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1507 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1508 if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), who)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1509 button = gaim_new_item_from_stock(menu, _("Un-Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1510 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1511 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1512 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1513 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1514 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1515 } |
9498 | 1516 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1517 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1518 button = gaim_new_item_from_stock(menu, _("Info"), GAIM_STOCK_INFO, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1519 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1520 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1521 } |
1522 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1523 if (prpl_info->get_cb_away) { |
10221 | 1524 button = gaim_new_item_from_stock(menu, _("Get Away Message"), GAIM_STOCK_AWAY, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1525 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1526 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1527 } |
1528 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1529 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1530 if (gaim_find_buddy(gc->account, who)) |
10221 | 1531 button = gaim_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1532 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1533 else |
10221 | 1534 button = gaim_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1535 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1536 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1537 } |
1538 | |
1539 return menu; | |
1540 } | |
1541 | |
1542 | |
1543 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1544 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1545 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1546 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1547 GaimPluginProtocolInfo *prpl_info = NULL; |
1548 GaimGtkChatPane *gtkchat; | |
1549 GaimConnection *gc; | |
1550 GaimAccount *account; | |
1551 GtkTreeSelection *sel; | |
1552 GtkTreeIter iter; | |
1553 GtkTreeModel *model; | |
1554 GtkWidget *menu; | |
1555 gchar *who; | |
1556 | |
1557 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1558 gtkchat = gtkconv->u.chat; | |
1559 account = gaim_conversation_get_account(conv); | |
1560 gc = account->gc; | |
1561 | |
1562 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1563 | |
1564 if (gc != NULL) | |
1565 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1566 | |
1567 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1568 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1569 return FALSE; | |
1570 | |
9498 | 1571 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1572 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1573 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1574 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1575 0, GDK_CURRENT_TIME); |
10504 | 1576 g_free(who); |
8143 | 1577 |
1578 return TRUE; | |
1579 } | |
1580 | |
1581 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1582 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1583 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1584 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1585 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1586 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1587 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1588 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1589 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1590 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1591 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1592 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1593 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1594 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1595 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1596 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1597 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1598 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1599 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1600 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1601 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1602 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1603 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1604 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1605 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1606 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1607 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1608 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1609 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1610 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1611 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1612 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1613 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1614 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1615 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1616 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1617 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1618 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1620 chat_do_im(gtkconv, who); |
7398 | 1621 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1622 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1623 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1624 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1625 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1626 |
10504 | 1627 g_free(who); |
1628 gtk_tree_path_free(path); | |
1629 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1630 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1631 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1632 |
8133 | 1633 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1634 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1635 { |
10827 | 1636 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1637 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1638 int index, i, total, found = 0; |
8133 | 1639 |
11581 | 1640 win = gtkconv->win; |
1641 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1642 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1643 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1644 /* First check the tabs after (forward) or before (!forward) this position. */ |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1645 for (i = forward ? index + 1 : index - 1; |
11581 | 1646 !found && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1647 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1648 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1649 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1650 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1651 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1652 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1653 found = 1; |
8133 | 1654 } |
11252 | 1655 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1656 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1657 /* Now check from the beginning up to (forward) or end back to (!forward) this position. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1658 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1659 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1660 (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1661 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1662 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1663 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1664 found = 1; |
8133 | 1665 } |
10827 | 1666 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1667 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1668 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1669 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1670 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1671 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1672 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1673 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1674 } |
11581 | 1675 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1676 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1677 } |
8133 | 1678 } |
1679 | |
10827 | 1680 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1681 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1682 } |
1683 | |
4359 | 1684 static gboolean |
8105 | 1685 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1686 { |
11581 | 1687 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1688 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1689 GaimGtkConversation *gtkconv; |
8105 | 1690 int curconv; |
1691 | |
10810 | 1692 gtkconv = (GaimGtkConversation *)data; |
10849 | 1693 conv = gtkconv->active_conv; |
11581 | 1694 win = gtkconv->win; |
1695 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1696 |
8105 | 1697 /* If CTRL was held down... */ |
1698 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1699 switch (event->keyval) { |
1700 case GDK_Up: | |
1701 if (!conv->send_history) | |
1702 break; | |
1703 | |
1704 if (!conv->send_history->prev) { | |
1705 GtkTextIter start, end; | |
1706 | |
1707 if (conv->send_history->data) | |
1708 g_free(conv->send_history->data); | |
1709 | |
1710 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1711 &start); | |
1712 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1713 | |
1714 conv->send_history->data = | |
8506 | 1715 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1716 } |
8677 | 1717 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1718 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1719 GObject *object; |
8677 | 1720 GtkTextIter iter; |
1721 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1722 |
1723 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1724 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1725 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1726 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1727 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1728 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1729 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1730 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1731 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1732 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1733 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1734 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1735 |
8061 | 1736 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1737 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1738 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1739 0, NULL); |
8677 | 1740 /* this is mainly just a hack so the formatting at the |
1741 * cursor gets picked up. */ | |
1742 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1743 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1744 } |
1745 | |
8105 | 1746 return TRUE; |
4359 | 1747 break; |
1748 | |
1749 case GDK_Down: | |
1750 if (!conv->send_history) | |
1751 break; | |
1752 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1753 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1754 GObject *object; |
8677 | 1755 GtkTextIter iter; |
1756 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1757 |
4359 | 1758 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1759 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1760 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1761 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1762 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1763 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1764 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1765 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1766 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1767 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1768 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1769 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1770 |
8105 | 1771 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1772 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1773 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1774 0, NULL); |
8677 | 1775 /* this is mainly just a hack so the formatting at the |
1776 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1777 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1778 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1779 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1780 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1781 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1782 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1783 } |
4359 | 1784 } |
1785 | |
8105 | 1786 return TRUE; |
4359 | 1787 break; |
8105 | 1788 |
8108 | 1789 case GDK_Page_Down: |
8143 | 1790 case ']': |
11581 | 1791 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1792 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1793 else |
11581 | 1794 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1795 return TRUE; |
1796 break; | |
1797 | |
8108 | 1798 case GDK_Page_Up: |
8143 | 1799 case '[': |
11581 | 1800 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1801 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1802 else |
11581 | 1803 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1804 return TRUE; |
1805 break; | |
1806 | |
8108 | 1807 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1808 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1809 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1810 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1811 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1812 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1813 } |
8108 | 1814 |
1815 return TRUE; | |
1816 break; | |
1817 | |
11252 | 1818 case GDK_comma: |
11581 | 1819 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1820 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1821 curconv - 1); |
1822 break; | |
1823 | |
1824 case GDK_period: | |
11581 | 1825 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1826 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1827 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1828 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1829 #else |
1830 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1831 #endif | |
11252 | 1832 break; |
1833 | |
8105 | 1834 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1835 } |
8758 | 1836 |
8105 | 1837 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1838 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1839 { |
10864 | 1840 if (event->keyval > '0' && event->keyval <= '9') |
1841 { | |
8105 | 1842 int switchto = event->keyval - '1'; |
11581 | 1843 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1844 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1845 |
1846 return TRUE; | |
1847 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1848 } |
8758 | 1849 |
8105 | 1850 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1851 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1852 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1853 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1854 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1855 case GDK_Tab: |
9605 | 1856 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1857 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1858 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1859 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1860 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1861 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1862 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1863 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1864 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1865 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1866 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1867 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1868 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1869 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1870 } |
4359 | 1871 return FALSE; |
1872 } | |
1873 | |
1874 /* | |
1875 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1876 * This guy just kills a single right click from being propagated any |
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1877 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1878 * prevents right clicks on the GtkTextView in a convo dialog from |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1879 * going all the way down to the notebook. I suspect a bug in |
4359 | 1880 * GtkTextView, but I'm not ready to point any fingers yet. |
1881 */ | |
1882 static gboolean | |
1883 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1884 { | |
1885 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1886 /* Right single click */ | |
1887 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1888 | |
1889 return TRUE; | |
1890 } | |
1891 | |
1892 return FALSE; | |
1893 } | |
1894 | |
8173 | 1895 /* |
1896 * If someone tries to type into the conversation backlog of a | |
1897 * conversation window then we yank focus from the conversation backlog | |
1898 * and give it to the text entry box so that people can type | |
1899 * all the live long day and it will get entered into the entry box. | |
1900 */ | |
6057 | 1901 static gboolean |
8105 | 1902 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1903 { |
1904 GaimGtkConversation *gtkconv = data; | |
1905 | |
8237 | 1906 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1907 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1908 (event->keyval == GDK_F10) || |
1909 (event->keyval == GDK_Shift_L) || | |
1910 (event->keyval == GDK_Shift_R) || | |
1911 (event->keyval == GDK_Escape) || | |
8177 | 1912 (event->keyval == GDK_Up) || |
1913 (event->keyval == GDK_Down) || | |
1914 (event->keyval == GDK_Left) || | |
8191 | 1915 (event->keyval == GDK_Right) || |
1916 (event->keyval == GDK_Home) || | |
9297 | 1917 (event->keyval == GDK_End) || |
1918 (event->keyval == GDK_Tab) || | |
1919 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1920 return FALSE; |
1921 | |
1922 if (event->type == GDK_KEY_RELEASE) | |
1923 gtk_widget_grab_focus(gtkconv->entry); | |
1924 | |
1925 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1926 | |
1927 return TRUE; | |
6057 | 1928 } |
1929 | |
4359 | 1930 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1931 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1932 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1933 GaimGtkConversation *gtkconv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1934 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1935 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1936 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1937 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1938 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1939 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1940 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1941 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1942 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1943 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1944 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1945 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1946 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1947 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1948 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1949 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1950 void |
11604 | 1951 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1952 { | |
1953 GaimGtkConversation *gtkconv; | |
1954 | |
1955 g_return_if_fail(conv != NULL); | |
1956 | |
1957 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1958 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1959 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1960 |
1961 gray_stuff_out(gtkconv); | |
1962 update_typing_icon(gtkconv); | |
1963 | |
1964 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
1965 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
1966 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
1967 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 1968 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
1969 gaim_account_get_protocol_name(conv->account)); | |
1970 } | |
1971 | |
1972 static void | |
4673 | 1973 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1974 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1975 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 1976 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1977 GaimConversation *conv; |
4359 | 1978 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1979 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1980 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1981 |
11594 | 1982 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 1983 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 1984 } |
1985 | |
1986 static void | |
1987 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1988 gchar *new_text, gint new_text_length, gpointer user_data) | |
1989 { | |
10810 | 1990 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
1991 GaimConversation *conv; | |
1992 | |
1993 g_return_if_fail(gtkconv != NULL); | |
11508 | 1994 |
10810 | 1995 conv = gtkconv->active_conv; |
4359 | 1996 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1997 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1998 return; |
1999 | |
10810 | 2000 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2001 gtk_text_iter_is_end(position))); | |
4359 | 2002 } |
2003 | |
2004 static void | |
2005 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2006 GtkTextIter *end_pos, gpointer user_data) | |
2007 { | |
10810 | 2008 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2009 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2010 GaimConvIm *im; |
4359 | 2011 |
10810 | 2012 g_return_if_fail(gtkconv != NULL); |
11508 | 2013 |
10810 | 2014 conv = gtkconv->active_conv; |
4359 | 2015 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2016 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2017 return; |
2018 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2019 im = GAIM_CONV_IM(conv); |
4359 | 2020 |
2021 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2022 | |
2023 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2024 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2025 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2026 |
2027 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2028 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2029 GAIM_NOT_TYPING); |
4359 | 2030 } |
2031 else { | |
2032 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2033 got_typing_keypress(gtkconv, FALSE); |
4359 | 2034 } |
2035 } | |
2036 | |
8189 | 2037 /************************************************************************** |
2038 * A bunch of buddy icon functions | |
2039 **************************************************************************/ | |
11581 | 2040 GdkPixbuf * |
2041 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2042 { |
10116 | 2043 GaimAccount *account = NULL; |
2044 const char *name = NULL; | |
7143 | 2045 GdkPixbuf *status = NULL; |
2046 | |
10116 | 2047 g_return_val_if_fail(conv != NULL, NULL); |
2048 | |
2049 account = gaim_conversation_get_account(conv); | |
2050 name = gaim_conversation_get_name(conv); | |
2051 | |
2052 g_return_val_if_fail(account != NULL, NULL); | |
2053 g_return_val_if_fail(name != NULL, NULL); | |
2054 | |
11338 | 2055 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2056 GaimBuddy *b = gaim_find_buddy(account, name); |
2057 if (b != NULL) { | |
2058 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2059 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2060 } |
2061 } | |
2062 | |
2063 if (!status) { | |
2064 GdkPixbuf *pixbuf; | |
10884 | 2065 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2066 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2067 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2068 { |
7143 | 2069 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2070 GDK_INTERP_BILINEAR); | |
2071 g_object_unref(pixbuf); | |
2072 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2073 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2074 status = pixbuf; |
7143 | 2075 } |
2076 return status; | |
2077 } | |
2078 | |
8189 | 2079 static void |
2080 update_tab_icon(GaimConversation *conv) | |
2081 { | |
2082 GaimGtkConversation *gtkconv; | |
11581 | 2083 GaimGtkWindow *win; |
8189 | 2084 GaimAccount *account; |
2085 const char *name; | |
2086 GdkPixbuf *status = NULL; | |
2087 | |
10116 | 2088 g_return_if_fail(conv != NULL); |
2089 | |
8189 | 2090 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2091 win = gtkconv->win; |
8189 | 2092 name = gaim_conversation_get_name(conv); |
2093 account = gaim_conversation_get_account(conv); | |
2094 | |
11581 | 2095 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2096 |
10116 | 2097 g_return_if_fail(status != NULL); |
2098 | |
8189 | 2099 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2100 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2101 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2102 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2103 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2104 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2105 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2106 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2107 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2108 { |
11581 | 2109 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2110 | |
2111 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2112 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2113 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2114 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2115 } |
8189 | 2116 } |
2117 | |
2118 static gboolean | |
2119 redraw_icon(gpointer data) | |
2120 { | |
10810 | 2121 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2122 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2123 GaimAccount *account; |
2124 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2125 |
2126 GdkPixbuf *buf; | |
2127 GdkPixbuf *scale; | |
2128 GdkPixmap *pm; | |
2129 GdkBitmap *bm; | |
2130 gint delay; | |
9318 | 2131 int scale_width, scale_height; |
8189 | 2132 |
2133 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2134 account = gaim_conversation_get_account(conv); |
2135 if(account && account->gc) | |
2136 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2137 |
2138 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2139 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2140 | |
10483 | 2141 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2142 NULL, &scale_width, &scale_height); |
2143 | |
2144 /* this code is ugly, and scares me */ | |
8189 | 2145 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2146 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2147 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2148 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2149 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2150 GDK_INTERP_BILINEAR); |
8189 | 2151 |
2152 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2153 g_object_unref(G_OBJECT(scale)); | |
2154 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2155 g_object_unref(G_OBJECT(pm)); | |
2156 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2157 | |
2158 if (bm) | |
2159 g_object_unref(G_OBJECT(bm)); | |
2160 | |
9131 | 2161 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2162 |
2163 if (delay < 100) | |
9131 | 2164 delay = 100; |
2165 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2166 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2167 |
2168 return FALSE; | |
2169 } | |
2170 | |
2171 static void | |
10810 | 2172 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2173 { |
2174 int delay; | |
2175 | |
8228 | 2176 if (gtkconv->u.im->anim == NULL) |
2177 return; | |
2178 | |
8202 | 2179 if (gtkconv->u.im->icon_timer != 0) |
2180 return; | |
2181 | |
8189 | 2182 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2183 return; | |
2184 | |
10639 | 2185 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2186 | |
2187 if (delay < 100) | |
2188 delay = 100; | |
2189 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2190 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2191 } |
2192 | |
2193 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2194 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2195 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2196 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2197 GaimGtkWindow *gtkwin; |
2198 | |
2199 g_return_if_fail(conv != NULL); | |
2200 | |
9887 | 2201 if (gtkconv->u.im->icon_container != NULL) |
2202 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2203 |
2204 if (gtkconv->u.im->anim != NULL) | |
2205 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2206 | |
2207 if (gtkconv->u.im->icon_timer != 0) | |
2208 g_source_remove(gtkconv->u.im->icon_timer); | |
2209 | |
2210 if (gtkconv->u.im->iter != NULL) | |
2211 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2212 | |
2213 gtkconv->u.im->icon_timer = 0; | |
2214 gtkconv->u.im->icon = NULL; | |
2215 gtkconv->u.im->anim = NULL; | |
2216 gtkconv->u.im->iter = NULL; | |
10456 | 2217 gtkconv->u.im->icon_container = NULL; |
9687 | 2218 gtkconv->u.im->show_icon = FALSE; |
10456 | 2219 |
11581 | 2220 gtkwin = gtkconv->win; |
10456 | 2221 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2222 } |
2223 | |
9497 | 2224 static void |
9504 | 2225 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2226 { |
10810 | 2227 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2228 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2229 FILE *fp; |
2230 GaimBuddyIcon *icon; | |
2231 const void *data; | |
2232 size_t len; | |
2233 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2234 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2235 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2236 return; |
2237 } | |
2238 | |
2239 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2240 data = gaim_buddy_icon_get_data(icon, &len); | |
2241 | |
2242 if ((len <= 0) || (data == NULL)) { | |
9504 | 2243 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2244 return; |
2245 } | |
2246 | |
2247 fwrite(data, 1, len, fp); | |
2248 fclose(fp); | |
2249 } | |
2250 | |
2251 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2252 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2253 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2254 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2255 const gchar *ext; |
9497 | 2256 gchar *buf; |
2257 | |
2258 g_return_if_fail(conv != NULL); | |
9504 | 2259 |
10953 | 2260 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2261 if (ext == NULL) | |
2262 ext = "icon"; | |
2263 | |
2264 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2265 |
2266 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2267 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2268 |
2269 g_free(buf); | |
2270 } | |
2271 | |
11581 | 2272 static void |
2273 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2274 { | |
2275 if (gtkconv->u.im->icon_timer != 0) | |
2276 g_source_remove(gtkconv->u.im->icon_timer); | |
2277 | |
2278 gtkconv->u.im->icon_timer = 0; | |
2279 } | |
2280 | |
2281 | |
2282 static void | |
2283 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2284 { | |
2285 gtkconv->u.im->animate = | |
2286 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2287 | |
2288 if (gtkconv->u.im->animate) | |
2289 start_anim(NULL, gtkconv); | |
2290 else | |
2291 stop_anim(NULL, gtkconv); | |
2292 } | |
2293 | |
8189 | 2294 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2295 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2296 { |
2297 static GtkWidget *menu = NULL; | |
2298 GtkWidget *button; | |
2299 | |
2300 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2301 return FALSE; | |
2302 | |
2303 /* | |
2304 * If a menu already exists, destroy it before creating a new one, | |
2305 * thus freeing-up the memory it occupied. | |
2306 */ | |
2307 if (menu != NULL) | |
2308 gtk_widget_destroy(menu); | |
2309 | |
2310 menu = gtk_menu_new(); | |
2311 | |
2312 if (gtkconv->u.im->anim && | |
2313 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2314 { | |
2315 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2316 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2317 gtkconv->u.im->icon_timer); |
2318 } | |
2319 | |
2320 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2321 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2322 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2323 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2324 gtk_widget_show(button); | |
2325 | |
2326 gaim_new_item_from_stock(menu, _("Save Icon As..."), GTK_STOCK_SAVE_AS, | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2327 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2328 0, 0, NULL); |
2329 | |
2330 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2331 | |
2332 return TRUE; | |
2333 } | |
10456 | 2334 |
2335 static void | |
2336 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2337 { | |
11581 | 2338 GaimGtkWindow *win = data; |
10456 | 2339 GaimConversation *conv; |
2340 GaimGtkConversation *gtkconv; | |
2341 gboolean active; | |
2342 | |
11581 | 2343 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2344 |
2345 if (!conv) | |
2346 return; | |
2347 | |
11338 | 2348 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2349 |
2350 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2351 | |
2352 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2353 gtkconv->u.im->show_icon = active; | |
2354 if (active) | |
2355 gaim_gtkconv_update_buddy_icon(conv); | |
2356 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2357 remove_icon(gtkconv); |
10456 | 2358 } |
2359 | |
8189 | 2360 /************************************************************************** |
2361 * End of the bunch of buddy icon functions | |
2362 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2363 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2364 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2365 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2366 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2367 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2368 if(gtkconv->win==hidden_convwin) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2369 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2370 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2371 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2372 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2373 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2374 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2375 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2376 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2377 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2378 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2379 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2380 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2381 GaimUnseenState min_state) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2382 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2383 GList *l; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2384 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2385 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2386 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2387 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2388 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2389 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2390 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2391 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2392 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2393 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2394 GaimConversation *conv = (GaimConversation*)l->data; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2395 if(GAIM_IS_GTK_CONVERSATION(conv)) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2396 if(GAIM_GTK_CONVERSATION(conv)->unseen_state>=min_state) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2397 return conv; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2398 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2399 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2400 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2401 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2402 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2403 } |
8189 | 2404 |
11581 | 2405 GaimGtkWindow * |
2406 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2407 { | |
2408 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2409 return gtkconv->win; | |
2410 } | |
2411 | |
2412 static GtkItemFactoryEntry menu_items[] = | |
2413 { | |
2414 /* Conversation menu */ | |
2415 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2416 | |
2417 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2418 0, "<StockItem>", GAIM_STOCK_IM }, | |
2419 | |
2420 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2421 | |
2422 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2423 "<StockItem>", GTK_STOCK_FIND }, | |
2424 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, | |
2425 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | |
2426 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
2427 { N_("/Conversation/Clear"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, | |
2428 | |
2429 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2430 | |
2431 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2432 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
2433 0, NULL }, | |
2434 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, | |
2435 "<StockItem>", GAIM_STOCK_INFO }, | |
2436 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2437 "<StockItem>", GAIM_STOCK_INVITE }, | |
2438 | |
2439 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2440 | |
2441 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2442 "<StockItem>", GAIM_STOCK_EDIT }, | |
2443 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2444 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2445 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2446 "<StockItem>", GTK_STOCK_ADD }, | |
2447 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2448 "<StockItem>", GTK_STOCK_REMOVE }, | |
2449 | |
2450 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2451 | |
2452 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2453 "<StockItem>", GAIM_STOCK_LINK }, | |
2454 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2455 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2456 | |
2457 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2458 | |
2459 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2460 "<StockItem>", GTK_STOCK_CLOSE }, | |
2461 | |
2462 /* Options */ | |
2463 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2464 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2465 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2466 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2467 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2468 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2469 }; | |
2470 | |
2471 static const int menu_item_count = | |
2472 sizeof(menu_items) / sizeof(*menu_items); | |
2473 | |
2474 static char * | |
2475 item_factory_translate_func (const char *path, gpointer func_data) | |
2476 { | |
2477 return _((char *)path); | |
2478 } | |
2479 | |
2480 static GtkWidget * | |
2481 setup_menubar(GaimGtkWindow *win) | |
2482 { | |
2483 GtkAccelGroup *accel_group; | |
2484 | |
2485 accel_group = gtk_accel_group_new (); | |
2486 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2487 g_object_unref(accel_group); | |
2488 | |
2489 win->menu.item_factory = | |
2490 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2491 | |
2492 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2493 item_factory_translate_func, | |
2494 NULL, NULL); | |
2495 | |
2496 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2497 menu_items, win); | |
2498 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2499 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2500 | |
2501 | |
2502 win->menu.menubar = | |
2503 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2504 | |
2505 | |
2506 win->menu.view_log = | |
2507 gtk_item_factory_get_widget(win->menu.item_factory, | |
2508 N_("/Conversation/View Log")); | |
2509 | |
2510 /* --- */ | |
2511 | |
2512 win->menu.send_file = | |
2513 gtk_item_factory_get_widget(win->menu.item_factory, | |
2514 N_("/Conversation/Send File...")); | |
2515 | |
2516 win->menu.add_pounce = | |
2517 gtk_item_factory_get_widget(win->menu.item_factory, | |
2518 N_("/Conversation/Add Buddy Pounce...")); | |
2519 | |
2520 /* --- */ | |
2521 | |
2522 win->menu.get_info = | |
2523 gtk_item_factory_get_widget(win->menu.item_factory, | |
2524 N_("/Conversation/Get Info")); | |
2525 | |
2526 win->menu.invite = | |
2527 gtk_item_factory_get_widget(win->menu.item_factory, | |
2528 N_("/Conversation/Invite...")); | |
2529 | |
2530 /* --- */ | |
2531 | |
2532 win->menu.alias = | |
2533 gtk_item_factory_get_widget(win->menu.item_factory, | |
2534 N_("/Conversation/Alias...")); | |
2535 | |
2536 win->menu.block = | |
2537 gtk_item_factory_get_widget(win->menu.item_factory, | |
2538 N_("/Conversation/Block...")); | |
2539 | |
2540 win->menu.add = | |
2541 gtk_item_factory_get_widget(win->menu.item_factory, | |
2542 N_("/Conversation/Add...")); | |
2543 | |
2544 win->menu.remove = | |
2545 gtk_item_factory_get_widget(win->menu.item_factory, | |
2546 N_("/Conversation/Remove...")); | |
2547 | |
2548 /* --- */ | |
2549 | |
2550 win->menu.insert_link = | |
2551 gtk_item_factory_get_widget(win->menu.item_factory, | |
2552 N_("/Conversation/Insert Link...")); | |
2553 | |
2554 win->menu.insert_image = | |
2555 gtk_item_factory_get_widget(win->menu.item_factory, | |
2556 N_("/Conversation/Insert Image...")); | |
2557 | |
2558 /* --- */ | |
2559 | |
2560 win->menu.logging = | |
2561 gtk_item_factory_get_widget(win->menu.item_factory, | |
2562 N_("/Options/Enable Logging")); | |
2563 win->menu.sounds = | |
2564 gtk_item_factory_get_widget(win->menu.item_factory, | |
2565 N_("/Options/Enable Sounds")); | |
2566 win->menu.show_formatting_toolbar = | |
2567 gtk_item_factory_get_widget(win->menu.item_factory, | |
2568 N_("/Options/Show Formatting Toolbars")); | |
2569 win->menu.show_timestamps = | |
2570 gtk_item_factory_get_widget(win->menu.item_factory, | |
2571 N_("/Options/Show Timestamps")); | |
2572 win->menu.show_icon = | |
2573 gtk_item_factory_get_widget(win->menu.item_factory, | |
2574 N_("/Options/Show Buddy Icon")); | |
2575 | |
2576 | |
2577 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2578 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2579 win->menu.tray); | |
2580 gtk_widget_show(win->menu.tray); | |
2581 | |
2582 gtk_widget_show(win->menu.menubar); | |
2583 | |
2584 return win->menu.menubar; | |
2585 } | |
2586 | |
4359 | 2587 |
2588 /************************************************************************** | |
2589 * Utility functions | |
2590 **************************************************************************/ | |
2591 | |
2592 static void | |
10810 | 2593 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2594 { |
10810 | 2595 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2596 GaimConvIm *im; |
4685 | 2597 |
4359 | 2598 /* |
2599 * 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
|
2600 * send GAIM_TYPED any time soon. |
4359 | 2601 */ |
2602 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2603 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2604 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2605 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2606 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2607 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2608 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2609 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2610 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2611 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2612 |
2613 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2614 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2615 GAIM_TYPING); |
4359 | 2616 |
2617 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2618 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2619 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2620 gaim_conv_im_set_type_again(im, 0); |
4359 | 2621 } |
2622 } | |
2623 | |
4736 | 2624 static void |
10810 | 2625 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2626 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2627 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2628 GaimConvIm *im = NULL; |
10810 | 2629 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2630 char *stock_id, *tooltip; |
11508 | 2631 |
11581 | 2632 gtkwin = gtkconv->win; |
4736 | 2633 |
12008 | 2634 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2635 im = GAIM_CONV_IM(conv); |
4736 | 2636 |
12008 | 2637 if (gtkwin->menu.typing_icon) { |
2638 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2639 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2640 |
12008 | 2641 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2642 return; | |
2643 | |
2644 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2645 stock_id = GAIM_STOCK_TYPING; | |
2646 tooltip = _("User is typing..."); | |
2647 } else { | |
2648 stock_id = GAIM_STOCK_TYPED; | |
2649 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2650 } |
12008 | 2651 |
2652 if (gtkwin->menu.typing_icon == NULL) | |
2653 { | |
2654 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
|
2655 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
|
2656 gtkwin->menu.typing_icon, |
12008 | 2657 tooltip); |
4736 | 2658 } |
12008 | 2659 else |
2660 { | |
2661 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2662 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2663 gtkwin->menu.typing_icon, | |
2664 tooltip); | |
2665 } | |
2666 | |
2667 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2668 } |
2669 | |
4685 | 2670 static gboolean |
11594 | 2671 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2672 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2673 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2674 GaimConversation *conv; |
4359 | 2675 GtkWidget *menu; |
2676 GList *child; | |
11594 | 2677 GaimBuddy *b; |
11581 | 2678 |
2679 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2680 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2681 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2682 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2683 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2684 account = gaim_conversation_get_account(conv); |
11581 | 2685 |
11594 | 2686 if (win->menu.send_to == NULL) |
4685 | 2687 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2688 |
11594 | 2689 if (!(b = gaim_find_buddy(account, conv->name))) |
2690 return FALSE; | |
2691 | |
2692 | |
2693 gtk_widget_show(win->menu.send_to); | |
4359 | 2694 |
2695 menu = gtk_menu_item_get_submenu( | |
11594 | 2696 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2697 |
2698 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2699 child != NULL; | |
2700 child = child->next) { | |
2701 | |
2702 GtkWidget *item = child->data; | |
11594 | 2703 GaimBuddy *item_buddy; |
2704 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2705 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2706 "gaim_buddy_name"); | |
2707 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2708 | |
2709 if (b == item_buddy) { | |
4359 | 2710 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2711 break; | |
2712 } | |
2713 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2714 |
4685 | 2715 return FALSE; |
4359 | 2716 } |
2717 | |
2718 static void | |
11594 | 2719 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2720 { | |
2721 GaimAccount *account; | |
2722 GtkWidget *box; | |
2723 GtkWidget *label; | |
2724 GtkWidget *image; | |
2725 GtkWidget *menuitem; | |
11625 | 2726 GdkPixbuf *pixbuf; |
11616 | 2727 gchar *text; |
11594 | 2728 |
2729 account = bud->account; | |
2730 | |
2731 /* Create a pixmap for the protocol icon. */ | |
11625 | 2732 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2733 /* Now convert it to GtkImage */ |
2734 if (pixbuf == NULL) | |
2735 image = gtk_image_new(); | |
2736 else | |
11625 | 2737 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2738 |
2739 gtk_size_group_add_widget(sg, image); | |
2740 | |
2741 g_object_unref(G_OBJECT(pixbuf)); | |
2742 | |
2743 /* Make our menu item */ | |
11616 | 2744 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2745 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2746 g_free(text); | |
11594 | 2747 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2748 | |
2749 /* Do some evil, see some evil, speak some evil. */ | |
2750 box = gtk_hbox_new(FALSE, 0); | |
2751 | |
2752 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2753 g_object_ref(label); | |
2754 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2755 | |
2756 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2757 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2758 | |
2759 g_object_unref(label); | |
2760 | |
2761 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2762 | |
2763 gtk_widget_show(label); | |
2764 gtk_widget_show(image); | |
2765 gtk_widget_show(box); | |
2766 | |
2767 /* Set our data and callbacks. */ | |
2768 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2769 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2770 | |
2771 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2772 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2773 | |
2774 gtk_widget_show(menuitem); | |
2775 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2776 } | |
2777 | |
2778 static void | |
2779 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2780 { |
4359 | 2781 GtkWidget *menu; |
2782 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2783 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2784 GaimGtkConversation *gtkconv; |
2785 GSList *l, *buds; | |
2786 | |
2787 g_return_if_fail(win != NULL); | |
2788 | |
2789 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2790 | |
11604 | 2791 g_return_if_fail(gtkconv != NULL); |
2792 | |
11594 | 2793 if (win->menu.send_to != NULL) |
2794 gtk_widget_destroy(win->menu.send_to); | |
2795 | |
4359 | 2796 |
2797 /* Build the Send As menu */ | |
11594 | 2798 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2799 gtk_widget_show(win->menu.send_to); | |
4359 | 2800 |
2801 menu = gtk_menu_new(); | |
11581 | 2802 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2803 win->menu.send_to, 2); |
2804 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2805 |
2806 gtk_widget_show(menu); | |
2807 | |
11604 | 2808 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2809 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2810 for (l = buds; l != NULL; l = l->next) { | |
2811 GaimBuddy *b; | |
2812 GaimBlistNode *node; | |
2813 | |
2814 b = l->data; | |
2815 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2816 | |
2817 for (node = node->child; node != NULL; node = node->next) | |
2818 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2819 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2820 } | |
2821 | |
2822 g_slist_free(buds); | |
4359 | 2823 } |
2824 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2825 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2826 |
11594 | 2827 gtk_widget_show(win->menu.send_to); |
2828 if (!group) | |
2829 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2830 update_send_to_selection(win); | |
4359 | 2831 } |
2832 | |
2833 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2834 generate_invite_user_names(GaimConnection *gc) |
4359 | 2835 { |
6695 | 2836 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2837 static GList *tmp = NULL; |
2838 | |
2839 if (tmp) | |
2840 g_list_free(tmp); | |
2841 | |
2842 tmp = g_list_append(NULL, ""); | |
2843 | |
2844 if (gc != NULL) { | |
4785 | 2845 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2846 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2847 continue; | |
6695 | 2848 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2849 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2850 continue; |
6695 | 2851 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2852 GaimBuddy *buddy; | |
2853 | |
2854 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2855 continue; | |
2856 | |
2857 buddy = (GaimBuddy *)bnode; | |
2858 | |
2859 if (buddy->account == gc->account && | |
2860 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2861 tmp = g_list_insert_sorted(tmp, buddy->name, |
2862 (GCompareFunc)g_utf8_collate); | |
6695 | 2863 } |
4359 | 2864 } |
2865 } | |
2866 } | |
2867 | |
2868 return tmp; | |
2869 } | |
2870 | |
9498 | 2871 static GdkPixbuf * |
9554 | 2872 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2873 { |
9554 | 2874 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2875 char *filename; |
10274 | 2876 const char *image = NULL; |
9554 | 2877 |
2878 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2879 image = "founder.png"; |
9554 | 2880 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2881 image = "op.png"; |
9554 | 2882 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2883 image = "halfop.png"; |
9554 | 2884 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2885 image = "voice.png"; |
9554 | 2886 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2887 image = "ignored.png"; |
2888 } else { | |
2889 return NULL; | |
9554 | 2890 } |
10274 | 2891 |
2892 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2893 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2894 g_free(filename); | |
2895 | |
2896 if (!pixbuf) | |
2897 return NULL; | |
2898 | |
2899 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2900 g_object_unref(pixbuf); | |
2901 | |
2902 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2903 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2904 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2905 g_free(filename); | |
10274 | 2906 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2907 g_object_unref(pixbuf); |
10274 | 2908 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2909 g_object_unref(scale2); | |
9498 | 2910 } |
2911 | |
10274 | 2912 return scale; |
9498 | 2913 } |
2914 | |
4359 | 2915 static void |
11869 | 2916 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 2917 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2918 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2919 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2920 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2921 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2922 GaimPluginProtocolInfo *prpl_info; |
4359 | 2923 GtkListStore *ls; |
9498 | 2924 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2925 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2926 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2927 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2928 GdkColor send_color; |
11508 | 2929 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2930 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 2931 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2932 chat = GAIM_CONV_CHAT(conv); |
4359 | 2933 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2934 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2935 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2936 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2937 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2938 return; |
4359 | 2939 |
2940 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
2941 | |
9554 | 2942 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 2943 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
2944 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
|
2945 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2946 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2947 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2948 |
4359 | 2949 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2950 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2951 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2952 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2953 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2954 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2955 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
|
2956 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2957 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2958 |
9554 | 2959 if (pixbuf) |
2960 g_object_unref(pixbuf); | |
4359 | 2961 } |
2962 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2963 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2964 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
|
2965 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2966 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2967 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2968 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2969 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2970 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2971 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2972 /* if we're here, it's a possible completion */ |
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 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2975 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2976 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2977 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2978 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2979 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2980 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2981 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2982 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2983 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2984 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2985 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2986 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2987 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2988 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2989 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2990 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2991 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2992 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2993 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2994 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2995 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2996 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2997 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2998 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2999 |
9605 | 3000 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3001 tab_complete(GaimConversation *conv) |
4359 | 3002 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3003 GaimGtkConversation *gtkconv; |
4359 | 3004 GtkTextIter cursor, word_start, start_buffer; |
3005 int start; | |
3006 int most_matched = -1; | |
3007 char *entered, *partial = NULL; | |
3008 char *text; | |
8021 | 3009 char *nick_partial; |
9605 | 3010 const char *prefix; |
4359 | 3011 GList *matches = NULL; |
9605 | 3012 gboolean command = FALSE; |
4359 | 3013 |
3014 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3015 | |
3016 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3017 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3018 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3019 | |
3020 word_start = cursor; | |
3021 | |
3022 /* if there's nothing there just return */ | |
3023 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3024 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
|
3025 |
4359 | 3026 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3027 &cursor, FALSE); | |
3028 | |
3029 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3030 start = strlen(text) - 1; | |
3031 | |
8021 | 3032 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3033 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3034 start-=2; |
3035 } | |
4359 | 3036 |
3037 /* find the start of the word that we're tabbing */ | |
3038 while (start >= 0 && text[start] != ' ') { | |
3039 gtk_text_iter_backward_char(&word_start); | |
3040 start--; | |
3041 } | |
3042 | |
9605 | 3043 prefix = gaim_gtk_get_cmd_prefix(); |
3044 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3045 command = TRUE; | |
3046 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3047 } | |
3048 | |
4359 | 3049 g_free(text); |
3050 | |
3051 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3052 &cursor, FALSE); | |
3053 | |
8021 | 3054 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3055 g_free(entered); |
11338 | 3056 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3057 } |
3058 | |
8021 | 3059 nick_partial = g_malloc(strlen(entered)+1); |
3060 | |
9605 | 3061 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3062 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3064 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3065 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3066 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3067 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3068 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3069 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3070 g_list_free(list); |
11338 | 3071 } 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
|
3072 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3073 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3074 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
|
3075 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3076 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3077 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3078 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3079 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3080 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3081 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3082 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3083 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3084 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3085 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3086 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
|
3087 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3088 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3089 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3090 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3091 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3092 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3093 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3094 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3095 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3096 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3097 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3098 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3099 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3100 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3101 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3102 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3103 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3104 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3105 } |
9605 | 3106 } else { |
3107 g_free(nick_partial); | |
3108 g_free(entered); | |
3109 return FALSE; | |
3110 } | |
3111 | |
8021 | 3112 g_free(nick_partial); |
3113 | |
4359 | 3114 /* we're only here if we're doing new style */ |
3115 | |
3116 /* if there weren't any matches, return */ | |
3117 if (!matches) { | |
3118 /* if matches isn't set partials won't be either */ | |
3119 g_free(entered); | |
11338 | 3120 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3121 } |
3122 | |
3123 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3124 | |
3125 if (!matches->next) { | |
3126 /* there was only one match. fill it in. */ | |
3127 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3128 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3129 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3130 | |
3131 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3132 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3133 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3134 g_free(tmp); | |
3135 } | |
3136 else | |
3137 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3138 matches->data, -1); | |
3139 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3140 g_free(matches->data); |
4359 | 3141 matches = g_list_remove(matches, matches->data); |
3142 } | |
3143 else { | |
3144 /* | |
3145 * there were lots of matches, fill in as much as possible | |
3146 * and display all of them | |
3147 */ | |
3148 char *addthis = g_malloc0(1); | |
3149 | |
3150 while (matches) { | |
3151 char *tmp = addthis; | |
3152 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3153 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3154 g_free(matches->data); |
4359 | 3155 matches = g_list_remove(matches, matches->data); |
3156 } | |
3157 | |
6982 | 3158 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3159 time(NULL)); |
3160 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3161 g_free(addthis); | |
3162 } | |
3163 | |
3164 g_free(entered); | |
3165 g_free(partial); | |
9605 | 3166 |
3167 return TRUE; | |
4359 | 3168 } |
3169 | |
10810 | 3170 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3171 { |
3172 GaimPluginProtocolInfo *prpl_info = NULL; | |
3173 GaimConnection *gc; | |
10810 | 3174 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3175 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3176 char *new_topic; |
8858 | 3177 const char *current_topic; |
7971 | 3178 |
3179 gc = gaim_conversation_get_gc(conv); | |
3180 | |
3181 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3182 return; | |
3183 | |
3184 if(prpl_info->set_chat_topic == NULL) | |
3185 return; | |
3186 | |
3187 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3188 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3189 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3190 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3191 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3192 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3193 g_free(new_topic); |
7971 | 3194 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3195 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3196 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3197 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3198 |
8858 | 3199 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3200 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3201 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3202 g_free(new_topic); |
7971 | 3203 } |
3204 | |
9554 | 3205 static gint |
3206 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3207 { | |
3208 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3209 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3210 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3211 gint ret = 0; |
3212 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3213 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3214 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3215 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3216 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3217 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3218 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3219 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3220 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3221 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3222 -1); |
9554 | 3223 |
3224 if (user1 == NULL || user2 == NULL) { | |
3225 if (!(user1 == NULL && user2 == NULL)) | |
3226 ret = (user1 == NULL) ? -1: 1; | |
3227 } else if (f1 != f2) { | |
3228 /* sort more important users first */ | |
3229 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3230 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3231 ret = buddy1 ? -1 : 1; |
9554 | 3232 } else { |
10904 | 3233 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3234 } |
3235 | |
3236 g_free(user1); | |
3237 g_free(user2); | |
3238 | |
3239 return ret; | |
3240 } | |
3241 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3242 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3243 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
|
3244 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3245 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3246 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3247 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3248 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3249 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3250 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3251 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3252 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3253 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3254 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3255 /* 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
|
3256 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
|
3257 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3258 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
|
3259 return; |
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 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3262 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3263 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3264 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3265 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3266 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
|
3267 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3268 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3269 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3270 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3271 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3272 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3273 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3274 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3275 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3276 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3277 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3278 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3280 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3281 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3282 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3283 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3284 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3285 } |
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 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 } while (f != 0); |
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 g_free(normalized_name); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3295 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3296 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
|
3297 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3298 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 GaimPluginProtocolInfo *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 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3305 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3306 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3310 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
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 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 } |
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 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3325 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3331 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3339 /* 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
|
3340 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3341 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3342 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 /* 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
|
3344 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
|
3345 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3346 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
|
3347 return; |
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 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3352 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 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
|
3355 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 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
|
3358 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3360 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3361 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3362 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3363 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3366 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3367 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3369 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3370 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3371 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3372 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3373 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3374 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3375 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3376 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3377 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3378 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3379 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3380 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3381 /* If 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
|
3382 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3383 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3384 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3385 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3386 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3387 |
4359 | 3388 static GtkWidget * |
10810 | 3389 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3390 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3391 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3392 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3393 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3394 GaimConnection *gc; |
4359 | 3395 GtkWidget *vpaned, *hpaned; |
10175 | 3396 GtkWidget *vbox, *hbox, *frame; |
4359 | 3397 GtkWidget *lbox, *bbox; |
3398 GtkWidget *label; | |
3399 GtkWidget *list; | |
3400 GtkWidget *button; | |
7949 | 3401 GtkWidget *sw; |
4359 | 3402 GtkListStore *ls; |
3403 GtkCellRenderer *rend; | |
3404 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3406 GList *focus_chain = NULL; |
4359 | 3407 |
3408 gtkchat = gtkconv->u.chat; | |
3409 gc = gaim_conversation_get_gc(conv); | |
3410 | |
3411 /* Setup the outer pane. */ | |
3412 vpaned = gtk_vpaned_new(); | |
3413 gtk_widget_show(vpaned); | |
3414 | |
3415 /* Setup the top part of the pane. */ | |
11243 | 3416 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3417 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3418 gtk_widget_show(vbox); |
3419 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3420 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3421 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3422 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3423 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3424 { |
11243 | 3425 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3426 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3427 gtk_widget_show(hbox); |
3428 | |
3429 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3430 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3431 gtk_widget_show(label); |
3432 | |
3433 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3434 |
7971 | 3435 if(prpl_info->set_chat_topic == NULL) { |
3436 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3437 } else { | |
3438 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3439 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3440 } |
3441 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3442 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3443 gtk_widget_show(gtkchat->topic_text); |
3444 } | |
3445 | |
3446 /* Setup the horizontal pane. */ | |
3447 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3448 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3449 gtk_widget_show(hpaned); |
3450 | |
10175 | 3451 /* Setup gtkihmtml. */ |
3452 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3453 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3454 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3455 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3456 gtk_widget_show(frame); | |
3457 | |
3458 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3459 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3460 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3461 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3462 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3463 |
4359 | 3464 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3465 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3466 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3467 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3468 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3469 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3470 |
3471 /* Build the right pane. */ | |
11243 | 3472 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3473 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3474 gtk_widget_show(lbox); |
3475 | |
3476 /* Setup the label telling how many people are in the room. */ | |
3477 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3478 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3479 gtk_widget_show(gtkchat->count); | |
3480 | |
3481 /* Setup the list of users. */ | |
7949 | 3482 sw = gtk_scrolled_window_new(NULL, NULL); |
3483 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3484 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3485 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3486 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3487 gtk_widget_show(sw); | |
4359 | 3488 |
9554 | 3489 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
|
3490 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
|
3491 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3492 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3493 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3494 GTK_SORT_ASCENDING); |
3495 | |
3496 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3497 | |
9498 | 3498 rend = gtk_cell_renderer_pixbuf_new(); |
3499 | |
4359 | 3500 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3501 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3502 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3503 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3504 |
3505 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3506 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3507 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3508 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3509 |
9498 | 3510 rend = gtk_cell_renderer_text_new(); |
3511 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3512 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3513 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3514 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3515 NULL); |
4359 | 3516 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3517 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3518 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3519 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3520 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3521 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3522 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3523 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3524 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3525 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3526 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3527 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3528 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3529 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3530 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3531 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3532 #endif |
4359 | 3533 |
3534 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3535 | |
3536 gtk_widget_set_size_request(list, 150, -1); | |
3537 | |
3538 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3539 gtk_widget_show(list); | |
3540 | |
3541 gtkchat->list = list; | |
3542 | |
7949 | 3543 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3544 |
3545 /* Setup the user list toolbar. */ | |
11243 | 3546 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3547 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3548 gtk_widget_show(bbox); | |
3549 | |
3550 /* IM */ | |
10221 | 3551 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3552 GAIM_BUTTON_VERTICAL); |
10500 | 3553 gtkchat->userlist_im = button; |
4359 | 3554 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3555 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
|
3556 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3557 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3558 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3559 |
3560 gtk_widget_show(button); | |
3561 | |
3562 /* Ignore */ | |
3563 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3564 GAIM_BUTTON_VERTICAL); | |
10500 | 3565 gtkchat->userlist_ignore = button; |
4359 | 3566 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3567 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
|
3568 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3569 _("Ignore the user"), NULL); |
4359 | 3570 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3571 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3572 gtk_widget_show(button); |
3573 | |
3574 /* Info */ | |
3575 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3576 GAIM_BUTTON_VERTICAL); | |
10500 | 3577 gtkchat->userlist_info = button; |
4359 | 3578 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3579 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3580 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3581 _("Get the user's information"), NULL); |
4359 | 3582 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3583 G_CALLBACK(info_cb), gtkconv); |
4359 | 3584 |
3585 gtk_widget_show(button); | |
3586 | |
10175 | 3587 /* Setup the bottom half of the conversation window */ |
11243 | 3588 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3589 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3590 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3591 |
11243 | 3592 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3593 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3594 gtk_widget_show(gtkconv->lower_hbox); | |
3595 | |
11243 | 3596 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3597 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3598 gtk_widget_show(vbox); | |
3599 | |
10175 | 3600 /* Setup the toolbar, entry widget and all signals */ |
3601 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3602 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3603 gtk_widget_show(frame); |
3604 | |
9005 | 3605 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3606 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3607 gaim_account_get_protocol_name(conv->account)); |
10175 | 3608 gtk_widget_set_size_request(gtkconv->entry, -1, |
3609 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3610 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3611 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3612 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3613 |
3614 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3615 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3616 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3617 G_CALLBACK(send_cb), gtkconv); |
4359 | 3618 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3619 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3620 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3621 G_CALLBACK(size_allocate_cb), gtkconv); |
3622 | |
3623 default_formatize(gtkconv); | |
4359 | 3624 |
9080 | 3625 /* |
3626 * Focus for chat windows should be as follows: | |
3627 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3628 * user list buttons -> entry -> buttons at bottom | |
3629 */ | |
9332 | 3630 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3631 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3632 | |
4359 | 3633 return vpaned; |
3634 } | |
3635 | |
3636 static GtkWidget * | |
10810 | 3637 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3638 { |
10810 | 3639 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3640 GtkWidget *frame; |
4359 | 3641 GtkWidget *paned; |
10175 | 3642 GtkWidget *vbox; |
3643 GtkWidget *vbox2; | |
9080 | 3644 GList *focus_chain = NULL; |
4359 | 3645 |
10175 | 3646 /* Setup the outer pane */ |
4359 | 3647 paned = gtk_vpaned_new(); |
3648 gtk_widget_show(paned); | |
3649 | |
10175 | 3650 /* Setup the top part of the pane */ |
11243 | 3651 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3652 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3653 gtk_widget_show(vbox); |
3654 | |
10175 | 3655 /* Setup the gtkimhtml widget */ |
3656 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3657 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3658 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3659 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3660 gtk_widget_show(frame); | |
3661 | |
3662 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3663 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3664 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3665 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3666 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3667 |
3668 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3669 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3670 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3671 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3672 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3673 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3674 |
10175 | 3675 /* Setup the bottom half of the conversation window */ |
11243 | 3676 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3677 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3678 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3679 |
11243 | 3680 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3681 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3682 gtk_widget_show(gtkconv->lower_hbox); | |
3683 | |
11243 | 3684 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3685 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3686 gtk_widget_show(vbox2); | |
8821 | 3687 |
10175 | 3688 /* Setup the toolbar, entry widget and all signals */ |
3689 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3690 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3691 gtk_widget_show(frame); |
3692 | |
9005 | 3693 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3694 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3695 gaim_account_get_protocol_name(conv->account)); |
10175 | 3696 gtk_widget_set_size_request(gtkconv->entry, -1, |
3697 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3698 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3699 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3700 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
|
3701 |
4359 | 3702 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3703 G_CALLBACK(entry_key_press_cb), gtkconv); |
3704 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3705 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3706 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3707 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3708 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3709 |
3710 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3711 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3712 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3713 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3714 |
8481 | 3715 /* had to move this after the imtoolbar is attached so that the |
3716 * signals get fired to toggle the buttons on the toolbar as well. | |
3717 */ | |
10810 | 3718 default_formatize(gtkconv); |
4359 | 3719 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3720 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3721 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3722 |
8758 | 3723 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3724 gtkconv->u.im->show_icon = TRUE; |
4359 | 3725 |
9080 | 3726 /* |
3727 * Focus for IM windows should be as follows: | |
10356 | 3728 * Tab title -> conversation scrollback -> entry |
9080 | 3729 */ |
9332 | 3730 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3731 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3732 |
4359 | 3733 return paned; |
3734 } | |
3735 | |
3736 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3737 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3738 GtkSelectionData *sd, guint info, guint t, |
3739 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3740 { |
10810 | 3741 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3742 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3743 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3744 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3745 { |
4781 | 3746 GaimBlistNode *n = NULL; |
6695 | 3747 GaimBuddy *b; |
11581 | 3748 GaimGtkConversation *gtkconv = NULL; |
9622 | 3749 |
11812 | 3750 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3751 |
6695 | 3752 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3753 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3754 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3755 b = (GaimBuddy*)n; | |
3756 else | |
4781 | 3757 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3758 |
9622 | 3759 /* |
3760 * If we already have an open conversation with this buddy, then | |
3761 * just move the conv to this window. Otherwise, create a new | |
3762 * conv and add it to this window. | |
3763 */ | |
11338 | 3764 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3765 if (c != NULL) { |
11581 | 3766 GaimGtkWindow *oldwin; |
3767 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3768 oldwin = gtkconv->win; | |
9622 | 3769 if (oldwin != win) { |
11581 | 3770 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3771 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3772 } |
3773 } else { | |
11338 | 3774 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3775 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3776 if (gtkconv->win != win) |
3777 { | |
3778 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3779 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3780 } | |
9622 | 3781 } |
3782 | |
3783 /* Make this conversation the active conversation */ | |
11581 | 3784 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3785 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3786 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3787 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3788 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
|
3789 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3790 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3791 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3792 GaimAccount *account; |
11581 | 3793 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3794 |
11137 | 3795 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3796 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3797 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3798 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3799 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3800 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3801 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3802 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3803 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3804 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3805 { |
11338 | 3806 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3807 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3808 if (gtkconv->win != win) |
3809 { | |
3810 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3811 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3812 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3813 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3814 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3815 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3816 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3817 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3818 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3819 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3820 } |
9525 | 3821 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3822 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3823 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3824 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3825 } |
10145 | 3826 else |
3827 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3828 } |
4359 | 3829 |
3830 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3831 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3832 { |
10145 | 3833 GTK_IMHTML_DND_TARGETS, |
3834 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3835 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3836 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3837 |
10810 | 3838 static GaimGtkConversation * |
3839 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3840 { | |
3841 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3842 GaimContact *c; | |
3843 GaimBlistNode *cn; | |
10935 | 3844 |
10810 | 3845 if (!bud) |
3846 return NULL; | |
10935 | 3847 |
10810 | 3848 if (!(c = gaim_buddy_get_contact(bud))) |
3849 return NULL; | |
10935 | 3850 |
10810 | 3851 cn = (GaimBlistNode *)c; |
3852 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3853 GaimConversation *conv; | |
11338 | 3854 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3855 if (conv->ui_data) |
3856 return conv->ui_data; | |
3857 } | |
3858 } | |
10935 | 3859 |
10810 | 3860 return NULL; |
3861 } | |
3862 | |
11855 | 3863 static void |
3864 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3865 { | |
3866 GList *list; | |
3867 | |
3868 g_return_if_fail(bnode); | |
3869 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3870 | |
3871 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3872 { | |
3873 GaimGtkWindow *win = list->data; | |
3874 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3875 | |
3876 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3877 continue; | |
3878 | |
3879 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3880 } | |
3881 } | |
3882 | |
11581 | 3883 /************************************************************************** |
3884 * Conversation UI operations | |
3885 **************************************************************************/ | |
3886 void | |
3887 gaim_gtkconv_new(GaimConversation *conv) | |
3888 { | |
3889 GaimGtkConversation *gtkconv; | |
3890 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3891 GtkWidget *pane = NULL; |
3892 GtkWidget *tab_cont; | |
11581 | 3893 |
3894 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3895 conv->ui_data = gtkconv; |
3896 if (!g_list_find(gtkconv->convs, conv)) | |
3897 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3898 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3899 return; |
4359 | 3900 } |
3901 | |
11581 | 3902 gtkconv = g_new0(GaimGtkConversation, 1); |
3903 conv->ui_data = gtkconv; | |
3904 gtkconv->active_conv = conv; | |
3905 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3906 | |
3907 /* Setup some initial variables. */ | |
3908 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3909 gtkconv->tooltips = gtk_tooltips_new(); | |
3910 | |
3911 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3912 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3913 | |
3914 pane = setup_im_pane(gtkconv); | |
3915 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3916 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3917 pane = setup_chat_pane(gtkconv); | |
3918 } | |
3919 | |
12101 | 3920 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
3921 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
3922 | |
11581 | 3923 if (pane == NULL) { |
3924 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
3925 g_free(gtkconv->u.chat); | |
3926 else if (conv_type == GAIM_CONV_TYPE_IM) | |
3927 g_free(gtkconv->u.im); | |
3928 | |
3929 g_free(gtkconv); | |
3930 conv->ui_data = NULL; | |
3931 return; | |
10449 | 3932 } |
11581 | 3933 |
3934 /* Setup drag-and-drop */ | |
3935 gtk_drag_dest_set(pane, | |
3936 GTK_DEST_DEFAULT_MOTION | | |
3937 GTK_DEST_DEFAULT_DROP, | |
3938 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3939 GDK_ACTION_COPY); | |
3940 gtk_drag_dest_set(pane, | |
3941 GTK_DEST_DEFAULT_MOTION | | |
3942 GTK_DEST_DEFAULT_DROP, | |
3943 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3944 GDK_ACTION_COPY); | |
3945 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
3946 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3947 GDK_ACTION_COPY); | |
3948 | |
3949 gtk_drag_dest_set(gtkconv->entry, 0, | |
3950 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3951 GDK_ACTION_COPY); | |
3952 | |
3953 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
3954 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3955 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
3956 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3957 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
3958 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3959 | |
3960 /* Setup the container for the tab. */ | |
3961 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
3962 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
3963 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
3964 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
3965 gtk_widget_show(pane); | |
3966 | |
3967 gtkconv->make_sound = TRUE; | |
3968 | |
3969 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
3970 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
3971 else |
11581 | 3972 gtk_widget_hide(gtkconv->toolbar); |
3973 | |
3974 gtkconv->show_timestamps = TRUE; | |
3975 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
3976 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
3977 gaim_account_get_protocol_name(conv->account)); |
11581 | 3978 |
3979 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
3980 G_CALLBACK(gtk_widget_grab_focus), | |
3981 gtkconv->entry); | |
3982 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3983 if (conv_type == GAIM_CONV_TYPE_IM) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3984 /* put conv in hidden_convwin if hide_new pref is always */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3985 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always")==0) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3986 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3987 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3988 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3989 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3990 /* put conv in hidden_convwin if hide_new pref is away and account is away */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3991 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")==0 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3992 && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3993 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3994 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3995 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3996 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3997 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3998 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3999 |
11581 | 4000 gaim_gtkconv_placement_place(gtkconv); |
4001 } | |
4002 | |
4359 | 4003 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4004 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4005 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4006 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4007 |
10810 | 4008 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4009 /* Don't destroy ourselves until all our convos are gone */ | |
4010 if (gtkconv->convs) | |
4011 return; | |
11508 | 4012 |
11581 | 4013 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4014 | |
9504 | 4015 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4016 gaim_request_close_with_handle(conv); | |
4359 | 4017 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4018 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4019 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4020 |
11338 | 4021 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4022 if (gtkconv->u.im->icon_timer != 0) |
4023 g_source_remove(gtkconv->u.im->icon_timer); | |
4024 | |
4359 | 4025 if (gtkconv->u.im->anim != NULL) |
4793 | 4026 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4027 |
4028 g_free(gtkconv->u.im); | |
11581 | 4029 } 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
|
4030 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4031 g_free(gtkconv->u.chat); |
4032 } | |
4033 | |
4633 | 4034 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4035 | |
4359 | 4036 g_free(gtkconv); |
4037 } | |
4038 | |
4039 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4040 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4041 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4042 time_t mtime) |
4359 | 4043 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4044 GaimGtkConversation *gtkconv; |
4359 | 4045 |
4046 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4047 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4048 |
6982 | 4049 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4050 } |
4051 | |
4052 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4053 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4054 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4055 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4056 GaimGtkConversation *gtkconv; |
4359 | 4057 |
4058 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4059 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4060 |
10398 | 4061 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4062 |
6982 | 4063 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4064 } |
4065 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4066 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4067 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4068 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4069 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4070 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4071 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4072 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4073 char *buddyname; |
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 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4076 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4077 && (strlen(tag->name) > 6), FALSE); |
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 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4080 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4081 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4082 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4083 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
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 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4086 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4087 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4088 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4089 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4090 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4091 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4092 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4093 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4094 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4095 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4096 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4097 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4098 gaim_conversation_get_gc(conv); |
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 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4101 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4102 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4103 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4104 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4105 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4106 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4107 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4108 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4109 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4110 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4111 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4112 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4113 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4114 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4115 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4116 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4117 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4118 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4119 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4120 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4121 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4122 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4123 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4124 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4125 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4126 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4127 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4128 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4129 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4130 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4131 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4132 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4133 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4134 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4135 buddytag = gtk_text_buffer_create_tag( |
11096 | 4136 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4137 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4138 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4139 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4140 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4141 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4142 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4143 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4144 |
4359 | 4145 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4146 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4147 const char *message, GaimMessageFlags flags, |
4359 | 4148 time_t mtime) |
4149 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4150 GaimGtkConversation *gtkconv; |
11581 | 4151 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4152 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4153 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4154 GaimPluginProtocolInfo *prpl_info; |
4359 | 4155 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4156 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4157 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4158 int line_count; |
4359 | 4159 char buf2[BUF_LONG]; |
4160 char mdate[64]; | |
4161 char color[10]; | |
4162 char *str; | |
4163 char *with_font_tag; | |
4896 | 4164 char *sml_attrib = NULL; |
6982 | 4165 size_t length = strlen(message) + 1; |
4895 | 4166 |
4359 | 4167 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4168 |
4169 /* Set the active conversation to the one that just messaged us. */ | |
4170 /* 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
|
4171 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4172 |
4359 | 4173 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4174 account = gaim_conversation_get_account(conv); |
11581 | 4175 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4176 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4177 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4178 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4179 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4180 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4181 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4182 /* 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
|
4183 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4184 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4185 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4186 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4187 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4188 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4189 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4190 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4191 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4192 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4193 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4194 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4195 |
8677 | 4196 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4197 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4198 | |
5133 | 4199 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4200 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4201 else | |
4202 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4203 |
4896 | 4204 if(gc) |
9699 | 4205 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4206 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4207 |
10503 | 4208 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4209 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4210 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4211 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4212 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4213 |
7956 | 4214 /* this is gonna crash one day, I can feel it. */ |
4215 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4216 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4217 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4218 } |
4359 | 4219 |
10737 | 4220 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4221 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4222 g_snprintf(buf2, sizeof(buf2), |
8690 | 4223 "<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
|
4224 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4225 |
8962 | 4226 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4227 |
8722 | 4228 } else if (flags & GAIM_MESSAGE_ERROR) { |
4229 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4230 "<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
|
4231 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4232 |
8962 | 4233 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4234 | |
7431 | 4235 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4236 g_snprintf(buf2, BUF_LONG, |
8690 | 4237 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4238 sml_attrib ? sml_attrib : "", message); |
7440 | 4239 |
10884 | 4240 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4241 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4242 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4243 } else { |
4895 | 4244 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4245 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
|
4246 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4247 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4248 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
|
4249 int tag_end_offset = 0; |
7440 | 4250 |
6621 | 4251 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4252 str = g_malloc(1024); |
7440 | 4253 |
4359 | 4254 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4255 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4256 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4257 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4258 tag_start_offset += 3; |
4359 | 4259 } |
4260 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4261 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4262 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4263 tag_end_offset = 2; |
4359 | 4264 strcpy(color, "#00FF00"); |
4265 } | |
7440 | 4266 } |
4359 | 4267 else { |
10504 | 4268 if (gaim_message_meify(new_message, -1)) { |
4359 | 4269 str = g_malloc(1024); |
7440 | 4270 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4271 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4272 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
|
4273 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4274 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4275 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4276 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4277 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4278 } |
7440 | 4279 |
6621 | 4280 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4281 strcpy(color, "#AF7F00"); |
4282 else | |
4283 strcpy(color, "#062585"); | |
4284 } | |
4285 else { | |
4286 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4287 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4288 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
|
4289 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4290 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4291 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4292 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4293 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4294 } |
6621 | 4295 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4296 strcpy(color, "#AF7F00"); |
6621 | 4297 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4298 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4299 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4300 |
10108 | 4301 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4302 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4303 } else |
7854 | 4304 strcpy(color, RECV_COLOR); |
4359 | 4305 } |
6621 | 4306 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4307 strcpy(color, SEND_COLOR); |
10892 | 4308 else { |
4309 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4310 strcpy(color, "#000000"); | |
4311 } | |
4359 | 4312 } |
4313 } | |
10892 | 4314 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4315 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4316 g_free(alias_escaped); |
11508 | 4317 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4318 /* 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
|
4319 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4320 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4321 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4322 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4323 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4324 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4325 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4326 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4327 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4328 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4329 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4330 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4331 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4332 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4333 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4334 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4335 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4336 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4337 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4338 /* 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
|
4339 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4340 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4341 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4342 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4343 } |
7440 | 4344 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4345 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4346 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4347 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4348 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4349 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4350 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4351 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4352 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4353 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4354 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4355 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4356 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4357 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4358 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4359 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4360 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4361 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4362 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4363 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4364 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4365 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4366 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4367 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4368 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4369 |
4359 | 4370 g_free(str); |
4371 | |
4895 | 4372 if(gc){ |
4896 | 4373 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4374 char *post = "</font>"; |
4375 int pre_len = strlen(pre); | |
4376 int post_len = strlen(post); | |
7440 | 4377 |
4895 | 4378 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4379 |
4895 | 4380 strcpy(with_font_tag, pre); |
4381 memcpy(with_font_tag + pre_len, new_message, length); | |
4382 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4383 |
4895 | 4384 length += pre_len + post_len; |
4385 g_free(pre); | |
4386 } | |
4608 | 4387 else |
4895 | 4388 with_font_tag = g_memdup(new_message, length); |
7440 | 4389 |
8962 | 4390 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4391 with_font_tag, gtk_font_options); | |
7440 | 4392 |
4393 g_free(with_font_tag); | |
7447 | 4394 g_free(new_message); |
7440 | 4395 } |
4396 | |
5012 | 4397 if(sml_attrib) |
4398 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4399 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4400 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4401 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4402 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4403 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4404 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4405 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4406 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4407 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4408 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4409 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4410 else if ((flags & GAIM_MESSAGE_NO_LOG) == GAIM_MESSAGE_NO_LOG) |
12132
95bffda9b762
[gaim-migrate @ 14432]
Richard Laager <rlaager@wiktel.com>
parents:
12131
diff
changeset
|
4411 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4412 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4413 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4414 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4415 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4416 } |
4359 | 4417 } |
4418 | |
4419 static void | |
11869 | 4420 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
|
4421 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4422 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4423 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4424 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4425 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4426 GList *ll; |
11869 | 4427 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4428 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4429 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4430 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4431 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4432 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4433 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4434 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4435 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
|
4436 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4437 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4438 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4439 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4440 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4441 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4442 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4443 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4444 l = users; |
11869 | 4445 ll = flags; |
4446 lll = aliases; | |
4447 while (l != NULL && ll != NULL && lll != NULL) { | |
4448 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
|
4449 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4450 ll = ll->next; |
11869 | 4451 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4452 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4453 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4454 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4455 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4456 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
|
4457 const char *new_name, const char *new_alias) |
4359 | 4458 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4459 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4460 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4461 GaimGtkChatPane *gtkchat; |
11869 | 4462 GaimConvChatBuddyFlags flags; |
4359 | 4463 GtkTreeIter iter; |
4464 GtkTreeModel *model; | |
4465 int f = 1; | |
4466 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4467 chat = GAIM_CONV_CHAT(conv); |
4359 | 4468 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4469 gtkchat = gtkconv->u.chat; | |
4470 | |
9554 | 4471 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4472 | |
4473 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4474 return; | |
4475 | |
4476 while (f != 0) { | |
4477 char *val; | |
4478 | |
11869 | 4479 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4480 |
4481 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4482 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4483 g_free(val); | |
4359 | 4484 break; |
4485 } | |
9554 | 4486 |
4487 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4488 | |
4489 g_free(val); | |
4359 | 4490 } |
4491 | |
9554 | 4492 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4493 return; |
4494 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4495 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4496 |
11869 | 4497 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4498 } |
4499 | |
4500 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4501 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4502 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4503 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4504 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4505 GaimGtkChatPane *gtkchat; |
4359 | 4506 GtkTreeIter iter; |
4507 GtkTreeModel *model; | |
4508 char tmp[BUF_LONG]; | |
4509 int num_users; | |
4510 int f = 1; | |
4511 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4512 chat = GAIM_CONV_CHAT(conv); |
4359 | 4513 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4514 gtkchat = gtkconv->u.chat; | |
4515 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4516 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
|
4517 |
9554 | 4518 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4519 | |
4520 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4521 return; | |
4522 | |
4523 while (f != 0) { | |
4524 char *val; | |
4525 | |
4526 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4527 | |
4528 if (!gaim_utf8_strcasecmp(user, val)) { | |
4529 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4530 g_free(val); | |
4359 | 4531 break; |
4532 } | |
9554 | 4533 |
4534 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4535 | |
4536 g_free(val); | |
4359 | 4537 } |
4538 | |
9554 | 4539 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4540 return; |
4541 | |
4542 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4543 ngettext("%d person in room", "%d people in room", |
4544 num_users), num_users); | |
4359 | 4545 |
4546 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4547 | |
4548 } | |
4549 | |
4550 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4551 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4552 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4553 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4554 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4555 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4556 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4557 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4558 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4559 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4560 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4561 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4562 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4563 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4564 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4565 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4566 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4567 num_users = g_list_length(gaim_conv_chat_get_users(chat)) - |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4568 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4569 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4570 for (l = users; l != NULL; l = l->next) { |
9554 | 4571 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4572 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4573 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4574 continue; |
4575 | |
4576 do { | |
4577 char *val; | |
4578 | |
4579 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4580 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4581 | |
9696 | 4582 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4583 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4584 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4585 #else |
4586 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4587 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4588 #endif | |
4589 } | |
9554 | 4590 else |
4591 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4592 | |
4593 g_free(val); | |
4594 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4595 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4596 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4597 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4598 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4599 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4600 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4601 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4602 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4603 |
9554 | 4604 static void |
4605 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4606 { | |
4607 GaimConvChat *chat; | |
11869 | 4608 GaimConvChatBuddyFlags flags; |
9554 | 4609 GaimGtkConversation *gtkconv; |
4610 GaimGtkChatPane *gtkchat; | |
4611 GtkTreeIter iter; | |
4612 GtkTreeModel *model; | |
4613 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4614 char *alias = NULL; |
9554 | 4615 |
4616 chat = GAIM_CONV_CHAT(conv); | |
4617 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4618 gtkchat = gtkconv->u.chat; | |
4619 | |
4620 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4621 | |
4622 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4623 return; | |
4624 | |
4625 while (f != 0) { | |
4626 char *val; | |
4627 | |
4628 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4629 | |
4630 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4631 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4632 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4633 g_free(val); | |
4634 break; | |
4635 } | |
4636 | |
4637 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4638 | |
4639 g_free(val); | |
4640 } | |
4641 | |
4642 if (!gaim_conv_chat_find_user(chat, user)) | |
4643 return; | |
4644 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4645 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4646 |
11869 | 4647 flags = gaim_conv_chat_user_get_flags(chat, user); |
4648 | |
4649 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4650 g_free(alias); |
9554 | 4651 } |
4652 | |
11581 | 4653 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4654 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4655 { |
11581 | 4656 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4657 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4658 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4659 |
11581 | 4660 win = gtkconv->win; |
4661 | |
4662 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
|
4663 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4664 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4665 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4666 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4667 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4668 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4669 |
10526 | 4670 static gboolean |
4671 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4672 { | |
4673 GaimGtkConversation *gtkconv; | |
4674 GtkIMHtmlSmiley *smiley; | |
4675 GdkPixbufLoader *loader; | |
11525 | 4676 struct smiley_list *list; |
4677 const char *sml = NULL, *conv_sml; | |
4678 | |
4679 if (!conv || !smile || !*smile) { | |
10526 | 4680 return FALSE; |
4681 } | |
4682 | |
11525 | 4683 /* If smileys are off, return false */ |
4684 if (gaim_gtkthemes_smileys_disabled()) | |
4685 return FALSE; | |
4686 | |
4687 /* If possible add this smiley to the current theme. | |
4688 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4689 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4690 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4691 |
4692 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4693 if (!strcmp(list->sml, conv_sml)) { | |
4694 sml = list->sml; | |
4695 break; | |
4696 } | |
4697 } | |
4698 | |
10526 | 4699 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4700 | |
4701 if (smiley) { | |
11525 | 4702 |
4703 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4704 return FALSE; | |
4705 } | |
4706 | |
4707 /* Close the old GdkPixbufAnimation, then create a new one for | |
4708 * the smiley we are about to receive */ | |
4709 g_object_unref(G_OBJECT(smiley->icon)); | |
4710 | |
4711 smiley->loader = gdk_pixbuf_loader_new(); | |
4712 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4713 if (smiley->icon) | |
4714 g_object_ref(G_OBJECT(smiley->icon)); | |
4715 | |
4716 /* A custom smiley is already associated */ | |
4717 return TRUE; | |
10526 | 4718 } |
4719 | |
4720 loader = gdk_pixbuf_loader_new(); | |
4721 | |
4722 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4723 /* 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
|
4724 GtkIMHtmlSmiley by opaque */ |
10526 | 4725 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4726 smiley->file = NULL; | |
4727 smiley->smile = g_strdup(smile); | |
4728 smiley->loader = loader; | |
11525 | 4729 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4730 |
4731 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4732 if (smiley->icon) | |
4733 g_object_ref(G_OBJECT(smiley->icon)); | |
4734 | |
11525 | 4735 |
10526 | 4736 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4737 |
10526 | 4738 return TRUE; |
4739 } | |
4740 | |
10537 | 4741 static void |
10526 | 4742 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4743 const guchar *data, gsize size) |
10526 | 4744 { |
4745 GaimGtkConversation *gtkconv; | |
4746 GtkIMHtmlSmiley *smiley; | |
10537 | 4747 GdkPixbufLoader *loader; |
10526 | 4748 const char *sml; |
4749 | |
4750 sml = gaim_account_get_protocol_name(conv->account); | |
4751 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4752 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4753 | |
10537 | 4754 if (!smiley) |
10526 | 4755 return; |
10537 | 4756 |
10526 | 4757 loader = smiley->loader; |
10537 | 4758 if (!loader) |
10526 | 4759 return; |
4760 | |
4761 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4762 } | |
4763 | |
4764 static void | |
4765 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4766 { | |
4767 GaimGtkConversation *gtkconv; | |
4768 GtkIMHtmlSmiley *smiley; | |
4769 GdkPixbufLoader *loader; | |
4770 const char *sml; | |
11525 | 4771 GtkWidget *icon = NULL; |
4772 GtkTextChildAnchor *anchor = NULL; | |
4773 GtkTextIter end; | |
4774 GtkIMHtml *imhtml; | |
4775 GSList *current = NULL; | |
10526 | 4776 |
4777 g_return_if_fail(conv != NULL); | |
4778 g_return_if_fail(smile != NULL); | |
4779 | |
4780 sml = gaim_account_get_protocol_name(conv->account); | |
4781 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4782 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4783 | |
10537 | 4784 if (!smiley) |
10526 | 4785 return; |
4786 | |
4787 loader = smiley->loader; | |
4788 | |
10537 | 4789 if (!loader) |
10526 | 4790 return; |
10537 | 4791 |
11525 | 4792 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4793 if (smiley->icon) | |
4794 g_object_ref(G_OBJECT(smiley->icon)); | |
4795 | |
4796 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4797 | |
4798 icon = gtk_image_new_from_animation(smiley->icon); | |
4799 | |
4800 if (icon) { | |
12047 | 4801 gtk_widget_show(icon); |
4802 | |
11525 | 4803 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
4804 | |
4805 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4806 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4807 | |
4808 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4809 } | |
4810 | |
4811 } | |
4812 | |
4813 g_slist_free(smiley->anchors); | |
4814 smiley->anchors = NULL; | |
4815 | |
4816 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4817 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4818 * makes me question it */ | |
4819 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4820 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4821 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4822 | |
10526 | 4823 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4824 | |
4825 gdk_pixbuf_loader_close(loader, NULL); | |
4826 g_object_unref(G_OBJECT(loader)); | |
4827 smiley->loader = NULL; | |
4828 } | |
4829 | |
11581 | 4830 /* |
4831 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4832 * sensitive/insensitive. This is called after changing tabs and when an | |
4833 * account signs on or off. | |
4834 */ | |
4835 static void | |
4836 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4837 { | |
4838 GaimGtkWindow *win; | |
4839 GaimConversation *conv = gtkconv->active_conv; | |
4840 GaimConnection *gc; | |
4841 GaimPluginProtocolInfo *prpl_info = NULL; | |
4842 GdkPixbuf *window_icon = NULL; | |
4843 GtkIMHtmlButtons buttons; | |
4844 GaimAccount *account; | |
4845 | |
4846 win = gaim_gtkconv_get_window(gtkconv); | |
4847 gc = gaim_conversation_get_gc(conv); | |
4848 account = gaim_conversation_get_account(conv); | |
4849 | |
4850 if (gc != NULL) | |
4851 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4852 | |
11594 | 4853 if (win->menu.send_to != NULL) |
11734 | 4854 update_send_to_selection(win); |
11581 | 4855 |
4856 /* | |
4857 * Handle hiding and showing stuff based on what type of conv this is. | |
4858 * Stuff that Gaim IMs support in general should be shown for IM | |
4859 * conversations. Stuff that Gaim chats support in general should be | |
4860 * shown for chat conversations. It doesn't matter whether the PRPL | |
4861 * supports it or not--that only affects if the button or menu item | |
4862 * is sensitive or not. | |
4863 */ | |
4864 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4865 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4866 | |
4867 /* Deal with menu items */ | |
4868 gtk_widget_show(win->menu.view_log); | |
4869 gtk_widget_show(win->menu.send_file); | |
4870 gtk_widget_show(win->menu.add_pounce); | |
4871 gtk_widget_show(win->menu.get_info); | |
4872 gtk_widget_hide(win->menu.invite); | |
4873 gtk_widget_show(win->menu.alias); | |
4874 gtk_widget_show(win->menu.block); | |
4875 | |
4876 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4877 gtk_widget_show(win->menu.add); | |
4878 gtk_widget_hide(win->menu.remove); | |
4879 } else { | |
4880 gtk_widget_show(win->menu.remove); | |
4881 gtk_widget_hide(win->menu.add); | |
4882 } | |
4883 | |
4884 gtk_widget_show(win->menu.insert_link); | |
4885 gtk_widget_show(win->menu.insert_image); | |
4886 gtk_widget_show(win->menu.show_icon); | |
4887 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4888 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4889 | |
4890 /* Deal with menu items */ | |
4891 gtk_widget_show(win->menu.view_log); | |
4892 gtk_widget_hide(win->menu.send_file); | |
4893 gtk_widget_hide(win->menu.add_pounce); | |
4894 gtk_widget_hide(win->menu.get_info); | |
4895 gtk_widget_show(win->menu.invite); | |
4896 gtk_widget_show(win->menu.alias); | |
4897 gtk_widget_hide(win->menu.block); | |
4898 gtk_widget_hide(win->menu.show_icon); | |
4899 | |
4900 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4901 /* If the chat is NOT in the buddy list */ | |
4902 gtk_widget_show(win->menu.add); | |
4903 gtk_widget_hide(win->menu.remove); | |
4904 } else { | |
4905 /* If the chat IS in the buddy list */ | |
4906 gtk_widget_hide(win->menu.add); | |
4907 gtk_widget_show(win->menu.remove); | |
4908 } | |
4909 | |
4910 gtk_widget_show(win->menu.insert_link); | |
4911 gtk_widget_hide(win->menu.insert_image); | |
4912 } | |
4913 | |
4914 /* | |
4915 * Handle graying stuff out based on whether an account is connected | |
4916 * and what features that account supports. | |
4917 */ | |
4918 if ((gc != NULL) && | |
12012 | 4919 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
4920 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
4921 { | |
11581 | 4922 /* Account is online */ |
4923 /* Deal with the toolbar */ | |
12012 | 4924 if (conv->features & GAIM_CONNECTION_HTML) |
4925 { | |
4926 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
4927 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
4928 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
4929 buttons &= ~GTK_IMHTML_IMAGE; | |
4930 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
4931 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
4932 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
4933 { | |
4934 buttons &= ~GTK_IMHTML_GROW; | |
4935 buttons &= ~GTK_IMHTML_SHRINK; | |
4936 } | |
4937 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
4938 buttons &= ~GTK_IMHTML_LINKDESC; | |
4939 } else { | |
4940 buttons = GTK_IMHTML_SMILEY; | |
4941 } | |
4942 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
4943 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 4944 |
4945 /* Deal with menu items */ | |
12012 | 4946 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4947 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4948 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
4949 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
4950 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
4951 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 4952 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 4953 |
4954 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
4955 { | |
4956 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
4957 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
4958 gtk_widget_set_sensitive(win->menu.send_file, | |
4959 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
4960 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
4961 gtk_widget_set_sensitive(win->menu.alias, | |
4962 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
4963 } | |
4964 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
4965 { | |
4966 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
4967 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
4968 gtk_widget_set_sensitive(win->menu.alias, | |
4969 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
4970 } | |
11581 | 4971 |
4972 /* Deal with chat userlist buttons */ | |
12012 | 4973 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4974 { | |
4975 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
4976 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
4977 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
4978 } | |
4979 } else { | |
11581 | 4980 /* Account is offline */ |
4981 /* Or it's a chat that we've left. */ | |
4982 | |
4983 /* Then deal with menu items */ | |
12012 | 4984 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4985 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
4986 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4987 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
4988 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
4989 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
4990 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
4991 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
4992 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
4993 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
4994 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 4995 |
4996 /* Deal with chat userlist buttons */ | |
12012 | 4997 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4998 { | |
4999 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5000 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5001 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5002 } | |
5003 } | |
11581 | 5004 |
5005 /* | |
5006 * Update the window's icon | |
5007 */ | |
5008 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
12012 | 5009 (gtkconv->u.im->anim)) |
11581 | 5010 { |
5011 window_icon = | |
5012 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5013 g_object_ref(window_icon); | |
5014 } else { | |
5015 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5016 } | |
5017 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5018 if (window_icon != NULL) | |
5019 g_object_unref(G_OBJECT(window_icon)); | |
5020 } | |
5021 | |
10526 | 5022 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5023 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5024 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5025 { |
11581 | 5026 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5027 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5028 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5029 GaimConvChat *chat; |
4359 | 5030 |
10116 | 5031 g_return_if_fail(conv != NULL); |
5032 | |
4359 | 5033 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5034 win = gtkconv->win; |
10810 | 5035 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5036 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5037 * instead of the gross hack? | |
5038 */ | |
4359 | 5039 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5040 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5041 { |
4359 | 5042 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5043 |
11338 | 5044 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5045 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5046 |
4359 | 5047 gaim_gtkconv_update_buttons_by_protocol(conv); |
5048 | |
11734 | 5049 update_send_to_selection(win); |
4359 | 5050 |
11525 | 5051 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5052 |
6395 | 5053 update_tab_icon(conv); |
4359 | 5054 } |
5055 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5056 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5057 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5058 { |
9472 | 5059 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5060 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5061 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5062 /* 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
|
5063 char style[51]; |
4736 | 5064 |
11338 | 5065 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5066 im = GAIM_CONV_IM(conv); |
4359 | 5067 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5068 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5069 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5070 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5071 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5072 else | |
5073 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5074 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5075 *style = '\0'; |
4359 | 5076 |
5077 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5078 gtk_widget_realize(gtkconv->tab_label); | |
5079 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5080 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5081 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5082 { |
11759 | 5083 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5084 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5085 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5086 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5087 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5088 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5089 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5090 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5091 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5092 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5093 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5094 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5095 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5096 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5097 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5098 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5099 { |
11758 | 5100 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5101 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5102 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5103 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5104 { |
8536 | 5105 char *html_title,*label; |
5106 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5107 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5108 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5109 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5110 style, html_title); |
8536 | 5111 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5112 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5113 g_free(label); |
4359 | 5114 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5115 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5116 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5117 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5118 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5119 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5120 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5121 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5122 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5123 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5124 gtk_window_set_title(GTK_WINDOW(win->window), title); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5125 } |
9472 | 5126 |
5127 g_free(title); | |
4359 | 5128 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5129 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5130 { |
7154 | 5131 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5132 chat = GAIM_CONV_CHAT(conv); |
4359 | 5133 gtkchat = gtkconv->u.chat; |
5134 | |
7154 | 5135 topic = gaim_conv_chat_get_topic(chat); |
5136 | |
9554 | 5137 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5138 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5139 topic ? topic : "", NULL); |
4359 | 5140 } |
5141 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5142 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5143 { |
11581 | 5144 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5145 generate_send_to_items(win); |
8946 | 5146 update_tab_icon(conv); |
9472 | 5147 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5148 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5149 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5150 { |
8946 | 5151 update_tab_icon(conv); |
4359 | 5152 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5153 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
|
5154 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5155 { |
9472 | 5156 gaim_conversation_autoset_title(conv); |
10810 | 5157 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5158 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5159 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5160 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5161 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5162 } |
10665 | 5163 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5164 { | |
10810 | 5165 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5166 } |
4359 | 5167 } |
5168 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5169 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5170 { |
11581 | 5171 gaim_gtkconv_new, |
4359 | 5172 gaim_gtkconv_destroy, /* destroy_conversation */ |
5173 gaim_gtkconv_write_chat, /* write_chat */ | |
5174 gaim_gtkconv_write_im, /* write_im */ | |
5175 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5176 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5177 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5178 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5179 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5180 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5181 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5182 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5183 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5184 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5185 gaim_gtkconv_updated /* updated */ |
5186 }; | |
5187 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5188 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5189 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5190 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5191 return &conversation_ui_ops; |
4359 | 5192 } |
5193 | |
5194 /************************************************************************** | |
5195 * Public conversation utility functions | |
5196 **************************************************************************/ | |
5197 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5198 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5199 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5200 GaimGtkConversation *gtkconv; |
11581 | 5201 GaimGtkWindow *win; |
4359 | 5202 |
10381 | 5203 GdkPixbufLoader *loader; |
5204 GdkPixbufAnimation *anim; | |
4359 | 5205 GError *err = NULL; |
5206 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5207 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5208 size_t len; |
4359 | 5209 |
5210 GdkPixbuf *buf; | |
5211 | |
5212 GtkWidget *event; | |
5213 GtkWidget *frame; | |
5214 GdkPixbuf *scale; | |
5215 GdkPixmap *pm; | |
5216 GdkBitmap *bm; | |
9318 | 5217 int scale_width, scale_height; |
5218 | |
5219 GaimAccount *account; | |
5220 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5221 |
9324 | 5222 GaimBuddyIcon *icon; |
5223 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5224 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5225 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5226 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5227 |
5228 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5229 win = gtkconv->win; |
10175 | 5230 |
9687 | 5231 if (!gtkconv->u.im->show_icon) |
5232 return; | |
5233 | |
9318 | 5234 account = gaim_conversation_get_account(conv); |
5235 if(account && account->gc) | |
5236 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5237 |
9845 | 5238 /* Remove the current icon stuff */ |
9885 | 5239 if (gtkconv->u.im->icon_container != NULL) |
5240 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5241 gtkconv->u.im->icon_container = NULL; | |
9845 | 5242 |
5243 if (gtkconv->u.im->anim != NULL) | |
5244 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5245 | |
9887 | 5246 gtkconv->u.im->anim = NULL; |
5247 | |
9845 | 5248 if (gtkconv->u.im->icon_timer != 0) |
5249 g_source_remove(gtkconv->u.im->icon_timer); | |
5250 | |
5251 gtkconv->u.im->icon_timer = 0; | |
5252 | |
5253 if (gtkconv->u.im->iter != NULL) | |
5254 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5255 |
10116 | 5256 gtkconv->u.im->iter = NULL; |
5257 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5258 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5259 return; |
5260 | |
5261 if (gaim_conversation_get_gc(conv) == NULL) | |
5262 return; | |
5263 | |
9324 | 5264 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5265 | |
5266 if (icon == NULL) | |
5267 return; | |
5268 | |
5269 data = gaim_buddy_icon_get_data(icon, &len); | |
5270 | |
10381 | 5271 loader = gdk_pixbuf_loader_new(); |
5272 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5273 anim = gdk_pixbuf_loader_get_animation(loader); | |
5274 if (anim) | |
5275 g_object_ref(G_OBJECT(anim)); | |
5276 gdk_pixbuf_loader_close(loader, &err); | |
5277 g_object_unref(loader); | |
5278 | |
5279 if (!anim) | |
9324 | 5280 return; |
10381 | 5281 gtkconv->u.im->anim = anim; |
9324 | 5282 |
4359 | 5283 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5284 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5285 "Buddy icon error: %s\n", err->message); |
4359 | 5286 g_error_free(err); |
5287 } | |
5288 | |
5289 if (!gtkconv->u.im->anim) | |
5290 return; | |
5291 | |
5292 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5293 gtkconv->u.im->iter = NULL; | |
5294 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5295 } else { | |
5296 gtkconv->u.im->iter = | |
8496 | 5297 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5298 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5299 if (gtkconv->u.im->animate) |
10810 | 5300 start_anim(NULL, gtkconv); |
4359 | 5301 } |
5302 | |
10483 | 5303 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5304 NULL, &scale_width, &scale_height); |
4359 | 5305 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5306 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5307 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5308 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5309 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5310 GDK_INTERP_BILINEAR); |
4359 | 5311 |
5312 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5313 g_object_unref(G_OBJECT(scale)); |
4359 | 5314 |
8821 | 5315 |
9885 | 5316 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5317 |
4359 | 5318 frame = gtk_frame_new(NULL); |
5319 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5320 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5321 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5322 FALSE, FALSE, 0); | |
8821 | 5323 |
4359 | 5324 event = gtk_event_box_new(); |
5325 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5326 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5327 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5328 gtk_widget_show(event); |
5329 | |
4635 | 5330 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5331 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5332 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5333 gtk_widget_show(gtkconv->u.im->icon); | |
5334 | |
4793 | 5335 g_object_unref(G_OBJECT(pm)); |
4359 | 5336 |
5337 if (bm) | |
4793 | 5338 g_object_unref(G_OBJECT(bm)); |
7143 | 5339 |
10356 | 5340 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5341 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5342 |
9885 | 5343 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5344 gtk_widget_show(frame); |
5345 | |
7143 | 5346 /* The buddy icon code needs badly to be fixed. */ |
5347 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5348 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5349 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5350 } |
5351 | |
5352 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5353 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5354 { |
11581 | 5355 GaimGtkWindow *win; |
4359 | 5356 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5357 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5358 return; |
5359 | |
11581 | 5360 win = GAIM_GTK_CONVERSATION(conv)->win; |
5361 | |
5362 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5363 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5364 } |
5365 | |
5366 int | |
11614 | 5367 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5368 { |
4359 | 5369 gint nb_x, nb_y, x_rel, y_rel; |
5370 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5371 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5372 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5373 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5374 gboolean horiz; |
4359 | 5375 |
11614 | 5376 if (to_right) |
5377 *to_right = FALSE; | |
5378 | |
11581 | 5379 notebook = GTK_NOTEBOOK(win->notebook); |
5380 | |
5381 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5382 x_rel = x - nb_x; |
5383 y_rel = y - nb_y; | |
5384 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5385 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5386 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5387 |
11780 | 5388 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5389 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5390 #else |
5391 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5392 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5393 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5394 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5395 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5396 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5397 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5398 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5399 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5400 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5401 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5402 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
|
5403 page_num = i; |
11614 | 5404 |
5405 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5406 *to_right = TRUE; | |
5407 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5408 break; |
4359 | 5409 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5410 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5411 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5412 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
|
5413 page_num = i; |
11614 | 5414 |
5415 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5416 *to_right = TRUE; | |
5417 | |
4359 | 5418 break; |
5419 } | |
5420 } | |
5421 } | |
5422 | |
5423 return page_num; | |
5424 } | |
5425 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5426 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5427 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
|
5428 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5429 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5430 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5431 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5432 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5433 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5434 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5435 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5436 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5437 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5438 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5439 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5440 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5441 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5442 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5443 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5444 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5445 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5446 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5447 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5448 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5449 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5450 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5451 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5452 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5453 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5454 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5455 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5456 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5457 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5458 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5459 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5460 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5461 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5462 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5463 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5464 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5465 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5466 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5467 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5468 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5469 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5470 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5471 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5472 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5473 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5474 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5475 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5476 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5477 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5478 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5479 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5480 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5481 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5482 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5483 GtkPositionType pos; |
11581 | 5484 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5485 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5486 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5487 |
11581 | 5488 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5489 win = l->data; | |
5490 | |
11619 | 5491 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
|
5492 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5493 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5494 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5495 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5496 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5497 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5498 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5499 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5500 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5501 GaimGtkConversation *gtkconv; |
11581 | 5502 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5503 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5504 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5505 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5506 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5507 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5508 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5509 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5510 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5511 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5512 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5513 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5514 gtk_check_menu_item_set_active( |
11581 | 5515 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5516 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5517 |
5518 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5519 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5520 else |
8317 | 5521 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5522 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5523 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5524 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5525 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5526 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5527 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5528 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5529 GList *l; |
8189 | 5530 GaimConversation *conv; |
5531 GaimGtkConversation *gtkconv; | |
11581 | 5532 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5533 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5534 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
|
5535 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5536 |
8189 | 5537 /* Set the "animate" flag for each icon based on the new preference */ |
5538 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5539 conv = (GaimConversation *)l->data; | |
5540 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5541 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5542 } |
8189 | 5543 |
5544 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5545 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5546 win = l->data; | |
5547 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5548 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5549 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5550 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5551 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5552 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5553 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
|
5554 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5555 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5556 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5557 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5558 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5559 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5560 |
11338 | 5561 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5562 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5563 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5564 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5565 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5566 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5567 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5568 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5569 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5570 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5571 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5572 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5573 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5574 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5575 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5576 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5577 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5578 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5579 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5580 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5581 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")!=0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5582 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5583 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5584 if(gaim_status_type_get_primitive(gaim_status_get_type(oldstatus))!=GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5585 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5586 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5587 if(gaim_status_type_get_primitive(gaim_status_get_type(newstatus))==GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5588 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5589 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5590 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5591 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5592 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5593 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5594 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5595 if(gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5596 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5597 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5598 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5599 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5600 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5601 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5602 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5603 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5604 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5605 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5606 hide_new_pref_cb(const char *name, GaimPrefType type, gpointer value, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5607 gpointer data) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5608 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5609 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5610 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5611 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5612 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5613 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5614 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5615 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5616 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5617 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always")==0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5618 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5619 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5620 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")==0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5621 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5622 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5623 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5624 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5625 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5626 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5627 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5628 if(when_away && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5629 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5630 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5631 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5632 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5633 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5634 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5635 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5636 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5637 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5638 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5639 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5640 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5641 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5642 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5643 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5644 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5645 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5646 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5647 |
11581 | 5648 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5649 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5650 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5651 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5652 |
11581 | 5653 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5654 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5655 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5656 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5657 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5658 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5659 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5660 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5661 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5662 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5663 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5664 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5665 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5666 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5667 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5668 if (gaim_conversation_get_account(conv) == account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5669 gaim_conversation_update(conv, GPOINTER_TO_INT(event)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5670 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5671 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5672 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5673 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5674 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5675 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5676 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5677 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5678 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5679 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5680 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5681 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5682 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5683 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5684 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5685 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5686 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5687 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5688 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5689 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5690 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5691 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5692 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5693 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5694 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5695 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5696 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5697 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5698 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5699 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5700 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5701 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5702 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5703 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5704 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5705 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5706 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
|
5707 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5708 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5709 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5710 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5711 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5712 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5713 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5714 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5715 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5716 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5717 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5718 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5719 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5720 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5721 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5722 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5723 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
|
5724 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5725 /* convert old queuing prefs to hide_new 3-way pref */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5726 if(gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5727 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5728 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "always"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5729 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5730 else if(gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5731 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5732 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "away"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5733 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5734 else { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5735 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5736 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5737 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5738 /* Connect callbacks. */ |
10087 | 5739 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
|
5740 close_on_tabs_pref_cb, NULL); |
10087 | 5741 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
|
5742 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5743 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5744 spellcheck_pref_cb, NULL); |
10087 | 5745 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5746 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5747 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5748 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5749 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5750 |
10087 | 5751 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5752 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5753 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5754 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5755 /* IM callbacks */ |
10087 | 5756 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
|
5757 animate_buddy_icons_pref_cb, NULL); |
10087 | 5758 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
|
5759 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5760 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5761 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5762 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5763 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5764 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5765 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5766 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5767 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5768 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5769 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5770 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5771 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5772 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5773 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5774 |
5775 /********************************************************************** | |
5776 * Register commands | |
5777 **********************************************************************/ | |
9829 | 5778 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5779 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5780 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5781 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5782 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5783 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5784 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5785 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5786 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
|
5787 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5788 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5789 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5790 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5791 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5792 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5793 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5794 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5795 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5796 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5797 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5798 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5799 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5800 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5801 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5802 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5803 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5804 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5805 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5806 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5807 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5808 G_CALLBACK(buddy_update_cb), NULL); |
5809 | |
11581 | 5810 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5811 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5812 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5813 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5814 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5815 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5816 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5817 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5818 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5819 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5820 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5821 { |
10443 | 5822 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5823 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5824 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5825 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5826 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5827 } |
11581 | 5828 |
5829 | |
5830 | |
5831 | |
5832 | |
5833 | |
5834 | |
5835 | |
5836 | |
5837 | |
5838 | |
5839 | |
5840 | |
5841 | |
5842 | |
5843 | |
5844 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5845 * and touch each others' private members all day long */ | |
5846 | |
5847 /** | |
5848 * @file gtkconvwin.c GTK+ Conversation Window API | |
5849 * @ingroup gtkui | |
5850 * | |
5851 * gaim | |
5852 * | |
5853 * Gaim is the legal property of its developers, whose names are too numerous | |
5854 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5855 * source distribution. | |
5856 * | |
5857 * This program is free software; you can redistribute it and/or modify | |
5858 * it under the terms of the GNU General Public License as published by | |
5859 * the Free Software Foundation; either version 2 of the License, or | |
5860 * (at your option) any later version. | |
5861 * | |
5862 * This program is distributed in the hope that it will be useful, | |
5863 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
5864 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
5865 * GNU General Public License for more details. | |
5866 * | |
5867 * You should have received a copy of the GNU General Public License | |
5868 * along with this program; if not, write to the Free Software | |
5869 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5870 * | |
5871 */ | |
5872 #include "internal.h" | |
5873 #include "gtkgaim.h" | |
5874 | |
5875 | |
5876 #include <gdk/gdkkeysyms.h> | |
5877 | |
5878 #include "account.h" | |
5879 #include "cmds.h" | |
5880 #include "debug.h" | |
5881 #include "imgstore.h" | |
5882 #include "log.h" | |
5883 #include "notify.h" | |
5884 #include "prpl.h" | |
5885 #include "request.h" | |
5886 #include "util.h" | |
5887 | |
5888 #include "gtkdnd-hints.h" | |
5889 #include "gtkblist.h" | |
5890 #include "gtkconv.h" | |
5891 #include "gtkdialogs.h" | |
5892 #include "gtkmenutray.h" | |
5893 #include "gtkpounce.h" | |
5894 #include "gtkprefs.h" | |
5895 #include "gtkprivacy.h" | |
5896 #include "gtkutils.h" | |
5897 #include "gtkstock.h" | |
5898 #include "gtkimhtml.h" | |
5899 #include "gtkimhtmltoolbar.h" | |
5900 | |
5901 static void | |
5902 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
5903 { | |
5904 gtk_widget_destroy(warn_close_dialog); | |
5905 warn_close_dialog = NULL; | |
5906 | |
5907 if (resp == GTK_RESPONSE_OK) | |
5908 gaim_gtk_conv_window_destroy(win); | |
5909 } | |
5910 | |
5911 static void | |
5912 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
5913 { | |
5914 GtkWidget *label; | |
5915 GtkWidget *vbox, *hbox; | |
5916 GtkWidget *img; | |
5917 | |
5918 g_return_if_fail(warn_close_dialog == NULL); | |
5919 | |
5920 | |
5921 warn_close_dialog = gtk_dialog_new_with_buttons( | |
5922 _("Confirm close"), | |
5923 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
5924 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
5925 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
5926 | |
5927 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
5928 GTK_RESPONSE_OK); | |
5929 | |
5930 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
5931 6); | |
5932 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
5933 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
5934 FALSE); | |
5935 | |
5936 /* Setup the outside spacing. */ | |
5937 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
5938 | |
5939 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
5940 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
5941 | |
5942 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
5943 GTK_ICON_SIZE_DIALOG); | |
5944 /* Setup the inner hbox and put the dialog's icon in it. */ | |
5945 hbox = gtk_hbox_new(FALSE, 12); | |
5946 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
5947 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
5948 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
5949 | |
5950 /* Setup the right vbox. */ | |
5951 vbox = gtk_vbox_new(FALSE, 12); | |
5952 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
5953 | |
5954 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
5955 gtk_widget_set_size_request(label, 350, -1); | |
5956 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
5957 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
5958 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
5959 | |
5960 /* Connect the signals. */ | |
5961 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
5962 G_CALLBACK(do_close), gtkwin); | |
5963 | |
5964 } | |
5965 | |
5966 /************************************************************************** | |
5967 * Callbacks | |
5968 **************************************************************************/ | |
5969 | |
5970 static gboolean | |
5971 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
5972 { | |
5973 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5974 GList *l; |
11581 | 5975 |
5976 /* If there are unread messages then show a warning dialog */ | |
5977 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
5978 l != NULL; l = l->next) | |
5979 { | |
5980 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5981 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
|
5982 gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5983 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5984 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5985 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5986 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5987 return TRUE; |
11581 | 5988 } |
5989 } | |
5990 | |
5991 gaim_gtk_conv_window_destroy(win); | |
5992 | |
5993 return TRUE; | |
5994 } | |
5995 | |
11604 | 5996 static void |
5997 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
5998 { | |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5999 /* only allow NONE or higher priority unseen state */ |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6000 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
|
6001 || state > gtkconv->unseen_state) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6002 gtkconv->unseen_state = state; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6003 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6004 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6005 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6006 |
11581 | 6007 /* |
6008 * When a conversation window is focused, we know the user | |
6009 * has looked at it so we know there are no longer unseen | |
6010 * messages. | |
6011 */ | |
6012 static gint | |
6013 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6014 { | |
6015 GaimGtkWindow *win = d; | |
11604 | 6016 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6017 | |
6018 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6019 |
6020 return FALSE; | |
6021 } | |
6022 | |
11851 | 6023 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6024 /* Courtesy of Galeon! */ |
6025 static void | |
6026 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6027 { | |
6028 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6029 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6030 } | |
11851 | 6031 #endif |
11581 | 6032 |
6033 static void | |
6034 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6035 { | |
6036 static GdkCursor *cursor = NULL; | |
6037 | |
6038 gtkwin->in_drag = TRUE; | |
6039 | |
6040 if (gtkwin->drag_leave_signal) { | |
6041 g_signal_handler_disconnect(G_OBJECT(widget), | |
6042 gtkwin->drag_leave_signal); | |
6043 gtkwin->drag_leave_signal = 0; | |
6044 } | |
6045 | |
6046 if (cursor == NULL) | |
6047 cursor = gdk_cursor_new(GDK_FLEUR); | |
6048 | |
6049 /* Grab the pointer */ | |
6050 gtk_grab_add(gtkwin->notebook); | |
6051 #ifndef _WIN32 | |
6052 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6053 always be true after a button press. */ | |
6054 if (!gdk_pointer_is_grabbed()) | |
6055 #endif | |
6056 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6057 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6058 NULL, cursor, GDK_CURRENT_TIME); | |
6059 } | |
6060 | |
6061 static gboolean | |
6062 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6063 { | |
6064 | |
6065 /* | |
6066 * Make sure the user moved the mouse far enough for the | |
6067 * drag to be initiated. | |
6068 */ | |
6069 if (win->in_predrag) { | |
6070 if (e->x_root < win->drag_min_x || | |
6071 e->x_root >= win->drag_max_x || | |
6072 e->y_root < win->drag_min_y || | |
6073 e->y_root >= win->drag_max_y) { | |
6074 | |
6075 win->in_predrag = FALSE; | |
6076 notebook_init_grab(win, widget); | |
6077 } | |
6078 } | |
6079 else { /* Otherwise, draw the arrows. */ | |
6080 GaimGtkWindow *dest_win; | |
6081 GtkNotebook *dest_notebook; | |
6082 GtkWidget *tab; | |
6083 gint nb_x, nb_y, page_num; | |
6084 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6085 gboolean horiz_tabs = FALSE; | |
11614 | 6086 GaimGtkConversation *gtkconv; |
6087 gboolean to_right = FALSE; | |
11581 | 6088 |
6089 /* Get the window that the cursor is over. */ | |
6090 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6091 | |
6092 if (dest_win == NULL) { | |
6093 dnd_hints_hide_all(); | |
6094 | |
6095 return TRUE; | |
6096 } | |
6097 | |
6098 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6099 | |
6100 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6101 | |
6102 arrow1_x = arrow2_x = nb_x; | |
6103 arrow1_y = arrow2_y = nb_y; | |
6104 | |
6105 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6106 e->x_root, e->y_root, &to_right); |
6107 to_right = to_right && (win != dest_win); | |
11581 | 6108 |
6109 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6110 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6111 | |
6112 horiz_tabs = TRUE; | |
6113 } | |
6114 | |
11614 | 6115 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6116 tab = gtkconv->tabby; | |
11581 | 6117 |
6118 if (horiz_tabs) { | |
6119 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6120 | |
11614 | 6121 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6122 arrow1_x += tab->allocation.width; |
6123 arrow2_x += tab->allocation.width; | |
6124 } | |
6125 | |
6126 arrow1_y = nb_y + tab->allocation.y; | |
6127 arrow2_y = nb_y + tab->allocation.y + | |
6128 tab->allocation.height; | |
6129 } else { | |
6130 arrow1_x = nb_x + tab->allocation.x; | |
6131 arrow2_x = nb_x + tab->allocation.x + | |
6132 tab->allocation.width; | |
6133 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
6134 | |
6135 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
6136 arrow1_y += tab->allocation.height; | |
6137 arrow2_y += tab->allocation.height; | |
6138 } | |
6139 } | |
6140 | |
6141 if (horiz_tabs) { | |
6142 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6143 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6144 } else { | |
6145 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6146 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6147 } | |
6148 } | |
6149 | |
6150 return TRUE; | |
6151 } | |
6152 | |
6153 static gboolean | |
6154 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6155 { | |
6156 if (win->in_drag) | |
6157 return FALSE; | |
6158 | |
6159 if (e->x_root < win->drag_min_x || | |
6160 e->x_root >= win->drag_max_x || | |
6161 e->y_root < win->drag_min_y || | |
6162 e->y_root >= win->drag_max_y) { | |
6163 | |
6164 win->in_predrag = FALSE; | |
6165 notebook_init_grab(win, widget); | |
6166 } | |
6167 | |
6168 return TRUE; | |
6169 } | |
6170 | |
6171 /* | |
6172 * THANK YOU GALEON! | |
6173 */ | |
6174 static gboolean | |
6175 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6176 { | |
6177 gint nb_x, nb_y, x_rel, y_rel; | |
6178 int tab_clicked; | |
6179 GtkWidget *page; | |
6180 GtkWidget *tab; | |
6181 | |
6182 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6183 return FALSE; | |
6184 | |
6185 | |
6186 if (win->in_drag) { | |
6187 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6188 "Already in the middle of a window drag at tab_press_cb\n"); | |
6189 return TRUE; | |
6190 } | |
6191 | |
6192 /* | |
6193 * Make sure a tab was actually clicked. The arrow buttons | |
6194 * mess things up. | |
6195 */ | |
11614 | 6196 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6197 |
6198 if (tab_clicked == -1) | |
6199 return FALSE; | |
6200 | |
6201 /* | |
6202 * Get the relative position of the press event, with regards to | |
6203 * the position of the notebook. | |
6204 */ | |
6205 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6206 | |
6207 x_rel = e->x_root - nb_x; | |
6208 y_rel = e->y_root - nb_y; | |
6209 | |
6210 /* Reset the min/max x/y */ | |
6211 win->drag_min_x = 0; | |
6212 win->drag_min_y = 0; | |
6213 win->drag_max_x = 0; | |
6214 win->drag_max_y = 0; | |
6215 | |
6216 /* Find out which tab was dragged. */ | |
6217 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6218 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6219 | |
6220 win->drag_min_x = tab->allocation.x + nb_x; | |
6221 win->drag_min_y = tab->allocation.y + nb_y; | |
6222 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6223 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6224 | |
6225 /* Make sure the click occurred in the tab. */ | |
6226 if (e->x_root < win->drag_min_x || | |
6227 e->x_root >= win->drag_max_x || | |
6228 e->y_root < win->drag_min_y || | |
6229 e->y_root >= win->drag_max_y) { | |
6230 | |
6231 return FALSE; | |
6232 } | |
6233 | |
6234 win->in_predrag = TRUE; | |
6235 win->drag_tab = tab_clicked; | |
6236 | |
6237 /* Connect the new motion signals. */ | |
6238 win->drag_motion_signal = | |
6239 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6240 G_CALLBACK(notebook_motion_cb), win); | |
6241 | |
6242 win->drag_leave_signal = | |
6243 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6244 G_CALLBACK(notebook_leave_cb), win); | |
6245 | |
6246 return FALSE; | |
6247 } | |
6248 | |
6249 static gboolean | |
6250 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6251 { | |
6252 GaimGtkWindow *dest_win; | |
6253 GaimConversation *conv; | |
6254 GaimGtkConversation *gtkconv; | |
6255 gint dest_page_num = 0; | |
6256 gboolean new_window = FALSE; | |
11614 | 6257 gboolean to_right = FALSE; |
11581 | 6258 |
6259 /* | |
6260 * Don't check to make sure that the event's window matches the | |
6261 * widget's, because we may be getting an event passed on from the | |
6262 * close button. | |
6263 */ | |
6264 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6265 return FALSE; | |
6266 | |
6267 if (gdk_pointer_is_grabbed()) { | |
6268 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6269 gtk_grab_remove(widget); | |
6270 } | |
6271 | |
6272 if (!win->in_predrag && !win->in_drag) | |
6273 return FALSE; | |
6274 | |
6275 /* Disconnect the motion signal. */ | |
6276 if (win->drag_motion_signal) { | |
6277 g_signal_handler_disconnect(G_OBJECT(widget), | |
6278 win->drag_motion_signal); | |
6279 | |
6280 win->drag_motion_signal = 0; | |
6281 } | |
6282 | |
6283 /* | |
6284 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6285 * signal. | |
6286 */ | |
6287 if (win->in_predrag) { | |
6288 win->in_predrag = FALSE; | |
6289 | |
6290 if (win->drag_leave_signal) { | |
6291 g_signal_handler_disconnect(G_OBJECT(widget), | |
6292 win->drag_leave_signal); | |
6293 | |
6294 win->drag_leave_signal = 0; | |
6295 } | |
6296 } | |
6297 | |
6298 /* If we're not in drag... */ | |
6299 /* We're perfectly normal people! */ | |
6300 if (!win->in_drag) | |
6301 return FALSE; | |
6302 | |
6303 win->in_drag = FALSE; | |
6304 | |
6305 dnd_hints_hide_all(); | |
6306 | |
6307 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6308 | |
6309 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6310 | |
6311 if (dest_win == NULL) { | |
6312 /* If the current window doesn't have any other conversations, | |
6313 * there isn't much point transferring the conv to a new window. */ | |
6314 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6315 /* Make a new window to stick this to. */ | |
6316 dest_win = gaim_gtk_conv_window_new(); | |
6317 new_window = TRUE; | |
6318 } | |
6319 } | |
6320 | |
6321 if (dest_win == NULL) | |
6322 return FALSE; | |
6323 | |
6324 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6325 "conversation-dragging", win, dest_win); | |
6326 | |
6327 /* Get the destination page number. */ | |
6328 if (!new_window) | |
6329 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6330 e->x_root, e->y_root, &to_right); |
11581 | 6331 |
6332 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6333 | |
6334 if (win == dest_win) { | |
6335 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6336 } else { | |
6337 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6338 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6339 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6340 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6341 if (new_window) { | |
6342 gint win_width, win_height; | |
6343 | |
6344 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6345 &win_width, &win_height); | |
6346 | |
6347 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6348 e->x_root - (win_width / 2), | |
6349 e->y_root - (win_height / 2)); | |
6350 | |
6351 gaim_gtk_conv_window_show(dest_win); | |
6352 } | |
6353 } | |
6354 | |
6355 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6356 | |
6357 return TRUE; | |
6358 } | |
6359 | |
6360 | |
6361 static void | |
6362 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6363 gpointer user_data) | |
6364 { | |
6365 GaimGtkWindow *win; | |
6366 GaimConversation *conv; | |
6367 GaimGtkConversation *gtkconv; | |
6368 | |
6369 win = user_data; | |
6370 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6371 | |
6372 g_return_if_fail(conv != NULL); | |
6373 | |
6374 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6375 return; | |
6376 | |
6377 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6378 | |
6379 stop_anim(NULL, gtkconv); | |
6380 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6381 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6382 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6383 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6384 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6385 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6386 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6387 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6388 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6389 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6390 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6391 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6392 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6393 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6394 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6395 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6396 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6397 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6398 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6399 /* Nothing to do if there's only one tab in the window */ |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6400 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6401 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6402 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6403 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6404 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6405 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6406 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6407 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6408 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6409 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6410 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6411 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6412 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6413 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6414 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6415 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6416 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6417 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6418 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6419 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6420 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6421 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6422 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6423 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6424 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6425 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6426 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6427 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6428 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6429 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6430 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6431 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6432 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6433 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6434 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6435 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6436 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6437 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6438 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6439 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6440 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6441 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6442 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6443 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6444 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6445 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6446 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6447 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6448 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6449 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6450 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6451 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6452 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6453 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6454 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6455 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
6456 gaim_gtkconv_get_tab_at_xy(win, event->x_root, event->y_root, NULL)); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6457 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6458 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6459 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6460 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6461 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6462 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6463 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6464 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6465 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6466 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6467 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6468 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6469 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6470 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6471 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6472 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6473 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6474 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6475 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6476 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6477 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6478 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6479 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6480 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6481 gaim_separator(menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6482 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6483 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6484 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6485 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6486 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6487 G_CALLBACK(close_others_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6488 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6489 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6490 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6491 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6492 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6493 G_CALLBACK(close_window), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6494 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6495 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6496 } |
11581 | 6497 |
6498 static void | |
6499 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6500 gpointer user_data) | |
6501 { | |
6502 GaimGtkWindow *win; | |
6503 GaimConversation *conv; | |
6504 GaimGtkConversation *gtkconv; | |
6505 | |
6506 win = user_data; | |
6507 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6508 conv = gtkconv->active_conv; | |
6509 | |
6510 g_return_if_fail(conv != NULL); | |
6511 | |
6512 /* | |
6513 * Only set "unseen" to "none" if the window has focus | |
6514 */ | |
6515 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6516 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6517 |
6518 /* Update the menubar */ | |
6519 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6520 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
|
6521 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6522 |
11594 | 6523 generate_send_to_items(win); |
6524 | |
11604 | 6525 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6526 |
6527 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6528 gtkconv->make_sound); | |
6529 | |
6530 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6531 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6532 | |
6533 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6534 gtkconv->show_timestamps); | |
6535 | |
6536 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6537 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6538 gtkconv->u.im->show_icon); | |
11604 | 6539 |
11581 | 6540 /* |
6541 * We pause icons when they are not visible. If this icon should | |
6542 * be animated then start it back up again. | |
6543 */ | |
6544 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6545 (gtkconv->u.im->animate)) | |
6546 start_anim(NULL, gtkconv); | |
6547 } | |
6548 | |
6549 /************************************************************************** | |
6550 * GTK+ window ops | |
6551 **************************************************************************/ | |
6552 | |
6553 GList * | |
6554 gaim_gtk_conv_windows_get_list() | |
6555 { | |
6556 return window_list; | |
6557 } | |
6558 | |
6559 GaimGtkWindow * | |
6560 gaim_gtk_conv_window_new() | |
6561 { | |
6562 GaimGtkWindow *win; | |
6563 GtkPositionType pos; | |
6564 GtkWidget *testidea; | |
6565 GtkWidget *menubar; | |
6566 | |
6567 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6568 | |
6569 window_list = g_list_append(window_list, win); | |
6570 | |
6571 /* Create the window. */ | |
6572 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6573 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6574 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6575 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6576 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6577 | |
6578 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6579 G_CALLBACK(close_win_cb), win); | |
6580 | |
6581 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6582 G_CALLBACK(focus_win_cb), win); | |
6583 | |
6584 /* Create the notebook. */ | |
6585 win->notebook = gtk_notebook_new(); | |
6586 | |
6587 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6588 | |
6589 #if 0 | |
6590 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6591 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6592 #endif | |
6593 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6594 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6595 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6596 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6597 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6598 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6599 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6600 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6601 |
11581 | 6602 gtk_widget_show(win->notebook); |
6603 | |
6604 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6605 G_CALLBACK(before_switch_conv_cb), win); | |
6606 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6607 G_CALLBACK(switch_conv_cb), win); | |
6608 | |
6609 /* Setup the tab drag and drop signals. */ | |
6610 gtk_widget_add_events(win->notebook, | |
6611 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6612 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6613 G_CALLBACK(notebook_press_cb), win); | |
6614 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6615 G_CALLBACK(notebook_release_cb), win); | |
6616 | |
6617 testidea = gtk_vbox_new(FALSE, 0); | |
6618 | |
6619 /* Setup the menubar. */ | |
6620 menubar = setup_menubar(win); | |
6621 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6622 | |
6623 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6624 | |
6625 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6626 | |
6627 gtk_widget_show(testidea); | |
6628 | |
6629 return win; | |
6630 } | |
6631 | |
6632 void | |
6633 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6634 { | |
6635 window_list = g_list_remove(window_list, win); | |
6636 | |
11611 | 6637 if (win->gtkconvs) { |
6638 while (win->gtkconvs) { | |
6639 GList *nextgtk = win->gtkconvs->next; | |
6640 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6641 GList *nextcore = gtkconv->convs->next; | |
6642 GaimConversation *conv = gtkconv->convs->data; | |
6643 gaim_conversation_destroy(conv); | |
6644 if (!nextgtk && !nextcore) | |
6645 /* we'll end up invoking ourselves when we destroy our last child */ | |
6646 /* so don't destroy ourselves right now */ | |
6647 return; | |
6648 } | |
6649 return; | |
6650 } | |
11581 | 6651 gtk_widget_destroy(win->window); |
6652 | |
6653 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6654 | |
6655 g_free(win); | |
6656 } | |
6657 | |
6658 void | |
6659 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6660 { | |
6661 gtk_widget_show(win->window); | |
6662 } | |
6663 | |
6664 void | |
6665 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6666 { | |
6667 gtk_widget_hide(win->window); | |
6668 } | |
6669 | |
6670 void | |
6671 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6672 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6673 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6674 } |
6675 | |
6676 void | |
6677 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6678 { | |
6679 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6680 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6681 gtkconv->tab_cont)); | |
6682 } | |
6683 | |
6684 void | |
6685 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6686 { | |
6687 GaimConversation *conv = gtkconv->active_conv; | |
6688 GaimGtkConversation *focus_gtkconv; | |
6689 GtkWidget *tabby, *menu_tabby; | |
6690 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6691 GtkWidget *close_image; | |
6692 GaimConversationType conv_type; | |
6693 const char *name; | |
6694 const gchar *tmp_lab; | |
6695 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6696 gboolean tabs_side = FALSE; |
6697 gint angle = 0; | |
11581 | 6698 |
6699 name = gaim_conversation_get_name(conv); | |
6700 conv_type = gaim_conversation_get_type(conv); | |
6701 | |
6702 | |
6703 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6704 gtkconv->win = win; | |
6705 | |
11619 | 6706 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6707 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6708 tabs_side = TRUE; | |
6709 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6710 angle = 90; | |
6711 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6712 angle = 270; | |
6713 | |
6714 if (angle) | |
6715 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6716 else | |
6717 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6718 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6719 | |
6720 /* Close button. */ | |
6721 gtkconv->close = gtk_button_new(); | |
6722 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6723 if (gtk_check_version(2, 4, 2) == NULL) { | |
6724 /* Need to account for extra padding around the gtkbutton */ | |
6725 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6726 "focus-line-width", &focus_width, | |
6727 "focus-padding", &focus_pad, | |
6728 NULL); | |
6729 close_button_width += (focus_width + focus_pad) * 2; | |
6730 close_button_height += (focus_width + focus_pad) * 2; | |
6731 } | |
6732 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6733 close_button_width, close_button_height); | |
6734 | |
6735 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6736 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6737 gtk_widget_show(close_image); | |
6738 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6739 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6740 _("Close conversation"), NULL); | |
6741 | |
6742 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6743 G_CALLBACK(close_conv_cb), gtkconv); | |
6744 | |
11851 | 6745 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6746 /* |
6747 * I love Galeon. They have a fix for that stupid annoying visible | |
6748 * border bug. I love you guys! -- ChipX86 | |
6749 */ | |
11851 | 6750 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6751 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6752 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6753 #endif |
11581 | 6754 |
6755 /* Status icon. */ | |
6756 gtkconv->icon = gtk_image_new(); | |
6757 gtkconv->menu_icon = gtk_image_new(); | |
6758 update_tab_icon(conv); | |
6759 | |
6760 /* Tab label. */ | |
6761 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6762 |
11581 | 6763 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6764 if (!angle) |
6765 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6766 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6767 if (tabs_side) { |
6768 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6769 } | |
6770 if (angle) | |
6771 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6772 #endif |
6773 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6774 #if 0 | |
6775 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6776 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6777 #endif | |
6778 | |
6779 /* Pack it all together. */ | |
11619 | 6780 if (angle == 90) |
6781 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6782 else | |
6783 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6784 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6785 FALSE, FALSE, 0); | |
6786 | |
6787 gtk_widget_show_all(gtkconv->icon); | |
6788 gtk_widget_show_all(gtkconv->menu_icon); | |
6789 | |
6790 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6791 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6792 gtk_widget_show(gtkconv->tab_label); | |
6793 gtk_widget_show(gtkconv->menu_label); | |
6794 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6795 | |
11619 | 6796 if (angle == 90) |
6797 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6798 else | |
6799 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6800 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6801 gtk_widget_show(gtkconv->close); | |
6802 | |
6803 gtk_widget_show(tabby); | |
6804 gtk_widget_show(menu_tabby); | |
6805 | |
6806 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6807 gaim_gtkconv_update_buddy_icon(conv); | |
6808 | |
6809 /* Add this pane to the conversation's notebook. */ | |
6810 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6811 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6812 |
6813 | |
6814 gtk_widget_show(tab_cont); | |
6815 | |
6816 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6817 /* Er, bug in notebooks? Switch to the page manually. */ | |
6818 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6819 | |
6820 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6821 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6822 } else | |
6823 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6824 | |
6825 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6826 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6827 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6828 | |
6829 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6830 update_send_to_selection(win); |
11581 | 6831 } |
6832 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6833 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6834 private_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv, gboolean destroy_empty) |
11581 | 6835 { |
6836 unsigned int index; | |
6837 GaimConversationType conv_type; | |
6838 | |
6839 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6840 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6841 | |
6842 g_object_ref(gtkconv->tab_cont); | |
6843 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6844 | |
6845 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6846 | |
6847 /* go back to tabless if need be */ | |
6848 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6849 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6850 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6851 } | |
6852 | |
6853 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6854 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6855 if (destroy_empty && !win->gtkconvs) |
11582 | 6856 gaim_gtk_conv_window_destroy(win); |
11581 | 6857 } |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6858 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6859 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6860 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6861 private_remove_gtkconv(win, gtkconv, TRUE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6862 } |
11581 | 6863 |
6864 GaimGtkConversation * | |
6865 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
6866 { | |
6867 GtkWidget *tab_cont; | |
6868 | |
6869 if (index == -1) | |
6870 index = 0; | |
6871 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 6872 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 6873 } |
6874 | |
6875 GaimGtkConversation * | |
6876 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
6877 { | |
6878 int index; | |
6879 GtkWidget *tab_cont; | |
6880 | |
6881 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
6882 if (index == -1) | |
6883 index = 0; | |
6884 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
6885 if (!tab_cont) | |
6886 return NULL; | |
6887 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
6888 } | |
6889 | |
6890 | |
6891 GaimConversation * | |
6892 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
6893 { | |
6894 GaimGtkConversation *gtkconv; | |
6895 | |
6896 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
6897 return gtkconv ? gtkconv->active_conv : NULL; | |
6898 } | |
6899 | |
6900 gboolean | |
6901 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
6902 { | |
6903 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
6904 } | |
6905 | |
6906 gboolean | |
6907 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
6908 { | |
6909 gboolean has_focus = FALSE; | |
6910 | |
6911 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
6912 | |
6913 return has_focus; | |
6914 } | |
6915 | |
6916 GaimGtkWindow * | |
6917 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
6918 { | |
6919 GaimGtkWindow *win; | |
6920 GdkWindow *gdkwin; | |
6921 GList *l; | |
6922 | |
6923 gdkwin = gdk_window_at_pointer(&x, &y); | |
6924 | |
6925 if (gdkwin) | |
6926 gdkwin = gdk_window_get_toplevel(gdkwin); | |
6927 | |
6928 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
6929 win = l->data; | |
6930 | |
6931 if (gdkwin == win->window->window) | |
6932 return win; | |
6933 } | |
6934 | |
6935 return NULL; | |
6936 } | |
6937 | |
6938 GList * | |
6939 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
6940 { | |
6941 return win->gtkconvs; | |
6942 } | |
6943 | |
6944 guint | |
6945 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
6946 { | |
6947 return g_list_length(win->gtkconvs); | |
6948 } | |
6949 | |
6950 GaimGtkWindow * | |
6951 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
6952 { | |
6953 GList *wins, *convs; | |
6954 GaimGtkWindow *win; | |
6955 GaimGtkConversation *conv; | |
6956 | |
6957 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6958 return NULL; | |
6959 | |
6960 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
6961 win = wins->data; | |
6962 | |
6963 for (convs = win->gtkconvs; | |
6964 convs != NULL; | |
6965 convs = convs->next) { | |
6966 | |
6967 conv = convs->data; | |
6968 | |
6969 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6970 return win; | |
6971 } | |
6972 } | |
6973 | |
6974 return NULL; | |
6975 } | |
6976 | |
6977 GaimGtkWindow * | |
6978 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
6979 { | |
6980 GList *wins, *convs; | |
6981 GaimGtkWindow *win; | |
6982 GaimGtkConversation *conv; | |
6983 | |
6984 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6985 return NULL; | |
6986 | |
6987 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6988 wins != NULL; | |
6989 wins = wins->prev) { | |
6990 | |
6991 win = wins->data; | |
6992 | |
6993 for (convs = win->gtkconvs; | |
6994 convs != NULL; | |
6995 convs = convs->next) { | |
6996 | |
6997 conv = convs->data; | |
6998 | |
6999 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7000 return win; | |
7001 } | |
7002 } | |
7003 | |
7004 return NULL; | |
7005 } | |
7006 | |
7007 | |
7008 /************************************************************************** | |
7009 * Conversation placement functions | |
7010 **************************************************************************/ | |
7011 typedef struct | |
7012 { | |
7013 char *id; | |
7014 char *name; | |
7015 GaimConvPlacementFunc fnc; | |
7016 | |
7017 } ConvPlacementData; | |
7018 | |
7019 static GList *conv_placement_fncs = NULL; | |
7020 static GaimConvPlacementFunc place_conv = NULL; | |
7021 | |
7022 /* This one places conversations in the last made window. */ | |
7023 static void | |
7024 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7025 { | |
7026 GaimGtkWindow *win; | |
7027 | |
7028 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7029 win = l ? l->data : NULL;; | |
7030 | |
7031 if (win == NULL) { | |
7032 win = gaim_gtk_conv_window_new(); | |
7033 | |
7034 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7035 gaim_gtk_conv_window_show(win); | |
7036 } else { | |
7037 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7038 } | |
7039 } | |
7040 | |
7041 /* This one places conversations in the last made window of the same type. */ | |
7042 static void | |
7043 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7044 { | |
7045 GaimGtkWindow *win; | |
7046 | |
7047 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7048 | |
7049 if (win == NULL) { | |
7050 win = gaim_gtk_conv_window_new(); | |
7051 | |
7052 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7053 gaim_gtk_conv_window_show(win); | |
7054 } else | |
7055 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7056 } | |
7057 | |
7058 /* This one places each conversation in its own window. */ | |
7059 static void | |
7060 conv_placement_new_window(GaimGtkConversation *conv) | |
7061 { | |
7062 GaimGtkWindow *win; | |
7063 | |
7064 win = gaim_gtk_conv_window_new(); | |
7065 | |
7066 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7067 | |
7068 gaim_gtk_conv_window_show(win); | |
7069 } | |
7070 | |
7071 static GaimGroup * | |
7072 conv_get_group(GaimGtkConversation *conv) | |
7073 { | |
7074 GaimGroup *group = NULL; | |
7075 | |
7076 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7077 GaimBuddy *buddy; | |
7078 | |
7079 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7080 gaim_conversation_get_name(conv->active_conv)); | |
7081 | |
7082 if (buddy != NULL) | |
12088 | 7083 group = gaim_buddy_get_group(buddy); |
11581 | 7084 |
7085 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7086 GaimChat *chat; | |
7087 | |
7088 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7089 gaim_conversation_get_name(conv->active_conv)); | |
7090 | |
7091 if (chat != NULL) | |
7092 group = gaim_chat_get_group(chat); | |
7093 } | |
7094 | |
7095 return group; | |
7096 } | |
7097 | |
7098 /* | |
7099 * This groups things by, well, group. Buddies from groups will always be | |
7100 * grouped together, and a buddy from a group not belonging to any currently | |
7101 * open windows will get a new window. | |
7102 */ | |
7103 static void | |
7104 conv_placement_by_group(GaimGtkConversation *conv) | |
7105 { | |
7106 GaimConversationType type; | |
7107 GaimGroup *group = NULL; | |
7108 GList *wl, *cl; | |
7109 | |
7110 type = gaim_conversation_get_type(conv->active_conv); | |
7111 | |
7112 group = conv_get_group(conv); | |
7113 | |
7114 /* Go through the list of IMs and find one with this group. */ | |
7115 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7116 GaimGtkWindow *win2; | |
7117 GaimGtkConversation *conv2; | |
7118 GaimGroup *group2 = NULL; | |
7119 | |
7120 win2 = wl->data; | |
7121 | |
7122 for (cl = win2->gtkconvs; | |
7123 cl != NULL; | |
7124 cl = cl->next) { | |
7125 conv2 = cl->data; | |
7126 | |
7127 group2 = conv_get_group(conv2); | |
7128 | |
7129 if (group == group2) { | |
7130 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7131 | |
7132 return; | |
7133 } | |
7134 } | |
7135 } | |
7136 | |
7137 /* Make a new window. */ | |
7138 conv_placement_new_window(conv); | |
7139 } | |
7140 | |
7141 /* This groups things by account. Otherwise, the same semantics as above */ | |
7142 static void | |
7143 conv_placement_by_account(GaimGtkConversation *conv) | |
7144 { | |
7145 GaimConversationType type; | |
7146 GList *wins, *convs; | |
7147 GaimAccount *account; | |
7148 | |
7149 account = gaim_conversation_get_account(conv->active_conv); | |
7150 type = gaim_conversation_get_type(conv->active_conv); | |
7151 | |
7152 /* Go through the list of IMs and find one with this group. */ | |
7153 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7154 GaimGtkWindow *win2; | |
7155 GaimGtkConversation *conv2; | |
7156 | |
7157 win2 = wins->data; | |
7158 | |
7159 for (convs = win2->gtkconvs; | |
7160 convs != NULL; | |
7161 convs = convs->next) { | |
7162 conv2 = convs->data; | |
7163 | |
7164 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7165 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7166 return; | |
7167 } | |
7168 } | |
7169 } | |
7170 | |
7171 /* Make a new window. */ | |
7172 conv_placement_new_window(conv); | |
7173 } | |
7174 | |
7175 static ConvPlacementData * | |
7176 get_conv_placement_data(const char *id) | |
7177 { | |
7178 ConvPlacementData *data = NULL; | |
7179 GList *n; | |
7180 | |
7181 for (n = conv_placement_fncs; n; n = n->next) { | |
7182 data = n->data; | |
7183 if (!strcmp(data->id, id)) | |
7184 return data; | |
7185 } | |
7186 | |
7187 return NULL; | |
7188 } | |
7189 | |
7190 static void | |
7191 add_conv_placement_fnc(const char *id, const char *name, | |
7192 GaimConvPlacementFunc fnc) | |
7193 { | |
7194 ConvPlacementData *data; | |
7195 | |
7196 data = g_new(ConvPlacementData, 1); | |
7197 | |
7198 data->id = g_strdup(id); | |
7199 data->name = g_strdup(name); | |
7200 data->fnc = fnc; | |
7201 | |
7202 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7203 } | |
7204 | |
7205 static void | |
7206 ensure_default_funcs(void) | |
7207 { | |
7208 if (conv_placement_fncs == NULL) { | |
7209 add_conv_placement_fnc("last", _("Last created window"), | |
7210 conv_placement_last_created_win); | |
7211 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7212 conv_placement_last_created_win_type); | |
7213 add_conv_placement_fnc("new", _("New window"), | |
7214 conv_placement_new_window); | |
7215 add_conv_placement_fnc("group", _("By group"), | |
7216 conv_placement_by_group); | |
7217 add_conv_placement_fnc("account", _("By account"), | |
7218 conv_placement_by_account); | |
7219 } | |
7220 } | |
7221 | |
7222 GList * | |
7223 gaim_gtkconv_placement_get_options(void) | |
7224 { | |
7225 GList *n, *list = NULL; | |
7226 ConvPlacementData *data; | |
7227 | |
7228 ensure_default_funcs(); | |
7229 | |
7230 for (n = conv_placement_fncs; n; n = n->next) { | |
7231 data = n->data; | |
7232 list = g_list_append(list, data->name); | |
7233 list = g_list_append(list, data->id); | |
7234 } | |
7235 | |
7236 return list; | |
7237 } | |
7238 | |
7239 | |
7240 void | |
7241 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7242 GaimConvPlacementFunc fnc) | |
7243 { | |
7244 g_return_if_fail(id != NULL); | |
7245 g_return_if_fail(name != NULL); | |
7246 g_return_if_fail(fnc != NULL); | |
7247 | |
7248 ensure_default_funcs(); | |
7249 | |
7250 add_conv_placement_fnc(id, name, fnc); | |
7251 } | |
7252 | |
7253 void | |
7254 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7255 { | |
7256 ConvPlacementData *data = get_conv_placement_data(id); | |
7257 | |
7258 if (data == NULL) | |
7259 return; | |
7260 | |
7261 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7262 | |
7263 g_free(data->id); | |
7264 g_free(data->name); | |
7265 g_free(data); | |
7266 } | |
7267 | |
7268 const char * | |
7269 gaim_gtkconv_placement_get_name(const char *id) | |
7270 { | |
7271 ConvPlacementData *data; | |
7272 | |
7273 ensure_default_funcs(); | |
7274 | |
7275 data = get_conv_placement_data(id); | |
7276 | |
7277 if (data == NULL) | |
7278 return NULL; | |
7279 | |
7280 return data->name; | |
7281 } | |
7282 | |
7283 GaimConvPlacementFunc | |
7284 gaim_gtkconv_placement_get_fnc(const char *id) | |
7285 { | |
7286 ConvPlacementData *data; | |
7287 | |
7288 ensure_default_funcs(); | |
7289 | |
7290 data = get_conv_placement_data(id); | |
7291 | |
7292 if (data == NULL) | |
7293 return NULL; | |
7294 | |
7295 return data->fnc; | |
7296 } | |
7297 | |
7298 void | |
7299 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7300 { | |
7301 g_return_if_fail(func != NULL); | |
7302 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7303 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7304 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7305 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7306 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7307 place_conv = NULL; |
11581 | 7308 } |
7309 | |
7310 GaimConvPlacementFunc | |
7311 gaim_gtkconv_placement_get_current_func(void) | |
7312 { | |
7313 return place_conv; | |
7314 } | |
7315 | |
7316 void | |
7317 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7318 { | |
7319 if (place_conv) | |
7320 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7321 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7322 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7323 } |