Mercurial > pidgin
annotate src/gtkconv.c @ 12115:e9790eb93216
[gaim-migrate @ 14415]
quoth charkins:
" This patch has a few small fixes for the visibility
stuff in gtkblist.c.
First, tracking of the ICONIFIED state of the blist was
removed. This was intended to allow the blist to
"remember" if it was minimized between restarts.
Unfortunately, this is not possible because the
ICONIFIED state gets set when the blist is on a
different desktop with many window managers.
Second, while talking about the ICONIFIED issue on
#gtk@GIMPNet, muntyan_ asked about a bug where the
blist would get shown on an account re-connect with
1.5.0. Luke mentioned something about this with cvs as
well. This patch introduces a check in
gaim_gtk_blist_show() to prevent the window from being
shown if it already exists and is visible.
Third, sadrul pointed me to a one-line fix for the
missing blist on startup. I added a second line to make
sure the blist restores its proper size as well.
Finally, when the last visibility manager is removed,
gaim will now minimize the blist if it was previously
hidden, rather than showing it. This could prevent a
race condition with out-of-process applets, preventing
gaim from maintaining the visibility state properly
between restarts.
This was 'cvs diff'ed against the last available anon
cvs from Friday. Hopefully it'll apply cleanly."
it did.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 16 Nov 2005 17:55:26 +0000 |
parents | 8c6ea55c84a4 |
children | e75ef7aa913e |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1 /** |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
2 * @file gtkconv.c GTK+ Conversation API |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3 * @ingroup gtkui |
4359 | 4 * |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
5 * gaim |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
6 * |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
10 * |
4359 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
28 |
4359 | 29 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
30 # include <X11/Xlib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
31 #endif |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
32 |
4359 | 33 #ifdef USE_GTKSPELL |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
34 # include <gtkspell/gtkspell.h> |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
35 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
36 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
37 # endif |
4359 | 38 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
39 |
4359 | 40 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
41 |
9699 | 42 #include "account.h" |
9130 | 43 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
44 #include "debug.h" |
6982 | 45 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
46 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
47 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
48 #include "prpl.h" |
6038 | 49 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
50 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
52 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
53 #include "gtkblist.h" |
5717 | 54 #include "gtkconv.h" |
11583 | 55 #include "gtkconvwin.h" |
9709 | 56 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
57 #include "gtkimhtml.h" |
8317 | 58 #include "gtkimhtmltoolbar.h" |
7431 | 59 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
60 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
61 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
62 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
63 #include "gtkprivacy.h" |
11525 | 64 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
65 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
66 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
67 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
69 |
11731 | 70 #define SEND_COLOR "#001f41" |
71 #define RECV_COLOR "#a63802" | |
7854 | 72 |
10108 | 73 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
74 | |
75 /* These colors come from the default GNOME palette */ | |
76 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
77 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
78 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
79 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
80 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
81 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
84 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
86 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
94 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
95 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
96 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
97 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
98 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 99 }; |
6291 | 100 |
4359 | 101 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
102 | |
11581 | 103 typedef struct { |
4359 | 104 GtkWidget *window; |
105 | |
106 GtkWidget *entry; | |
107 GtkWidget *message; | |
108 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
109 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
110 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
111 } InviteBuddyInfo; |
4359 | 112 |
113 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
114 static GtkWidget *warn_close_dialog = NULL; |
4359 | 115 |
11594 | 116 static gboolean update_send_to_selection(GaimGtkWindow *win); |
117 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 118 |
4359 | 119 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 120 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 121 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
122 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
123 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 124 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 125 static gboolean tab_complete(GaimConversation *conv); |
11604 | 126 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 127 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 128 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
129 static char *item_factory_translate_func (const char *path, gpointer func_data); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
130 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
4359 | 131 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
132 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
133 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
134 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
135 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
136 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
137 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
138 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
139 (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
140 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
141 /* The colors are chosen to look fine on white; we should never have to darken */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
142 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
143 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
144 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
145 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
146 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
147 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
148 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
149 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
150 |
4359 | 151 /************************************************************************** |
152 * Callbacks | |
153 **************************************************************************/ | |
10971 | 154 |
4359 | 155 static gint |
10810 | 156 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 157 { |
10810 | 158 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 159 |
10810 | 160 l = list; |
161 while (l) { | |
162 GaimConversation *conv = l->data; | |
163 gaim_conversation_destroy(conv); | |
164 l = l->next; | |
165 } | |
11508 | 166 |
10810 | 167 g_list_free(list); |
11508 | 168 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
169 return TRUE; |
4359 | 170 } |
171 | |
8914 | 172 static gboolean |
10810 | 173 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 174 { |
10810 | 175 GaimConversation *conv = gtkconv->active_conv; |
11508 | 176 |
8914 | 177 if (!GTK_WIDGET_VISIBLE(w)) |
178 return FALSE; | |
179 | |
180 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
181 return FALSE; | |
182 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
183 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
184 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
185 * if there is only one conversation in the window. This way we'll be setting new windows to the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
186 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
187 /* I think that the above justification is not the majority, and that the new tab resizing should |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
188 * negate it anyway. --luke */ |
11338 | 189 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 190 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
191 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
192 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
193 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
194 } |
8914 | 195 if (w == gtkconv->entry) |
196 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
197 } | |
11338 | 198 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 199 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
200 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
201 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
202 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
203 } |
8914 | 204 if (w == gtkconv->entry) |
205 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
206 } | |
207 | |
208 return FALSE; | |
209 } | |
210 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
211 static void |
10810 | 212 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
213 { |
10810 | 214 GaimConversation *conv = c->active_conv; |
11508 | 215 |
10665 | 216 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
217 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
218 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
219 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
220 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
221 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
222 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
223 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
224 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
225 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
226 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
227 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline") != GTK_IMHTML(c->entry)->edit.underline) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
228 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
229 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
230 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
231 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
232 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
233 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
234 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
235 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
236 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
237 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
238 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
242 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
243 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
244 fg_color.blue / 256); |
8061 | 245 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
251 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 g_free(color); |
8677 | 267 |
9025 | 268 |
10665 | 269 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 270 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
271 else | |
272 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 273 } |
274 } | |
9130 | 275 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
276 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
277 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
278 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
279 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
280 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
281 |
9130 | 282 static const char * |
283 gaim_gtk_get_cmd_prefix(void) | |
284 { | |
285 return "/"; | |
286 } | |
287 | |
9167 | 288 static GaimCmdRet |
9829 | 289 say_command_cb(GaimConversation *conv, |
290 const char *cmd, char **args, char **error, void *data) | |
291 { | |
11338 | 292 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 293 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 294 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 295 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
296 | |
297 return GAIM_CMD_RET_OK; | |
298 } | |
299 | |
300 static GaimCmdRet | |
9167 | 301 me_command_cb(GaimConversation *conv, |
9597 | 302 const char *cmd, char **args, char **error, void *data) |
9167 | 303 { |
304 char *tmp; | |
305 | |
306 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 307 |
11338 | 308 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 309 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 310 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 311 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
312 | |
313 g_free(tmp); | |
314 return GAIM_CMD_RET_OK; | |
315 } | |
316 | |
9212 | 317 static GaimCmdRet |
318 debug_command_cb(GaimConversation *conv, | |
9597 | 319 const char *cmd, char **args, char **error, void *data) |
9212 | 320 { |
321 char *tmp, *markup; | |
322 GaimCmdStatus status; | |
323 | |
324 if (!g_ascii_strcasecmp(args[0], "version")) { | |
325 tmp = g_strdup_printf(_("me is using Gaim v%s."), VERSION); | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
326 markup = g_markup_escape_text(tmp, -1); |
9212 | 327 |
328 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
329 | |
330 g_free(tmp); | |
331 g_free(markup); | |
332 return status; | |
333 } else { | |
334 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
335 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
336 return GAIM_CMD_STATUS_OK; | |
337 } | |
338 } | |
339 | |
9213 | 340 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
341 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
342 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
343 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
344 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
345 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
346 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
347 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
348 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
349 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
350 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
351 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
352 static GaimCmdRet |
9213 | 353 help_command_cb(GaimConversation *conv, |
9597 | 354 const char *cmd, char **args, char **error, void *data) |
9213 | 355 { |
9597 | 356 GList *l, *text; |
9213 | 357 GString *s; |
9597 | 358 |
359 if (args[0] != NULL) { | |
360 s = g_string_new(""); | |
361 text = gaim_cmd_help(conv, args[0]); | |
362 | |
363 if (text) { | |
364 for (l = text; l; l = l->next) | |
365 if (l->next) | |
9816 | 366 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 367 else |
9816 | 368 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 369 } else { |
370 g_string_append(s, _("No such command (in this context).")); | |
371 } | |
372 } else { | |
373 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
374 "The following commands are available in this context:\n")); | |
375 | |
376 text = gaim_cmd_list(conv); | |
377 for (l = text; l; l = l->next) | |
9213 | 378 if (l->next) |
9597 | 379 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 380 else |
9597 | 381 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 382 } |
383 | |
384 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
385 g_string_free(s, TRUE); | |
386 | |
387 return GAIM_CMD_STATUS_OK; | |
388 } | |
389 | |
4359 | 390 static void |
9374 | 391 send_history_add(GaimConversation *conv, const char *message) |
392 { | |
393 GList *first; | |
394 | |
395 first = g_list_first(conv->send_history); | |
396 | |
397 if (first->data) | |
398 g_free(first->data); | |
399 | |
400 first->data = g_strdup(message); | |
401 | |
402 conv->send_history = g_list_prepend(first, NULL); | |
403 } | |
404 | |
9832 | 405 static gboolean |
406 check_for_and_do_command(GaimConversation *conv) | |
407 { | |
408 GaimGtkConversation *gtkconv; | |
409 char *cmd; | |
410 const char *prefix; | |
411 GaimAccount *account; | |
412 GtkTextIter start; | |
413 | |
414 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
415 account = gaim_conversation_get_account(conv); | |
416 prefix = gaim_gtk_get_cmd_prefix(); | |
417 | |
418 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
419 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
420 | |
421 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
422 && !gtk_text_iter_get_child_anchor(&start)) { | |
423 GaimCmdStatus status; | |
424 char *error, *cmdline, *markup, *send_history; | |
425 GtkTextIter end; | |
426 | |
427 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
428 send_history_add(conv, send_history); | |
429 g_free(send_history); | |
430 | |
431 cmdline = cmd + strlen(prefix); | |
432 | |
433 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
434 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
435 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
436 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
437 g_free(cmd); | |
438 g_free(markup); | |
439 | |
440 switch (status) { | |
441 case GAIM_CMD_STATUS_OK: | |
442 return TRUE; | |
443 case GAIM_CMD_STATUS_NOT_FOUND: | |
444 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
445 gaim_conversation_write(conv, "", _("No such command."), | |
446 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
447 | |
448 return TRUE; | |
449 } | |
450 return FALSE; | |
451 case GAIM_CMD_STATUS_WRONG_ARGS: | |
452 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
453 "to that command."), | |
454 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
455 return TRUE; | |
456 case GAIM_CMD_STATUS_FAILED: | |
457 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
458 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
459 if(error) | |
460 g_free(error); | |
461 return TRUE; | |
462 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 463 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 464 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 465 GAIM_MESSAGE_NO_LOG, time(NULL)); |
466 else | |
10843 | 467 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 468 GAIM_MESSAGE_NO_LOG, time(NULL)); |
469 return TRUE; | |
470 case GAIM_CMD_STATUS_WRONG_PRPL: | |
471 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
472 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
473 return TRUE; | |
474 } | |
475 } | |
476 | |
477 g_free(cmd); | |
478 return FALSE; | |
479 } | |
480 | |
9374 | 481 static void |
10810 | 482 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 483 { |
10810 | 484 GaimConversation *conv = gtkconv->active_conv; |
8655 | 485 GaimAccount *account; |
8677 | 486 GaimConnection *gc; |
8448 | 487 char *buf, *clean; |
4359 | 488 |
8655 | 489 account = gaim_conversation_get_account(conv); |
9130 | 490 |
9471 | 491 if (!gaim_account_is_connected(account)) |
492 return; | |
493 | |
11338 | 494 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 495 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 496 return; |
497 | |
9832 | 498 if (check_for_and_do_command(conv)) { |
499 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
500 return; | |
9130 | 501 } |
502 | |
8442 | 503 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 504 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 505 |
4359 | 506 gtk_widget_grab_focus(gtkconv->entry); |
507 | |
8448 | 508 if (strlen(clean) == 0) { |
509 g_free(clean); | |
4359 | 510 return; |
511 } | |
512 | |
8677 | 513 gc = gaim_account_get_connection(account); |
10665 | 514 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 515 char **bufs; |
516 int i; | |
517 | |
518 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
519 for (i = 0; bufs[i]; i++) { | |
9374 | 520 send_history_add(conv, bufs[i]); |
11338 | 521 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 522 gaim_conv_im_send(GAIM_CONV_IM(conv), bufs[i]); |
11338 | 523 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 524 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), bufs[i]); |
525 } | |
526 | |
527 g_strfreev(bufs); | |
528 | |
529 } else { | |
9374 | 530 send_history_add(conv, buf); |
11338 | 531 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 532 gaim_conv_im_send(GAIM_CONV_IM(conv), buf); |
11338 | 533 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 534 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), buf); |
535 } | |
4359 | 536 |
8677 | 537 g_free(clean); |
4359 | 538 g_free(buf); |
539 | |
8061 | 540 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 541 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 542 } |
543 | |
544 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
545 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 546 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
547 GaimAccount *account; |
4359 | 548 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
549 GaimConversation *conv = gtkconv->active_conv; |
4359 | 550 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
551 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
552 name = gaim_conversation_get_name(conv); |
7879 | 553 |
11338 | 554 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 555 GaimBuddy *b; |
556 | |
557 b = gaim_find_buddy(account, name); | |
558 if (b != NULL) | |
9730 | 559 gaim_gtkdialogs_remove_buddy(b); |
7859 | 560 else if (account != NULL && gaim_account_is_connected(account)) |
561 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 562 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 563 GaimChat *c; |
564 | |
565 c = gaim_blist_find_chat(account, name); | |
566 if (c != NULL) | |
9730 | 567 gaim_gtkdialogs_remove_chat(c); |
7859 | 568 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 569 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 570 } |
4359 | 571 |
572 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
573 } | |
574 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
575 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 576 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
577 GaimConversation *conv = gtkconv->active_conv; |
7975 | 578 GaimPluginProtocolInfo *prpl_info = NULL; |
579 GaimConnection *gc; | |
580 | |
581 if ((gc = gaim_conversation_get_gc(conv))) { | |
582 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
583 | |
584 /* | |
585 * If there are special needs for getting info on users in | |
586 * buddy chat "rooms"... | |
587 */ | |
588 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
589 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
590 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
591 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
592 } |
7975 | 593 else |
594 prpl_info->get_info(gc, who); | |
595 } | |
596 } | |
597 | |
598 | |
4359 | 599 static void |
10810 | 600 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 601 { |
10810 | 602 GaimConversation *conv = gtkconv->active_conv; |
4359 | 603 |
11338 | 604 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 605 serv_get_info(gaim_conversation_get_gc(conv), |
606 gaim_conversation_get_name(conv)); | |
607 | |
608 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 609 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 610 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
611 GaimGtkChatPane *gtkchat; |
4359 | 612 GtkTreeIter iter; |
613 GtkTreeModel *model; | |
614 GtkTreeSelection *sel; | |
9554 | 615 char *name; |
4359 | 616 |
617 gtkchat = gtkconv->u.chat; | |
618 | |
619 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
620 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
621 | |
622 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 623 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 624 else |
625 return; | |
626 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
627 chat_do_info(gtkconv, name); |
9554 | 628 g_free(name); |
4359 | 629 } |
630 } | |
631 | |
632 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
633 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 634 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
635 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
636 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
637 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
638 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
639 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
640 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
641 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 642 |
643 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
644 } | |
645 | |
646 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
647 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 648 { |
649 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
650 GaimGtkConversation *gtkconv; |
4359 | 651 |
652 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
653 | |
654 if (resp == GTK_RESPONSE_OK) { | |
655 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
656 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
657 | |
10113 | 658 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 659 return; |
660 | |
661 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
662 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 663 message, buddy); |
664 } | |
665 | |
666 gtk_widget_destroy(invite_dialog); | |
667 invite_dialog = NULL; | |
668 | |
669 g_free(info); | |
670 } | |
671 | |
672 static void | |
9909 | 673 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
674 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
675 { | |
676 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
677 const char *convprotocol; | |
678 | |
679 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
680 | |
681 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
682 { | |
683 GaimBlistNode *node = NULL; | |
684 GaimBuddy *buddy; | |
685 | |
686 memcpy(&node, sd->data, sizeof(node)); | |
687 | |
688 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
689 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
690 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
691 buddy = (GaimBuddy *)node; | |
692 else | |
693 return; | |
694 | |
695 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
696 { | |
697 gaim_notify_error(NULL, NULL, | |
698 _("That buddy is not on the same protocol as this " | |
10843 | 699 "chat."), NULL); |
9909 | 700 } |
701 else | |
702 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
703 | |
704 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
705 } | |
706 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
707 { | |
708 char *protocol = NULL; | |
709 char *username = NULL; | |
710 GaimAccount *account; | |
711 | |
11137 | 712 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 713 &protocol, &username, NULL)) |
714 { | |
715 if (account == NULL) | |
716 { | |
717 gaim_notify_error(NULL, NULL, | |
718 _("You are not currently signed on with an account that " | |
719 "can invite that buddy."), NULL); | |
720 } | |
721 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
722 { | |
723 gaim_notify_error(NULL, NULL, | |
724 _("That buddy is not on the same protocol as this " | |
10843 | 725 "chat."), NULL); |
9909 | 726 } |
727 else | |
728 { | |
729 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
730 } | |
731 } | |
732 | |
733 if (username != NULL) g_free(username); | |
734 if (protocol != NULL) g_free(protocol); | |
735 | |
736 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
737 } | |
738 } | |
739 | |
740 static const GtkTargetEntry dnd_targets[] = | |
741 { | |
742 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
743 {"application/x-im-contact", 0, 1} | |
744 }; | |
745 | |
746 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
747 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 748 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
749 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
750 InviteBuddyInfo *info = NULL; |
4359 | 751 |
752 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
753 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
754 GaimGtkWindow *gtkwin; |
4359 | 755 GtkWidget *label; |
756 GtkWidget *vbox, *hbox; | |
757 GtkWidget *table; | |
758 GtkWidget *img; | |
759 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
760 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 761 GTK_ICON_SIZE_DIALOG); |
4359 | 762 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
763 info = g_new0(InviteBuddyInfo, 1); |
4359 | 764 info->conv = conv; |
765 | |
11581 | 766 gc = gaim_conversation_get_gc(conv); |
767 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 768 |
769 /* Create the new dialog. */ | |
770 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 771 _("Invite Buddy Into Chat Room"), |
7879 | 772 GTK_WINDOW(gtkwin->window), 0, |
773 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
774 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 775 |
776 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 777 GTK_RESPONSE_OK); |
11243 | 778 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 779 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
780 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
781 | |
9909 | 782 info->window = GTK_WIDGET(invite_dialog); |
783 | |
4359 | 784 /* Setup the outside spacing. */ |
785 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
786 | |
11243 | 787 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
788 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 789 |
790 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 791 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 792 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
793 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
794 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
795 | |
796 /* Setup the right vbox. */ | |
797 vbox = gtk_vbox_new(FALSE, 0); | |
798 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
799 | |
800 /* Put our happy label in it. */ | |
801 label = gtk_label_new(_("Please enter the name of the user you wish " | |
802 "to invite, along with an optional invite " | |
803 "message.")); | |
804 gtk_widget_set_size_request(label, 350, -1); | |
805 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
806 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
807 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
808 | |
809 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 810 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 811 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
812 | |
813 /* Setup the table we're going to use to lay stuff out. */ | |
814 table = gtk_table_new(2, 2, FALSE); | |
11243 | 815 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
816 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
817 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 818 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
819 | |
820 /* Now the Buddy label */ | |
821 label = gtk_label_new(NULL); | |
822 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
823 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
824 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
825 | |
826 /* Now the Buddy drop-down entry field. */ | |
827 info->entry = gtk_combo_new(); | |
828 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
829 gtk_entry_set_activates_default( | |
830 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
831 | |
832 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
833 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
834 | |
835 /* Fill in the names. */ | |
836 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
837 generate_invite_user_names(gc)); | |
838 | |
839 | |
840 /* Now the label for "Message" */ | |
841 label = gtk_label_new(NULL); | |
842 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
843 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
844 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
845 | |
846 | |
847 /* And finally, the Message entry field. */ | |
848 info->message = gtk_entry_new(); | |
849 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
850 | |
851 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
852 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
853 | |
854 /* Connect the signals. */ | |
855 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
856 G_CALLBACK(do_invite), info); | |
9909 | 857 /* Setup drag-and-drop */ |
858 gtk_drag_dest_set(info->window, | |
859 GTK_DEST_DEFAULT_MOTION | | |
860 GTK_DEST_DEFAULT_DROP, | |
861 dnd_targets, | |
862 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
863 GDK_ACTION_COPY); | |
864 gtk_drag_dest_set(info->entry, | |
865 GTK_DEST_DEFAULT_MOTION | | |
866 GTK_DEST_DEFAULT_DROP, | |
867 dnd_targets, | |
868 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
869 GDK_ACTION_COPY); | |
870 | |
871 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
872 G_CALLBACK(invite_dnd_recv), info); | |
873 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
874 G_CALLBACK(invite_dnd_recv), info); | |
875 | |
4359 | 876 } |
877 | |
878 gtk_widget_show_all(invite_dialog); | |
879 | |
880 if (info != NULL) | |
881 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
882 } | |
883 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
884 static void |
7748 | 885 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
886 { | |
9714 | 887 gaim_gtkdialogs_im(); |
7748 | 888 } |
889 | |
890 static void | |
9504 | 891 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 892 { |
9504 | 893 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 894 FILE *fp; |
895 const char *name; | |
10849 | 896 gchar *text; |
9489 | 897 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
898 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 899 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 900 return; |
901 } | |
902 | |
903 name = gaim_conversation_get_name(conv); | |
10849 | 904 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 905 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 906 |
907 text = gtk_imhtml_get_markup( | |
908 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
909 fprintf(fp, "%s", text); | |
910 g_free(text); | |
911 | |
912 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 913 fclose(fp); |
914 } | |
915 | |
10849 | 916 /* |
917 * It would be kinda cool if this gave the option of saving a | |
918 * plaintext v. HTML file. | |
919 */ | |
9489 | 920 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
921 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
922 { |
11581 | 923 GaimGtkWindow *win = data; |
924 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 925 gchar *buf; |
926 | |
927 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 928 |
10849 | 929 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
930 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 931 |
932 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
933 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
934 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
935 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
936 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
937 { |
11581 | 938 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
939 GaimConversation *conv; |
9917 | 940 GaimLogType type; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
941 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
942 GaimAccount *account; |
10845 | 943 GSList *buddies, *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
944 |
11581 | 945 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
946 |
11338 | 947 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 948 type = GAIM_LOG_IM; |
11338 | 949 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 950 type = GAIM_LOG_CHAT; |
951 else | |
952 return; | |
953 | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
954 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
955 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
956 |
10845 | 957 buddies = gaim_find_buddies(account, name); |
958 for (cur = buddies; cur != NULL; cur = cur->next) | |
959 { | |
960 GaimBlistNode *node = cur->data; | |
10846 | 961 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 962 { |
963 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
964 g_slist_free(buddies); | |
965 return; | |
966 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
967 } |
10845 | 968 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
969 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
970 gaim_gtk_log_show(type, name, account); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
971 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
972 |
8974 | 973 static void |
974 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
975 { | |
11581 | 976 GaimGtkWindow *win = data; |
8974 | 977 GaimConversation *conv; |
978 GaimGtkConversation *gtkconv; | |
979 | |
11581 | 980 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 981 gtkconv = GAIM_GTK_CONVERSATION(conv); |
982 | |
983 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
984 } | |
985 | |
7295 | 986 struct _search { |
987 GaimGtkConversation *gtkconv; | |
988 GtkWidget *entry; | |
989 }; | |
990 | |
7929 | 991 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 992 { |
7929 | 993 switch (resp) { |
994 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
995 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
996 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 997 break; |
998 | |
999 case GTK_RESPONSE_DELETE_EVENT: | |
1000 case GTK_RESPONSE_CLOSE: | |
1001 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1002 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1003 s->gtkconv->dialogs.search = NULL; | |
1004 g_free(s); | |
1005 break; | |
1006 } | |
7295 | 1007 } |
1008 | |
1009 static void | |
7751 | 1010 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1011 { |
11581 | 1012 GaimGtkWindow *gtkwin = data; |
1013 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1014 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1015 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1016 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1017 GTK_ICON_SIZE_DIALOG); |
7929 | 1018 GtkWidget *label; |
7295 | 1019 struct _search *s; |
1020 | |
7798 | 1021 if (gtkconv->dialogs.search) { |
1022 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1023 return; |
7798 | 1024 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1025 |
7295 | 1026 s = g_malloc(sizeof(struct _search)); |
1027 s->gtkconv = gtkconv; | |
7929 | 1028 |
1029 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1030 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1031 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1032 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1033 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1034 GTK_RESPONSE_OK); |
7929 | 1035 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1036 G_CALLBACK(do_search_cb), s); | |
1037 | |
11243 | 1038 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1039 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1040 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1041 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BORDER); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1042 gtk_container_set_border_width( |
11243 | 1043 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1044 | |
1045 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1046 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1047 hbox); |
7929 | 1048 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1049 | |
1050 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1051 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1052 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1053 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1054 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1055 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1056 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1057 | |
1058 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1059 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1060 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1061 g_signal_connect(G_OBJECT(s->entry), "changed", |
1062 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1063 gtkconv->dialogs.search); | |
1064 gtk_box_pack_start(GTK_BOX(hbox), s->entry, FALSE, FALSE, 0); | |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1065 |
7295 | 1066 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1067 gtk_widget_grab_focus(s->entry); |
7295 | 1068 } |
1069 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1070 static void |
9468 | 1071 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1072 { | |
11581 | 1073 GaimGtkWindow *win = data; |
1074 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1075 |
11338 | 1076 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1077 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1078 } | |
1079 | |
1080 } | |
1081 | |
1082 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1083 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1084 { |
11581 | 1085 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1086 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1087 |
11581 | 1088 conv = gaim_gtk_conv_window_get_active_gtkconv(win)->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1089 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1090 gaim_gtkpounce_dialog_show(gaim_conversation_get_account(conv), |
11581 | 1091 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1092 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1093 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1094 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1095 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1096 { |
11581 | 1097 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1098 GaimGtkConversation *gtkconv; |
8756 | 1099 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1100 |
11581 | 1101 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1102 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1103 | |
1104 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1105 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1106 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1107 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1108 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1109 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1110 { |
11581 | 1111 GaimGtkWindow *win = data; |
8756 | 1112 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1113 GaimGtkConversation *gtkconv; |
8756 | 1114 GtkIMHtmlToolbar *toolbar; |
1115 | |
11581 | 1116 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1117 conv = gtkconv->active_conv; | |
8756 | 1118 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1119 | |
1120 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1121 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1122 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1123 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1124 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1125 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1126 { |
11581 | 1127 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 GaimConversation *conv; |
7879 | 1129 GaimAccount *account; |
1130 const char *name; | |
1131 | |
11581 | 1132 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1133 account = gaim_conversation_get_account(conv); |
1134 name = gaim_conversation_get_name(conv); | |
1135 | |
11338 | 1136 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1137 GaimBuddy *b; |
1138 | |
1139 b = gaim_find_buddy(account, name); | |
1140 if (b != NULL) | |
9730 | 1141 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1142 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1143 GaimChat *c; |
1144 | |
1145 c = gaim_blist_find_chat(account, name); | |
1146 if (c != NULL) | |
9730 | 1147 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1148 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1149 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1150 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1151 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1152 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 { |
11581 | 1154 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 |
11581 | 1157 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 |
10810 | 1159 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1160 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1163 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 { |
11581 | 1165 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1166 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1167 |
11581 | 1168 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1170 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1171 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1174 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1175 { |
11581 | 1176 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1178 |
11581 | 1179 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1180 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1181 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1182 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1185 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 { |
11581 | 1187 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 |
11581 | 1190 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1192 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1193 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1196 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 { |
11581 | 1198 GaimGtkWindow *win = data; |
1199 | |
1200 close_conv_cb(NULL, GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1202 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1204 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1205 { |
11581 | 1206 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1207 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1208 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 |
11581 | 1210 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1215 logging = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1216 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1217 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1218 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1219 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1220 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1221 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1222 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1223 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1224 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1225 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1226 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1227 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1228 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1229 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1230 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1231 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1232 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1233 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1234 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1235 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1236 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1237 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1238 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1239 /* Disable the logging second, so that the above message can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1240 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1241 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1244 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1245 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1246 { |
11581 | 1247 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1248 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1249 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1250 |
11581 | 1251 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1252 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1253 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1254 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1255 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1256 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1257 |
10377 | 1258 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1259 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1260 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1261 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1262 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1263 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1264 { |
11581 | 1265 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1266 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1267 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1268 |
11581 | 1269 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1270 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1271 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1272 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1274 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1275 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1278 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1279 |
7961 | 1280 static void |
9188 | 1281 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1282 { | |
11581 | 1283 GaimGtkWindow *win = data; |
9188 | 1284 GaimConversation *conv; |
1285 GaimGtkConversation *gtkconv; | |
1286 | |
11581 | 1287 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1288 |
1289 if (!conv) | |
1290 return; | |
1291 | |
1292 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1293 | |
1294 gtkconv->show_timestamps = | |
1295 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
1296 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
1297 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); | |
1298 } | |
1299 | |
1300 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1301 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1302 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1303 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1304 GaimAccount *account; |
1305 GaimConnection *gc; | |
7961 | 1306 GaimPluginProtocolInfo *prpl_info = NULL; |
1307 char *real_who; | |
1308 | |
1309 account = gaim_conversation_get_account(conv); | |
10431 | 1310 g_return_if_fail(account != NULL); |
1311 | |
1312 gc = gaim_account_get_connection(account); | |
1313 g_return_if_fail(gc != NULL); | |
1314 | |
1315 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1316 | |
1317 if (prpl_info && prpl_info->get_cb_real_name) | |
1318 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1319 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1320 else | |
1321 real_who = g_strdup(who); | |
1322 | |
1323 if(!real_who) | |
1324 return; | |
1325 | |
10431 | 1326 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1327 |
1328 g_free(real_who); | |
1329 } | |
1330 | |
1331 static void | |
10810 | 1332 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1333 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1334 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1335 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1336 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1337 GtkTreeSelection *sel; |
9554 | 1338 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1339 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1343 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1344 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1345 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1346 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1347 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1348 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1349 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1350 chat_do_im(gtkconv, name); |
9554 | 1351 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1352 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1353 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1354 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1355 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1356 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1357 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1358 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1359 GaimConvChat *chat; |
11869 | 1360 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1361 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1363 GtkTreeSelection *sel; |
10504 | 1364 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1365 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1366 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1367 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1373 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1374 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1375 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1376 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1377 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1378 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1381 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1382 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1384 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1385 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1387 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 |
11869 | 1389 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1390 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1391 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1395 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1396 { |
1397 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1398 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1399 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1401 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1403 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1404 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1405 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1406 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1407 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1408 | |
1409 serv_send_file(gc, who, NULL); | |
1410 } | |
1411 | |
1412 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1413 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1416 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1417 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1418 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1419 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1421 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1423 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1425 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1429 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1430 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1431 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1433 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1434 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1435 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1436 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1437 * May want to expand this to work similarly to menu_info_cb? |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1438 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1439 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1441 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1442 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1443 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1444 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1445 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1446 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1447 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1448 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1449 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1450 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1451 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1452 GaimAccount *account; |
6695 | 1453 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1455 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1456 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1457 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1458 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1459 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 if (b != NULL) |
9730 | 1461 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1462 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1463 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1464 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1467 |
8143 | 1468 static GtkWidget * |
10504 | 1469 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1470 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1471 { | |
1472 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1473 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1474 gboolean is_me = FALSE; |
8143 | 1475 GtkWidget *button; |
1476 | |
1477 /* | |
1478 * If a menu already exists, destroy it before creating a new one, | |
1479 * thus freeing-up the memory it occupied. | |
1480 */ | |
1481 if (menu) | |
1482 gtk_widget_destroy(menu); | |
1483 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1484 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1485 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1486 |
8143 | 1487 menu = gtk_menu_new(); |
1488 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1489 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1490 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1491 G_CALLBACK(menu_chat_im_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1492 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1493 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1494 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1495 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1496 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1497 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1498 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1499 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1500 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1501 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1502 if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), who)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1503 button = gaim_new_item_from_stock(menu, _("Un-Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1504 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1505 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1506 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1507 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1508 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1509 } |
9498 | 1510 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1511 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1512 button = gaim_new_item_from_stock(menu, _("Info"), GAIM_STOCK_INFO, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1513 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1514 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1515 } |
1516 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1517 if (prpl_info->get_cb_away) { |
10221 | 1518 button = gaim_new_item_from_stock(menu, _("Get Away Message"), GAIM_STOCK_AWAY, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1519 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1520 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1521 } |
1522 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1523 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1524 if (gaim_find_buddy(gc->account, who)) |
10221 | 1525 button = gaim_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1526 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1527 else |
10221 | 1528 button = gaim_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1529 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1530 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1531 } |
1532 | |
1533 return menu; | |
1534 } | |
1535 | |
1536 | |
1537 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1538 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1539 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1540 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1541 GaimPluginProtocolInfo *prpl_info = NULL; |
1542 GaimGtkChatPane *gtkchat; | |
1543 GaimConnection *gc; | |
1544 GaimAccount *account; | |
1545 GtkTreeSelection *sel; | |
1546 GtkTreeIter iter; | |
1547 GtkTreeModel *model; | |
1548 GtkWidget *menu; | |
1549 gchar *who; | |
1550 | |
1551 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1552 gtkchat = gtkconv->u.chat; | |
1553 account = gaim_conversation_get_account(conv); | |
1554 gc = account->gc; | |
1555 | |
1556 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1557 | |
1558 if (gc != NULL) | |
1559 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1560 | |
1561 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1562 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1563 return FALSE; | |
1564 | |
9498 | 1565 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1566 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1567 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1568 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1569 0, GDK_CURRENT_TIME); |
10504 | 1570 g_free(who); |
8143 | 1571 |
1572 return TRUE; | |
1573 } | |
1574 | |
1575 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1576 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1577 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1578 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1579 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1580 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1581 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1582 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1583 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1584 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1585 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1586 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1587 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1588 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1589 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1590 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1591 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1592 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1593 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1594 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1595 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1596 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1597 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1598 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1599 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1600 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1601 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1602 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1603 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1604 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1605 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1606 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1607 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1608 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1609 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1610 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1611 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1612 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1613 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1614 chat_do_im(gtkconv, who); |
7398 | 1615 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1616 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1617 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1618 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1620 |
10504 | 1621 g_free(who); |
1622 gtk_tree_path_free(path); | |
1623 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1624 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1625 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1626 |
8133 | 1627 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1628 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1629 { |
10827 | 1630 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1631 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1632 int index, i, total, found = 0; |
8133 | 1633 |
11581 | 1634 win = gtkconv->win; |
1635 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1636 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1637 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1638 /* First check the tabs after (forward) or before (!forward) this position. */ |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1639 for (i = forward ? index + 1 : index - 1; |
11581 | 1640 !found && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1641 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1642 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1643 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1644 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1645 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1646 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1647 found = 1; |
8133 | 1648 } |
11252 | 1649 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1650 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1651 /* Now check from the beginning up to (forward) or end back to (!forward) this position. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1652 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1653 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1654 (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1655 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1656 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1657 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1658 found = 1; |
8133 | 1659 } |
10827 | 1660 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1661 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1662 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1663 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1664 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1665 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1666 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1667 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1668 } |
11581 | 1669 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1670 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1671 } |
8133 | 1672 } |
1673 | |
10827 | 1674 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1675 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1676 } |
1677 | |
4359 | 1678 static gboolean |
8105 | 1679 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1680 { |
11581 | 1681 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1682 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1683 GaimGtkConversation *gtkconv; |
8105 | 1684 int curconv; |
1685 | |
10810 | 1686 gtkconv = (GaimGtkConversation *)data; |
10849 | 1687 conv = gtkconv->active_conv; |
11581 | 1688 win = gtkconv->win; |
1689 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1690 |
8105 | 1691 /* If CTRL was held down... */ |
1692 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1693 switch (event->keyval) { |
1694 case GDK_Up: | |
1695 if (!conv->send_history) | |
1696 break; | |
1697 | |
1698 if (!conv->send_history->prev) { | |
1699 GtkTextIter start, end; | |
1700 | |
1701 if (conv->send_history->data) | |
1702 g_free(conv->send_history->data); | |
1703 | |
1704 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1705 &start); | |
1706 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1707 | |
1708 conv->send_history->data = | |
8506 | 1709 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1710 } |
8677 | 1711 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1712 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1713 GObject *object; |
8677 | 1714 GtkTextIter iter; |
1715 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1716 |
1717 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1718 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1719 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1720 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1721 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1722 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1723 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1724 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1725 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1726 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1727 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1728 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1729 |
8061 | 1730 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1731 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1732 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1733 0, NULL); |
8677 | 1734 /* this is mainly just a hack so the formatting at the |
1735 * cursor gets picked up. */ | |
1736 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1737 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1738 } |
1739 | |
8105 | 1740 return TRUE; |
4359 | 1741 break; |
1742 | |
1743 case GDK_Down: | |
1744 if (!conv->send_history) | |
1745 break; | |
1746 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1747 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1748 GObject *object; |
8677 | 1749 GtkTextIter iter; |
1750 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1751 |
4359 | 1752 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1753 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1754 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1755 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1756 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1757 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1758 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1759 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1760 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1761 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1762 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1763 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1764 |
8105 | 1765 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1766 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1767 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1768 0, NULL); |
8677 | 1769 /* this is mainly just a hack so the formatting at the |
1770 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1771 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1772 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1773 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1774 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1775 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1776 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1777 } |
4359 | 1778 } |
1779 | |
8105 | 1780 return TRUE; |
4359 | 1781 break; |
8105 | 1782 |
8108 | 1783 case GDK_Page_Down: |
8143 | 1784 case ']': |
11581 | 1785 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1786 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1787 else |
11581 | 1788 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1789 return TRUE; |
1790 break; | |
1791 | |
8108 | 1792 case GDK_Page_Up: |
8143 | 1793 case '[': |
11581 | 1794 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1795 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1796 else |
11581 | 1797 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1798 return TRUE; |
1799 break; | |
1800 | |
8108 | 1801 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1802 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1803 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1804 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1805 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1806 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1807 } |
8108 | 1808 |
1809 return TRUE; | |
1810 break; | |
1811 | |
11252 | 1812 case GDK_comma: |
11581 | 1813 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1814 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1815 curconv - 1); |
1816 break; | |
1817 | |
1818 case GDK_period: | |
11581 | 1819 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1820 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1821 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1822 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1823 #else |
1824 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1825 #endif | |
11252 | 1826 break; |
1827 | |
8105 | 1828 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1829 } |
8758 | 1830 |
8105 | 1831 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1832 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1833 { |
10864 | 1834 if (event->keyval > '0' && event->keyval <= '9') |
1835 { | |
8105 | 1836 int switchto = event->keyval - '1'; |
11581 | 1837 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1838 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1839 |
1840 return TRUE; | |
1841 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1842 } |
8758 | 1843 |
8105 | 1844 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1845 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1846 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1847 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1848 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1849 case GDK_Tab: |
9605 | 1850 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1851 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1852 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1853 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1854 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1855 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1856 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1857 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1858 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1859 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1860 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1861 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1862 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1863 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1864 } |
4359 | 1865 return FALSE; |
1866 } | |
1867 | |
1868 /* | |
1869 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1870 * This guy just kills a single right click from being propagated any |
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1871 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1872 * prevents right clicks on the GtkTextView in a convo dialog from |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1873 * going all the way down to the notebook. I suspect a bug in |
4359 | 1874 * GtkTextView, but I'm not ready to point any fingers yet. |
1875 */ | |
1876 static gboolean | |
1877 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1878 { | |
1879 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1880 /* Right single click */ | |
1881 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1882 | |
1883 return TRUE; | |
1884 } | |
1885 | |
1886 return FALSE; | |
1887 } | |
1888 | |
8173 | 1889 /* |
1890 * If someone tries to type into the conversation backlog of a | |
1891 * conversation window then we yank focus from the conversation backlog | |
1892 * and give it to the text entry box so that people can type | |
1893 * all the live long day and it will get entered into the entry box. | |
1894 */ | |
6057 | 1895 static gboolean |
8105 | 1896 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1897 { |
1898 GaimGtkConversation *gtkconv = data; | |
1899 | |
8237 | 1900 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1901 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1902 (event->keyval == GDK_F10) || |
1903 (event->keyval == GDK_Shift_L) || | |
1904 (event->keyval == GDK_Shift_R) || | |
1905 (event->keyval == GDK_Escape) || | |
8177 | 1906 (event->keyval == GDK_Up) || |
1907 (event->keyval == GDK_Down) || | |
1908 (event->keyval == GDK_Left) || | |
8191 | 1909 (event->keyval == GDK_Right) || |
1910 (event->keyval == GDK_Home) || | |
9297 | 1911 (event->keyval == GDK_End) || |
1912 (event->keyval == GDK_Tab) || | |
1913 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1914 return FALSE; |
1915 | |
1916 if (event->type == GDK_KEY_RELEASE) | |
1917 gtk_widget_grab_focus(gtkconv->entry); | |
1918 | |
1919 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1920 | |
1921 return TRUE; | |
6057 | 1922 } |
1923 | |
4359 | 1924 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1925 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1926 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1927 GaimGtkConversation *gtkconv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1928 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1929 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1930 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1931 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1932 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1933 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1934 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1935 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1936 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1937 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1938 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1939 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1940 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1941 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1942 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1943 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1944 void |
11604 | 1945 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1946 { | |
1947 GaimGtkConversation *gtkconv; | |
1948 | |
1949 g_return_if_fail(conv != NULL); | |
1950 | |
1951 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1952 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1953 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1954 |
1955 gray_stuff_out(gtkconv); | |
1956 update_typing_icon(gtkconv); | |
1957 | |
1958 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
1959 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
1960 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
1961 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 1962 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
1963 gaim_account_get_protocol_name(conv->account)); | |
1964 } | |
1965 | |
1966 static void | |
4673 | 1967 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1968 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1969 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 1970 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1971 GaimConversation *conv; |
4359 | 1972 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1973 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1974 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1975 |
11594 | 1976 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 1977 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 1978 } |
1979 | |
1980 static void | |
1981 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1982 gchar *new_text, gint new_text_length, gpointer user_data) | |
1983 { | |
10810 | 1984 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
1985 GaimConversation *conv; | |
1986 | |
1987 g_return_if_fail(gtkconv != NULL); | |
11508 | 1988 |
10810 | 1989 conv = gtkconv->active_conv; |
4359 | 1990 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1991 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1992 return; |
1993 | |
10810 | 1994 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
1995 gtk_text_iter_is_end(position))); | |
4359 | 1996 } |
1997 | |
1998 static void | |
1999 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2000 GtkTextIter *end_pos, gpointer user_data) | |
2001 { | |
10810 | 2002 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2003 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2004 GaimConvIm *im; |
4359 | 2005 |
10810 | 2006 g_return_if_fail(gtkconv != NULL); |
11508 | 2007 |
10810 | 2008 conv = gtkconv->active_conv; |
4359 | 2009 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2010 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2011 return; |
2012 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2013 im = GAIM_CONV_IM(conv); |
4359 | 2014 |
2015 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2016 | |
2017 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2018 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2019 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2020 |
2021 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2022 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2023 GAIM_NOT_TYPING); |
4359 | 2024 } |
2025 else { | |
2026 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2027 got_typing_keypress(gtkconv, FALSE); |
4359 | 2028 } |
2029 } | |
2030 | |
8189 | 2031 /************************************************************************** |
2032 * A bunch of buddy icon functions | |
2033 **************************************************************************/ | |
11581 | 2034 GdkPixbuf * |
2035 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2036 { |
10116 | 2037 GaimAccount *account = NULL; |
2038 const char *name = NULL; | |
7143 | 2039 GdkPixbuf *status = NULL; |
2040 | |
10116 | 2041 g_return_val_if_fail(conv != NULL, NULL); |
2042 | |
2043 account = gaim_conversation_get_account(conv); | |
2044 name = gaim_conversation_get_name(conv); | |
2045 | |
2046 g_return_val_if_fail(account != NULL, NULL); | |
2047 g_return_val_if_fail(name != NULL, NULL); | |
2048 | |
11338 | 2049 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2050 GaimBuddy *b = gaim_find_buddy(account, name); |
2051 if (b != NULL) { | |
2052 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2053 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2054 } |
2055 } | |
2056 | |
2057 if (!status) { | |
2058 GdkPixbuf *pixbuf; | |
10884 | 2059 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2060 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2061 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2062 { |
7143 | 2063 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2064 GDK_INTERP_BILINEAR); | |
2065 g_object_unref(pixbuf); | |
2066 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2067 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2068 status = pixbuf; |
7143 | 2069 } |
2070 return status; | |
2071 } | |
2072 | |
8189 | 2073 static void |
2074 update_tab_icon(GaimConversation *conv) | |
2075 { | |
2076 GaimGtkConversation *gtkconv; | |
11581 | 2077 GaimGtkWindow *win; |
8189 | 2078 GaimAccount *account; |
2079 const char *name; | |
2080 GdkPixbuf *status = NULL; | |
2081 | |
10116 | 2082 g_return_if_fail(conv != NULL); |
2083 | |
8189 | 2084 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2085 win = gtkconv->win; |
8189 | 2086 name = gaim_conversation_get_name(conv); |
2087 account = gaim_conversation_get_account(conv); | |
2088 | |
11581 | 2089 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2090 |
10116 | 2091 g_return_if_fail(status != NULL); |
2092 | |
8189 | 2093 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2094 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2095 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2096 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2097 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2098 |
11581 | 2099 if (gaim_gtk_conv_window_get_active_conversation(win) == conv && |
11338 | 2100 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2101 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2102 { |
11581 | 2103 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2104 | |
2105 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2106 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2107 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2108 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2109 } |
8189 | 2110 } |
2111 | |
2112 static gboolean | |
2113 redraw_icon(gpointer data) | |
2114 { | |
10810 | 2115 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2116 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2117 GaimAccount *account; |
2118 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2119 |
2120 GdkPixbuf *buf; | |
2121 GdkPixbuf *scale; | |
2122 GdkPixmap *pm; | |
2123 GdkBitmap *bm; | |
2124 gint delay; | |
9318 | 2125 int scale_width, scale_height; |
8189 | 2126 |
2127 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2128 account = gaim_conversation_get_account(conv); |
2129 if(account && account->gc) | |
2130 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2131 |
2132 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2133 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2134 | |
10483 | 2135 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2136 NULL, &scale_width, &scale_height); |
2137 | |
2138 /* this code is ugly, and scares me */ | |
8189 | 2139 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2140 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2141 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2142 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2143 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2144 GDK_INTERP_BILINEAR); |
8189 | 2145 |
2146 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2147 g_object_unref(G_OBJECT(scale)); | |
2148 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2149 g_object_unref(G_OBJECT(pm)); | |
2150 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2151 | |
2152 if (bm) | |
2153 g_object_unref(G_OBJECT(bm)); | |
2154 | |
9131 | 2155 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2156 |
2157 if (delay < 100) | |
9131 | 2158 delay = 100; |
2159 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2160 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2161 |
2162 return FALSE; | |
2163 } | |
2164 | |
2165 static void | |
10810 | 2166 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2167 { |
2168 int delay; | |
2169 | |
8228 | 2170 if (gtkconv->u.im->anim == NULL) |
2171 return; | |
2172 | |
8202 | 2173 if (gtkconv->u.im->icon_timer != 0) |
2174 return; | |
2175 | |
8189 | 2176 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2177 return; | |
2178 | |
10639 | 2179 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2180 | |
2181 if (delay < 100) | |
2182 delay = 100; | |
2183 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2184 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2185 } |
2186 | |
2187 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2188 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2189 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2190 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2191 GaimGtkWindow *gtkwin; |
2192 | |
2193 g_return_if_fail(conv != NULL); | |
2194 | |
9887 | 2195 if (gtkconv->u.im->icon_container != NULL) |
2196 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2197 |
2198 if (gtkconv->u.im->anim != NULL) | |
2199 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2200 | |
2201 if (gtkconv->u.im->icon_timer != 0) | |
2202 g_source_remove(gtkconv->u.im->icon_timer); | |
2203 | |
2204 if (gtkconv->u.im->iter != NULL) | |
2205 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2206 | |
2207 gtkconv->u.im->icon_timer = 0; | |
2208 gtkconv->u.im->icon = NULL; | |
2209 gtkconv->u.im->anim = NULL; | |
2210 gtkconv->u.im->iter = NULL; | |
10456 | 2211 gtkconv->u.im->icon_container = NULL; |
9687 | 2212 gtkconv->u.im->show_icon = FALSE; |
10456 | 2213 |
11581 | 2214 gtkwin = gtkconv->win; |
10456 | 2215 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2216 } |
2217 | |
9497 | 2218 static void |
9504 | 2219 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2220 { |
10810 | 2221 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2222 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2223 FILE *fp; |
2224 GaimBuddyIcon *icon; | |
2225 const void *data; | |
2226 size_t len; | |
2227 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2228 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2229 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2230 return; |
2231 } | |
2232 | |
2233 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2234 data = gaim_buddy_icon_get_data(icon, &len); | |
2235 | |
2236 if ((len <= 0) || (data == NULL)) { | |
9504 | 2237 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2238 return; |
2239 } | |
2240 | |
2241 fwrite(data, 1, len, fp); | |
2242 fclose(fp); | |
2243 } | |
2244 | |
2245 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2246 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2247 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2248 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2249 const gchar *ext; |
9497 | 2250 gchar *buf; |
2251 | |
2252 g_return_if_fail(conv != NULL); | |
9504 | 2253 |
10953 | 2254 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2255 if (ext == NULL) | |
2256 ext = "icon"; | |
2257 | |
2258 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2259 |
2260 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2261 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2262 |
2263 g_free(buf); | |
2264 } | |
2265 | |
11581 | 2266 static void |
2267 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2268 { | |
2269 if (gtkconv->u.im->icon_timer != 0) | |
2270 g_source_remove(gtkconv->u.im->icon_timer); | |
2271 | |
2272 gtkconv->u.im->icon_timer = 0; | |
2273 } | |
2274 | |
2275 | |
2276 static void | |
2277 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2278 { | |
2279 gtkconv->u.im->animate = | |
2280 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2281 | |
2282 if (gtkconv->u.im->animate) | |
2283 start_anim(NULL, gtkconv); | |
2284 else | |
2285 stop_anim(NULL, gtkconv); | |
2286 } | |
2287 | |
8189 | 2288 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2289 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2290 { |
2291 static GtkWidget *menu = NULL; | |
2292 GtkWidget *button; | |
2293 | |
2294 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2295 return FALSE; | |
2296 | |
2297 /* | |
2298 * If a menu already exists, destroy it before creating a new one, | |
2299 * thus freeing-up the memory it occupied. | |
2300 */ | |
2301 if (menu != NULL) | |
2302 gtk_widget_destroy(menu); | |
2303 | |
2304 menu = gtk_menu_new(); | |
2305 | |
2306 if (gtkconv->u.im->anim && | |
2307 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2308 { | |
2309 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2310 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2311 gtkconv->u.im->icon_timer); |
2312 } | |
2313 | |
2314 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2315 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2316 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2317 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2318 gtk_widget_show(button); | |
2319 | |
2320 gaim_new_item_from_stock(menu, _("Save Icon As..."), GTK_STOCK_SAVE_AS, | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2321 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2322 0, 0, NULL); |
2323 | |
2324 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2325 | |
2326 return TRUE; | |
2327 } | |
10456 | 2328 |
2329 static void | |
2330 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2331 { | |
11581 | 2332 GaimGtkWindow *win = data; |
10456 | 2333 GaimConversation *conv; |
2334 GaimGtkConversation *gtkconv; | |
2335 gboolean active; | |
2336 | |
11581 | 2337 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2338 |
2339 if (!conv) | |
2340 return; | |
2341 | |
11338 | 2342 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2343 |
2344 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2345 | |
2346 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2347 gtkconv->u.im->show_icon = active; | |
2348 if (active) | |
2349 gaim_gtkconv_update_buddy_icon(conv); | |
2350 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2351 remove_icon(gtkconv); |
10456 | 2352 } |
2353 | |
8189 | 2354 /************************************************************************** |
2355 * End of the bunch of buddy icon functions | |
2356 **************************************************************************/ | |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2357 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2358 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2359 GaimUnseenState min_state) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2360 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2361 GList *l; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2362 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2363 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2364 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2365 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2366 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2367 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2368 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2369 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2370 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2371 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2372 GaimConversation *conv = (GaimConversation*)l->data; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2373 if(GAIM_IS_GTK_CONVERSATION(conv)) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2374 if(GAIM_GTK_CONVERSATION(conv)->unseen_state>=min_state) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2375 return conv; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2376 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2377 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2378 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2379 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2380 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2381 } |
8189 | 2382 |
11581 | 2383 GaimGtkWindow * |
2384 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2385 { | |
2386 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2387 return gtkconv->win; | |
2388 } | |
2389 | |
2390 static GtkItemFactoryEntry menu_items[] = | |
2391 { | |
2392 /* Conversation menu */ | |
2393 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2394 | |
2395 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2396 0, "<StockItem>", GAIM_STOCK_IM }, | |
2397 | |
2398 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2399 | |
2400 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2401 "<StockItem>", GTK_STOCK_FIND }, | |
2402 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, | |
2403 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | |
2404 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
2405 { N_("/Conversation/Clear"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, | |
2406 | |
2407 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2408 | |
2409 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2410 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
2411 0, NULL }, | |
2412 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, | |
2413 "<StockItem>", GAIM_STOCK_INFO }, | |
2414 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2415 "<StockItem>", GAIM_STOCK_INVITE }, | |
2416 | |
2417 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2418 | |
2419 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2420 "<StockItem>", GAIM_STOCK_EDIT }, | |
2421 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2422 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2423 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2424 "<StockItem>", GTK_STOCK_ADD }, | |
2425 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2426 "<StockItem>", GTK_STOCK_REMOVE }, | |
2427 | |
2428 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2429 | |
2430 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2431 "<StockItem>", GAIM_STOCK_LINK }, | |
2432 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2433 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2434 | |
2435 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2436 | |
2437 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2438 "<StockItem>", GTK_STOCK_CLOSE }, | |
2439 | |
2440 /* Options */ | |
2441 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2442 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2443 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2444 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2445 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2446 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2447 }; | |
2448 | |
2449 static const int menu_item_count = | |
2450 sizeof(menu_items) / sizeof(*menu_items); | |
2451 | |
2452 static char * | |
2453 item_factory_translate_func (const char *path, gpointer func_data) | |
2454 { | |
2455 return _((char *)path); | |
2456 } | |
2457 | |
2458 static GtkWidget * | |
2459 setup_menubar(GaimGtkWindow *win) | |
2460 { | |
2461 GtkAccelGroup *accel_group; | |
2462 | |
2463 accel_group = gtk_accel_group_new (); | |
2464 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2465 g_object_unref(accel_group); | |
2466 | |
2467 win->menu.item_factory = | |
2468 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2469 | |
2470 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2471 item_factory_translate_func, | |
2472 NULL, NULL); | |
2473 | |
2474 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2475 menu_items, win); | |
2476 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2477 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2478 | |
2479 | |
2480 win->menu.menubar = | |
2481 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2482 | |
2483 | |
2484 win->menu.view_log = | |
2485 gtk_item_factory_get_widget(win->menu.item_factory, | |
2486 N_("/Conversation/View Log")); | |
2487 | |
2488 /* --- */ | |
2489 | |
2490 win->menu.send_file = | |
2491 gtk_item_factory_get_widget(win->menu.item_factory, | |
2492 N_("/Conversation/Send File...")); | |
2493 | |
2494 win->menu.add_pounce = | |
2495 gtk_item_factory_get_widget(win->menu.item_factory, | |
2496 N_("/Conversation/Add Buddy Pounce...")); | |
2497 | |
2498 /* --- */ | |
2499 | |
2500 win->menu.get_info = | |
2501 gtk_item_factory_get_widget(win->menu.item_factory, | |
2502 N_("/Conversation/Get Info")); | |
2503 | |
2504 win->menu.invite = | |
2505 gtk_item_factory_get_widget(win->menu.item_factory, | |
2506 N_("/Conversation/Invite...")); | |
2507 | |
2508 /* --- */ | |
2509 | |
2510 win->menu.alias = | |
2511 gtk_item_factory_get_widget(win->menu.item_factory, | |
2512 N_("/Conversation/Alias...")); | |
2513 | |
2514 win->menu.block = | |
2515 gtk_item_factory_get_widget(win->menu.item_factory, | |
2516 N_("/Conversation/Block...")); | |
2517 | |
2518 win->menu.add = | |
2519 gtk_item_factory_get_widget(win->menu.item_factory, | |
2520 N_("/Conversation/Add...")); | |
2521 | |
2522 win->menu.remove = | |
2523 gtk_item_factory_get_widget(win->menu.item_factory, | |
2524 N_("/Conversation/Remove...")); | |
2525 | |
2526 /* --- */ | |
2527 | |
2528 win->menu.insert_link = | |
2529 gtk_item_factory_get_widget(win->menu.item_factory, | |
2530 N_("/Conversation/Insert Link...")); | |
2531 | |
2532 win->menu.insert_image = | |
2533 gtk_item_factory_get_widget(win->menu.item_factory, | |
2534 N_("/Conversation/Insert Image...")); | |
2535 | |
2536 /* --- */ | |
2537 | |
2538 win->menu.logging = | |
2539 gtk_item_factory_get_widget(win->menu.item_factory, | |
2540 N_("/Options/Enable Logging")); | |
2541 win->menu.sounds = | |
2542 gtk_item_factory_get_widget(win->menu.item_factory, | |
2543 N_("/Options/Enable Sounds")); | |
2544 win->menu.show_formatting_toolbar = | |
2545 gtk_item_factory_get_widget(win->menu.item_factory, | |
2546 N_("/Options/Show Formatting Toolbars")); | |
2547 win->menu.show_timestamps = | |
2548 gtk_item_factory_get_widget(win->menu.item_factory, | |
2549 N_("/Options/Show Timestamps")); | |
2550 win->menu.show_icon = | |
2551 gtk_item_factory_get_widget(win->menu.item_factory, | |
2552 N_("/Options/Show Buddy Icon")); | |
2553 | |
2554 | |
2555 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2556 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2557 win->menu.tray); | |
2558 gtk_widget_show(win->menu.tray); | |
2559 | |
2560 gtk_widget_show(win->menu.menubar); | |
2561 | |
2562 return win->menu.menubar; | |
2563 } | |
2564 | |
4359 | 2565 |
2566 /************************************************************************** | |
2567 * Utility functions | |
2568 **************************************************************************/ | |
2569 | |
2570 static void | |
10810 | 2571 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2572 { |
10810 | 2573 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2574 GaimConvIm *im; |
4685 | 2575 |
4359 | 2576 /* |
2577 * We know we got something, so we at least have to make sure we don't | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2578 * send GAIM_TYPED any time soon. |
4359 | 2579 */ |
2580 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2581 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2582 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2583 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2584 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2585 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2586 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2587 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2588 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2589 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2590 |
2591 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2592 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2593 GAIM_TYPING); |
4359 | 2594 |
2595 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2596 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2597 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2598 gaim_conv_im_set_type_again(im, 0); |
4359 | 2599 } |
2600 } | |
2601 | |
4736 | 2602 static void |
10810 | 2603 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2604 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2605 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2606 GaimConvIm *im = NULL; |
10810 | 2607 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2608 char *stock_id, *tooltip; |
11508 | 2609 |
11581 | 2610 gtkwin = gtkconv->win; |
4736 | 2611 |
12008 | 2612 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2613 im = GAIM_CONV_IM(conv); |
4736 | 2614 |
12008 | 2615 if (gtkwin->menu.typing_icon) { |
2616 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2617 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2618 |
12008 | 2619 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2620 return; | |
2621 | |
2622 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2623 stock_id = GAIM_STOCK_TYPING; | |
2624 tooltip = _("User is typing..."); | |
2625 } else { | |
2626 stock_id = GAIM_STOCK_TYPED; | |
2627 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2628 } |
12008 | 2629 |
2630 if (gtkwin->menu.typing_icon == NULL) | |
2631 { | |
2632 gtkwin->menu.typing_icon = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_MENU); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2633 gaim_gtk_menu_tray_append(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), |
11908
34ea75bdd0c9
[gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents:
11869
diff
changeset
|
2634 gtkwin->menu.typing_icon, |
12008 | 2635 tooltip); |
4736 | 2636 } |
12008 | 2637 else |
2638 { | |
2639 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2640 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2641 gtkwin->menu.typing_icon, | |
2642 tooltip); | |
2643 } | |
2644 | |
2645 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2646 } |
2647 | |
4685 | 2648 static gboolean |
11594 | 2649 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2650 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2651 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2652 GaimConversation *conv; |
4359 | 2653 GtkWidget *menu; |
2654 GList *child; | |
11594 | 2655 GaimBuddy *b; |
11581 | 2656 |
2657 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2658 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2659 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2660 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2661 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2662 account = gaim_conversation_get_account(conv); |
11581 | 2663 |
11594 | 2664 if (win->menu.send_to == NULL) |
4685 | 2665 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2666 |
11594 | 2667 if (!(b = gaim_find_buddy(account, conv->name))) |
2668 return FALSE; | |
2669 | |
2670 | |
2671 gtk_widget_show(win->menu.send_to); | |
4359 | 2672 |
2673 menu = gtk_menu_item_get_submenu( | |
11594 | 2674 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2675 |
2676 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2677 child != NULL; | |
2678 child = child->next) { | |
2679 | |
2680 GtkWidget *item = child->data; | |
11594 | 2681 GaimBuddy *item_buddy; |
2682 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2683 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2684 "gaim_buddy_name"); | |
2685 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2686 | |
2687 if (b == item_buddy) { | |
4359 | 2688 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2689 break; | |
2690 } | |
2691 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2692 |
4685 | 2693 return FALSE; |
4359 | 2694 } |
2695 | |
2696 static void | |
11594 | 2697 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2698 { | |
2699 GaimAccount *account; | |
2700 GtkWidget *box; | |
2701 GtkWidget *label; | |
2702 GtkWidget *image; | |
2703 GtkWidget *menuitem; | |
11625 | 2704 GdkPixbuf *pixbuf; |
11616 | 2705 gchar *text; |
11594 | 2706 |
2707 account = bud->account; | |
2708 | |
2709 /* Create a pixmap for the protocol icon. */ | |
11625 | 2710 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2711 /* Now convert it to GtkImage */ |
2712 if (pixbuf == NULL) | |
2713 image = gtk_image_new(); | |
2714 else | |
11625 | 2715 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2716 |
2717 gtk_size_group_add_widget(sg, image); | |
2718 | |
2719 g_object_unref(G_OBJECT(pixbuf)); | |
2720 | |
2721 /* Make our menu item */ | |
11616 | 2722 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2723 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2724 g_free(text); | |
11594 | 2725 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2726 | |
2727 /* Do some evil, see some evil, speak some evil. */ | |
2728 box = gtk_hbox_new(FALSE, 0); | |
2729 | |
2730 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2731 g_object_ref(label); | |
2732 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2733 | |
2734 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2735 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2736 | |
2737 g_object_unref(label); | |
2738 | |
2739 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2740 | |
2741 gtk_widget_show(label); | |
2742 gtk_widget_show(image); | |
2743 gtk_widget_show(box); | |
2744 | |
2745 /* Set our data and callbacks. */ | |
2746 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2747 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2748 | |
2749 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2750 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2751 | |
2752 gtk_widget_show(menuitem); | |
2753 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2754 } | |
2755 | |
2756 static void | |
2757 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2758 { |
4359 | 2759 GtkWidget *menu; |
2760 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2761 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2762 GaimGtkConversation *gtkconv; |
2763 GSList *l, *buds; | |
2764 | |
2765 g_return_if_fail(win != NULL); | |
2766 | |
2767 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2768 | |
11604 | 2769 g_return_if_fail(gtkconv != NULL); |
2770 | |
11594 | 2771 if (win->menu.send_to != NULL) |
2772 gtk_widget_destroy(win->menu.send_to); | |
2773 | |
4359 | 2774 |
2775 /* Build the Send As menu */ | |
11594 | 2776 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2777 gtk_widget_show(win->menu.send_to); | |
4359 | 2778 |
2779 menu = gtk_menu_new(); | |
11581 | 2780 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2781 win->menu.send_to, 2); |
2782 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2783 |
2784 gtk_widget_show(menu); | |
2785 | |
11604 | 2786 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2787 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2788 for (l = buds; l != NULL; l = l->next) { | |
2789 GaimBuddy *b; | |
2790 GaimBlistNode *node; | |
2791 | |
2792 b = l->data; | |
2793 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2794 | |
2795 for (node = node->child; node != NULL; node = node->next) | |
2796 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2797 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2798 } | |
2799 | |
2800 g_slist_free(buds); | |
4359 | 2801 } |
2802 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2803 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2804 |
11594 | 2805 gtk_widget_show(win->menu.send_to); |
2806 if (!group) | |
2807 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2808 update_send_to_selection(win); | |
4359 | 2809 } |
2810 | |
2811 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2812 generate_invite_user_names(GaimConnection *gc) |
4359 | 2813 { |
6695 | 2814 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2815 static GList *tmp = NULL; |
2816 | |
2817 if (tmp) | |
2818 g_list_free(tmp); | |
2819 | |
2820 tmp = g_list_append(NULL, ""); | |
2821 | |
2822 if (gc != NULL) { | |
4785 | 2823 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2824 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2825 continue; | |
6695 | 2826 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2827 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2828 continue; |
6695 | 2829 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2830 GaimBuddy *buddy; | |
2831 | |
2832 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2833 continue; | |
2834 | |
2835 buddy = (GaimBuddy *)bnode; | |
2836 | |
2837 if (buddy->account == gc->account && | |
2838 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2839 tmp = g_list_insert_sorted(tmp, buddy->name, |
2840 (GCompareFunc)g_utf8_collate); | |
6695 | 2841 } |
4359 | 2842 } |
2843 } | |
2844 } | |
2845 | |
2846 return tmp; | |
2847 } | |
2848 | |
9498 | 2849 static GdkPixbuf * |
9554 | 2850 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2851 { |
9554 | 2852 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2853 char *filename; |
10274 | 2854 const char *image = NULL; |
9554 | 2855 |
2856 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2857 image = "founder.png"; |
9554 | 2858 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2859 image = "op.png"; |
9554 | 2860 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2861 image = "halfop.png"; |
9554 | 2862 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2863 image = "voice.png"; |
9554 | 2864 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2865 image = "ignored.png"; |
2866 } else { | |
2867 return NULL; | |
9554 | 2868 } |
10274 | 2869 |
2870 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2871 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2872 g_free(filename); | |
2873 | |
2874 if (!pixbuf) | |
2875 return NULL; | |
2876 | |
2877 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2878 g_object_unref(pixbuf); | |
2879 | |
2880 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2881 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2882 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2883 g_free(filename); | |
10274 | 2884 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2885 g_object_unref(pixbuf); |
10274 | 2886 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2887 g_object_unref(scale2); | |
9498 | 2888 } |
2889 | |
10274 | 2890 return scale; |
9498 | 2891 } |
2892 | |
4359 | 2893 static void |
11869 | 2894 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 2895 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2896 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2897 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2898 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2899 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2900 GaimPluginProtocolInfo *prpl_info; |
4359 | 2901 GtkListStore *ls; |
9498 | 2902 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2903 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2904 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2905 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2906 GdkColor send_color; |
11508 | 2907 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2908 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 2909 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2910 chat = GAIM_CONV_CHAT(conv); |
4359 | 2911 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2912 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2913 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2914 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2915 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2916 return; |
4359 | 2917 |
2918 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
2919 | |
9554 | 2920 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 2921 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
2922 if (!strcmp(chat->nick, gaim_normalize(conv->account, old_name != NULL ? old_name : name))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
2923 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2924 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2925 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2926 |
4359 | 2927 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2928 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2929 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2930 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2931 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2932 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2933 CHAT_USERS_COLOR_COLUMN, is_me ? &send_color : get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2934 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2935 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2936 |
9554 | 2937 if (pixbuf) |
2938 g_object_unref(pixbuf); | |
4359 | 2939 } |
2940 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2941 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2942 tab_complete_process_item(int *most_matched, char *entered, char **partial, char *nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2943 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2944 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2945 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2946 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2947 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2948 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2949 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2950 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2951 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2952 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2953 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2954 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2955 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2956 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2957 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2958 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2959 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2960 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2961 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2962 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2963 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2964 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2965 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2966 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2967 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2968 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2969 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2970 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2971 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2972 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2973 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2974 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2975 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2976 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2977 |
9605 | 2978 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2979 tab_complete(GaimConversation *conv) |
4359 | 2980 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2981 GaimGtkConversation *gtkconv; |
4359 | 2982 GtkTextIter cursor, word_start, start_buffer; |
2983 int start; | |
2984 int most_matched = -1; | |
2985 char *entered, *partial = NULL; | |
2986 char *text; | |
8021 | 2987 char *nick_partial; |
9605 | 2988 const char *prefix; |
4359 | 2989 GList *matches = NULL; |
9605 | 2990 gboolean command = FALSE; |
4359 | 2991 |
2992 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2993 | |
2994 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
2995 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2996 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2997 | |
2998 word_start = cursor; | |
2999 | |
3000 /* if there's nothing there just return */ | |
3001 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3002 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
3003 |
4359 | 3004 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3005 &cursor, FALSE); | |
3006 | |
3007 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3008 start = strlen(text) - 1; | |
3009 | |
8021 | 3010 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3011 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3012 start-=2; |
3013 } | |
4359 | 3014 |
3015 /* find the start of the word that we're tabbing */ | |
3016 while (start >= 0 && text[start] != ' ') { | |
3017 gtk_text_iter_backward_char(&word_start); | |
3018 start--; | |
3019 } | |
3020 | |
9605 | 3021 prefix = gaim_gtk_get_cmd_prefix(); |
3022 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3023 command = TRUE; | |
3024 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3025 } | |
3026 | |
4359 | 3027 g_free(text); |
3028 | |
3029 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3030 &cursor, FALSE); | |
3031 | |
8021 | 3032 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3033 g_free(entered); |
11338 | 3034 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3035 } |
3036 | |
8021 | 3037 nick_partial = g_malloc(strlen(entered)+1); |
3038 | |
9605 | 3039 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3040 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3041 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3042 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3043 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3044 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3045 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3046 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3047 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3048 g_list_free(list); |
11338 | 3049 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3050 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3051 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3052 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(GAIM_GTK_CONVERSATION(conv)->u.chat->list)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3053 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3054 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3055 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3056 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3057 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3058 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3059 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3060 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3061 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3062 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3064 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3065 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3066 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3067 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3068 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3069 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3070 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3071 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3072 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3073 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3074 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3075 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3076 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3077 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3078 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3079 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3080 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3081 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3082 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3083 } |
9605 | 3084 } else { |
3085 g_free(nick_partial); | |
3086 g_free(entered); | |
3087 return FALSE; | |
3088 } | |
3089 | |
8021 | 3090 g_free(nick_partial); |
3091 | |
4359 | 3092 /* we're only here if we're doing new style */ |
3093 | |
3094 /* if there weren't any matches, return */ | |
3095 if (!matches) { | |
3096 /* if matches isn't set partials won't be either */ | |
3097 g_free(entered); | |
11338 | 3098 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3099 } |
3100 | |
3101 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3102 | |
3103 if (!matches->next) { | |
3104 /* there was only one match. fill it in. */ | |
3105 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3106 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3107 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3108 | |
3109 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3110 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3111 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3112 g_free(tmp); | |
3113 } | |
3114 else | |
3115 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3116 matches->data, -1); | |
3117 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3118 g_free(matches->data); |
4359 | 3119 matches = g_list_remove(matches, matches->data); |
3120 } | |
3121 else { | |
3122 /* | |
3123 * there were lots of matches, fill in as much as possible | |
3124 * and display all of them | |
3125 */ | |
3126 char *addthis = g_malloc0(1); | |
3127 | |
3128 while (matches) { | |
3129 char *tmp = addthis; | |
3130 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3131 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3132 g_free(matches->data); |
4359 | 3133 matches = g_list_remove(matches, matches->data); |
3134 } | |
3135 | |
6982 | 3136 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3137 time(NULL)); |
3138 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3139 g_free(addthis); | |
3140 } | |
3141 | |
3142 g_free(entered); | |
3143 g_free(partial); | |
9605 | 3144 |
3145 return TRUE; | |
4359 | 3146 } |
3147 | |
10810 | 3148 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3149 { |
3150 GaimPluginProtocolInfo *prpl_info = NULL; | |
3151 GaimConnection *gc; | |
10810 | 3152 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3153 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3154 char *new_topic; |
8858 | 3155 const char *current_topic; |
7971 | 3156 |
3157 gc = gaim_conversation_get_gc(conv); | |
3158 | |
3159 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3160 return; | |
3161 | |
3162 if(prpl_info->set_chat_topic == NULL) | |
3163 return; | |
3164 | |
3165 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3166 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3167 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3168 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3169 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3170 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3171 g_free(new_topic); |
7971 | 3172 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3173 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3174 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3175 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3176 |
8858 | 3177 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3178 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3179 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3180 g_free(new_topic); |
7971 | 3181 } |
3182 | |
9554 | 3183 static gint |
3184 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3185 { | |
3186 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3187 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3188 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3189 gint ret = 0; |
3190 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3191 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3192 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3193 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3194 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3195 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3196 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3197 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3198 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3199 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3200 -1); |
9554 | 3201 |
3202 if (user1 == NULL || user2 == NULL) { | |
3203 if (!(user1 == NULL && user2 == NULL)) | |
3204 ret = (user1 == NULL) ? -1: 1; | |
3205 } else if (f1 != f2) { | |
3206 /* sort more important users first */ | |
3207 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3208 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3209 ret = buddy1 ? -1 : 1; |
9554 | 3210 } else { |
10904 | 3211 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3212 } |
3213 | |
3214 g_free(user1); | |
3215 g_free(user2); | |
3216 | |
3217 return ret; | |
3218 } | |
3219 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3220 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3221 update_chat_alias(GaimBuddy *buddy, GaimConversation *conv, GaimConnection *gc, GaimPluginProtocolInfo *prpl_info) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3222 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3223 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3224 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3225 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3226 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3227 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3228 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3229 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3230 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3231 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3232 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3233 /* This is safe because this callback is only used in chats, not IMs. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3234 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkconv->u.chat->list)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3235 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3236 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3237 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3238 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3239 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3240 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3241 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3242 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3243 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3244 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3245 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3246 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3247 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3248 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3249 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3250 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3251 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3252 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3253 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3254 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3255 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3256 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3257 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3258 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3259 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3260 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3261 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3262 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3263 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3264 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3265 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3266 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3267 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3268 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3269 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3270 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3271 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3272 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3273 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3274 blist_node_aliased_cb(GaimBlistNode *node, const char *old_alias, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3275 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3276 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3277 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3278 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3280 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3281 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3282 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3283 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3284 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3285 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3286 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3287 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3291 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3292 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3293 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3294 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3295 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3296 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3297 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3298 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3300 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3301 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3305 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3306 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3308 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3309 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3310 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3313 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3314 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3317 /* Do nothing if the buddy does not belong to the conv's account */ |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3318 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3319 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3320 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 /* This is safe because this callback is only used in chats, not IMs. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 model = gtk_tree_view_get_model(GTK_TREE_VIEW(GAIM_GTK_CONVERSATION(conv)->u.chat->list)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3323 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3324 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3325 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3326 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3331 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 gtk_list_store_set(GTK_LIST_STORE(model), &iter, CHAT_USERS_BUDDY_COLUMN, is_buddy, -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3341 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3344 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3346 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3347 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3352 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3355 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3358 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 /* If there's another buddy for the same "dude" on the list, do nothing. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3360 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3361 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3362 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3363 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 |
4359 | 3366 static GtkWidget * |
10810 | 3367 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3368 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3369 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3370 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3371 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3372 GaimConnection *gc; |
4359 | 3373 GtkWidget *vpaned, *hpaned; |
10175 | 3374 GtkWidget *vbox, *hbox, *frame; |
4359 | 3375 GtkWidget *lbox, *bbox; |
3376 GtkWidget *label; | |
3377 GtkWidget *list; | |
3378 GtkWidget *button; | |
7949 | 3379 GtkWidget *sw; |
4359 | 3380 GtkListStore *ls; |
3381 GtkCellRenderer *rend; | |
3382 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3383 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3384 GList *focus_chain = NULL; |
4359 | 3385 |
3386 gtkchat = gtkconv->u.chat; | |
3387 gc = gaim_conversation_get_gc(conv); | |
3388 | |
3389 /* Setup the outer pane. */ | |
3390 vpaned = gtk_vpaned_new(); | |
3391 gtk_widget_show(vpaned); | |
3392 | |
3393 /* Setup the top part of the pane. */ | |
11243 | 3394 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3395 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3396 gtk_widget_show(vbox); |
3397 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3398 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3399 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3400 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3401 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3402 { |
11243 | 3403 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3404 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3405 gtk_widget_show(hbox); |
3406 | |
3407 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3408 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3409 gtk_widget_show(label); |
3410 | |
3411 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3412 |
7971 | 3413 if(prpl_info->set_chat_topic == NULL) { |
3414 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3415 } else { | |
3416 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3417 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3418 } |
3419 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3420 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3421 gtk_widget_show(gtkchat->topic_text); |
3422 } | |
3423 | |
3424 /* Setup the horizontal pane. */ | |
3425 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3426 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3427 gtk_widget_show(hpaned); |
3428 | |
10175 | 3429 /* Setup gtkihmtml. */ |
3430 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3431 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3432 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3433 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3434 gtk_widget_show(frame); | |
3435 | |
3436 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3437 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3438 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3439 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3440 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3441 |
4359 | 3442 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3443 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3444 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3445 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3446 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3447 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3448 |
3449 /* Build the right pane. */ | |
11243 | 3450 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3451 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3452 gtk_widget_show(lbox); |
3453 | |
3454 /* Setup the label telling how many people are in the room. */ | |
3455 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3456 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3457 gtk_widget_show(gtkchat->count); | |
3458 | |
3459 /* Setup the list of users. */ | |
7949 | 3460 sw = gtk_scrolled_window_new(NULL, NULL); |
3461 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3462 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3463 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3464 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3465 gtk_widget_show(sw); | |
4359 | 3466 |
9554 | 3467 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3468 G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_BOOLEAN); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3469 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3470 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3471 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3472 GTK_SORT_ASCENDING); |
3473 | |
3474 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3475 | |
9498 | 3476 rend = gtk_cell_renderer_pixbuf_new(); |
3477 | |
4359 | 3478 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3479 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3480 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3481 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3482 |
3483 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3484 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3485 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3486 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3487 |
9498 | 3488 rend = gtk_cell_renderer_text_new(); |
3489 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3490 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3491 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3492 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3493 NULL); |
4359 | 3494 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3495 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3496 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3497 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3498 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3499 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3500 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3501 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3502 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3503 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3504 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3505 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3506 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3507 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3508 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3509 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3510 #endif |
4359 | 3511 |
3512 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3513 | |
3514 gtk_widget_set_size_request(list, 150, -1); | |
3515 | |
3516 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3517 gtk_widget_show(list); | |
3518 | |
3519 gtkchat->list = list; | |
3520 | |
7949 | 3521 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3522 |
3523 /* Setup the user list toolbar. */ | |
11243 | 3524 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3525 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3526 gtk_widget_show(bbox); | |
3527 | |
3528 /* IM */ | |
10221 | 3529 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3530 GAIM_BUTTON_VERTICAL); |
10500 | 3531 gtkchat->userlist_im = button; |
4359 | 3532 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3533 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3534 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3535 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3536 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3537 |
3538 gtk_widget_show(button); | |
3539 | |
3540 /* Ignore */ | |
3541 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3542 GAIM_BUTTON_VERTICAL); | |
10500 | 3543 gtkchat->userlist_ignore = button; |
4359 | 3544 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3545 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3546 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3547 _("Ignore the user"), NULL); |
4359 | 3548 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3549 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3550 gtk_widget_show(button); |
3551 | |
3552 /* Info */ | |
3553 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3554 GAIM_BUTTON_VERTICAL); | |
10500 | 3555 gtkchat->userlist_info = button; |
4359 | 3556 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3557 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3558 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3559 _("Get the user's information"), NULL); |
4359 | 3560 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3561 G_CALLBACK(info_cb), gtkconv); |
4359 | 3562 |
3563 gtk_widget_show(button); | |
3564 | |
10175 | 3565 /* Setup the bottom half of the conversation window */ |
11243 | 3566 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3567 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3568 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3569 |
11243 | 3570 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3571 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3572 gtk_widget_show(gtkconv->lower_hbox); | |
3573 | |
11243 | 3574 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3575 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3576 gtk_widget_show(vbox); | |
3577 | |
10175 | 3578 /* Setup the toolbar, entry widget and all signals */ |
3579 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3580 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3581 gtk_widget_show(frame); |
3582 | |
9005 | 3583 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3584 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3585 gaim_account_get_protocol_name(conv->account)); |
10175 | 3586 gtk_widget_set_size_request(gtkconv->entry, -1, |
3587 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3588 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3589 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3590 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3591 |
3592 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3593 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3594 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3595 G_CALLBACK(send_cb), gtkconv); |
4359 | 3596 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3597 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3598 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3599 G_CALLBACK(size_allocate_cb), gtkconv); |
3600 | |
3601 default_formatize(gtkconv); | |
4359 | 3602 |
9080 | 3603 /* |
3604 * Focus for chat windows should be as follows: | |
3605 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3606 * user list buttons -> entry -> buttons at bottom | |
3607 */ | |
9332 | 3608 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3609 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3610 | |
4359 | 3611 return vpaned; |
3612 } | |
3613 | |
3614 static GtkWidget * | |
10810 | 3615 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3616 { |
10810 | 3617 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3618 GtkWidget *frame; |
4359 | 3619 GtkWidget *paned; |
10175 | 3620 GtkWidget *vbox; |
3621 GtkWidget *vbox2; | |
9080 | 3622 GList *focus_chain = NULL; |
4359 | 3623 |
10175 | 3624 /* Setup the outer pane */ |
4359 | 3625 paned = gtk_vpaned_new(); |
3626 gtk_widget_show(paned); | |
3627 | |
10175 | 3628 /* Setup the top part of the pane */ |
11243 | 3629 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3630 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3631 gtk_widget_show(vbox); |
3632 | |
10175 | 3633 /* Setup the gtkimhtml widget */ |
3634 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3635 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3636 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3637 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3638 gtk_widget_show(frame); | |
3639 | |
3640 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3641 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3642 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3643 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3644 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3645 |
3646 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3647 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3648 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3649 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3650 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3651 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3652 |
10175 | 3653 /* Setup the bottom half of the conversation window */ |
11243 | 3654 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3655 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3656 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3657 |
11243 | 3658 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3659 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3660 gtk_widget_show(gtkconv->lower_hbox); | |
3661 | |
11243 | 3662 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3663 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3664 gtk_widget_show(vbox2); | |
8821 | 3665 |
10175 | 3666 /* Setup the toolbar, entry widget and all signals */ |
3667 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3668 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3669 gtk_widget_show(frame); |
3670 | |
9005 | 3671 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3672 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3673 gaim_account_get_protocol_name(conv->account)); |
10175 | 3674 gtk_widget_set_size_request(gtkconv->entry, -1, |
3675 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3676 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3677 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3678 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3679 |
4359 | 3680 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3681 G_CALLBACK(entry_key_press_cb), gtkconv); |
3682 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3683 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3684 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3685 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3686 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3687 |
3688 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3689 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3690 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3691 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3692 |
8481 | 3693 /* had to move this after the imtoolbar is attached so that the |
3694 * signals get fired to toggle the buttons on the toolbar as well. | |
3695 */ | |
10810 | 3696 default_formatize(gtkconv); |
4359 | 3697 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3698 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3699 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3700 |
8758 | 3701 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3702 gtkconv->u.im->show_icon = TRUE; |
4359 | 3703 |
9080 | 3704 /* |
3705 * Focus for IM windows should be as follows: | |
10356 | 3706 * Tab title -> conversation scrollback -> entry |
9080 | 3707 */ |
9332 | 3708 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3709 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3710 |
4359 | 3711 return paned; |
3712 } | |
3713 | |
3714 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3715 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3716 GtkSelectionData *sd, guint info, guint t, |
3717 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3718 { |
10810 | 3719 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3720 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3721 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3722 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3723 { |
4781 | 3724 GaimBlistNode *n = NULL; |
6695 | 3725 GaimBuddy *b; |
11581 | 3726 GaimGtkConversation *gtkconv = NULL; |
9622 | 3727 |
11812 | 3728 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3729 |
6695 | 3730 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3731 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3732 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3733 b = (GaimBuddy*)n; | |
3734 else | |
4781 | 3735 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3736 |
9622 | 3737 /* |
3738 * If we already have an open conversation with this buddy, then | |
3739 * just move the conv to this window. Otherwise, create a new | |
3740 * conv and add it to this window. | |
3741 */ | |
11338 | 3742 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3743 if (c != NULL) { |
11581 | 3744 GaimGtkWindow *oldwin; |
3745 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3746 oldwin = gtkconv->win; | |
9622 | 3747 if (oldwin != win) { |
11581 | 3748 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3749 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3750 } |
3751 } else { | |
11338 | 3752 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3753 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3754 if (gtkconv->win != win) |
3755 { | |
3756 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3757 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3758 } | |
9622 | 3759 } |
3760 | |
3761 /* Make this conversation the active conversation */ | |
11581 | 3762 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3763 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3764 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3765 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3766 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3767 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3768 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3769 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3770 GaimAccount *account; |
11581 | 3771 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3772 |
11137 | 3773 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3774 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3775 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3776 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3777 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3778 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3779 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3780 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3781 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3782 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3783 { |
11338 | 3784 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3785 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3786 if (gtkconv->win != win) |
3787 { | |
3788 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3789 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3790 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3791 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3792 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3793 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3794 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3795 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3796 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3797 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3798 } |
9525 | 3799 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3800 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3801 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3802 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3803 } |
10145 | 3804 else |
3805 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3806 } |
4359 | 3807 |
3808 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3809 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3810 { |
10145 | 3811 GTK_IMHTML_DND_TARGETS, |
3812 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3813 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3814 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3815 |
10810 | 3816 static GaimGtkConversation * |
3817 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3818 { | |
3819 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3820 GaimContact *c; | |
3821 GaimBlistNode *cn; | |
10935 | 3822 |
10810 | 3823 if (!bud) |
3824 return NULL; | |
10935 | 3825 |
10810 | 3826 if (!(c = gaim_buddy_get_contact(bud))) |
3827 return NULL; | |
10935 | 3828 |
10810 | 3829 cn = (GaimBlistNode *)c; |
3830 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3831 GaimConversation *conv; | |
11338 | 3832 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3833 if (conv->ui_data) |
3834 return conv->ui_data; | |
3835 } | |
3836 } | |
10935 | 3837 |
10810 | 3838 return NULL; |
3839 } | |
3840 | |
11855 | 3841 static void |
3842 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3843 { | |
3844 GList *list; | |
3845 | |
3846 g_return_if_fail(bnode); | |
3847 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3848 | |
3849 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3850 { | |
3851 GaimGtkWindow *win = list->data; | |
3852 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3853 | |
3854 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3855 continue; | |
3856 | |
3857 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3858 } | |
3859 } | |
3860 | |
11581 | 3861 /************************************************************************** |
3862 * Conversation UI operations | |
3863 **************************************************************************/ | |
3864 void | |
3865 gaim_gtkconv_new(GaimConversation *conv) | |
3866 { | |
3867 GaimGtkConversation *gtkconv; | |
3868 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3869 GtkWidget *pane = NULL; |
3870 GtkWidget *tab_cont; | |
11581 | 3871 |
3872 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3873 conv->ui_data = gtkconv; |
3874 if (!g_list_find(gtkconv->convs, conv)) | |
3875 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3876 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3877 return; |
4359 | 3878 } |
3879 | |
11581 | 3880 gtkconv = g_new0(GaimGtkConversation, 1); |
3881 conv->ui_data = gtkconv; | |
3882 gtkconv->active_conv = conv; | |
3883 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3884 | |
3885 /* Setup some initial variables. */ | |
3886 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3887 gtkconv->tooltips = gtk_tooltips_new(); | |
3888 | |
3889 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3890 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3891 | |
3892 pane = setup_im_pane(gtkconv); | |
3893 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3894 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3895 pane = setup_chat_pane(gtkconv); | |
3896 } | |
3897 | |
12101 | 3898 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
3899 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
3900 | |
11581 | 3901 if (pane == NULL) { |
3902 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
3903 g_free(gtkconv->u.chat); | |
3904 else if (conv_type == GAIM_CONV_TYPE_IM) | |
3905 g_free(gtkconv->u.im); | |
3906 | |
3907 g_free(gtkconv); | |
3908 conv->ui_data = NULL; | |
3909 return; | |
10449 | 3910 } |
11581 | 3911 |
3912 /* Setup drag-and-drop */ | |
3913 gtk_drag_dest_set(pane, | |
3914 GTK_DEST_DEFAULT_MOTION | | |
3915 GTK_DEST_DEFAULT_DROP, | |
3916 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3917 GDK_ACTION_COPY); | |
3918 gtk_drag_dest_set(pane, | |
3919 GTK_DEST_DEFAULT_MOTION | | |
3920 GTK_DEST_DEFAULT_DROP, | |
3921 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3922 GDK_ACTION_COPY); | |
3923 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
3924 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3925 GDK_ACTION_COPY); | |
3926 | |
3927 gtk_drag_dest_set(gtkconv->entry, 0, | |
3928 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3929 GDK_ACTION_COPY); | |
3930 | |
3931 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
3932 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3933 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
3934 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3935 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
3936 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3937 | |
3938 /* Setup the container for the tab. */ | |
3939 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
3940 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
3941 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
3942 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
3943 gtk_widget_show(pane); | |
3944 | |
3945 gtkconv->make_sound = TRUE; | |
3946 | |
3947 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
3948 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
3949 else |
11581 | 3950 gtk_widget_hide(gtkconv->toolbar); |
3951 | |
3952 gtkconv->show_timestamps = TRUE; | |
3953 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
3954 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
3955 gaim_account_get_protocol_name(conv->account)); |
11581 | 3956 |
3957 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
3958 G_CALLBACK(gtk_widget_grab_focus), | |
3959 gtkconv->entry); | |
3960 | |
3961 gaim_gtkconv_placement_place(gtkconv); | |
3962 } | |
3963 | |
4359 | 3964 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3965 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 3966 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3967 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 3968 |
10810 | 3969 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
3970 /* Don't destroy ourselves until all our convos are gone */ | |
3971 if (gtkconv->convs) | |
3972 return; | |
11508 | 3973 |
11581 | 3974 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
3975 | |
9504 | 3976 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
3977 gaim_request_close_with_handle(conv); | |
4359 | 3978 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3979 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 3980 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3981 |
11338 | 3982 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 3983 if (gtkconv->u.im->icon_timer != 0) |
3984 g_source_remove(gtkconv->u.im->icon_timer); | |
3985 | |
4359 | 3986 if (gtkconv->u.im->anim != NULL) |
4793 | 3987 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 3988 |
3989 g_free(gtkconv->u.im); | |
11581 | 3990 } 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
|
3991 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 3992 g_free(gtkconv->u.chat); |
3993 } | |
3994 | |
4633 | 3995 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
3996 | |
4359 | 3997 g_free(gtkconv); |
3998 } | |
3999 | |
4000 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4001 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4002 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4003 time_t mtime) |
4359 | 4004 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4005 GaimGtkConversation *gtkconv; |
4359 | 4006 |
4007 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4008 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4009 |
6982 | 4010 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4011 } |
4012 | |
4013 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4014 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4015 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4016 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4017 GaimGtkConversation *gtkconv; |
4359 | 4018 |
4019 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4020 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4021 |
10398 | 4022 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4023 |
6982 | 4024 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4025 } |
4026 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4027 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4028 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4029 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4030 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4031 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4032 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4033 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4034 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4035 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4036 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4037 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4038 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4039 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4040 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4041 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4042 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4043 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4044 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4045 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4046 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4047 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4048 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4049 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4050 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4051 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4052 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4053 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4054 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4055 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4056 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4057 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4058 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4059 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4060 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4061 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4062 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4063 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4064 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4065 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4066 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4067 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4068 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4069 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4070 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4071 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4072 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4073 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4074 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4075 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4076 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4077 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4078 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4079 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4080 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4081 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4082 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4083 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4084 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4085 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4086 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4087 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4088 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4089 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4090 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4091 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4092 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4093 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4094 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4095 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4096 buddytag = gtk_text_buffer_create_tag( |
11096 | 4097 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4098 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4099 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4100 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4101 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4102 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4103 return buddytag; |
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 |
4359 | 4106 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4107 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4108 const char *message, GaimMessageFlags flags, |
4359 | 4109 time_t mtime) |
4110 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4111 GaimGtkConversation *gtkconv; |
11581 | 4112 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4113 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4114 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4115 GaimPluginProtocolInfo *prpl_info; |
4359 | 4116 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4117 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4118 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4119 int line_count; |
4359 | 4120 char buf2[BUF_LONG]; |
4121 char mdate[64]; | |
4122 char color[10]; | |
4123 char *str; | |
4124 char *with_font_tag; | |
4896 | 4125 char *sml_attrib = NULL; |
6982 | 4126 size_t length = strlen(message) + 1; |
4895 | 4127 |
4359 | 4128 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4129 |
4130 /* Set the active conversation to the one that just messaged us. */ | |
4131 /* 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
|
4132 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4133 |
4359 | 4134 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4135 account = gaim_conversation_get_account(conv); |
11581 | 4136 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4137 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4138 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4139 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4140 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4141 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4142 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4143 /* 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
|
4144 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4145 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4146 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4147 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4148 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4149 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4150 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4151 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4152 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4153 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4154 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4155 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4156 |
8677 | 4157 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4158 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4159 | |
5133 | 4160 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4161 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4162 else | |
4163 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4164 |
4896 | 4165 if(gc) |
9699 | 4166 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4167 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4168 |
10503 | 4169 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4170 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4171 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4172 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4173 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4174 |
7956 | 4175 /* this is gonna crash one day, I can feel it. */ |
4176 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4177 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4178 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4179 } |
4359 | 4180 |
10737 | 4181 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4182 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4183 g_snprintf(buf2, sizeof(buf2), |
8690 | 4184 "<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
|
4185 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4186 |
8962 | 4187 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4188 |
8722 | 4189 } else if (flags & GAIM_MESSAGE_ERROR) { |
4190 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4191 "<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
|
4192 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4193 |
8962 | 4194 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4195 | |
7431 | 4196 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4197 g_snprintf(buf2, BUF_LONG, |
8690 | 4198 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4199 sml_attrib ? sml_attrib : "", message); |
7440 | 4200 |
10884 | 4201 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4202 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4203 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4204 } else { |
4895 | 4205 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4206 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
|
4207 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4208 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4209 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
|
4210 int tag_end_offset = 0; |
7440 | 4211 |
6621 | 4212 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4213 str = g_malloc(1024); |
7440 | 4214 |
4359 | 4215 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4216 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4217 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4218 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4219 tag_start_offset += 3; |
4359 | 4220 } |
4221 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4222 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4223 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4224 tag_end_offset = 2; |
4359 | 4225 strcpy(color, "#00FF00"); |
4226 } | |
7440 | 4227 } |
4359 | 4228 else { |
10504 | 4229 if (gaim_message_meify(new_message, -1)) { |
4359 | 4230 str = g_malloc(1024); |
7440 | 4231 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4232 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4233 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
|
4234 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4235 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4236 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4237 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4238 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4239 } |
7440 | 4240 |
6621 | 4241 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4242 strcpy(color, "#AF7F00"); |
4243 else | |
4244 strcpy(color, "#062585"); | |
4245 } | |
4246 else { | |
4247 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4248 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4249 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
|
4250 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4251 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4252 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4253 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4254 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4255 } |
6621 | 4256 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4257 strcpy(color, "#AF7F00"); |
6621 | 4258 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4259 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4260 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4261 |
10108 | 4262 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4263 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4264 } else |
7854 | 4265 strcpy(color, RECV_COLOR); |
4359 | 4266 } |
6621 | 4267 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4268 strcpy(color, SEND_COLOR); |
10892 | 4269 else { |
4270 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4271 strcpy(color, "#000000"); | |
4272 } | |
4359 | 4273 } |
4274 } | |
10892 | 4275 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4276 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4277 g_free(alias_escaped); |
11508 | 4278 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4279 /* 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
|
4280 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4281 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4282 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4283 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4284 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4285 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4286 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4287 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4288 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4289 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4290 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4291 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4292 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4293 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4294 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4295 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4296 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4297 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4298 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4299 /* 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
|
4300 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4301 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4302 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4303 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4304 } |
7440 | 4305 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4306 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4307 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4308 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4309 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4310 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4311 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4312 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4313 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4314 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4315 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4316 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4317 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4318 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4319 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4320 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4321 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4322 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4323 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4324 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4325 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4326 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4327 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4328 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4329 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4330 |
4359 | 4331 g_free(str); |
4332 | |
4895 | 4333 if(gc){ |
4896 | 4334 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4335 char *post = "</font>"; |
4336 int pre_len = strlen(pre); | |
4337 int post_len = strlen(post); | |
7440 | 4338 |
4895 | 4339 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4340 |
4895 | 4341 strcpy(with_font_tag, pre); |
4342 memcpy(with_font_tag + pre_len, new_message, length); | |
4343 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4344 |
4895 | 4345 length += pre_len + post_len; |
4346 g_free(pre); | |
4347 } | |
4608 | 4348 else |
4895 | 4349 with_font_tag = g_memdup(new_message, length); |
7440 | 4350 |
8962 | 4351 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4352 with_font_tag, gtk_font_options); | |
7440 | 4353 |
4354 g_free(with_font_tag); | |
7447 | 4355 g_free(new_message); |
7440 | 4356 } |
4357 | |
5012 | 4358 if(sml_attrib) |
4359 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4360 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4361 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4362 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4363 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4364 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4365 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4366 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4367 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4368 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4369 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4370 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4371 else if ((flags & GAIM_MESSAGE_NO_LOG) == GAIM_MESSAGE_NO_LOG) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4372 unseen = GAIM_UNSEEN_NOLOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4373 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4374 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4375 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4376 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4377 } |
4359 | 4378 } |
4379 | |
4380 static void | |
11869 | 4381 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
|
4382 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4383 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4384 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4385 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4386 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4387 GList *ll; |
11869 | 4388 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4389 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4390 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4391 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4392 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4393 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4394 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4395 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4396 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
|
4397 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4398 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4399 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4400 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4401 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4402 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4403 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4404 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4405 l = users; |
11869 | 4406 ll = flags; |
4407 lll = aliases; | |
4408 while (l != NULL && ll != NULL && lll != NULL) { | |
4409 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
|
4410 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4411 ll = ll->next; |
11869 | 4412 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4413 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4414 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4415 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4416 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4417 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
|
4418 const char *new_name, const char *new_alias) |
4359 | 4419 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4420 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4421 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4422 GaimGtkChatPane *gtkchat; |
11869 | 4423 GaimConvChatBuddyFlags flags; |
4359 | 4424 GtkTreeIter iter; |
4425 GtkTreeModel *model; | |
4426 int f = 1; | |
4427 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4428 chat = GAIM_CONV_CHAT(conv); |
4359 | 4429 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4430 gtkchat = gtkconv->u.chat; | |
4431 | |
9554 | 4432 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4433 | |
4434 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4435 return; | |
4436 | |
4437 while (f != 0) { | |
4438 char *val; | |
4439 | |
11869 | 4440 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4441 |
4442 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4443 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4444 g_free(val); | |
4359 | 4445 break; |
4446 } | |
9554 | 4447 |
4448 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4449 | |
4450 g_free(val); | |
4359 | 4451 } |
4452 | |
9554 | 4453 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4454 return; |
4455 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4456 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4457 |
11869 | 4458 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4459 } |
4460 | |
4461 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4462 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4463 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4464 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4465 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4466 GaimGtkChatPane *gtkchat; |
4359 | 4467 GtkTreeIter iter; |
4468 GtkTreeModel *model; | |
4469 char tmp[BUF_LONG]; | |
4470 int num_users; | |
4471 int f = 1; | |
4472 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4473 chat = GAIM_CONV_CHAT(conv); |
4359 | 4474 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4475 gtkchat = gtkconv->u.chat; | |
4476 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4477 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
|
4478 |
9554 | 4479 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4480 | |
4481 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4482 return; | |
4483 | |
4484 while (f != 0) { | |
4485 char *val; | |
4486 | |
4487 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4488 | |
4489 if (!gaim_utf8_strcasecmp(user, val)) { | |
4490 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4491 g_free(val); | |
4359 | 4492 break; |
4493 } | |
9554 | 4494 |
4495 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4496 | |
4497 g_free(val); | |
4359 | 4498 } |
4499 | |
9554 | 4500 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4501 return; |
4502 | |
4503 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4504 ngettext("%d person in room", "%d people in room", |
4505 num_users), num_users); | |
4359 | 4506 |
4507 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4508 | |
4509 } | |
4510 | |
4511 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4512 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4513 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4514 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4515 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4516 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4517 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4518 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4519 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4520 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4521 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4522 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4523 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4524 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4525 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4526 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4527 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4528 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
|
4529 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4530 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4531 for (l = users; l != NULL; l = l->next) { |
9554 | 4532 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4533 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4534 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4535 continue; |
4536 | |
4537 do { | |
4538 char *val; | |
4539 | |
4540 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4541 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4542 | |
9696 | 4543 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4544 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4545 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4546 #else |
4547 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4548 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4549 #endif | |
4550 } | |
9554 | 4551 else |
4552 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4553 | |
4554 g_free(val); | |
4555 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4556 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4557 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4558 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4559 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4560 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4561 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4562 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4563 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4564 |
9554 | 4565 static void |
4566 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4567 { | |
4568 GaimConvChat *chat; | |
11869 | 4569 GaimConvChatBuddyFlags flags; |
9554 | 4570 GaimGtkConversation *gtkconv; |
4571 GaimGtkChatPane *gtkchat; | |
4572 GtkTreeIter iter; | |
4573 GtkTreeModel *model; | |
4574 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4575 char *alias = NULL; |
9554 | 4576 |
4577 chat = GAIM_CONV_CHAT(conv); | |
4578 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4579 gtkchat = gtkconv->u.chat; | |
4580 | |
4581 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4582 | |
4583 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4584 return; | |
4585 | |
4586 while (f != 0) { | |
4587 char *val; | |
4588 | |
4589 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4590 | |
4591 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4592 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4593 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4594 g_free(val); | |
4595 break; | |
4596 } | |
4597 | |
4598 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4599 | |
4600 g_free(val); | |
4601 } | |
4602 | |
4603 if (!gaim_conv_chat_find_user(chat, user)) | |
4604 return; | |
4605 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4606 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4607 |
11869 | 4608 flags = gaim_conv_chat_user_get_flags(chat, user); |
4609 | |
4610 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4611 g_free(alias); |
9554 | 4612 } |
4613 | |
11581 | 4614 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4615 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4616 { |
11581 | 4617 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4618 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4619 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4620 |
11581 | 4621 win = gtkconv->win; |
4622 | |
4623 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
|
4624 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4625 if (has_focus) |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4626 { |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4627 GaimConversation *c = gaim_gtk_conv_window_get_active_conversation(win); |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4628 if (GAIM_GTK_CONVERSATION(c) == gtkconv) |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4629 return TRUE; |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4630 } |
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4631 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4632 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4633 |
10526 | 4634 static gboolean |
4635 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4636 { | |
4637 GaimGtkConversation *gtkconv; | |
4638 GtkIMHtmlSmiley *smiley; | |
4639 GdkPixbufLoader *loader; | |
11525 | 4640 struct smiley_list *list; |
4641 const char *sml = NULL, *conv_sml; | |
4642 | |
4643 if (!conv || !smile || !*smile) { | |
10526 | 4644 return FALSE; |
4645 } | |
4646 | |
11525 | 4647 /* If smileys are off, return false */ |
4648 if (gaim_gtkthemes_smileys_disabled()) | |
4649 return FALSE; | |
4650 | |
4651 /* If possible add this smiley to the current theme. | |
4652 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4653 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4654 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4655 |
4656 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4657 if (!strcmp(list->sml, conv_sml)) { | |
4658 sml = list->sml; | |
4659 break; | |
4660 } | |
4661 } | |
4662 | |
10526 | 4663 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4664 | |
4665 if (smiley) { | |
11525 | 4666 |
4667 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4668 return FALSE; | |
4669 } | |
4670 | |
4671 /* Close the old GdkPixbufAnimation, then create a new one for | |
4672 * the smiley we are about to receive */ | |
4673 g_object_unref(G_OBJECT(smiley->icon)); | |
4674 | |
4675 smiley->loader = gdk_pixbuf_loader_new(); | |
4676 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4677 if (smiley->icon) | |
4678 g_object_ref(G_OBJECT(smiley->icon)); | |
4679 | |
4680 /* A custom smiley is already associated */ | |
4681 return TRUE; | |
10526 | 4682 } |
4683 | |
4684 loader = gdk_pixbuf_loader_new(); | |
4685 | |
4686 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4687 /* 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
|
4688 GtkIMHtmlSmiley by opaque */ |
10526 | 4689 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4690 smiley->file = NULL; | |
4691 smiley->smile = g_strdup(smile); | |
4692 smiley->loader = loader; | |
11525 | 4693 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4694 |
4695 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4696 if (smiley->icon) | |
4697 g_object_ref(G_OBJECT(smiley->icon)); | |
4698 | |
11525 | 4699 |
10526 | 4700 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4701 |
10526 | 4702 return TRUE; |
4703 } | |
4704 | |
10537 | 4705 static void |
10526 | 4706 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4707 const guchar *data, gsize size) |
10526 | 4708 { |
4709 GaimGtkConversation *gtkconv; | |
4710 GtkIMHtmlSmiley *smiley; | |
10537 | 4711 GdkPixbufLoader *loader; |
10526 | 4712 const char *sml; |
4713 | |
4714 sml = gaim_account_get_protocol_name(conv->account); | |
4715 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4716 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4717 | |
10537 | 4718 if (!smiley) |
10526 | 4719 return; |
10537 | 4720 |
10526 | 4721 loader = smiley->loader; |
10537 | 4722 if (!loader) |
10526 | 4723 return; |
4724 | |
4725 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4726 } | |
4727 | |
4728 static void | |
4729 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4730 { | |
4731 GaimGtkConversation *gtkconv; | |
4732 GtkIMHtmlSmiley *smiley; | |
4733 GdkPixbufLoader *loader; | |
4734 const char *sml; | |
11525 | 4735 GtkWidget *icon = NULL; |
4736 GtkTextChildAnchor *anchor = NULL; | |
4737 GtkTextIter end; | |
4738 GtkIMHtml *imhtml; | |
4739 GSList *current = NULL; | |
10526 | 4740 |
4741 g_return_if_fail(conv != NULL); | |
4742 g_return_if_fail(smile != NULL); | |
4743 | |
4744 sml = gaim_account_get_protocol_name(conv->account); | |
4745 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4746 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4747 | |
10537 | 4748 if (!smiley) |
10526 | 4749 return; |
4750 | |
4751 loader = smiley->loader; | |
4752 | |
10537 | 4753 if (!loader) |
10526 | 4754 return; |
10537 | 4755 |
11525 | 4756 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4757 if (smiley->icon) | |
4758 g_object_ref(G_OBJECT(smiley->icon)); | |
4759 | |
4760 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4761 | |
4762 icon = gtk_image_new_from_animation(smiley->icon); | |
4763 | |
4764 if (icon) { | |
12047 | 4765 gtk_widget_show(icon); |
4766 | |
11525 | 4767 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
4768 | |
4769 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4770 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4771 | |
4772 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4773 } | |
4774 | |
4775 } | |
4776 | |
4777 g_slist_free(smiley->anchors); | |
4778 smiley->anchors = NULL; | |
4779 | |
4780 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4781 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4782 * makes me question it */ | |
4783 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4784 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4785 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4786 | |
10526 | 4787 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4788 | |
4789 gdk_pixbuf_loader_close(loader, NULL); | |
4790 g_object_unref(G_OBJECT(loader)); | |
4791 smiley->loader = NULL; | |
4792 } | |
4793 | |
11581 | 4794 /* |
4795 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4796 * sensitive/insensitive. This is called after changing tabs and when an | |
4797 * account signs on or off. | |
4798 */ | |
4799 static void | |
4800 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4801 { | |
4802 GaimGtkWindow *win; | |
4803 GaimConversation *conv = gtkconv->active_conv; | |
4804 GaimConnection *gc; | |
4805 GaimPluginProtocolInfo *prpl_info = NULL; | |
4806 GdkPixbuf *window_icon = NULL; | |
4807 GtkIMHtmlButtons buttons; | |
4808 GaimAccount *account; | |
4809 | |
4810 win = gaim_gtkconv_get_window(gtkconv); | |
4811 gc = gaim_conversation_get_gc(conv); | |
4812 account = gaim_conversation_get_account(conv); | |
4813 | |
4814 if (gc != NULL) | |
4815 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4816 | |
11594 | 4817 if (win->menu.send_to != NULL) |
11734 | 4818 update_send_to_selection(win); |
11581 | 4819 |
4820 /* | |
4821 * Handle hiding and showing stuff based on what type of conv this is. | |
4822 * Stuff that Gaim IMs support in general should be shown for IM | |
4823 * conversations. Stuff that Gaim chats support in general should be | |
4824 * shown for chat conversations. It doesn't matter whether the PRPL | |
4825 * supports it or not--that only affects if the button or menu item | |
4826 * is sensitive or not. | |
4827 */ | |
4828 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4829 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4830 | |
4831 /* Deal with menu items */ | |
4832 gtk_widget_show(win->menu.view_log); | |
4833 gtk_widget_show(win->menu.send_file); | |
4834 gtk_widget_show(win->menu.add_pounce); | |
4835 gtk_widget_show(win->menu.get_info); | |
4836 gtk_widget_hide(win->menu.invite); | |
4837 gtk_widget_show(win->menu.alias); | |
4838 gtk_widget_show(win->menu.block); | |
4839 | |
4840 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4841 gtk_widget_show(win->menu.add); | |
4842 gtk_widget_hide(win->menu.remove); | |
4843 } else { | |
4844 gtk_widget_show(win->menu.remove); | |
4845 gtk_widget_hide(win->menu.add); | |
4846 } | |
4847 | |
4848 gtk_widget_show(win->menu.insert_link); | |
4849 gtk_widget_show(win->menu.insert_image); | |
4850 gtk_widget_show(win->menu.show_icon); | |
4851 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4852 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4853 | |
4854 /* Deal with menu items */ | |
4855 gtk_widget_show(win->menu.view_log); | |
4856 gtk_widget_hide(win->menu.send_file); | |
4857 gtk_widget_hide(win->menu.add_pounce); | |
4858 gtk_widget_hide(win->menu.get_info); | |
4859 gtk_widget_show(win->menu.invite); | |
4860 gtk_widget_show(win->menu.alias); | |
4861 gtk_widget_hide(win->menu.block); | |
4862 gtk_widget_hide(win->menu.show_icon); | |
4863 | |
4864 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4865 /* If the chat is NOT in the buddy list */ | |
4866 gtk_widget_show(win->menu.add); | |
4867 gtk_widget_hide(win->menu.remove); | |
4868 } else { | |
4869 /* If the chat IS in the buddy list */ | |
4870 gtk_widget_hide(win->menu.add); | |
4871 gtk_widget_show(win->menu.remove); | |
4872 } | |
4873 | |
4874 gtk_widget_show(win->menu.insert_link); | |
4875 gtk_widget_hide(win->menu.insert_image); | |
4876 } | |
4877 | |
4878 /* | |
4879 * Handle graying stuff out based on whether an account is connected | |
4880 * and what features that account supports. | |
4881 */ | |
4882 if ((gc != NULL) && | |
12012 | 4883 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
4884 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
4885 { | |
11581 | 4886 /* Account is online */ |
4887 /* Deal with the toolbar */ | |
12012 | 4888 if (conv->features & GAIM_CONNECTION_HTML) |
4889 { | |
4890 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
4891 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
4892 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
4893 buttons &= ~GTK_IMHTML_IMAGE; | |
4894 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
4895 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
4896 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
4897 { | |
4898 buttons &= ~GTK_IMHTML_GROW; | |
4899 buttons &= ~GTK_IMHTML_SHRINK; | |
4900 } | |
4901 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
4902 buttons &= ~GTK_IMHTML_LINKDESC; | |
4903 } else { | |
4904 buttons = GTK_IMHTML_SMILEY; | |
4905 } | |
4906 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
4907 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 4908 |
4909 /* Deal with menu items */ | |
12012 | 4910 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4911 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4912 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
4913 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
4914 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
4915 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 4916 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 4917 |
4918 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
4919 { | |
4920 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
4921 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
4922 gtk_widget_set_sensitive(win->menu.send_file, | |
4923 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
4924 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
4925 gtk_widget_set_sensitive(win->menu.alias, | |
4926 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
4927 } | |
4928 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
4929 { | |
4930 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
4931 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
4932 gtk_widget_set_sensitive(win->menu.alias, | |
4933 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
4934 } | |
11581 | 4935 |
4936 /* Deal with chat userlist buttons */ | |
12012 | 4937 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4938 { | |
4939 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
4940 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
4941 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
4942 } | |
4943 } else { | |
11581 | 4944 /* Account is offline */ |
4945 /* Or it's a chat that we've left. */ | |
4946 | |
4947 /* Then deal with menu items */ | |
12012 | 4948 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4949 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
4950 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4951 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
4952 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
4953 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
4954 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
4955 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
4956 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
4957 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
4958 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 4959 |
4960 /* Deal with chat userlist buttons */ | |
12012 | 4961 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4962 { | |
4963 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
4964 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
4965 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
4966 } | |
4967 } | |
11581 | 4968 |
4969 /* | |
4970 * Update the window's icon | |
4971 */ | |
4972 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
12012 | 4973 (gtkconv->u.im->anim)) |
11581 | 4974 { |
4975 window_icon = | |
4976 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
4977 g_object_ref(window_icon); | |
4978 } else { | |
4979 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
4980 } | |
4981 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
4982 if (window_icon != NULL) | |
4983 g_object_unref(G_OBJECT(window_icon)); | |
4984 } | |
4985 | |
10526 | 4986 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4987 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4988 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 4989 { |
11581 | 4990 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4991 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4992 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4993 GaimConvChat *chat; |
4359 | 4994 |
10116 | 4995 g_return_if_fail(conv != NULL); |
4996 | |
4359 | 4997 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4998 win = gtkconv->win; |
10810 | 4999 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5000 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5001 * instead of the gross hack? | |
5002 */ | |
4359 | 5003 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5004 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5005 { |
4359 | 5006 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5007 |
11338 | 5008 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5009 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5010 |
4359 | 5011 gaim_gtkconv_update_buttons_by_protocol(conv); |
5012 | |
11734 | 5013 update_send_to_selection(win); |
4359 | 5014 |
11525 | 5015 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5016 |
6395 | 5017 update_tab_icon(conv); |
4359 | 5018 } |
5019 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5020 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5021 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5022 { |
9472 | 5023 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5024 GaimConvIm *im = NULL; |
9472 | 5025 GaimConnection *gc = gaim_conversation_get_gc(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5026 /* 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
|
5027 char style[51]; |
4736 | 5028 |
11338 | 5029 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5030 im = GAIM_CONV_IM(conv); |
4359 | 5031 |
11338 | 5032 if (!gc || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5033 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5034 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5035 else | |
5036 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5037 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5038 *style = '\0'; |
4359 | 5039 |
5040 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5041 gtk_widget_realize(gtkconv->tab_label); | |
5042 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5043 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5044 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5045 { |
11759 | 5046 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5047 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5048 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5049 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5050 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5051 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5052 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5053 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5054 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5055 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5056 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5057 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5058 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5059 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5060 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5061 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5062 { |
11758 | 5063 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5064 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5065 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5066 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5067 { |
8536 | 5068 char *html_title,*label; |
5069 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5070 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5071 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5072 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5073 style, html_title); |
8536 | 5074 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5075 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5076 g_free(label); |
4359 | 5077 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5078 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5079 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5080 |
11581 | 5081 if (conv == gaim_gtk_conv_window_get_active_conversation(win)) |
10810 | 5082 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5083 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5084 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5085 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
11581 | 5086 if (conv == gaim_gtk_conv_window_get_active_conversation(win)) |
5087 gtk_window_set_title(GTK_WINDOW(win->window), title); | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5088 } |
9472 | 5089 |
5090 g_free(title); | |
4359 | 5091 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5092 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5093 { |
7154 | 5094 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5095 chat = GAIM_CONV_CHAT(conv); |
4359 | 5096 gtkchat = gtkconv->u.chat; |
5097 | |
7154 | 5098 topic = gaim_conv_chat_get_topic(chat); |
5099 | |
9554 | 5100 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5101 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5102 topic ? topic : "", NULL); |
4359 | 5103 } |
5104 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5105 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5106 { |
11581 | 5107 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5108 generate_send_to_items(win); |
8946 | 5109 update_tab_icon(conv); |
9472 | 5110 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5111 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5112 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5113 { |
8946 | 5114 update_tab_icon(conv); |
4359 | 5115 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5116 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
|
5117 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5118 { |
9472 | 5119 gaim_conversation_autoset_title(conv); |
10810 | 5120 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5121 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5122 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5123 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5124 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5125 } |
10665 | 5126 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5127 { | |
10810 | 5128 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5129 } |
4359 | 5130 } |
5131 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5132 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5133 { |
11581 | 5134 gaim_gtkconv_new, |
4359 | 5135 gaim_gtkconv_destroy, /* destroy_conversation */ |
5136 gaim_gtkconv_write_chat, /* write_chat */ | |
5137 gaim_gtkconv_write_im, /* write_im */ | |
5138 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5139 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5140 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5141 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5142 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5143 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5144 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5145 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5146 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5147 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5148 gaim_gtkconv_updated /* updated */ |
5149 }; | |
5150 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5151 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5152 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5153 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5154 return &conversation_ui_ops; |
4359 | 5155 } |
5156 | |
5157 /************************************************************************** | |
5158 * Public conversation utility functions | |
5159 **************************************************************************/ | |
5160 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5161 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5162 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5163 GaimGtkConversation *gtkconv; |
11581 | 5164 GaimGtkWindow *win; |
4359 | 5165 |
10381 | 5166 GdkPixbufLoader *loader; |
5167 GdkPixbufAnimation *anim; | |
4359 | 5168 GError *err = NULL; |
5169 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5170 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5171 size_t len; |
4359 | 5172 |
5173 GdkPixbuf *buf; | |
5174 | |
5175 GtkWidget *event; | |
5176 GtkWidget *frame; | |
5177 GdkPixbuf *scale; | |
5178 GdkPixmap *pm; | |
5179 GdkBitmap *bm; | |
9318 | 5180 int scale_width, scale_height; |
5181 | |
5182 GaimAccount *account; | |
5183 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5184 |
9324 | 5185 GaimBuddyIcon *icon; |
5186 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5187 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5188 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5189 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5190 |
5191 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5192 win = gtkconv->win; |
10175 | 5193 |
9687 | 5194 if (!gtkconv->u.im->show_icon) |
5195 return; | |
5196 | |
9318 | 5197 account = gaim_conversation_get_account(conv); |
5198 if(account && account->gc) | |
5199 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5200 |
9845 | 5201 /* Remove the current icon stuff */ |
9885 | 5202 if (gtkconv->u.im->icon_container != NULL) |
5203 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5204 gtkconv->u.im->icon_container = NULL; | |
9845 | 5205 |
5206 if (gtkconv->u.im->anim != NULL) | |
5207 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5208 | |
9887 | 5209 gtkconv->u.im->anim = NULL; |
5210 | |
9845 | 5211 if (gtkconv->u.im->icon_timer != 0) |
5212 g_source_remove(gtkconv->u.im->icon_timer); | |
5213 | |
5214 gtkconv->u.im->icon_timer = 0; | |
5215 | |
5216 if (gtkconv->u.im->iter != NULL) | |
5217 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5218 |
10116 | 5219 gtkconv->u.im->iter = NULL; |
5220 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5221 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5222 return; |
5223 | |
5224 if (gaim_conversation_get_gc(conv) == NULL) | |
5225 return; | |
5226 | |
9324 | 5227 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5228 | |
5229 if (icon == NULL) | |
5230 return; | |
5231 | |
5232 data = gaim_buddy_icon_get_data(icon, &len); | |
5233 | |
10381 | 5234 loader = gdk_pixbuf_loader_new(); |
5235 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5236 anim = gdk_pixbuf_loader_get_animation(loader); | |
5237 if (anim) | |
5238 g_object_ref(G_OBJECT(anim)); | |
5239 gdk_pixbuf_loader_close(loader, &err); | |
5240 g_object_unref(loader); | |
5241 | |
5242 if (!anim) | |
9324 | 5243 return; |
10381 | 5244 gtkconv->u.im->anim = anim; |
9324 | 5245 |
4359 | 5246 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5247 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5248 "Buddy icon error: %s\n", err->message); |
4359 | 5249 g_error_free(err); |
5250 } | |
5251 | |
5252 if (!gtkconv->u.im->anim) | |
5253 return; | |
5254 | |
5255 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5256 gtkconv->u.im->iter = NULL; | |
5257 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5258 } else { | |
5259 gtkconv->u.im->iter = | |
8496 | 5260 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5261 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5262 if (gtkconv->u.im->animate) |
10810 | 5263 start_anim(NULL, gtkconv); |
4359 | 5264 } |
5265 | |
10483 | 5266 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5267 NULL, &scale_width, &scale_height); |
4359 | 5268 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5269 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5270 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5271 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5272 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5273 GDK_INTERP_BILINEAR); |
4359 | 5274 |
5275 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5276 g_object_unref(G_OBJECT(scale)); |
4359 | 5277 |
8821 | 5278 |
9885 | 5279 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5280 |
4359 | 5281 frame = gtk_frame_new(NULL); |
5282 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5283 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5284 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5285 FALSE, FALSE, 0); | |
8821 | 5286 |
4359 | 5287 event = gtk_event_box_new(); |
5288 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5289 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5290 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5291 gtk_widget_show(event); |
5292 | |
4635 | 5293 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5294 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5295 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5296 gtk_widget_show(gtkconv->u.im->icon); | |
5297 | |
4793 | 5298 g_object_unref(G_OBJECT(pm)); |
4359 | 5299 |
5300 if (bm) | |
4793 | 5301 g_object_unref(G_OBJECT(bm)); |
7143 | 5302 |
10356 | 5303 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5304 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5305 |
9885 | 5306 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5307 gtk_widget_show(frame); |
5308 | |
7143 | 5309 /* The buddy icon code needs badly to be fixed. */ |
5310 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
11581 | 5311 if(conv == gaim_gtk_conv_window_get_active_conversation(gtkconv->win)) |
5312 gtk_window_set_icon(GTK_WINDOW(win->window), buf); | |
4359 | 5313 } |
5314 | |
5315 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5316 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5317 { |
11581 | 5318 GaimGtkWindow *win; |
4359 | 5319 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5320 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5321 return; |
5322 | |
11581 | 5323 win = GAIM_GTK_CONVERSATION(conv)->win; |
5324 | |
5325 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5326 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5327 } |
5328 | |
5329 int | |
11614 | 5330 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5331 { |
4359 | 5332 gint nb_x, nb_y, x_rel, y_rel; |
5333 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5334 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5335 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5336 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5337 gboolean horiz; |
4359 | 5338 |
11614 | 5339 if (to_right) |
5340 *to_right = FALSE; | |
5341 | |
11581 | 5342 notebook = GTK_NOTEBOOK(win->notebook); |
5343 | |
5344 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5345 x_rel = x - nb_x; |
5346 y_rel = y - nb_y; | |
5347 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5348 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5349 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5350 |
11780 | 5351 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5352 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5353 #else |
5354 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5355 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5356 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5357 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5358 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5359 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5360 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5361 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5362 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5363 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5364 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5365 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
|
5366 page_num = i; |
11614 | 5367 |
5368 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5369 *to_right = TRUE; | |
5370 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5371 break; |
4359 | 5372 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5373 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5374 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5375 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
|
5376 page_num = i; |
11614 | 5377 |
5378 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5379 *to_right = TRUE; | |
5380 | |
4359 | 5381 break; |
5382 } | |
5383 } | |
5384 } | |
5385 | |
5386 return page_num; | |
5387 } | |
5388 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5389 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5390 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
|
5391 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5392 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5393 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5394 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5395 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5396 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5397 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5398 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5399 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5400 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5401 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5402 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5403 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5404 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5405 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5406 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5407 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5408 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5409 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5410 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5411 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5412 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5413 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5414 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5415 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5416 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5417 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5418 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5419 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5420 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5421 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5422 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5423 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5424 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5425 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5426 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5427 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5428 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5429 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5430 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5431 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5432 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5433 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5434 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5435 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5436 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5437 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5438 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5439 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5440 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5441 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5442 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5443 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5444 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5445 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5446 GtkPositionType pos; |
11581 | 5447 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5448 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5449 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5450 |
11581 | 5451 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5452 win = l->data; | |
5453 | |
11619 | 5454 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
|
5455 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5456 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5457 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5458 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5459 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5460 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5461 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5462 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5463 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5464 GaimGtkConversation *gtkconv; |
11581 | 5465 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5466 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5467 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5468 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5469 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5470 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5471 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5472 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5473 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5474 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5475 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5476 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5477 gtk_check_menu_item_set_active( |
11581 | 5478 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5479 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5480 |
5481 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5482 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5483 else |
8317 | 5484 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5485 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5486 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5487 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5488 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5489 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5490 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5491 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5492 GList *l; |
8189 | 5493 GaimConversation *conv; |
5494 GaimGtkConversation *gtkconv; | |
11581 | 5495 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5496 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5497 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
|
5498 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5499 |
8189 | 5500 /* Set the "animate" flag for each icon based on the new preference */ |
5501 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5502 conv = (GaimConversation *)l->data; | |
5503 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5504 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5505 } |
8189 | 5506 |
5507 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5508 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5509 win = l->data; | |
5510 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5511 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5512 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5513 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5514 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5515 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5516 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
|
5517 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5518 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5519 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5520 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5521 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5522 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5523 |
11338 | 5524 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5525 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5526 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5527 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5528 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5529 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5530 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5531 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5532 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5533 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5534 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5535 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5536 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5537 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5538 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5539 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5540 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5541 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5542 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5543 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5544 |
11581 | 5545 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5546 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5547 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5548 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5549 |
11581 | 5550 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5551 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5552 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5553 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5554 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5555 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5556 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5557 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5558 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5559 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5560 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5561 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5562 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5563 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5564 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5565 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5566 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5567 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5568 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5569 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5570 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5571 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5572 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5573 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5574 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5575 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5576 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5577 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5578 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5579 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5580 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5581 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5582 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5583 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5584 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5585 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5586 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
|
5587 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5588 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5589 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5590 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5591 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5592 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5593 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5594 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5595 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5596 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5597 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5598 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5599 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5600 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5601 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5602 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5603 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
|
5604 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5605 /* Connect callbacks. */ |
10087 | 5606 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
|
5607 close_on_tabs_pref_cb, NULL); |
10087 | 5608 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
|
5609 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5610 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5611 spellcheck_pref_cb, NULL); |
10087 | 5612 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5613 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5614 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5615 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5616 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5617 |
10087 | 5618 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5619 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5620 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5621 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5622 /* IM callbacks */ |
10087 | 5623 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
|
5624 animate_buddy_icons_pref_cb, NULL); |
10087 | 5625 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
|
5626 show_buddy_icons_pref_cb, NULL); |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5627 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5628 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5629 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5630 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5631 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5632 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5633 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5634 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5635 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5636 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5637 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5638 |
5639 /********************************************************************** | |
5640 * Register commands | |
5641 **********************************************************************/ | |
9829 | 5642 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5643 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5644 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5645 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5646 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5647 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5648 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5649 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5650 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
|
5651 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5652 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5653 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5654 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5655 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5656 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5657 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5658 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5659 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5660 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5661 |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5662 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5663 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5664 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5665 G_CALLBACK(buddy_update_cb), NULL); |
5666 | |
11581 | 5667 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5668 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5669 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5670 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5671 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5672 { |
10443 | 5673 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5674 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5675 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5676 } |
11581 | 5677 |
5678 | |
5679 | |
5680 | |
5681 | |
5682 | |
5683 | |
5684 | |
5685 | |
5686 | |
5687 | |
5688 | |
5689 | |
5690 | |
5691 | |
5692 | |
5693 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5694 * and touch each others' private members all day long */ | |
5695 | |
5696 /** | |
5697 * @file gtkconvwin.c GTK+ Conversation Window API | |
5698 * @ingroup gtkui | |
5699 * | |
5700 * gaim | |
5701 * | |
5702 * Gaim is the legal property of its developers, whose names are too numerous | |
5703 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5704 * source distribution. | |
5705 * | |
5706 * This program is free software; you can redistribute it and/or modify | |
5707 * it under the terms of the GNU General Public License as published by | |
5708 * the Free Software Foundation; either version 2 of the License, or | |
5709 * (at your option) any later version. | |
5710 * | |
5711 * This program is distributed in the hope that it will be useful, | |
5712 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
5713 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
5714 * GNU General Public License for more details. | |
5715 * | |
5716 * You should have received a copy of the GNU General Public License | |
5717 * along with this program; if not, write to the Free Software | |
5718 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5719 * | |
5720 */ | |
5721 #include "internal.h" | |
5722 #include "gtkgaim.h" | |
5723 | |
5724 | |
5725 #include <gdk/gdkkeysyms.h> | |
5726 | |
5727 #include "account.h" | |
5728 #include "cmds.h" | |
5729 #include "debug.h" | |
5730 #include "imgstore.h" | |
5731 #include "log.h" | |
5732 #include "notify.h" | |
5733 #include "prpl.h" | |
5734 #include "request.h" | |
5735 #include "util.h" | |
5736 | |
5737 #include "gtkdnd-hints.h" | |
5738 #include "gtkblist.h" | |
5739 #include "gtkconv.h" | |
5740 #include "gtkdialogs.h" | |
5741 #include "gtkmenutray.h" | |
5742 #include "gtkpounce.h" | |
5743 #include "gtkprefs.h" | |
5744 #include "gtkprivacy.h" | |
5745 #include "gtkutils.h" | |
5746 #include "gtkstock.h" | |
5747 #include "gtkimhtml.h" | |
5748 #include "gtkimhtmltoolbar.h" | |
5749 | |
5750 static void | |
5751 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
5752 { | |
5753 gtk_widget_destroy(warn_close_dialog); | |
5754 warn_close_dialog = NULL; | |
5755 | |
5756 if (resp == GTK_RESPONSE_OK) | |
5757 gaim_gtk_conv_window_destroy(win); | |
5758 } | |
5759 | |
5760 static void | |
5761 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
5762 { | |
5763 GtkWidget *label; | |
5764 GtkWidget *vbox, *hbox; | |
5765 GtkWidget *img; | |
5766 | |
5767 g_return_if_fail(warn_close_dialog == NULL); | |
5768 | |
5769 | |
5770 warn_close_dialog = gtk_dialog_new_with_buttons( | |
5771 _("Confirm close"), | |
5772 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
5773 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
5774 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
5775 | |
5776 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
5777 GTK_RESPONSE_OK); | |
5778 | |
5779 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
5780 6); | |
5781 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
5782 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
5783 FALSE); | |
5784 | |
5785 /* Setup the outside spacing. */ | |
5786 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
5787 | |
5788 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
5789 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
5790 | |
5791 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
5792 GTK_ICON_SIZE_DIALOG); | |
5793 /* Setup the inner hbox and put the dialog's icon in it. */ | |
5794 hbox = gtk_hbox_new(FALSE, 12); | |
5795 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
5796 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
5797 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
5798 | |
5799 /* Setup the right vbox. */ | |
5800 vbox = gtk_vbox_new(FALSE, 12); | |
5801 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
5802 | |
5803 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
5804 gtk_widget_set_size_request(label, 350, -1); | |
5805 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
5806 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
5807 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
5808 | |
5809 /* Connect the signals. */ | |
5810 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
5811 G_CALLBACK(do_close), gtkwin); | |
5812 | |
5813 } | |
5814 | |
5815 /************************************************************************** | |
5816 * Callbacks | |
5817 **************************************************************************/ | |
5818 | |
5819 static gboolean | |
5820 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
5821 { | |
5822 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5823 GList *l; |
11581 | 5824 |
5825 /* If there are unread messages then show a warning dialog */ | |
5826 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
5827 l != NULL; l = l->next) | |
5828 { | |
5829 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5830 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
|
5831 gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5832 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5833 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5834 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5835 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5836 return TRUE; |
11581 | 5837 } |
5838 } | |
5839 | |
5840 gaim_gtk_conv_window_destroy(win); | |
5841 | |
5842 return TRUE; | |
5843 } | |
5844 | |
11604 | 5845 static void |
5846 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
5847 { | |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5848 /* only allow NONE or higher priority unseen state */ |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5849 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
|
5850 || state > gtkconv->unseen_state) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5851 gtkconv->unseen_state = state; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5852 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5853 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5854 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5855 |
11581 | 5856 /* |
5857 * When a conversation window is focused, we know the user | |
5858 * has looked at it so we know there are no longer unseen | |
5859 * messages. | |
5860 */ | |
5861 static gint | |
5862 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
5863 { | |
5864 GaimGtkWindow *win = d; | |
11604 | 5865 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
5866 | |
5867 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 5868 |
5869 return FALSE; | |
5870 } | |
5871 | |
11851 | 5872 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 5873 /* Courtesy of Galeon! */ |
5874 static void | |
5875 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
5876 { | |
5877 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
5878 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
5879 } | |
11851 | 5880 #endif |
11581 | 5881 |
5882 static void | |
5883 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
5884 { | |
5885 static GdkCursor *cursor = NULL; | |
5886 | |
5887 gtkwin->in_drag = TRUE; | |
5888 | |
5889 if (gtkwin->drag_leave_signal) { | |
5890 g_signal_handler_disconnect(G_OBJECT(widget), | |
5891 gtkwin->drag_leave_signal); | |
5892 gtkwin->drag_leave_signal = 0; | |
5893 } | |
5894 | |
5895 if (cursor == NULL) | |
5896 cursor = gdk_cursor_new(GDK_FLEUR); | |
5897 | |
5898 /* Grab the pointer */ | |
5899 gtk_grab_add(gtkwin->notebook); | |
5900 #ifndef _WIN32 | |
5901 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
5902 always be true after a button press. */ | |
5903 if (!gdk_pointer_is_grabbed()) | |
5904 #endif | |
5905 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
5906 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
5907 NULL, cursor, GDK_CURRENT_TIME); | |
5908 } | |
5909 | |
5910 static gboolean | |
5911 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
5912 { | |
5913 | |
5914 /* | |
5915 * Make sure the user moved the mouse far enough for the | |
5916 * drag to be initiated. | |
5917 */ | |
5918 if (win->in_predrag) { | |
5919 if (e->x_root < win->drag_min_x || | |
5920 e->x_root >= win->drag_max_x || | |
5921 e->y_root < win->drag_min_y || | |
5922 e->y_root >= win->drag_max_y) { | |
5923 | |
5924 win->in_predrag = FALSE; | |
5925 notebook_init_grab(win, widget); | |
5926 } | |
5927 } | |
5928 else { /* Otherwise, draw the arrows. */ | |
5929 GaimGtkWindow *dest_win; | |
5930 GtkNotebook *dest_notebook; | |
5931 GtkWidget *tab; | |
5932 gint nb_x, nb_y, page_num; | |
5933 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
5934 gboolean horiz_tabs = FALSE; | |
11614 | 5935 GaimGtkConversation *gtkconv; |
5936 gboolean to_right = FALSE; | |
11581 | 5937 |
5938 /* Get the window that the cursor is over. */ | |
5939 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
5940 | |
5941 if (dest_win == NULL) { | |
5942 dnd_hints_hide_all(); | |
5943 | |
5944 return TRUE; | |
5945 } | |
5946 | |
5947 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
5948 | |
5949 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
5950 | |
5951 arrow1_x = arrow2_x = nb_x; | |
5952 arrow1_y = arrow2_y = nb_y; | |
5953 | |
5954 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 5955 e->x_root, e->y_root, &to_right); |
5956 to_right = to_right && (win != dest_win); | |
11581 | 5957 |
5958 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
5959 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
5960 | |
5961 horiz_tabs = TRUE; | |
5962 } | |
5963 | |
11614 | 5964 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
5965 tab = gtkconv->tabby; | |
11581 | 5966 |
5967 if (horiz_tabs) { | |
5968 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
5969 | |
11614 | 5970 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 5971 arrow1_x += tab->allocation.width; |
5972 arrow2_x += tab->allocation.width; | |
5973 } | |
5974 | |
5975 arrow1_y = nb_y + tab->allocation.y; | |
5976 arrow2_y = nb_y + tab->allocation.y + | |
5977 tab->allocation.height; | |
5978 } else { | |
5979 arrow1_x = nb_x + tab->allocation.x; | |
5980 arrow2_x = nb_x + tab->allocation.x + | |
5981 tab->allocation.width; | |
5982 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
5983 | |
5984 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
5985 arrow1_y += tab->allocation.height; | |
5986 arrow2_y += tab->allocation.height; | |
5987 } | |
5988 } | |
5989 | |
5990 if (horiz_tabs) { | |
5991 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
5992 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
5993 } else { | |
5994 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
5995 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
5996 } | |
5997 } | |
5998 | |
5999 return TRUE; | |
6000 } | |
6001 | |
6002 static gboolean | |
6003 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6004 { | |
6005 if (win->in_drag) | |
6006 return FALSE; | |
6007 | |
6008 if (e->x_root < win->drag_min_x || | |
6009 e->x_root >= win->drag_max_x || | |
6010 e->y_root < win->drag_min_y || | |
6011 e->y_root >= win->drag_max_y) { | |
6012 | |
6013 win->in_predrag = FALSE; | |
6014 notebook_init_grab(win, widget); | |
6015 } | |
6016 | |
6017 return TRUE; | |
6018 } | |
6019 | |
6020 /* | |
6021 * THANK YOU GALEON! | |
6022 */ | |
6023 static gboolean | |
6024 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6025 { | |
6026 gint nb_x, nb_y, x_rel, y_rel; | |
6027 int tab_clicked; | |
6028 GtkWidget *page; | |
6029 GtkWidget *tab; | |
6030 | |
6031 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6032 return FALSE; | |
6033 | |
6034 | |
6035 if (win->in_drag) { | |
6036 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6037 "Already in the middle of a window drag at tab_press_cb\n"); | |
6038 return TRUE; | |
6039 } | |
6040 | |
6041 /* | |
6042 * Make sure a tab was actually clicked. The arrow buttons | |
6043 * mess things up. | |
6044 */ | |
11614 | 6045 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6046 |
6047 if (tab_clicked == -1) | |
6048 return FALSE; | |
6049 | |
6050 /* | |
6051 * Get the relative position of the press event, with regards to | |
6052 * the position of the notebook. | |
6053 */ | |
6054 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6055 | |
6056 x_rel = e->x_root - nb_x; | |
6057 y_rel = e->y_root - nb_y; | |
6058 | |
6059 /* Reset the min/max x/y */ | |
6060 win->drag_min_x = 0; | |
6061 win->drag_min_y = 0; | |
6062 win->drag_max_x = 0; | |
6063 win->drag_max_y = 0; | |
6064 | |
6065 /* Find out which tab was dragged. */ | |
6066 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6067 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6068 | |
6069 win->drag_min_x = tab->allocation.x + nb_x; | |
6070 win->drag_min_y = tab->allocation.y + nb_y; | |
6071 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6072 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6073 | |
6074 /* Make sure the click occurred in the tab. */ | |
6075 if (e->x_root < win->drag_min_x || | |
6076 e->x_root >= win->drag_max_x || | |
6077 e->y_root < win->drag_min_y || | |
6078 e->y_root >= win->drag_max_y) { | |
6079 | |
6080 return FALSE; | |
6081 } | |
6082 | |
6083 win->in_predrag = TRUE; | |
6084 win->drag_tab = tab_clicked; | |
6085 | |
6086 /* Connect the new motion signals. */ | |
6087 win->drag_motion_signal = | |
6088 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6089 G_CALLBACK(notebook_motion_cb), win); | |
6090 | |
6091 win->drag_leave_signal = | |
6092 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6093 G_CALLBACK(notebook_leave_cb), win); | |
6094 | |
6095 return FALSE; | |
6096 } | |
6097 | |
6098 static gboolean | |
6099 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6100 { | |
6101 GaimGtkWindow *dest_win; | |
6102 GaimConversation *conv; | |
6103 GaimGtkConversation *gtkconv; | |
6104 gint dest_page_num = 0; | |
6105 gboolean new_window = FALSE; | |
11614 | 6106 gboolean to_right = FALSE; |
11581 | 6107 |
6108 /* | |
6109 * Don't check to make sure that the event's window matches the | |
6110 * widget's, because we may be getting an event passed on from the | |
6111 * close button. | |
6112 */ | |
6113 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6114 return FALSE; | |
6115 | |
6116 if (gdk_pointer_is_grabbed()) { | |
6117 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6118 gtk_grab_remove(widget); | |
6119 } | |
6120 | |
6121 if (!win->in_predrag && !win->in_drag) | |
6122 return FALSE; | |
6123 | |
6124 /* Disconnect the motion signal. */ | |
6125 if (win->drag_motion_signal) { | |
6126 g_signal_handler_disconnect(G_OBJECT(widget), | |
6127 win->drag_motion_signal); | |
6128 | |
6129 win->drag_motion_signal = 0; | |
6130 } | |
6131 | |
6132 /* | |
6133 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6134 * signal. | |
6135 */ | |
6136 if (win->in_predrag) { | |
6137 win->in_predrag = FALSE; | |
6138 | |
6139 if (win->drag_leave_signal) { | |
6140 g_signal_handler_disconnect(G_OBJECT(widget), | |
6141 win->drag_leave_signal); | |
6142 | |
6143 win->drag_leave_signal = 0; | |
6144 } | |
6145 } | |
6146 | |
6147 /* If we're not in drag... */ | |
6148 /* We're perfectly normal people! */ | |
6149 if (!win->in_drag) | |
6150 return FALSE; | |
6151 | |
6152 win->in_drag = FALSE; | |
6153 | |
6154 dnd_hints_hide_all(); | |
6155 | |
6156 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6157 | |
6158 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6159 | |
6160 if (dest_win == NULL) { | |
6161 /* If the current window doesn't have any other conversations, | |
6162 * there isn't much point transferring the conv to a new window. */ | |
6163 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6164 /* Make a new window to stick this to. */ | |
6165 dest_win = gaim_gtk_conv_window_new(); | |
6166 new_window = TRUE; | |
6167 } | |
6168 } | |
6169 | |
6170 if (dest_win == NULL) | |
6171 return FALSE; | |
6172 | |
6173 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6174 "conversation-dragging", win, dest_win); | |
6175 | |
6176 /* Get the destination page number. */ | |
6177 if (!new_window) | |
6178 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6179 e->x_root, e->y_root, &to_right); |
11581 | 6180 |
6181 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6182 | |
6183 if (win == dest_win) { | |
6184 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6185 } else { | |
6186 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6187 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6188 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6189 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6190 if (new_window) { | |
6191 gint win_width, win_height; | |
6192 | |
6193 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6194 &win_width, &win_height); | |
6195 | |
6196 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6197 e->x_root - (win_width / 2), | |
6198 e->y_root - (win_height / 2)); | |
6199 | |
6200 gaim_gtk_conv_window_show(dest_win); | |
6201 } | |
6202 } | |
6203 | |
6204 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6205 | |
6206 return TRUE; | |
6207 } | |
6208 | |
6209 | |
6210 static void | |
6211 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6212 gpointer user_data) | |
6213 { | |
6214 GaimGtkWindow *win; | |
6215 GaimConversation *conv; | |
6216 GaimGtkConversation *gtkconv; | |
6217 | |
6218 win = user_data; | |
6219 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6220 | |
6221 g_return_if_fail(conv != NULL); | |
6222 | |
6223 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6224 return; | |
6225 | |
6226 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6227 | |
6228 stop_anim(NULL, gtkconv); | |
6229 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6230 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6231 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6232 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6233 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6234 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6235 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6236 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6237 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6238 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6239 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6240 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6241 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6242 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6243 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6244 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6245 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6246 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6247 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6248 /* 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
|
6249 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6250 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6251 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6252 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6253 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6254 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6255 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6256 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6257 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6258 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6259 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6260 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6261 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6262 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6263 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6264 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6265 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6266 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6267 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6268 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6269 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6270 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6271 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6272 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6273 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6274 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6275 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6276 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6277 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6278 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6279 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6280 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6281 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6282 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6283 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6284 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6285 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6286 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6287 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6288 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6289 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6290 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6291 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6292 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6293 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6294 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6295 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6296 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6297 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6298 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6299 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6300 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6301 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6302 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6303 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6304 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6305 gaim_gtkconv_get_tab_at_xy(win, event->x, event->y, NULL)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6306 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6307 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6308 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6309 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6310 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6311 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6312 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6313 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6314 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6315 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6316 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6317 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6318 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6319 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6320 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6321 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6322 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6323 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6324 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6325 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6326 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6327 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6328 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6329 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6330 gaim_separator(menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6331 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6332 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6333 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6334 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6335 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6336 G_CALLBACK(close_others_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6337 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6338 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6339 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6340 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6341 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6342 G_CALLBACK(close_window), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6343 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6344 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6345 } |
11581 | 6346 |
6347 static void | |
6348 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6349 gpointer user_data) | |
6350 { | |
6351 GaimGtkWindow *win; | |
6352 GaimConversation *conv; | |
6353 GaimGtkConversation *gtkconv; | |
6354 | |
6355 win = user_data; | |
6356 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6357 conv = gtkconv->active_conv; | |
6358 | |
6359 g_return_if_fail(conv != NULL); | |
6360 | |
6361 /* | |
6362 * Only set "unseen" to "none" if the window has focus | |
6363 */ | |
6364 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6365 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6366 |
6367 /* Update the menubar */ | |
6368 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6369 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
|
6370 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6371 |
11594 | 6372 generate_send_to_items(win); |
6373 | |
11604 | 6374 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6375 |
6376 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6377 gtkconv->make_sound); | |
6378 | |
6379 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6380 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6381 | |
6382 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6383 gtkconv->show_timestamps); | |
6384 | |
6385 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6386 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6387 gtkconv->u.im->show_icon); | |
11604 | 6388 |
11581 | 6389 /* |
6390 * We pause icons when they are not visible. If this icon should | |
6391 * be animated then start it back up again. | |
6392 */ | |
6393 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6394 (gtkconv->u.im->animate)) | |
6395 start_anim(NULL, gtkconv); | |
6396 } | |
6397 | |
6398 /************************************************************************** | |
6399 * GTK+ window ops | |
6400 **************************************************************************/ | |
6401 | |
6402 static GList *window_list = NULL; | |
6403 | |
6404 GList * | |
6405 gaim_gtk_conv_windows_get_list() | |
6406 { | |
6407 return window_list; | |
6408 } | |
6409 | |
6410 GaimGtkWindow * | |
6411 gaim_gtk_conv_window_new() | |
6412 { | |
6413 GaimGtkWindow *win; | |
6414 GtkPositionType pos; | |
6415 GtkWidget *testidea; | |
6416 GtkWidget *menubar; | |
6417 | |
6418 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6419 | |
6420 window_list = g_list_append(window_list, win); | |
6421 | |
6422 /* Create the window. */ | |
6423 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6424 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6425 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6426 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6427 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6428 | |
6429 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6430 G_CALLBACK(close_win_cb), win); | |
6431 | |
6432 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6433 G_CALLBACK(focus_win_cb), win); | |
6434 | |
6435 /* Create the notebook. */ | |
6436 win->notebook = gtk_notebook_new(); | |
6437 | |
6438 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6439 | |
6440 #if 0 | |
6441 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6442 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6443 #endif | |
6444 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6445 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6446 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6447 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6448 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6449 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6450 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6451 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6452 |
11581 | 6453 gtk_widget_show(win->notebook); |
6454 | |
6455 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6456 G_CALLBACK(before_switch_conv_cb), win); | |
6457 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6458 G_CALLBACK(switch_conv_cb), win); | |
6459 | |
6460 /* Setup the tab drag and drop signals. */ | |
6461 gtk_widget_add_events(win->notebook, | |
6462 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6463 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6464 G_CALLBACK(notebook_press_cb), win); | |
6465 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6466 G_CALLBACK(notebook_release_cb), win); | |
6467 | |
6468 testidea = gtk_vbox_new(FALSE, 0); | |
6469 | |
6470 /* Setup the menubar. */ | |
6471 menubar = setup_menubar(win); | |
6472 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6473 | |
6474 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6475 | |
6476 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6477 | |
6478 gtk_widget_show(testidea); | |
6479 | |
6480 return win; | |
6481 } | |
6482 | |
6483 void | |
6484 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6485 { | |
6486 window_list = g_list_remove(window_list, win); | |
6487 | |
11611 | 6488 if (win->gtkconvs) { |
6489 while (win->gtkconvs) { | |
6490 GList *nextgtk = win->gtkconvs->next; | |
6491 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6492 GList *nextcore = gtkconv->convs->next; | |
6493 GaimConversation *conv = gtkconv->convs->data; | |
6494 gaim_conversation_destroy(conv); | |
6495 if (!nextgtk && !nextcore) | |
6496 /* we'll end up invoking ourselves when we destroy our last child */ | |
6497 /* so don't destroy ourselves right now */ | |
6498 return; | |
6499 } | |
6500 return; | |
6501 } | |
11581 | 6502 gtk_widget_destroy(win->window); |
6503 | |
6504 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6505 | |
6506 g_free(win); | |
6507 } | |
6508 | |
6509 void | |
6510 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6511 { | |
6512 gtk_widget_show(win->window); | |
6513 } | |
6514 | |
6515 void | |
6516 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6517 { | |
6518 gtk_widget_hide(win->window); | |
6519 } | |
6520 | |
6521 void | |
6522 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6523 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6524 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6525 } |
6526 | |
6527 void | |
6528 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6529 { | |
6530 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6531 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6532 gtkconv->tab_cont)); | |
6533 } | |
6534 | |
6535 void | |
6536 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6537 { | |
6538 GaimConversation *conv = gtkconv->active_conv; | |
6539 GaimGtkConversation *focus_gtkconv; | |
6540 GtkWidget *tabby, *menu_tabby; | |
6541 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6542 GtkWidget *close_image; | |
6543 GaimConversationType conv_type; | |
6544 const char *name; | |
6545 const gchar *tmp_lab; | |
6546 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6547 gboolean tabs_side = FALSE; |
6548 gint angle = 0; | |
11581 | 6549 |
6550 name = gaim_conversation_get_name(conv); | |
6551 conv_type = gaim_conversation_get_type(conv); | |
6552 | |
6553 | |
6554 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6555 gtkconv->win = win; | |
6556 | |
11619 | 6557 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6558 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6559 tabs_side = TRUE; | |
6560 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6561 angle = 90; | |
6562 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6563 angle = 270; | |
6564 | |
6565 if (angle) | |
6566 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6567 else | |
6568 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6569 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6570 | |
6571 /* Close button. */ | |
6572 gtkconv->close = gtk_button_new(); | |
6573 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6574 if (gtk_check_version(2, 4, 2) == NULL) { | |
6575 /* Need to account for extra padding around the gtkbutton */ | |
6576 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6577 "focus-line-width", &focus_width, | |
6578 "focus-padding", &focus_pad, | |
6579 NULL); | |
6580 close_button_width += (focus_width + focus_pad) * 2; | |
6581 close_button_height += (focus_width + focus_pad) * 2; | |
6582 } | |
6583 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6584 close_button_width, close_button_height); | |
6585 | |
6586 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6587 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6588 gtk_widget_show(close_image); | |
6589 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6590 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6591 _("Close conversation"), NULL); | |
6592 | |
6593 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6594 G_CALLBACK(close_conv_cb), gtkconv); | |
6595 | |
11851 | 6596 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6597 /* |
6598 * I love Galeon. They have a fix for that stupid annoying visible | |
6599 * border bug. I love you guys! -- ChipX86 | |
6600 */ | |
11851 | 6601 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6602 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6603 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6604 #endif |
11581 | 6605 |
6606 /* Status icon. */ | |
6607 gtkconv->icon = gtk_image_new(); | |
6608 gtkconv->menu_icon = gtk_image_new(); | |
6609 update_tab_icon(conv); | |
6610 | |
6611 /* Tab label. */ | |
6612 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6613 |
11581 | 6614 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6615 if (!angle) |
6616 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6617 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6618 if (tabs_side) { |
6619 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6620 } | |
6621 if (angle) | |
6622 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6623 #endif |
6624 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6625 #if 0 | |
6626 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6627 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6628 #endif | |
6629 | |
6630 /* Pack it all together. */ | |
11619 | 6631 if (angle == 90) |
6632 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6633 else | |
6634 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6635 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6636 FALSE, FALSE, 0); | |
6637 | |
6638 gtk_widget_show_all(gtkconv->icon); | |
6639 gtk_widget_show_all(gtkconv->menu_icon); | |
6640 | |
6641 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6642 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6643 gtk_widget_show(gtkconv->tab_label); | |
6644 gtk_widget_show(gtkconv->menu_label); | |
6645 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6646 | |
11619 | 6647 if (angle == 90) |
6648 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6649 else | |
6650 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6651 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6652 gtk_widget_show(gtkconv->close); | |
6653 | |
6654 gtk_widget_show(tabby); | |
6655 gtk_widget_show(menu_tabby); | |
6656 | |
6657 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6658 gaim_gtkconv_update_buddy_icon(conv); | |
6659 | |
6660 /* Add this pane to the conversation's notebook. */ | |
6661 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6662 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6663 |
6664 | |
6665 gtk_widget_show(tab_cont); | |
6666 | |
6667 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6668 /* Er, bug in notebooks? Switch to the page manually. */ | |
6669 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6670 | |
6671 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6672 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6673 } else | |
6674 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6675 | |
6676 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6677 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6678 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6679 | |
6680 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6681 update_send_to_selection(win); |
11581 | 6682 } |
6683 | |
6684 void | |
6685 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6686 { | |
6687 unsigned int index; | |
6688 GaimConversationType conv_type; | |
6689 | |
6690 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6691 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6692 | |
6693 g_object_ref(gtkconv->tab_cont); | |
6694 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6695 | |
6696 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6697 | |
6698 /* go back to tabless if need be */ | |
6699 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6700 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6701 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6702 } | |
6703 | |
6704 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6705 |
6706 if (!win->gtkconvs) | |
6707 gaim_gtk_conv_window_destroy(win); | |
11581 | 6708 } |
6709 | |
6710 GaimGtkConversation * | |
6711 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
6712 { | |
6713 GtkWidget *tab_cont; | |
6714 | |
6715 if (index == -1) | |
6716 index = 0; | |
6717 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 6718 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 6719 } |
6720 | |
6721 GaimGtkConversation * | |
6722 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
6723 { | |
6724 int index; | |
6725 GtkWidget *tab_cont; | |
6726 | |
6727 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
6728 if (index == -1) | |
6729 index = 0; | |
6730 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
6731 if (!tab_cont) | |
6732 return NULL; | |
6733 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
6734 } | |
6735 | |
6736 | |
6737 GaimConversation * | |
6738 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
6739 { | |
6740 GaimGtkConversation *gtkconv; | |
6741 | |
6742 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
6743 return gtkconv ? gtkconv->active_conv : NULL; | |
6744 } | |
6745 | |
6746 gboolean | |
6747 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
6748 { | |
6749 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
6750 } | |
6751 | |
6752 gboolean | |
6753 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
6754 { | |
6755 gboolean has_focus = FALSE; | |
6756 | |
6757 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
6758 | |
6759 return has_focus; | |
6760 } | |
6761 | |
6762 GaimGtkWindow * | |
6763 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
6764 { | |
6765 GaimGtkWindow *win; | |
6766 GdkWindow *gdkwin; | |
6767 GList *l; | |
6768 | |
6769 gdkwin = gdk_window_at_pointer(&x, &y); | |
6770 | |
6771 if (gdkwin) | |
6772 gdkwin = gdk_window_get_toplevel(gdkwin); | |
6773 | |
6774 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
6775 win = l->data; | |
6776 | |
6777 if (gdkwin == win->window->window) | |
6778 return win; | |
6779 } | |
6780 | |
6781 return NULL; | |
6782 } | |
6783 | |
6784 GList * | |
6785 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
6786 { | |
6787 return win->gtkconvs; | |
6788 } | |
6789 | |
6790 guint | |
6791 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
6792 { | |
6793 return g_list_length(win->gtkconvs); | |
6794 } | |
6795 | |
6796 GaimGtkWindow * | |
6797 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
6798 { | |
6799 GList *wins, *convs; | |
6800 GaimGtkWindow *win; | |
6801 GaimGtkConversation *conv; | |
6802 | |
6803 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6804 return NULL; | |
6805 | |
6806 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
6807 win = wins->data; | |
6808 | |
6809 for (convs = win->gtkconvs; | |
6810 convs != NULL; | |
6811 convs = convs->next) { | |
6812 | |
6813 conv = convs->data; | |
6814 | |
6815 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6816 return win; | |
6817 } | |
6818 } | |
6819 | |
6820 return NULL; | |
6821 } | |
6822 | |
6823 GaimGtkWindow * | |
6824 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
6825 { | |
6826 GList *wins, *convs; | |
6827 GaimGtkWindow *win; | |
6828 GaimGtkConversation *conv; | |
6829 | |
6830 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6831 return NULL; | |
6832 | |
6833 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6834 wins != NULL; | |
6835 wins = wins->prev) { | |
6836 | |
6837 win = wins->data; | |
6838 | |
6839 for (convs = win->gtkconvs; | |
6840 convs != NULL; | |
6841 convs = convs->next) { | |
6842 | |
6843 conv = convs->data; | |
6844 | |
6845 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6846 return win; | |
6847 } | |
6848 } | |
6849 | |
6850 return NULL; | |
6851 } | |
6852 | |
6853 | |
6854 /************************************************************************** | |
6855 * Conversation placement functions | |
6856 **************************************************************************/ | |
6857 typedef struct | |
6858 { | |
6859 char *id; | |
6860 char *name; | |
6861 GaimConvPlacementFunc fnc; | |
6862 | |
6863 } ConvPlacementData; | |
6864 | |
6865 static GList *conv_placement_fncs = NULL; | |
6866 static GaimConvPlacementFunc place_conv = NULL; | |
6867 | |
6868 /* This one places conversations in the last made window. */ | |
6869 static void | |
6870 conv_placement_last_created_win(GaimGtkConversation *conv) | |
6871 { | |
6872 GaimGtkWindow *win; | |
6873 | |
6874 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6875 win = l ? l->data : NULL;; | |
6876 | |
6877 if (win == NULL) { | |
6878 win = gaim_gtk_conv_window_new(); | |
6879 | |
6880 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6881 gaim_gtk_conv_window_show(win); | |
6882 } else { | |
6883 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6884 } | |
6885 } | |
6886 | |
6887 /* This one places conversations in the last made window of the same type. */ | |
6888 static void | |
6889 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
6890 { | |
6891 GaimGtkWindow *win; | |
6892 | |
6893 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
6894 | |
6895 if (win == NULL) { | |
6896 win = gaim_gtk_conv_window_new(); | |
6897 | |
6898 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6899 gaim_gtk_conv_window_show(win); | |
6900 } else | |
6901 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6902 } | |
6903 | |
6904 /* This one places each conversation in its own window. */ | |
6905 static void | |
6906 conv_placement_new_window(GaimGtkConversation *conv) | |
6907 { | |
6908 GaimGtkWindow *win; | |
6909 | |
6910 win = gaim_gtk_conv_window_new(); | |
6911 | |
6912 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
6913 | |
6914 gaim_gtk_conv_window_show(win); | |
6915 } | |
6916 | |
6917 static GaimGroup * | |
6918 conv_get_group(GaimGtkConversation *conv) | |
6919 { | |
6920 GaimGroup *group = NULL; | |
6921 | |
6922 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
6923 GaimBuddy *buddy; | |
6924 | |
6925 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
6926 gaim_conversation_get_name(conv->active_conv)); | |
6927 | |
6928 if (buddy != NULL) | |
12088 | 6929 group = gaim_buddy_get_group(buddy); |
11581 | 6930 |
6931 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
6932 GaimChat *chat; | |
6933 | |
6934 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
6935 gaim_conversation_get_name(conv->active_conv)); | |
6936 | |
6937 if (chat != NULL) | |
6938 group = gaim_chat_get_group(chat); | |
6939 } | |
6940 | |
6941 return group; | |
6942 } | |
6943 | |
6944 /* | |
6945 * This groups things by, well, group. Buddies from groups will always be | |
6946 * grouped together, and a buddy from a group not belonging to any currently | |
6947 * open windows will get a new window. | |
6948 */ | |
6949 static void | |
6950 conv_placement_by_group(GaimGtkConversation *conv) | |
6951 { | |
6952 GaimConversationType type; | |
6953 GaimGroup *group = NULL; | |
6954 GList *wl, *cl; | |
6955 | |
6956 type = gaim_conversation_get_type(conv->active_conv); | |
6957 | |
6958 group = conv_get_group(conv); | |
6959 | |
6960 /* Go through the list of IMs and find one with this group. */ | |
6961 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
6962 GaimGtkWindow *win2; | |
6963 GaimGtkConversation *conv2; | |
6964 GaimGroup *group2 = NULL; | |
6965 | |
6966 win2 = wl->data; | |
6967 | |
6968 for (cl = win2->gtkconvs; | |
6969 cl != NULL; | |
6970 cl = cl->next) { | |
6971 conv2 = cl->data; | |
6972 | |
6973 group2 = conv_get_group(conv2); | |
6974 | |
6975 if (group == group2) { | |
6976 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
6977 | |
6978 return; | |
6979 } | |
6980 } | |
6981 } | |
6982 | |
6983 /* Make a new window. */ | |
6984 conv_placement_new_window(conv); | |
6985 } | |
6986 | |
6987 /* This groups things by account. Otherwise, the same semantics as above */ | |
6988 static void | |
6989 conv_placement_by_account(GaimGtkConversation *conv) | |
6990 { | |
6991 GaimConversationType type; | |
6992 GList *wins, *convs; | |
6993 GaimAccount *account; | |
6994 | |
6995 account = gaim_conversation_get_account(conv->active_conv); | |
6996 type = gaim_conversation_get_type(conv->active_conv); | |
6997 | |
6998 /* Go through the list of IMs and find one with this group. */ | |
6999 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7000 GaimGtkWindow *win2; | |
7001 GaimGtkConversation *conv2; | |
7002 | |
7003 win2 = wins->data; | |
7004 | |
7005 for (convs = win2->gtkconvs; | |
7006 convs != NULL; | |
7007 convs = convs->next) { | |
7008 conv2 = convs->data; | |
7009 | |
7010 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7011 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7012 return; | |
7013 } | |
7014 } | |
7015 } | |
7016 | |
7017 /* Make a new window. */ | |
7018 conv_placement_new_window(conv); | |
7019 } | |
7020 | |
7021 static ConvPlacementData * | |
7022 get_conv_placement_data(const char *id) | |
7023 { | |
7024 ConvPlacementData *data = NULL; | |
7025 GList *n; | |
7026 | |
7027 for (n = conv_placement_fncs; n; n = n->next) { | |
7028 data = n->data; | |
7029 if (!strcmp(data->id, id)) | |
7030 return data; | |
7031 } | |
7032 | |
7033 return NULL; | |
7034 } | |
7035 | |
7036 static void | |
7037 add_conv_placement_fnc(const char *id, const char *name, | |
7038 GaimConvPlacementFunc fnc) | |
7039 { | |
7040 ConvPlacementData *data; | |
7041 | |
7042 data = g_new(ConvPlacementData, 1); | |
7043 | |
7044 data->id = g_strdup(id); | |
7045 data->name = g_strdup(name); | |
7046 data->fnc = fnc; | |
7047 | |
7048 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7049 } | |
7050 | |
7051 static void | |
7052 ensure_default_funcs(void) | |
7053 { | |
7054 if (conv_placement_fncs == NULL) { | |
7055 add_conv_placement_fnc("last", _("Last created window"), | |
7056 conv_placement_last_created_win); | |
7057 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7058 conv_placement_last_created_win_type); | |
7059 add_conv_placement_fnc("new", _("New window"), | |
7060 conv_placement_new_window); | |
7061 add_conv_placement_fnc("group", _("By group"), | |
7062 conv_placement_by_group); | |
7063 add_conv_placement_fnc("account", _("By account"), | |
7064 conv_placement_by_account); | |
7065 } | |
7066 } | |
7067 | |
7068 GList * | |
7069 gaim_gtkconv_placement_get_options(void) | |
7070 { | |
7071 GList *n, *list = NULL; | |
7072 ConvPlacementData *data; | |
7073 | |
7074 ensure_default_funcs(); | |
7075 | |
7076 for (n = conv_placement_fncs; n; n = n->next) { | |
7077 data = n->data; | |
7078 list = g_list_append(list, data->name); | |
7079 list = g_list_append(list, data->id); | |
7080 } | |
7081 | |
7082 return list; | |
7083 } | |
7084 | |
7085 | |
7086 void | |
7087 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7088 GaimConvPlacementFunc fnc) | |
7089 { | |
7090 g_return_if_fail(id != NULL); | |
7091 g_return_if_fail(name != NULL); | |
7092 g_return_if_fail(fnc != NULL); | |
7093 | |
7094 ensure_default_funcs(); | |
7095 | |
7096 add_conv_placement_fnc(id, name, fnc); | |
7097 } | |
7098 | |
7099 void | |
7100 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7101 { | |
7102 ConvPlacementData *data = get_conv_placement_data(id); | |
7103 | |
7104 if (data == NULL) | |
7105 return; | |
7106 | |
7107 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7108 | |
7109 g_free(data->id); | |
7110 g_free(data->name); | |
7111 g_free(data); | |
7112 } | |
7113 | |
7114 const char * | |
7115 gaim_gtkconv_placement_get_name(const char *id) | |
7116 { | |
7117 ConvPlacementData *data; | |
7118 | |
7119 ensure_default_funcs(); | |
7120 | |
7121 data = get_conv_placement_data(id); | |
7122 | |
7123 if (data == NULL) | |
7124 return NULL; | |
7125 | |
7126 return data->name; | |
7127 } | |
7128 | |
7129 GaimConvPlacementFunc | |
7130 gaim_gtkconv_placement_get_fnc(const char *id) | |
7131 { | |
7132 ConvPlacementData *data; | |
7133 | |
7134 ensure_default_funcs(); | |
7135 | |
7136 data = get_conv_placement_data(id); | |
7137 | |
7138 if (data == NULL) | |
7139 return NULL; | |
7140 | |
7141 return data->fnc; | |
7142 } | |
7143 | |
7144 void | |
7145 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7146 { | |
7147 g_return_if_fail(func != NULL); | |
7148 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7149 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7150 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7151 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7152 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7153 place_conv = NULL; |
11581 | 7154 } |
7155 | |
7156 GaimConvPlacementFunc | |
7157 gaim_gtkconv_placement_get_current_func(void) | |
7158 { | |
7159 return place_conv; | |
7160 } | |
7161 | |
7162 void | |
7163 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7164 { | |
7165 if (place_conv) | |
7166 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7167 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7168 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7169 } |